mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-10-29 05:40:12 -04:00
output: add color primaries to output state
This commit is contained in:
parent
f3524de980
commit
e64de4d55f
3 changed files with 65 additions and 1 deletions
|
|
@ -14,6 +14,7 @@
|
|||
#include <time.h>
|
||||
#include <wayland-server-protocol.h>
|
||||
#include <wayland-util.h>
|
||||
#include <wlr/render/color.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_buffer.h>
|
||||
#include <wlr/util/addon.h>
|
||||
|
|
@ -74,6 +75,7 @@ enum wlr_output_state_field {
|
|||
WLR_OUTPUT_STATE_WAIT_TIMELINE = 1 << 10,
|
||||
WLR_OUTPUT_STATE_SIGNAL_TIMELINE = 1 << 11,
|
||||
WLR_OUTPUT_STATE_COLOR_TRANSFORM = 1 << 12,
|
||||
WLR_OUTPUT_STATE_IMAGE_DESCRIPTION = 1 << 13,
|
||||
};
|
||||
|
||||
enum wlr_output_state_mode_type {
|
||||
|
|
@ -81,6 +83,17 @@ enum wlr_output_state_mode_type {
|
|||
WLR_OUTPUT_STATE_MODE_CUSTOM,
|
||||
};
|
||||
|
||||
/**
|
||||
* Colorimetric image description.
|
||||
*
|
||||
* Carries information about the color encoding used for a struct wlr_buffer.
|
||||
*
|
||||
* Supported primaries are advertised in wlr_output.supported_primaries.
|
||||
*/
|
||||
struct wlr_output_image_description {
|
||||
enum wlr_color_named_primaries primaries;
|
||||
};
|
||||
|
||||
/**
|
||||
* Holds the double-buffered output state.
|
||||
*/
|
||||
|
|
@ -131,6 +144,8 @@ struct wlr_output_state {
|
|||
uint64_t signal_point;
|
||||
|
||||
struct wlr_color_transform *color_transform;
|
||||
|
||||
struct wlr_output_image_description *image_description;
|
||||
};
|
||||
|
||||
struct wlr_output_impl;
|
||||
|
|
@ -166,6 +181,8 @@ struct wlr_output {
|
|||
int32_t width, height;
|
||||
int32_t refresh; // mHz, may be zero
|
||||
|
||||
uint32_t supported_primaries; // bitfield of enum wlr_color_named_primaries
|
||||
|
||||
bool enabled;
|
||||
float scale;
|
||||
enum wl_output_subpixel subpixel;
|
||||
|
|
@ -582,6 +599,12 @@ void wlr_output_state_set_signal_timeline(struct wlr_output_state *state,
|
|||
void wlr_output_state_set_color_transform(struct wlr_output_state *state,
|
||||
struct wlr_color_transform *tr);
|
||||
|
||||
/**
|
||||
* Set the colorimetry image description.
|
||||
*/
|
||||
bool wlr_output_state_set_image_description(struct wlr_output_state *state,
|
||||
const struct wlr_output_image_description *image_desc);
|
||||
|
||||
/**
|
||||
* Copies the output state from src to dst. It is safe to then
|
||||
* wlr_output_state_finish() src and have dst still be valid.
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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(©, 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(©, src->color_transform);
|
||||
}
|
||||
if (src->committed & WLR_OUTPUT_STATE_IMAGE_DESCRIPTION) {
|
||||
if (!wlr_output_state_set_image_description(©, src->image_description)) {
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
wlr_output_state_finish(dst);
|
||||
*dst = copy;
|
||||
return true;
|
||||
|
||||
err:
|
||||
wlr_output_state_finish(dst);
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue