output: add color primaries to output state

This commit is contained in:
Simon Ser 2025-01-27 20:17:34 +01:00
parent f3524de980
commit e64de4d55f
3 changed files with 65 additions and 1 deletions

View file

@ -651,6 +651,10 @@ static bool output_basic_test(struct wlr_output *output,
wlr_log(WLR_DEBUG, "Tried to set a color transform on a disabled output");
return false;
}
if (!enabled && state->committed & WLR_OUTPUT_STATE_IMAGE_DESCRIPTION) {
wlr_log(WLR_DEBUG, "Tried to set the image description on a disabled output");
return false;
}
if (state->committed & WLR_OUTPUT_STATE_LAYERS) {
if (state->layers_len != (size_t)wl_list_length(&output->layers)) {
@ -669,6 +673,14 @@ static bool output_basic_test(struct wlr_output *output,
return false;
}
if ((state->committed & WLR_OUTPUT_STATE_IMAGE_DESCRIPTION) &&
state->image_description != NULL) {
if (!(output->supported_primaries & state->image_description->primaries)) {
wlr_log(WLR_DEBUG, "Unsupported image description primaries");
return false;
}
}
return true;
}

View file

@ -19,6 +19,7 @@ void wlr_output_state_finish(struct wlr_output_state *state) {
pixman_region32_fini(&state->damage);
wlr_drm_syncobj_timeline_unref(state->wait_timeline);
wlr_drm_syncobj_timeline_unref(state->signal_timeline);
free(state->image_description);
}
void wlr_output_state_set_enabled(struct wlr_output_state *state,
@ -122,6 +123,23 @@ void wlr_output_state_set_color_transform(struct wlr_output_state *state,
}
}
bool wlr_output_state_set_image_description(struct wlr_output_state *state,
const struct wlr_output_image_description *image_desc) {
struct wlr_output_image_description *copy = NULL;
if (image_desc != NULL) {
copy = malloc(sizeof(*copy));
if (copy == NULL) {
return false;
}
*copy = *image_desc;
}
state->committed |= WLR_OUTPUT_STATE_IMAGE_DESCRIPTION;
free(state->image_description);
state->image_description = copy;
return true;
}
bool wlr_output_state_copy(struct wlr_output_state *dst,
const struct wlr_output_state *src) {
struct wlr_output_state copy = *src;
@ -129,7 +147,8 @@ bool wlr_output_state_copy(struct wlr_output_state *dst,
WLR_OUTPUT_STATE_DAMAGE |
WLR_OUTPUT_STATE_WAIT_TIMELINE |
WLR_OUTPUT_STATE_SIGNAL_TIMELINE |
WLR_OUTPUT_STATE_COLOR_TRANSFORM);
WLR_OUTPUT_STATE_COLOR_TRANSFORM |
WLR_OUTPUT_STATE_IMAGE_DESCRIPTION);
copy.buffer = NULL;
copy.buffer_src_box = (struct wlr_fbox){0};
copy.buffer_dst_box = (struct wlr_box){0};
@ -137,6 +156,7 @@ bool wlr_output_state_copy(struct wlr_output_state *dst,
copy.wait_timeline = NULL;
copy.signal_timeline = NULL;
copy.color_transform = NULL;
copy.image_description = NULL;
if (src->committed & WLR_OUTPUT_STATE_BUFFER) {
wlr_output_state_set_buffer(&copy, src->buffer);
@ -160,8 +180,17 @@ bool wlr_output_state_copy(struct wlr_output_state *dst,
if (src->committed & WLR_OUTPUT_STATE_COLOR_TRANSFORM) {
wlr_output_state_set_color_transform(&copy, src->color_transform);
}
if (src->committed & WLR_OUTPUT_STATE_IMAGE_DESCRIPTION) {
if (!wlr_output_state_set_image_description(&copy, src->image_description)) {
goto err;
}
}
wlr_output_state_finish(dst);
*dst = copy;
return true;
err:
wlr_output_state_finish(dst);
return false;
}