-
Notifications
You must be signed in to change notification settings - Fork 58
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
Conversation
wlc_output_get_gamma_size(wlc_handle output) | ||
{ | ||
struct wlc_output *_output = convert_from_wlc_handle(output, "output"); | ||
|
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Closes #174