diff --git a/include/wlr/types/wlr_color_management_v1.h b/include/wlr/types/wlr_color_management_v1.h index 8caa61c6a..2fc46d5ea 100644 --- a/include/wlr/types/wlr_color_management_v1.h +++ b/include/wlr/types/wlr_color_management_v1.h @@ -78,7 +78,7 @@ struct wlr_color_manager_v1 { struct wl_list outputs; // wlr_color_management_output_v1.link struct wl_list surface_feedbacks; // wlr_color_management_surface_feedback_v1.link - uint32_t last_image_desc_identity; + uint64_t last_image_desc_identity; struct wl_listener display_destroy; } WLR_PRIVATE; diff --git a/protocol/meson.build b/protocol/meson.build index 613d18018..0283dad64 100644 --- a/protocol/meson.build +++ b/protocol/meson.build @@ -1,5 +1,5 @@ wayland_protos = dependency('wayland-protocols', - version: '>=1.44', + version: '>=1.47', fallback: 'wayland-protocols', default_options: ['tests=false'], ) diff --git a/types/wlr_color_management_v1.c b/types/wlr_color_management_v1.c index 18ce6ec26..0a19e8e78 100644 --- a/types/wlr_color_management_v1.c +++ b/types/wlr_color_management_v1.c @@ -12,7 +12,7 @@ #include "render/color.h" #include "util/mem.h" -#define COLOR_MANAGEMENT_V1_VERSION 1 +#define COLOR_MANAGEMENT_V1_VERSION 2 struct wlr_color_management_output_v1 { struct wl_resource *resource; @@ -178,9 +178,23 @@ static void image_desc_create_ready(struct wlr_color_manager_v1 *manager, wl_resource_set_implementation(image_desc->resource, &image_desc_impl, image_desc, image_desc_handle_resource_destroy); + uint32_t version = wl_resource_get_version(image_desc->resource); + if (!wp_color_manager_v1_transfer_function_is_valid(data->tf_named, version)) { + wp_image_description_v1_send_failed(image_desc->resource, + WP_IMAGE_DESCRIPTION_V1_CAUSE_LOW_VERSION, "unhandled value for tf_named"); + return; + } + // TODO: de-duplicate identity - uint32_t identity = ++manager->last_image_desc_identity; - wp_image_description_v1_send_ready(image_desc->resource, identity); + uint64_t identity = ++manager->last_image_desc_identity; + uint32_t identity_hi = identity >> 32; + uint32_t identity_lo = (uint32_t)identity; + + if (version >= WP_IMAGE_DESCRIPTION_V1_READY2_SINCE_VERSION) { + wp_image_description_v1_send_ready2(image_desc->resource, identity_hi, identity_lo); + } else { + wp_image_description_v1_send_ready(image_desc->resource, identity_lo); + } } static void image_desc_create_failed(struct wl_resource *parent_resource, uint32_t id, @@ -469,8 +483,10 @@ static void image_desc_creator_params_handle_create(struct wl_client *client, return; } - if (!check_mastering_luminance_range(params_resource, ¶ms->data, params->data.max_cll, "max_cll") || - !check_mastering_luminance_range(params_resource, ¶ms->data, params->data.max_fall, "max_fall")) { + uint32_t version = wl_resource_get_version(params_resource); + if (version < 2 && + (!check_mastering_luminance_range(params_resource, ¶ms->data, params->data.max_cll, "max_cll") || + !check_mastering_luminance_range(params_resource, ¶ms->data, params->data.max_fall, "max_fall"))) { return; } @@ -875,8 +891,11 @@ static void manager_bind(struct wl_client *client, void *data, manager->render_intents[i]); } for (size_t i = 0; i < manager->transfer_functions_len; i++) { - wp_color_manager_v1_send_supported_tf_named(resource, - manager->transfer_functions[i]); + enum wp_color_manager_v1_transfer_function tf = manager->transfer_functions[i]; + if (!wp_color_manager_v1_transfer_function_is_valid(tf, version)) { + continue; + } + wp_color_manager_v1_send_supported_tf_named(resource, tf); } for (size_t i = 0; i < manager->primaries_len; i++) { wp_color_manager_v1_send_supported_primaries_named(resource, @@ -910,6 +929,10 @@ struct wlr_color_manager_v1 *wlr_color_manager_v1_create(struct wl_display *disp } assert(has_perceptual_render_intent); + for (size_t i = 0; i < options->transfer_functions_len; i++) { + assert(options->transfer_functions[i] != WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB); + } + // TODO: add support for all of these features assert(!options->features.icc_v2_v4); assert(!options->features.set_primaries); @@ -973,14 +996,22 @@ void wlr_color_manager_v1_set_surface_preferred_image_description( struct wlr_color_manager_v1 *manager, struct wlr_surface *surface, const struct wlr_image_description_v1_data *data) { // TODO: de-duplicate identity - uint32_t identity = ++manager->last_image_desc_identity; + uint64_t identity = ++manager->last_image_desc_identity; + uint32_t identity_hi = identity >> 32; + uint32_t identity_lo = (uint32_t)identity; struct wlr_color_management_surface_feedback_v1 *surface_feedback; wl_list_for_each(surface_feedback, &manager->surface_feedbacks, link) { if (surface_feedback->surface == surface) { surface_feedback->data = *data; - wp_color_management_surface_feedback_v1_send_preferred_changed( - surface_feedback->resource, identity); + uint32_t version = wl_resource_get_version(surface_feedback->resource); + if (version >= WP_COLOR_MANAGEMENT_SURFACE_FEEDBACK_V1_PREFERRED_CHANGED2_SINCE_VERSION) { + wp_color_management_surface_feedback_v1_send_preferred_changed2( + surface_feedback->resource, identity_hi, identity_lo); + } else { + wp_color_management_surface_feedback_v1_send_preferred_changed( + surface_feedback->resource, identity_lo); + } } } } @@ -988,7 +1019,7 @@ void wlr_color_manager_v1_set_surface_preferred_image_description( enum wlr_color_transfer_function wlr_color_manager_v1_transfer_function_to_wlr(enum wp_color_manager_v1_transfer_function tf) { switch (tf) { - case WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB: + case WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_COMPOUND_POWER_2_4: return WLR_COLOR_TRANSFER_FUNCTION_SRGB; case WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_ST2084_PQ: return WLR_COLOR_TRANSFER_FUNCTION_ST2084_PQ; @@ -1007,7 +1038,7 @@ enum wp_color_manager_v1_transfer_function wlr_color_manager_v1_transfer_function_from_wlr(enum wlr_color_transfer_function tf) { switch (tf) { case WLR_COLOR_TRANSFER_FUNCTION_SRGB: - return WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB; + return WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_COMPOUND_POWER_2_4; case WLR_COLOR_TRANSFER_FUNCTION_ST2084_PQ: return WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_ST2084_PQ; case WLR_COLOR_TRANSFER_FUNCTION_EXT_LINEAR: @@ -1051,11 +1082,11 @@ wlr_color_manager_v1_transfer_function_list_from_renderer(struct wlr_renderer *r } const enum wp_color_manager_v1_transfer_function list[] = { - WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB, WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_GAMMA22, WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_ST2084_PQ, WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_EXT_LINEAR, WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_BT1886, + WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_COMPOUND_POWER_2_4, }; enum wp_color_manager_v1_transfer_function *out = NULL;