aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2023-03-06 16:19:48 +0100
committerAlexander Orzechowski <alex@ozal.ski>2023-06-08 18:47:46 +0000
commit026fc6eda01322327be9ebcd670de1fb1c76689b (patch)
treea4fff8e5ed4c4d40b609be3b4df870d6d361b3c9
parent5d5cf344860684211abbd2144a8fdb25cf02368c (diff)
gamma-control-v1: add wlr_gamma_control_v1_apply()
-rw-r--r--include/wlr/types/wlr_gamma_control_v1.h2
-rw-r--r--types/wlr_gamma_control_v1.c13
2 files changed, 15 insertions, 0 deletions
diff --git a/include/wlr/types/wlr_gamma_control_v1.h b/include/wlr/types/wlr_gamma_control_v1.h
index fa08586a..7a03a73e 100644
--- a/include/wlr/types/wlr_gamma_control_v1.h
+++ b/include/wlr/types/wlr_gamma_control_v1.h
@@ -41,5 +41,7 @@ struct wlr_gamma_control_manager_v1 *wlr_gamma_control_manager_v1_create(
struct wl_display *display);
struct wlr_gamma_control_v1 *wlr_gamma_control_manager_v1_get_control(
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
diff --git a/types/wlr_gamma_control_v1.c b/types/wlr_gamma_control_v1.c
index 4494b9da..5f3b750b 100644
--- a/types/wlr_gamma_control_v1.c
+++ b/types/wlr_gamma_control_v1.c
@@ -307,3 +307,16 @@ struct wlr_gamma_control_v1 *wlr_gamma_control_manager_v1_get_control(
}
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);
+}