color-representation: add support for identity+full

This commit is contained in:
Steve Williams 2026-01-31 15:11:14 +04:00
parent 7e34909a67
commit 23305aefa2

View file

@ -247,13 +247,25 @@ static void surface_synced_commit(struct wlr_surface_synced *synced) {
}
bool is_unset = color_repr->current.coefficients == 0 && color_repr->current.range == 0;
bool is_identity_full = color_repr->current.coefficients == WP_COLOR_REPRESENTATION_SURFACE_V1_COEFFICIENTS_IDENTITY && color_repr->current.range == WP_COLOR_REPRESENTATION_SURFACE_V1_RANGE_FULL;
bool is_ycbcr = pixel_format_is_ycbcr(dmabuf.format);
if (is_ycbcr) {
if (is_unset) {
color_repr->current.coefficients = WP_COLOR_REPRESENTATION_SURFACE_V1_COEFFICIENTS_BT601;
color_repr->current.range = WP_COLOR_REPRESENTATION_SURFACE_V1_RANGE_LIMITED;
}
else if(is_identity_full) {
wl_resource_post_error(color_repr->resource,
WP_COLOR_REPRESENTATION_SURFACE_V1_ERROR_PIXEL_FORMAT,
"unexpected encoding/range for yuv");
}
} else /* rgb */ {
if(is_identity_full) {
color_repr->current.coefficients = 0;
color_repr->current.range = 0;
is_unset = true;
}
if (!is_unset) {
wl_resource_post_error(color_repr->resource,
WP_COLOR_REPRESENTATION_SURFACE_V1_ERROR_PIXEL_FORMAT,
@ -461,6 +473,10 @@ struct wlr_color_representation_manager_v1 *wlr_color_representation_manager_v1_
struct wlr_color_representation_v1_coeffs_and_range coeffs_and_ranges[COEFFICIENTS_LEN * RANGES_LEN];
size_t coeffs_and_ranges_len = 0;
coeffs_and_ranges[coeffs_and_ranges_len++] = (struct wlr_color_representation_v1_coeffs_and_range){
.coeffs = WP_COLOR_REPRESENTATION_SURFACE_V1_COEFFICIENTS_IDENTITY,
.range = WP_COLOR_REPRESENTATION_SURFACE_V1_RANGE_FULL,
};
for (size_t i = 0; i < COEFFICIENTS_LEN; i++) {
enum wp_color_representation_surface_v1_coefficients coeffs = coefficients[i];
enum wlr_color_encoding enc = wlr_color_representation_v1_color_encoding_to_wlr(coeffs);