color_management_v1: support windows_scrgb and extended_target_volume

Implement create_windows_scrgb so compositors can advertise the
windows_scrgb feature: it returns an image description with the
ext-linear transfer characteristic and sRGB primaries, matching the
Windows-scRGB stimulus encoding described in the protocol.

Drop the blanket assertions against extended_target_volume and
windows_scrgb in wlr_color_manager_v1_create. extended_target_volume
is a capability flag only and now only requires that the compositor
also enables set_mastering_display_primaries, per the protocol.

These features unblock HDR support in clients that gate on them, such
as Wine/winewayland.drv, which only emits an HDR Static Metadata block
in its synthetic EDID when the compositor advertises both features
plus the ST2084 PQ named transfer function.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Christopher Snowhill 2026-05-13 23:07:25 -07:00
parent 51b9350e69
commit 70f976a3f2

View file

@ -947,9 +947,20 @@ static void manager_handle_create_parametric_creator(struct wl_client *client,
static void manager_handle_create_windows_scrgb(struct wl_client *client,
struct wl_resource *manager_resource, uint32_t id) {
struct wlr_color_manager_v1 *manager = manager_from_resource(manager_resource);
if (!manager->features.windows_scrgb) {
wl_resource_post_error(manager_resource,
WP_COLOR_MANAGER_V1_ERROR_UNSUPPORTED_FEATURE,
"get_windows_scrgb is not supported");
"create_windows_scrgb is not supported");
return;
}
// Windows-scRGB: sRGB (BT.709) primaries, extended-linear transfer
// characteristic. R=G=B=1.0 corresponds to 80 cd/m².
const struct wlr_image_description_v1_data data = {
.tf_named = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_EXT_LINEAR,
.primaries_named = WP_COLOR_MANAGER_V1_PRIMARIES_SRGB,
};
image_desc_create_ready(manager, manager_resource, id, &data, false);
}
static const struct wp_color_manager_v1_interface manager_impl = {
@ -1042,8 +1053,10 @@ struct wlr_color_manager_v1 *wlr_color_manager_v1_create(struct wl_display *disp
assert(!options->features.set_primaries);
assert(!options->features.set_tf_power);
assert(!options->features.set_luminances);
assert(!options->features.extended_target_volume);
assert(!options->features.windows_scrgb);
// extended_target_volume requires set_mastering_display_primaries
if (options->features.extended_target_volume) {
assert(options->features.set_mastering_display_primaries);
}
struct wlr_color_manager_v1 *manager = calloc(1, sizeof(*manager));
if (manager == NULL) {