Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gamma control API #216

Merged
merged 1 commit into from
Jan 4, 2017
Merged

Add gamma control API #216

merged 1 commit into from
Jan 4, 2017

Conversation

ddevault
Copy link
Collaborator

@ddevault ddevault commented Dec 28, 2016

Closes #174

wlc_output_get_gamma_size(wlc_handle output)
{
struct wlc_output *_output = convert_from_wlc_handle(output, "output");

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

precondition here if (!_output || !_output->bsurface.api.get_gamma_size) return 0;

@@ -280,6 +280,12 @@ bool wlc_output_get_sleep(wlc_handle output);
/** Wake up / sleep. */
void wlc_output_set_sleep(wlc_handle output, bool sleep);

/** Set gamma */
void wlc_output_set_gamma(wlc_handle output, uint16_t size, uint16_t *r, uint16_t *g, uint16_t *b);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering why the rgb are pointers? Arrays?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe document the units or something, or just refer to drm documentation since this API models it I guess.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I dunno how gamma works, I just gave an interface on top of drm. Will mention that in the docs.

struct wlc_output *_output = convert_from_wlc_handle(output, "output");

if (_output->bsurface.api.get_gamma_size)
return _output->bsurface.api.get_gamma_size(&_output->bsurface);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can then take out this branching and return this directly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't that segfault if get_gamma_size is NULL for this particular backend (which in practice will happen for the x backend)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The precondition mentioned above will check both if output is null or if that function pointer is null.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, got it.

void wlc_output_set_gamma(wlc_handle output, uint16_t size, uint16_t *r, uint16_t *g, uint16_t *b);

/** Get gamma size */
uint32_t wlc_output_get_gamma_size(wlc_handle output);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this same as size given in setter above? Why is it uint32_t here and uint16_t there? Same thing for the documentation here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch.

return _output->bsurface.api.get_gamma_size(&_output->bsurface);
else
return 0;
if (!_output || _output->bsurface.api.get_gamma_size) return 0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add newline, I just inlined the code in comment before. Sorry about that.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can squash the commits then, it looks good otherwise.

@Cloudef Cloudef merged commit 3ac1fda into Cloudef:master Jan 4, 2017
@ddevault ddevault deleted the redshift branch January 4, 2017 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants