gamma-control-v1: add wlr_gamma_control_v1_apply()

This commit is contained in:
Simon Ser 2023-03-06 16:19:48 +01:00 committed by Alexander Orzechowski
parent 5d5cf34486
commit 026fc6eda0
2 changed files with 15 additions and 0 deletions

View file

@ -41,5 +41,7 @@ struct wlr_gamma_control_manager_v1 *wlr_gamma_control_manager_v1_create(
struct wl_display *display); struct wl_display *display);
struct wlr_gamma_control_v1 *wlr_gamma_control_manager_v1_get_control( struct wlr_gamma_control_v1 *wlr_gamma_control_manager_v1_get_control(
struct wlr_gamma_control_manager_v1 *manager, struct wlr_output *output); struct wlr_gamma_control_manager_v1 *manager, struct wlr_output *output);
bool wlr_gamma_control_v1_apply(struct wlr_gamma_control_v1 *gamma_control,
struct wlr_output_state *output_state);
#endif #endif

View file

@ -307,3 +307,16 @@ struct wlr_gamma_control_v1 *wlr_gamma_control_manager_v1_get_control(
} }
return NULL; return NULL;
} }
bool wlr_gamma_control_v1_apply(struct wlr_gamma_control_v1 *gamma_control,
struct wlr_output_state *output_state) {
if (gamma_control == NULL || gamma_control->table == NULL) {
return wlr_output_state_set_gamma_lut(output_state, 0, NULL, NULL, NULL);
}
const uint16_t *r = gamma_control->table;
const uint16_t *g = gamma_control->table + gamma_control->ramp_size;
const uint16_t *b = gamma_control->table + 2 * gamma_control->ramp_size;
return wlr_output_state_set_gamma_lut(output_state,
gamma_control->ramp_size, r, g, b);
}