From 9124a98aec8a9bb1578302b41c0e17e50619b60b Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Wed, 26 Feb 2025 12:48:53 +0100 Subject: [PATCH] color: update color-management protocol to wp-v1 For a list of changes that got squashed into this commit see https://gitlab.freedesktop.org/rmader/weston/-/commits/color-management-protocol-wp-v1-bkp Co-authored-by: Leandro Ribeiro Signed-off-by: Robert Mader Signed-off-by: Leandro Ribeiro --- clients/color.c | 94 +- clients/window.c | 75 +- include/libweston/libweston.h | 9 +- libweston/color-lcms/color-lcms.c | 1 + libweston/color-lcms/color-lcms.h | 4 + libweston/color-lcms/color-profile.c | 31 + libweston/color-management.c | 421 ++++--- libweston/color-management.h | 12 + libweston/color-profile-param-builder.c | 61 +- libweston/color-properties.c | 90 +- libweston/color.h | 15 + libweston/compositor.c | 16 +- protocol/color-management-v1.xml | 1453 ---------------------- protocol/meson.build | 4 +- tests/color-management-parametric-test.c | 461 +++---- tests/color-management-test.c | 314 +++-- 16 files changed, 947 insertions(+), 2114 deletions(-) delete mode 100644 protocol/color-management-v1.xml diff --git a/clients/color.c b/clients/color.c index edb815c7c..e6262907e 100644 --- a/clients/color.c +++ b/clients/color.c @@ -52,16 +52,16 @@ struct color { struct widget *parent_widget; struct widget *widget; - struct xx_color_manager_v4 *color_manager; - struct xx_color_management_surface_v4 *color_surface; + struct wp_color_manager_v1 *color_manager; + struct wp_color_management_surface_v1 *color_surface; struct wp_single_pixel_buffer_manager_v1 *single_pixel_manager; struct wp_viewporter *viewporter; struct wp_viewport *viewport; struct pixel_color pixel_color; - enum xx_color_manager_v4_primaries primaries; - enum xx_color_manager_v4_transfer_function transfer_function; + enum wp_color_manager_v1_primaries primaries; + enum wp_color_manager_v1_transfer_function transfer_function; float min_lum; float max_lum; float ref_lum; @@ -105,14 +105,14 @@ static const struct weston_option cli_options[] = { }; static const struct valid_enum valid_primaries[] = { - { "srgb", XX_COLOR_MANAGER_V4_PRIMARIES_SRGB }, - { "bt2020", XX_COLOR_MANAGER_V4_PRIMARIES_BT2020 }, + { "srgb", WP_COLOR_MANAGER_V1_PRIMARIES_SRGB }, + { "bt2020", WP_COLOR_MANAGER_V1_PRIMARIES_BT2020 }, }; static const struct valid_enum valid_transfer_functions[] = { - { "srgb", XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_SRGB }, - { "pq", XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_ST2084_PQ }, - { "linear", XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_LINEAR }, + { "srgb", WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB }, + { "pq", WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_ST2084_PQ }, + { "linear", WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_EXT_LINEAR }, }; static bool @@ -196,11 +196,11 @@ validate_options(struct color *color) validate_option(opt_primaries, &color->primaries, valid_primaries, ARRAY_LENGTH(valid_primaries), - XX_COLOR_MANAGER_V4_PRIMARIES_SRGB) && + WP_COLOR_MANAGER_V1_PRIMARIES_SRGB) && validate_option(opt_transfer_function, &color->transfer_function, valid_transfer_functions, ARRAY_LENGTH(valid_transfer_functions), - XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_SRGB) && + WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB) && validate_luminance(opt_min_lum, &color->min_lum, -1.f) && validate_luminance(opt_max_lum, &color->max_lum, -1.f) && validate_luminance(opt_ref_lum, &color->ref_lum, -1.f); @@ -237,7 +237,7 @@ usage(const char *program_name, int exit_code) } static void -supported_intent(void *data, struct xx_color_manager_v4 *xx_color_manager_v4, +supported_intent(void *data, struct wp_color_manager_v1 *wp_color_manager_v1, uint32_t render_intent) { struct color *color = data; @@ -246,7 +246,7 @@ supported_intent(void *data, struct xx_color_manager_v4 *xx_color_manager_v4, } static void -supported_feature(void *data, struct xx_color_manager_v4 *xx_color_manager_v4, +supported_feature(void *data, struct wp_color_manager_v1 *wp_color_manager_v1, uint32_t feature) { struct color *color = data; @@ -255,7 +255,7 @@ supported_feature(void *data, struct xx_color_manager_v4 *xx_color_manager_v4, } static void -supported_tf_named(void *data, struct xx_color_manager_v4 *xx_color_manager_v4, +supported_tf_named(void *data, struct wp_color_manager_v1 *wp_color_manager_v1, uint32_t tf) { struct color *color = data; @@ -265,7 +265,7 @@ supported_tf_named(void *data, struct xx_color_manager_v4 *xx_color_manager_v4, static void supported_primaries_named(void *data, - struct xx_color_manager_v4 *xx_color_manager_v4, + struct wp_color_manager_v1 *wp_color_manager_v1, uint32_t primaries) { struct color *color = data; @@ -273,11 +273,17 @@ supported_primaries_named(void *data, color->supported_primaries_named |= 1 << primaries; } -static const struct xx_color_manager_v4_listener color_manager_listener = { +static void +done(void *data, struct wp_color_manager_v1 *wp_color_manager_v1) +{ +} + +static const struct wp_color_manager_v1_listener color_manager_listener = { supported_intent, supported_feature, supported_tf_named, supported_primaries_named, + done, }; static void @@ -287,12 +293,12 @@ global_handler(struct display *display, uint32_t name, struct color *color = data; struct wl_surface *surface = widget_get_wl_surface(color->widget); - if (strcmp(interface, xx_color_manager_v4_interface.name) == 0) { + if (strcmp(interface, wp_color_manager_v1_interface.name) == 0) { color->color_manager = display_bind(display, name, - &xx_color_manager_v4_interface, 1); - color->color_surface = xx_color_manager_v4_get_surface(color->color_manager, + &wp_color_manager_v1_interface, 1); + color->color_surface = wp_color_manager_v1_get_surface(color->color_manager, surface); - xx_color_manager_v4_add_listener(color->color_manager, + wp_color_manager_v1_add_listener(color->color_manager, &color_manager_listener, color); } else if (strcmp(interface, wp_single_pixel_buffer_manager_v1_interface.name) == 0) { color->single_pixel_manager = @@ -311,10 +317,10 @@ check_color_requirements(struct color *color) if (!color->color_manager) { fprintf(stderr, "The compositor doesn't expose %s\n", - xx_color_manager_v4_interface.name); + wp_color_manager_v1_interface.name); return false; } - if (!(color->supported_color_features & (1 << XX_COLOR_MANAGER_V4_FEATURE_PARAMETRIC))) { + if (!(color->supported_color_features & (1 << WP_COLOR_MANAGER_V1_FEATURE_PARAMETRIC))) { fprintf(stderr, "The color manager doesn't support the parametric creator\n"); return false; } @@ -326,12 +332,12 @@ check_color_requirements(struct color *color) fprintf(stderr, "The color manager doesn't support the transfer function\n"); return false; } - if (!(color->supported_rendering_intents & (1 << XX_COLOR_MANAGER_V4_RENDER_INTENT_PERCEPTUAL))) { + if (!(color->supported_rendering_intents & (1 << WP_COLOR_MANAGER_V1_RENDER_INTENT_PERCEPTUAL))) { fprintf(stderr, "The color manager doesn't support perceptual render intent\n"); return false; } if (color->min_lum != -1.f || color->max_lum != -1.f || color->ref_lum != -1.f) { - if (!(color->supported_color_features & (1 << XX_COLOR_MANAGER_V4_FEATURE_SET_LUMINANCES))) { + if (!(color->supported_color_features & (1 << WP_COLOR_MANAGER_V1_FEATURE_SET_LUMINANCES))) { fprintf(stderr, "The color manager doesn't support setting luminances\n"); return false; } @@ -348,10 +354,10 @@ static void color_destroy(struct color *color) { if (color->color_surface) - xx_color_management_surface_v4_destroy(color->color_surface); + wp_color_management_surface_v1_destroy(color->color_surface); if (color->color_manager) - xx_color_manager_v4_destroy(color->color_manager); + wp_color_manager_v1_destroy(color->color_manager); if (color->single_pixel_manager) wp_single_pixel_buffer_manager_v1_destroy(color->single_pixel_manager); @@ -432,7 +438,7 @@ set_single_pixel(struct color *color, struct widget *widget) static void image_description_failed(void *data, - struct xx_image_description_v4 *xx_image_description_v4, + struct wp_image_description_v1 *wp_image_description_v1, uint32_t cause, const char *msg) { enum image_description_status *image_desc_status = data; @@ -444,7 +450,7 @@ image_description_failed(void *data, } static void -image_description_ready(void *data, struct xx_image_description_v4 *xx_image_description_v4, +image_description_ready(void *data, struct wp_image_description_v1 *wp_image_description_v1, uint32_t identity) { enum image_description_status *image_desc_status = data; @@ -452,43 +458,43 @@ image_description_ready(void *data, struct xx_image_description_v4 *xx_image_des *image_desc_status = IMAGE_DESCRIPTION_READY; } -static const struct xx_image_description_v4_listener image_description_listener = { +static const struct wp_image_description_v1_listener image_description_listener = { image_description_failed, image_description_ready, }; -static struct xx_image_description_v4 * +static struct wp_image_description_v1 * create_image_description(struct color *color, uint32_t primaries_named, uint32_t tf_named) { - struct xx_image_description_creator_params_v4 *params_creator; - struct xx_image_description_v4 *image_description; + struct wp_image_description_creator_params_v1 *params_creator; + struct wp_image_description_v1 *image_description; enum image_description_status image_desc_status = IMAGE_DESCRIPTION_NOT_CREATED; int ret = 0; - params_creator = xx_color_manager_v4_new_parametric_creator(color->color_manager); - xx_image_description_creator_params_v4_set_primaries_named(params_creator, primaries_named); - xx_image_description_creator_params_v4_set_tf_named(params_creator, tf_named); + params_creator = wp_color_manager_v1_create_parametric_creator(color->color_manager); + wp_image_description_creator_params_v1_set_primaries_named(params_creator, primaries_named); + wp_image_description_creator_params_v1_set_tf_named(params_creator, tf_named); if (color->min_lum != -1 && color->max_lum != -1 && color->ref_lum != -1) - xx_image_description_creator_params_v4_set_luminances(params_creator, + wp_image_description_creator_params_v1_set_luminances(params_creator, color->min_lum * 10000, color->max_lum, color->ref_lum); - image_description = xx_image_description_creator_params_v4_create(params_creator); - xx_image_description_v4_add_listener(image_description, + image_description = wp_image_description_creator_params_v1_create(params_creator); + wp_image_description_v1_add_listener(image_description, &image_description_listener, &image_desc_status); while (ret != -1 && image_desc_status == IMAGE_DESCRIPTION_NOT_CREATED) ret = wl_display_dispatch(display_get_display(color->display)); if (ret == -1) { - xx_image_description_v4_destroy(image_description); + wp_image_description_v1_destroy(image_description); fprintf(stderr, "Error when creating the image description: %s\n", strerror(errno)); return NULL; } if (image_desc_status == IMAGE_DESCRIPTION_FAILED) { - xx_image_description_v4_destroy(image_description); + wp_image_description_v1_destroy(image_description); return NULL; } @@ -500,7 +506,7 @@ create_image_description(struct color *color, uint32_t primaries_named, uint32_t static bool set_image_description(struct color *color, struct widget *widget) { - struct xx_image_description_v4 *image_description; + struct wp_image_description_v1 *image_description; image_description = create_image_description(color, @@ -509,12 +515,12 @@ set_image_description(struct color *color, struct widget *widget) if (!image_description) return false; - xx_color_management_surface_v4_set_image_description( + wp_color_management_surface_v1_set_image_description( color->color_surface, image_description, - XX_COLOR_MANAGER_V4_RENDER_INTENT_PERCEPTUAL); + WP_COLOR_MANAGER_V1_RENDER_INTENT_PERCEPTUAL); - xx_image_description_v4_destroy(image_description); + wp_image_description_v1_destroy(image_description); return true; } diff --git a/clients/window.c b/clients/window.c index 18295ffa8..9d0aaf964 100644 --- a/clients/window.c +++ b/clients/window.c @@ -89,7 +89,7 @@ struct display { struct wl_data_device_manager *data_device_manager; struct text_cursor_position *text_cursor_position; struct xdg_wm_base *xdg_shell; - struct xx_color_manager_v4 *color_manager; + struct wp_color_manager_v1 *color_manager; struct zwp_tablet_manager_v2 *tablet_manager; struct zwp_relative_pointer_manager_v1 *relative_pointer_manager; struct zwp_pointer_constraints_v1 *pointer_constraints; @@ -215,7 +215,7 @@ struct surface { struct wl_callback *frame_cb; uint32_t last_time; - struct xx_color_management_surface_v4 *cm_surface; + struct wp_color_management_surface_v1 *cm_surface; struct rectangle allocation; struct rectangle server_allocation; @@ -476,7 +476,7 @@ struct shm_pool { }; struct cm_image_description { - struct xx_image_description_v4 *image_desc; + struct wp_image_description_v1 *image_desc; enum cm_image_desc_status { CM_IMAGE_DESC_NOT_CREATED = 0, CM_IMAGE_DESC_READY, @@ -489,27 +489,27 @@ render_intent_info_table[] = { { .intent = RENDER_INTENT_PERCEPTUAL, .desc = "Perceptual", - .protocol_intent = XX_COLOR_MANAGER_V4_RENDER_INTENT_PERCEPTUAL, + .protocol_intent = WP_COLOR_MANAGER_V1_RENDER_INTENT_PERCEPTUAL, }, { .intent = RENDER_INTENT_RELATIVE, .desc = "Media-relative colorimetric", - .protocol_intent = XX_COLOR_MANAGER_V4_RENDER_INTENT_RELATIVE, + .protocol_intent = WP_COLOR_MANAGER_V1_RENDER_INTENT_RELATIVE, }, { .intent = RENDER_INTENT_RELATIVE_BPC, .desc = "Media-relative colorimetric + black point compensation", - .protocol_intent = XX_COLOR_MANAGER_V4_RENDER_INTENT_RELATIVE_BPC, + .protocol_intent = WP_COLOR_MANAGER_V1_RENDER_INTENT_RELATIVE_BPC, }, { .intent = RENDER_INTENT_SATURATION, .desc = "Saturation", - .protocol_intent = XX_COLOR_MANAGER_V4_RENDER_INTENT_SATURATION, + .protocol_intent = WP_COLOR_MANAGER_V1_RENDER_INTENT_SATURATION, }, { .intent = RENDER_INTENT_ABSOLUTE, .desc = "ICC-absolute colorimetric", - .protocol_intent = XX_COLOR_MANAGER_V4_RENDER_INTENT_ABSOLUTE, + .protocol_intent = WP_COLOR_MANAGER_V1_RENDER_INTENT_ABSOLUTE, }, }; @@ -564,7 +564,7 @@ debug_print(void *proxy, int line, const char *func, const char *fmt, ...) #endif static void -cm_image_desc_ready(void *data, struct xx_image_description_v4 *xx_image_description_v4, +cm_image_desc_ready(void *data, struct wp_image_description_v1 *wp_image_description_v1, uint32_t identity) { struct cm_image_description *cm_image_desc = data; @@ -573,7 +573,7 @@ cm_image_desc_ready(void *data, struct xx_image_description_v4 *xx_image_descrip } static void -cm_image_desc_failed(void *data, struct xx_image_description_v4 *xx_image_description_v4, +cm_image_desc_failed(void *data, struct wp_image_description_v1 *wp_image_description_v1, uint32_t cause, const char *msg) { struct cm_image_description *cm_image_desc = data; @@ -584,7 +584,7 @@ cm_image_desc_failed(void *data, struct xx_image_description_v4 *xx_image_descri cm_image_desc->status = CM_IMAGE_DESC_FAILED; } -static const struct xx_image_description_v4_listener cm_image_desc_listener = { +static const struct wp_image_description_v1_listener cm_image_desc_listener = { .ready = cm_image_desc_ready, .failed = cm_image_desc_failed, }; @@ -606,10 +606,10 @@ widget_set_image_description_icc(struct widget *widget, int icc_fd, uint32_t length, uint32_t offset, enum render_intent intent, char **err_msg) { - struct xx_image_description_creator_icc_v4 *icc_creator; + struct wp_image_description_creator_icc_v1 *icc_creator; struct display *display = widget->window->display; struct surface *surface = widget->surface; - struct xx_color_manager_v4 *color_manager_wrapper; + struct wp_color_manager_v1 *color_manager_wrapper; struct wl_event_queue *queue; struct cm_image_description cm_image_desc; const struct render_intent_info *intent_info; @@ -619,11 +619,11 @@ widget_set_image_description_icc(struct widget *widget, int icc_fd, str_printf(err_msg, "%s extension not supported by the Wayland " \ "compositor, ignoring image color profile.", - xx_color_manager_v4_interface.name); + wp_color_manager_v1_interface.name); return false; } - if (!((display->color_manager_features >> XX_COLOR_MANAGER_V4_FEATURE_ICC_V2_V4) & 1)) { + if (!((display->color_manager_features >> WP_COLOR_MANAGER_V1_FEATURE_ICC_V2_V4) & 1)) { str_printf(err_msg, "Wayland compositor does not support creating image " \ "descriptions from ICC files, ignoring color profile."); @@ -646,15 +646,15 @@ widget_set_image_description_icc(struct widget *widget, int icc_fd, wl_proxy_set_queue((struct wl_proxy *)color_manager_wrapper, queue); /* Create ICC image description creator and set the ICC file. */ - icc_creator = xx_color_manager_v4_new_icc_creator(color_manager_wrapper); + icc_creator = wp_color_manager_v1_create_icc_creator(color_manager_wrapper); wl_proxy_wrapper_destroy(color_manager_wrapper); - xx_image_description_creator_icc_v4_set_icc_file(icc_creator, + wp_image_description_creator_icc_v1_set_icc_file(icc_creator, icc_fd, offset, length); /* Create the image description. It will also destroy the ICC creator. */ cm_image_desc.status = CM_IMAGE_DESC_NOT_CREATED; - cm_image_desc.image_desc = xx_image_description_creator_icc_v4_create(icc_creator); - xx_image_description_v4_add_listener(cm_image_desc.image_desc, + cm_image_desc.image_desc = wp_image_description_creator_icc_v1_create(icc_creator); + wp_image_description_v1_add_listener(cm_image_desc.image_desc, &cm_image_desc_listener, &cm_image_desc); /* Wait until compositor creates the image description or gracefully @@ -662,7 +662,7 @@ widget_set_image_description_icc(struct widget *widget, int icc_fd, while (ret != -1 && cm_image_desc.status == CM_IMAGE_DESC_NOT_CREATED) ret = wl_display_dispatch_queue(display->display, queue); if (ret == -1) { - xx_image_description_v4_destroy(cm_image_desc.image_desc); + wp_image_description_v1_destroy(cm_image_desc.image_desc); wl_event_queue_destroy(queue); str_printf(err_msg, "Disconnected from the Wayland compositor, " \ @@ -673,7 +673,7 @@ widget_set_image_description_icc(struct widget *widget, int icc_fd, /* Gracefully failed to create image description. Error already printed * in the handler. */ if (cm_image_desc.status == CM_IMAGE_DESC_FAILED) { - xx_image_description_v4_destroy(cm_image_desc.image_desc); + wp_image_description_v1_destroy(cm_image_desc.image_desc); wl_event_queue_destroy(queue); str_printf(err_msg, "Image description creation gracefully failed."); @@ -683,14 +683,14 @@ widget_set_image_description_icc(struct widget *widget, int icc_fd, if (!surface->cm_surface) surface->cm_surface = - xx_color_manager_v4_get_surface(display->color_manager, + wp_color_manager_v1_get_surface(display->color_manager, surface->surface); - xx_color_management_surface_v4_set_image_description(surface->cm_surface, + wp_color_management_surface_v1_set_image_description(surface->cm_surface, cm_image_desc.image_desc, intent_info->protocol_intent); - xx_image_description_v4_destroy(cm_image_desc.image_desc); + wp_image_description_v1_destroy(cm_image_desc.image_desc); wl_event_queue_destroy(queue); return true; @@ -1574,7 +1574,7 @@ surface_destroy(struct surface *surface) wp_viewport_destroy(surface->viewport); if (surface->cm_surface) - xx_color_management_surface_v4_destroy(surface->cm_surface); + wp_color_management_surface_v1_destroy(surface->cm_surface); wl_surface_destroy(surface->surface); @@ -6687,7 +6687,7 @@ display_bind_tablets(struct display *d, uint32_t id) } static void -cm_supported_intent(void *data, struct xx_color_manager_v4 *xx_color_manager_v4, +cm_supported_intent(void *data, struct wp_color_manager_v1 *wp_color_manager_v1, uint32_t render_intent) { struct display *d = data; @@ -6696,7 +6696,7 @@ cm_supported_intent(void *data, struct xx_color_manager_v4 *xx_color_manager_v4, } static void -cm_supported_feature(void *data, struct xx_color_manager_v4 *xx_color_manager_v4, +cm_supported_feature(void *data, struct wp_color_manager_v1 *wp_color_manager_v1, uint32_t feature) { struct display *d = data; @@ -6705,24 +6705,31 @@ cm_supported_feature(void *data, struct xx_color_manager_v4 *xx_color_manager_v4 } static void -cm_supported_tf_named(void *data, struct xx_color_manager_v4 *xx_color_manager_v4, +cm_supported_tf_named(void *data, struct wp_color_manager_v1 *wp_color_manager_v1, uint32_t tf_code) { /* unused in this file */ } static void -cm_supported_primaries_named(void *data, struct xx_color_manager_v4 *xx_color_manager_v4, +cm_supported_primaries_named(void *data, struct wp_color_manager_v1 *wp_color_manager_v1, uint32_t primaries_code) { /* unused in this file */ } -static const struct xx_color_manager_v4_listener cm_listener = { +static void +cm_done(void *data, struct wp_color_manager_v1 *wp_color_manager_v1) +{ + /* unused in this file */ +} + +static const struct wp_color_manager_v1_listener cm_listener = { .supported_intent = cm_supported_intent, .supported_feature = cm_supported_feature, .supported_tf_named = cm_supported_tf_named, .supported_primaries_named = cm_supported_primaries_named, + .done = cm_done, }; static void @@ -6793,11 +6800,11 @@ registry_handle_global(void *data, struct wl_registry *registry, uint32_t id, &wp_viewporter_interface, 1); } else if (strcmp(interface, "zwp_tablet_manager_v2") == 0) { display_bind_tablets(d, id); - } else if (strcmp(interface, "xx_color_manager_v4") == 0) { + } else if (strcmp(interface, "wp_color_manager_v1") == 0) { d->color_manager = wl_registry_bind(registry, id, - &xx_color_manager_v4_interface, 1); - xx_color_manager_v4_add_listener(d->color_manager, + &wp_color_manager_v1_interface, 1); + wp_color_manager_v1_add_listener(d->color_manager, &cm_listener, d); } @@ -7021,7 +7028,7 @@ display_destroy(struct display *display) xdg_wm_base_destroy(display->xdg_shell); if (display->color_manager) - xx_color_manager_v4_destroy(display->color_manager); + wp_color_manager_v1_destroy(display->color_manager); if (display->shm) wl_shm_destroy(display->shm); diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h index a04a5e4f1..4a397bf0f 100644 --- a/include/libweston/libweston.h +++ b/include/libweston/libweston.h @@ -340,16 +340,15 @@ enum weston_color_primaries { /** Transfer functions known by libweston */ enum weston_transfer_function { - WESTON_TF_LINEAR = 0, + WESTON_TF_BT1886 = 0, WESTON_TF_GAMMA22, WESTON_TF_GAMMA28, WESTON_TF_SRGB, WESTON_TF_EXT_SRGB, - WESTON_TF_BT709, - WESTON_TF_BT1361, WESTON_TF_ST240, WESTON_TF_ST428, WESTON_TF_ST2084_PQ, + WESTON_TF_EXT_LINEAR, WESTON_TF_LOG_100, WESTON_TF_LOG_316, WESTON_TF_XVYCC, @@ -360,7 +359,7 @@ enum weston_transfer_function { /** Error codes that the color profile parameters functions may return. */ enum weston_color_profile_param_builder_error { WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_INVALID_TF = 0, - WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_INVALID_PRIMARIES, + WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_INVALID_PRIMARIES_NAMED, WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_CIE_XY_OUT_OF_RANGE, WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_CREATE_FAILED, WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_INVALID_LUMINANCE, @@ -2095,7 +2094,7 @@ struct weston_surface { * * When a client uses this request, we add the wl_resource we create to * this list. */ - struct wl_list cm_feedback_surface_resource_list; + struct wl_list cm_surface_feedback_resource_list; struct wl_resource *cm_surface; uint64_t damage_track_id; diff --git a/libweston/color-lcms/color-lcms.c b/libweston/color-lcms/color-lcms.c index 526303718..785ee75f8 100644 --- a/libweston/color-lcms/color-lcms.c +++ b/libweston/color-lcms/color-lcms.c @@ -493,6 +493,7 @@ weston_color_manager_create(struct weston_compositor *compositor) cm->base.get_color_profile_from_icc = cmlcms_get_color_profile_from_icc; cm->base.get_color_profile_from_params = cmlcms_get_color_profile_from_params; cm->base.send_image_desc_info = cmlcms_send_image_desc_info; + cm->base.get_parametric_color_profile = cmlcms_get_parametric_color_profile; cm->base.destroy_color_transform = cmlcms_destroy_color_transform; cm->base.get_surface_color_transform = cmlcms_get_surface_color_transform; cm->base.create_output_color_outcome = cmlcms_create_output_color_outcome; diff --git a/libweston/color-lcms/color-lcms.h b/libweston/color-lcms/color-lcms.h index e519565e5..d057aba24 100644 --- a/libweston/color-lcms/color-lcms.h +++ b/libweston/color-lcms/color-lcms.h @@ -177,6 +177,10 @@ bool cmlcms_send_image_desc_info(struct cm_image_desc_info *cm_image_desc_info, struct weston_color_profile *cprof_base); +struct weston_color_profile * +cmlcms_get_parametric_color_profile(struct weston_color_profile *cprof_base, + char **errmsg); + void cmlcms_destroy_color_profile(struct weston_color_profile *cprof_base); diff --git a/libweston/color-lcms/color-profile.c b/libweston/color-lcms/color-profile.c index f7947b1d5..9edd64925 100644 --- a/libweston/color-lcms/color-profile.c +++ b/libweston/color-lcms/color-profile.c @@ -790,14 +790,45 @@ cmlcms_send_image_desc_info(struct cm_image_desc_info *cm_image_desc_info, weston_cm_send_primaries(cm_image_desc_info, &primaries_info->color_gamut); + /* Target primaries, equal to the primary primaries. */ + weston_cm_send_target_primaries(cm_image_desc_info, + &primaries_info->color_gamut); + /* sRGB transfer function. */ tf_info = weston_color_tf_info_from(compositor, WESTON_TF_GAMMA22); weston_cm_send_tf_named(cm_image_desc_info, tf_info); + + /* Primary luminance, default values from the protocol. */ + weston_cm_send_luminances(cm_image_desc_info, 0.2, 80.0, 80.0); + + /* Target luminance, min/max equals primary luminance min/max. */ + weston_cm_send_target_luminances(cm_image_desc_info, 0.2, 80.0); } return true; } +struct weston_color_profile * +cmlcms_get_parametric_color_profile(struct weston_color_profile *cprof_base, + char **errmsg) +{ + struct weston_color_manager_lcms *cm = to_cmlcms(cprof_base->cm); + struct weston_compositor *compositor = cm->base.compositor; + struct cmlcms_color_profile *cprof = to_cmlcms_cprof(cprof_base); + + switch(cprof->type) { + case CMLCMS_PROFILE_TYPE_ICC: + /* TODO: transform an ICC profile into an equivalent parametric one. */ + str_printf(errmsg, "we still can't create param cprof equivalent to ICC cprof"); + return NULL; + case CMLCMS_PROFILE_TYPE_PARAMS: + ref_cprof(cprof); + return cprof_base; + default: + weston_assert_not_reached(compositor, "unknown cprof type"); + } +} + void cmlcms_destroy_color_profile(struct weston_color_profile *cprof_base) { diff --git a/libweston/color-management.c b/libweston/color-management.c index 75b5c492f..f7478c699 100644 --- a/libweston/color-management.c +++ b/libweston/color-management.c @@ -122,13 +122,13 @@ weston_cm_send_icc_file(struct cm_image_desc_info *cm_image_desc_info, return; } - xx_image_description_info_v4_send_icc_file(cm_image_desc_info->owner, + wp_image_description_info_v1_send_icc_file(cm_image_desc_info->owner, fd, len); } /** * For a parametric image description, sends its - * enum xx_color_manager_v4_primaries code to the client. + * enum wp_color_manager_v1_primaries code to the client. * * This is a helper function that should be used by the color plugin * that owns the color profile and has information about it. @@ -140,7 +140,7 @@ WL_EXPORT void weston_cm_send_primaries_named(struct cm_image_desc_info *cm_image_desc_info, const struct weston_color_primaries_info *primaries_info) { - xx_image_description_info_v4_send_primaries_named(cm_image_desc_info->owner, + wp_image_description_info_v1_send_primaries_named(cm_image_desc_info->owner, primaries_info->protocol_primaries); } @@ -158,24 +158,53 @@ WL_EXPORT void weston_cm_send_primaries(struct cm_image_desc_info *cm_image_desc_info, const struct weston_color_gamut *color_gamut) { - xx_image_description_info_v4_send_primaries(cm_image_desc_info->owner, + wp_image_description_info_v1_send_primaries(cm_image_desc_info->owner, /* red */ - round(color_gamut->primary[0].x * 10000), - round(color_gamut->primary[0].y * 10000), + round(color_gamut->primary[0].x * 1000000), + round(color_gamut->primary[0].y * 1000000), /* green */ - round(color_gamut->primary[1].x * 10000), - round(color_gamut->primary[1].y * 10000), + round(color_gamut->primary[1].x * 1000000), + round(color_gamut->primary[1].y * 1000000), /* blue */ - round(color_gamut->primary[2].x * 10000), - round(color_gamut->primary[2].y * 10000), + round(color_gamut->primary[2].x * 1000000), + round(color_gamut->primary[2].y * 1000000), /* white point */ - round(color_gamut->white_point.x * 10000), - round(color_gamut->white_point.y * 10000)); + round(color_gamut->white_point.x * 1000000), + round(color_gamut->white_point.y * 1000000)); +} + +/** + * For a parametric image description, sends the target color volume primaries + * and white point using CIE 1931 xy chromaticity coordinates to the client. + * + * This is a helper function that should be used by the color plugin + * that owns the color profile and has information about it. + * + * \param cm_image_desc_info The image description info object + * \param color_gamut The CIE 1931 xy chromaticity coordinates + */ +WL_EXPORT void +weston_cm_send_target_primaries(struct cm_image_desc_info *cm_image_desc_info, + const struct weston_color_gamut *color_gamut) +{ + wp_image_description_info_v1_send_target_primaries(cm_image_desc_info->owner, + /* red */ + round(color_gamut->primary[0].x * 1000000), + round(color_gamut->primary[0].y * 1000000), + /* green */ + round(color_gamut->primary[1].x * 1000000), + round(color_gamut->primary[1].y * 1000000), + /* blue */ + round(color_gamut->primary[2].x * 1000000), + round(color_gamut->primary[2].y * 1000000), + /* white point */ + round(color_gamut->white_point.x * 1000000), + round(color_gamut->white_point.y * 1000000)); } /** * For a parametric image description, sends its - * enum xx_color_manager_v4_transfer_function code to the client. + * enum wp_color_manager_v1_transfer_function code to the client. * * This is a helper function that should be used by the color plugin * that owns the color profile and has information about it. @@ -187,10 +216,51 @@ WL_EXPORT void weston_cm_send_tf_named(struct cm_image_desc_info *cm_image_desc_info, const struct weston_color_tf_info *tf_info) { - xx_image_description_info_v4_send_tf_named(cm_image_desc_info->owner, + wp_image_description_info_v1_send_tf_named(cm_image_desc_info->owner, tf_info->protocol_tf); } +/** + * For a parametric image description, sends the primary luminances + * to the client. + * + * This is a helper function that should be used by the color plugin + * that owns the color profile and has information about it. + * + * \param cm_image_desc_info The image description info object + * \param min_lum The minimum luminance (cd/m²) + * \param max_lum The maximum luminance (cd/m²) + * \param ref_lum The reference white luminance (cd/m²) + */ +WL_EXPORT void +weston_cm_send_luminances(struct cm_image_desc_info *cm_image_desc_info, + float min_lum, float max_lum, float ref_lum) +{ + wp_image_description_info_v1_send_luminances(cm_image_desc_info->owner, + min_lum * 10000, + max_lum, ref_lum); +} + +/** + * For a parametric image description, sends the target luminances + * to the client. + * + * This is a helper function that should be used by the color plugin + * that owns the color profile and has information about it. + * + * \param cm_image_desc_info The image description info object + * \param min_lum The minimum target luminance (cd/m²) + * \param max_lum The maximum target luminance (cd/m²) + */ +WL_EXPORT void +weston_cm_send_target_luminances(struct cm_image_desc_info *cm_image_desc_info, + float min_lum, float max_lum) +{ + wp_image_description_info_v1_send_target_luminance(cm_image_desc_info->owner, + min_lum * 10000, + max_lum); +} + /** * Destroy an image description info object. */ @@ -228,7 +298,7 @@ image_description_info_create(struct wl_client *client, uint32_t version, cm_image_desc_info->compositor = compositor; cm_image_desc_info->owner = - wl_resource_create(client, &xx_image_description_info_v4_interface, + wl_resource_create(client, &wp_image_description_info_v1_interface, version, cm_image_desc_info_id); if (!cm_image_desc_info->owner) { free(cm_image_desc_info); @@ -258,7 +328,7 @@ image_description_get_information(struct wl_client *client, if (!cm_image_desc) { wl_resource_post_error(cm_image_desc_res, - XX_IMAGE_DESCRIPTION_V4_ERROR_NOT_READY, + WP_IMAGE_DESCRIPTION_V1_ERROR_NOT_READY, "we gracefully failed to create this image " \ "description"); return; @@ -266,14 +336,14 @@ image_description_get_information(struct wl_client *client, if (!cm_image_desc->cprof) { wl_resource_post_error(cm_image_desc_res, - XX_IMAGE_DESCRIPTION_V4_ERROR_NOT_READY, + WP_IMAGE_DESCRIPTION_V1_ERROR_NOT_READY, "image description not ready yet"); return; } if (!cm_image_desc->supports_get_info) { wl_resource_post_error(cm_image_desc_res, - XX_IMAGE_DESCRIPTION_V4_ERROR_NO_INFORMATION, + WP_IMAGE_DESCRIPTION_V1_ERROR_NO_INFORMATION, "get_information is not allowed for this " "image description"); return; @@ -293,7 +363,7 @@ image_description_get_information(struct wl_client *client, success = cm_image_desc->cm->send_image_desc_info(cm_image_desc_info, cm_image_desc->cprof); if (success) - xx_image_description_info_v4_send_done(cm_image_desc_info->owner); + wp_image_description_info_v1_send_done(cm_image_desc_info->owner); /* All info sent, so destroy the object. */ wl_resource_destroy(cm_image_desc_info->owner); @@ -331,7 +401,7 @@ image_description_resource_destroy(struct wl_resource *cm_image_desc_res) cm_image_desc_destroy(cm_image_desc); } -static const struct xx_image_description_v4_interface +static const struct wp_image_description_v1_interface image_description_implementation = { .destroy = image_description_destroy, .get_information = image_description_get_information, @@ -352,7 +422,7 @@ cm_image_desc_create(struct weston_color_manager *cm, cm_image_desc = xzalloc(sizeof(*cm_image_desc)); cm_image_desc->owner = - wl_resource_create(client, &xx_image_description_v4_interface, + wl_resource_create(client, &wp_image_description_v1_interface, version, image_description_id); if (!cm_image_desc->owner) { free(cm_image_desc); @@ -405,7 +475,7 @@ cm_output_get_image_description(struct wl_client *client, * that they are invalid through that). */ if (!head) { cm_image_desc_res = - wl_resource_create(client, &xx_image_description_v4_interface, + wl_resource_create(client, &wp_image_description_v1_interface, version, protocol_object_id); if (!cm_image_desc_res) { wl_resource_post_no_memory(cm_output_res); @@ -416,8 +486,8 @@ cm_output_get_image_description(struct wl_client *client, &image_description_implementation, NULL, image_description_resource_destroy); - xx_image_description_v4_send_failed(cm_image_desc_res, - XX_IMAGE_DESCRIPTION_V4_CAUSE_NO_OUTPUT, + wp_image_description_v1_send_failed(cm_image_desc_res, + WP_IMAGE_DESCRIPTION_V1_CAUSE_NO_OUTPUT, "the wl_output global no longer exists"); return; } @@ -441,7 +511,7 @@ cm_output_get_image_description(struct wl_client *client, return; } - xx_image_description_v4_send_ready(cm_image_desc->owner, + wp_image_description_v1_send_ready(cm_image_desc->owner, cm_image_desc->cprof->id); } @@ -479,7 +549,7 @@ cm_output_resource_destroy(struct wl_resource *cm_output_res) wl_list_remove(wl_resource_get_link(cm_output_res)); } -static const struct xx_color_management_output_v4_interface +static const struct wp_color_management_output_v1_interface cm_output_implementation = { .destroy = cm_output_destroy, .get_image_description = cm_output_get_image_description, @@ -506,7 +576,7 @@ weston_output_send_image_description_changed(struct weston_output *output) /* Send the events for each head attached to this weston_output. */ wl_list_for_each(head, &output->head_list, output_link) { wl_resource_for_each(res, &head->cm_output_resource_list) - xx_color_management_output_v4_send_image_description_changed(res); + wp_color_management_output_v1_send_image_description_changed(res); /* wl_output.done should be sent after collecting all the * changes related to the output. But in Weston we are lacking @@ -536,7 +606,7 @@ cm_get_output(struct wl_client *client, struct wl_resource *cm_res, uint32_t version = wl_resource_get_version(cm_res); struct wl_resource *res; - res = wl_resource_create(client, &xx_color_management_output_v4_interface, + res = wl_resource_create(client, &wp_color_management_output_v1_interface, version, cm_output_id); if (!res) { wl_resource_post_no_memory(cm_res); @@ -580,9 +650,8 @@ cm_surface_set_image_description(struct wl_client *client, /* The surface might have been already gone, in such case cm_surface is * inert. */ if (!surface) { - /* TODO: This error will be surface intert in the future */ wl_resource_post_error(cm_surface_res, - XX_COLOR_MANAGEMENT_SURFACE_V4_ERROR_IMAGE_DESCRIPTION, + WP_COLOR_MANAGEMENT_SURFACE_V1_ERROR_INERT, "the wl_surface has already been destroyed"); return; } @@ -590,17 +659,16 @@ cm_surface_set_image_description(struct wl_client *client, /* Invalid image description for this request, as we gracefully failed * to create it. */ if (!cm_image_desc) { - /* TODO: the version of the xx protocol that we are using still - * does not have an error for this. Fix when we update to the - * next version. */ - wl_resource_post_no_memory(cm_surface_res); + wl_resource_post_error(cm_surface_res, + WP_COLOR_MANAGEMENT_SURFACE_V1_ERROR_IMAGE_DESCRIPTION, + "we gracefully failed to create this image description"); return; } /* Invalid image description for this request, as it isn't ready yet. */ if (!cm_image_desc->cprof) { wl_resource_post_error(cm_surface_res, - XX_COLOR_MANAGEMENT_SURFACE_V4_ERROR_IMAGE_DESCRIPTION, + WP_COLOR_MANAGEMENT_SURFACE_V1_ERROR_IMAGE_DESCRIPTION, "the image description is not ready"); return; } @@ -611,14 +679,14 @@ cm_surface_set_image_description(struct wl_client *client, protocol_render_intent); if (!render_intent) { wl_resource_post_error(cm_surface_res, - XX_COLOR_MANAGEMENT_SURFACE_V4_ERROR_RENDER_INTENT, + WP_COLOR_MANAGEMENT_SURFACE_V1_ERROR_RENDER_INTENT, "unknown render intent"); return; } if (!((cm->supported_rendering_intents >> render_intent->intent) & 1)) { wl_resource_post_error(cm_surface_res, - XX_COLOR_MANAGEMENT_SURFACE_V4_ERROR_RENDER_INTENT, + WP_COLOR_MANAGEMENT_SURFACE_V1_ERROR_RENDER_INTENT, "unsupported render intent"); return; } @@ -644,9 +712,8 @@ cm_surface_unset_image_description(struct wl_client *client, /* The surface might have been already gone, in such case cm_surface is * inert. */ if (!surface) { - /* TODO: This error will be surface intert in the future */ wl_resource_post_error(cm_surface_res, - XX_COLOR_MANAGEMENT_SURFACE_V4_ERROR_IMAGE_DESCRIPTION, + WP_COLOR_MANAGEMENT_SURFACE_V1_ERROR_INERT, "the wl_surface has already been destroyed"); return; } @@ -689,7 +756,7 @@ cm_surface_resource_destroy(struct wl_resource *cm_surface_res) surface->pending.render_intent = NULL; } -static const struct xx_color_management_surface_v4_interface +static const struct wp_color_management_surface_v1_interface cm_surface_implementation = { .destroy = cm_surface_destroy, .set_image_description = cm_surface_set_image_description, @@ -710,12 +777,12 @@ cm_get_surface(struct wl_client *client, struct wl_resource *cm_res, if (surface->cm_surface) { wl_resource_post_error(cm_res, - XX_COLOR_MANAGER_V4_ERROR_SURFACE_EXISTS, + WP_COLOR_MANAGER_V1_ERROR_SURFACE_EXISTS, "surface already requested"); return; } - res = wl_resource_create(client, &xx_color_management_surface_v4_interface, + res = wl_resource_create(client, &wp_color_management_surface_v1_interface, version, cm_surface_id); if (!res) { wl_resource_post_no_memory(cm_res); @@ -729,13 +796,13 @@ cm_get_surface(struct wl_client *client, struct wl_resource *cm_res, } /** - * Client will not use the cm_feedback_surface anymore, so we destroy its resource. + * Client will not use the cm_surface_feedback anymore, so we destroy its resource. */ static void -cm_feedback_surface_destroy(struct wl_client *client, - struct wl_resource *cm_feedback_surface_res) +cm_surface_feedback_destroy(struct wl_client *client, + struct wl_resource *cm_surface_feedback_res) { - wl_resource_destroy(cm_feedback_surface_res); + wl_resource_destroy(cm_surface_feedback_res); } /** @@ -743,20 +810,20 @@ cm_feedback_surface_destroy(struct wl_client *client, * the surface. */ static void -cm_feedback_surface_get_preferred(struct wl_client *client, - struct wl_resource *cm_feedback_surface_res, +cm_surface_feedback_get_preferred(struct wl_client *client, + struct wl_resource *cm_surface_feedback_res, uint32_t protocol_object_id) { - struct weston_surface *surface = wl_resource_get_user_data(cm_feedback_surface_res); - uint32_t version = wl_resource_get_version(cm_feedback_surface_res); + struct weston_surface *surface = wl_resource_get_user_data(cm_surface_feedback_res); + uint32_t version = wl_resource_get_version(cm_surface_feedback_res); struct weston_color_manager *cm; struct cm_image_desc *cm_image_desc; - /* The surface might have been already gone, in such case cm_feedback_surface is + /* The surface might have been already gone, in such case cm_surface_feedback is * inert. */ if (!surface) { - wl_resource_post_error(cm_feedback_surface_res, - XX_COLOR_MANAGEMENT_FEEDBACK_SURFACE_V4_ERROR_INERT, + wl_resource_post_error(cm_surface_feedback_res, + WP_COLOR_MANAGEMENT_SURFACE_FEEDBACK_V1_ERROR_INERT, "the wl_surface has already been destroyed"); return; } @@ -767,38 +834,93 @@ cm_feedback_surface_get_preferred(struct wl_client *client, client, version, protocol_object_id, YES_GET_INFO); if (!cm_image_desc) { - wl_resource_post_no_memory(cm_feedback_surface_res); + wl_resource_post_no_memory(cm_surface_feedback_res); return; } - xx_image_description_v4_send_ready(cm_image_desc->owner, + wp_image_description_v1_send_ready(cm_image_desc->owner, cm_image_desc->cprof->id); } -static const struct xx_color_management_feedback_surface_v4_interface -cm_feedback_surface_implementation = { - .destroy = cm_feedback_surface_destroy, - .get_preferred = cm_feedback_surface_get_preferred, +static void +cm_surface_feedback_get_preferred_parametric(struct wl_client *client, + struct wl_resource *cm_surface_feedback_res, + uint32_t protocol_object_id) +{ + struct weston_surface *surface = wl_resource_get_user_data(cm_surface_feedback_res); + uint32_t version = wl_resource_get_version(cm_surface_feedback_res); + struct weston_color_manager *cm; + struct cm_image_desc *cm_image_desc; + char *err_msg; + + /* The surface might have been already gone, in such case cm_surface_feedback is + * inert. */ + if (!surface) { + wl_resource_post_error(cm_surface_feedback_res, + WP_COLOR_MANAGEMENT_SURFACE_FEEDBACK_V1_ERROR_INERT, + "the wl_surface has already been destroyed"); + return; + } + + cm = surface->compositor->color_manager; + + /* Create the image description with cprof == NULL. */ + cm_image_desc = cm_image_desc_create(cm, NULL, client, version, + protocol_object_id, YES_GET_INFO); + if (!cm_image_desc) { + wl_resource_post_no_memory(cm_surface_feedback_res); + return; + } + + cm_image_desc->cprof = + cm->get_parametric_color_profile(surface->preferred_color_profile, + &err_msg); + + /* Failed to get a parametric cprof for surface preferred cprof. */ + if (!cm_image_desc->cprof) { + wp_image_description_v1_send_failed(cm_image_desc->owner, + WP_IMAGE_DESCRIPTION_V1_CAUSE_UNSUPPORTED, + err_msg); + free(err_msg); + + /* Failed to create the image description, let's set the + * resource userdata to NULL (and other functions can tell that + * it is invalid through that). */ + wl_resource_set_user_data(cm_image_desc->owner, NULL); + cm_image_desc_destroy(cm_image_desc); + + return; + } + + wp_image_description_v1_send_ready(cm_image_desc->owner, + cm_image_desc->cprof->id); +} + +static const struct wp_color_management_surface_feedback_v1_interface +cm_surface_feedback_implementation = { + .destroy = cm_surface_feedback_destroy, + .get_preferred = cm_surface_feedback_get_preferred, + .get_preferred_parametric = cm_surface_feedback_get_preferred_parametric, }; /** - * Resource destruction function for the cm_feedback_surface. + * Resource destruction function for the cm_surface_feedback. */ static void -cm_feedback_surface_resource_destroy(struct wl_resource *cm_feedback_surface_res) +cm_surface_feedback_resource_destroy(struct wl_resource *cm_surface_feedback_res) { - struct weston_surface *surface = wl_resource_get_user_data(cm_feedback_surface_res); + struct weston_surface *surface = wl_resource_get_user_data(cm_surface_feedback_res); - /* For inert cm_feedback_surface, we don't have to do anything. + /* For inert cm_surface_feedback, we don't have to do anything. * - * We already did what was necessary when cm_feedback_surface became + * We already did what was necessary when cm_surface_feedback became * inert, in the surface destruction process: weston_surface_unref(). */ if (!surface) return; - /* We are destroying the cm_feedback_surface_res, so simply remove it from - * weston_surface::cm_feedback_surface_resource_list. */ - wl_list_remove(wl_resource_get_link(cm_feedback_surface_res)); + /* We are destroying the cm_surface_feedback_res, so simply remove it from + * weston_surface::cm_surface_feedback_resource_list. */ + wl_list_remove(wl_resource_get_link(cm_surface_feedback_res)); } /** @@ -810,33 +932,34 @@ void weston_surface_send_preferred_image_description_changed(struct weston_surface *surface) { struct wl_resource *res; + uint32_t id = surface->preferred_color_profile->id; - wl_resource_for_each(res, &surface->cm_feedback_surface_resource_list) - xx_color_management_feedback_surface_v4_send_preferred_changed(res); + wl_resource_for_each(res, &surface->cm_surface_feedback_resource_list) + wp_color_management_surface_feedback_v1_send_preferred_changed(res, id); } /** - * Client called get_feedback_surface(). We already have the backing object, so just + * Client called get_surface_feedback(). We already have the backing object, so just * create a resource for the client. */ static void -cm_get_feedback_surface(struct wl_client *client, struct wl_resource *cm_res, +cm_get_surface_feedback(struct wl_client *client, struct wl_resource *cm_res, uint32_t cm_surface_id, struct wl_resource *surface_res) { struct weston_surface *surface = wl_resource_get_user_data(surface_res); uint32_t version = wl_resource_get_version(cm_res); struct wl_resource *res; - res = wl_resource_create(client, &xx_color_management_feedback_surface_v4_interface, + res = wl_resource_create(client, &wp_color_management_surface_feedback_v1_interface, version, cm_surface_id); if (!res) { wl_resource_post_no_memory(cm_res); return; } - wl_resource_set_implementation(res, &cm_feedback_surface_implementation, - surface, cm_feedback_surface_resource_destroy); - wl_list_insert(&surface->cm_feedback_surface_resource_list, wl_resource_get_link(res)); + wl_resource_set_implementation(res, &cm_surface_feedback_implementation, + surface, cm_surface_feedback_resource_destroy); + wl_list_insert(&surface->cm_surface_feedback_resource_list, wl_resource_get_link(res)); } /** @@ -854,27 +977,27 @@ cm_creator_icc_set_icc_file(struct wl_client *client, const char *err_msg; if (cm_creator_icc->icc_data_length > 0) { - err_code = XX_IMAGE_DESCRIPTION_CREATOR_ICC_V4_ERROR_ALREADY_SET; + err_code = WP_IMAGE_DESCRIPTION_CREATOR_ICC_V1_ERROR_ALREADY_SET; err_msg = "ICC file was already set"; goto err; } - if (length == 0 || length > (4 * 1024 * 1024)) { - err_code = XX_IMAGE_DESCRIPTION_CREATOR_ICC_V4_ERROR_BAD_SIZE; + if (length == 0 || length > (32 * 1024 * 1024)) { + err_code = WP_IMAGE_DESCRIPTION_CREATOR_ICC_V1_ERROR_BAD_SIZE; err_msg = "invalid ICC file size, should be in the " \ - "(0, 4MB] interval"; + "(0, 32MB] interval"; goto err; } flags = fcntl(icc_profile_fd, F_GETFL); if ((flags & O_ACCMODE) == O_WRONLY) { - err_code = XX_IMAGE_DESCRIPTION_CREATOR_ICC_V4_ERROR_BAD_FD; + err_code = WP_IMAGE_DESCRIPTION_CREATOR_ICC_V1_ERROR_BAD_FD; err_msg = "ICC fd is not readable"; goto err; } if (lseek(icc_profile_fd, 0, SEEK_CUR) < 0) { - err_code = XX_IMAGE_DESCRIPTION_CREATOR_ICC_V4_ERROR_BAD_FD; + err_code = WP_IMAGE_DESCRIPTION_CREATOR_ICC_V1_ERROR_BAD_FD; err_msg = "ICC fd is not seekable"; goto err; } @@ -930,13 +1053,13 @@ create_image_description_color_profile_from_icc_creator(struct cm_image_desc *cm bool ret; if (!do_length_and_offset_fit(cm_creator_icc)) { - xx_image_description_v4_send_failed(cm_image_desc->owner, - XX_IMAGE_DESCRIPTION_V4_CAUSE_OPERATING_SYSTEM, + wp_image_description_v1_send_failed(cm_image_desc->owner, + WP_IMAGE_DESCRIPTION_V1_CAUSE_OPERATING_SYSTEM, "length + offset does not fit off_t"); return -1; } - /* Create buffer to read ICC profile. As they may have up to 4MB, we + /* Create buffer to read ICC profile. As they may have up to 32MB, we * send OOM if something fails (instead of using xalloc). */ icc_prof_data = zalloc(cm_creator_icc->icc_data_length); if (!icc_prof_data) { @@ -964,8 +1087,8 @@ create_image_description_color_profile_from_icc_creator(struct cm_image_desc *cm /* Reading the ICC failed */ free(icc_prof_data); str_printf(&err_msg, "failed to read ICC file: %s", strerror(errno)); - xx_image_description_v4_send_failed(cm_image_desc->owner, - XX_IMAGE_DESCRIPTION_V4_CAUSE_OPERATING_SYSTEM, + wp_image_description_v1_send_failed(cm_image_desc->owner, + WP_IMAGE_DESCRIPTION_V1_CAUSE_OPERATING_SYSTEM, err_msg); free(err_msg); return -1; @@ -976,7 +1099,7 @@ create_image_description_color_profile_from_icc_creator(struct cm_image_desc *cm * the given ICC file don't simply change. */ free(icc_prof_data); wl_resource_post_error(cm_creator_icc->owner, - XX_IMAGE_DESCRIPTION_CREATOR_ICC_V4_ERROR_OUT_OF_FILE, + WP_IMAGE_DESCRIPTION_CREATOR_ICC_V1_ERROR_OUT_OF_FILE, "tried to read ICC beyond EOF"); return -1; } @@ -998,15 +1121,15 @@ create_image_description_color_profile_from_icc_creator(struct cm_image_desc *cm * color-manager plugins and decide if we should gracefully fail * or return a protocol error. */ - xx_image_description_v4_send_failed(cm_image_desc->owner, - XX_IMAGE_DESCRIPTION_V4_CAUSE_UNSUPPORTED, + wp_image_description_v1_send_failed(cm_image_desc->owner, + WP_IMAGE_DESCRIPTION_V1_CAUSE_UNSUPPORTED, err_msg); free(err_msg); return -1; } cm_image_desc->cprof = cprof; - xx_image_description_v4_send_ready(cm_image_desc->owner, + wp_image_description_v1_send_ready(cm_image_desc->owner, cm_image_desc->cprof->id); return 0; } @@ -1030,7 +1153,7 @@ cm_creator_icc_create(struct wl_client *client, struct wl_resource *resource, if (cm_creator_icc->icc_data_length == 0) { wl_resource_post_error(resource, - XX_IMAGE_DESCRIPTION_CREATOR_ICC_V4_ERROR_INCOMPLETE_SET, + WP_IMAGE_DESCRIPTION_CREATOR_ICC_V1_ERROR_INCOMPLETE_SET, "trying to create image description before " \ "setting the ICC file"); return; @@ -1075,7 +1198,7 @@ cm_creator_icc_destructor(struct wl_resource *resource) free(cm_creator_icc); } -static const struct xx_image_description_creator_icc_v4_interface +static const struct wp_image_description_creator_icc_v1_interface cm_creator_icc_implementation = { .create = cm_creator_icc_create, .set_icc_file = cm_creator_icc_set_icc_file, @@ -1085,8 +1208,9 @@ cm_creator_icc_implementation = { * Creates an ICC-based image description creator for the client. */ static void -cm_new_image_description_creator_icc(struct wl_client *client, struct wl_resource *cm_res, - uint32_t cm_creator_icc_id) +cm_create_image_description_creator_icc(struct wl_client *client, + struct wl_resource *cm_res, + uint32_t cm_creator_icc_id) { struct cm_creator_icc *cm_creator_icc; struct weston_compositor *compositor = wl_resource_get_user_data(cm_res); @@ -1094,7 +1218,7 @@ cm_new_image_description_creator_icc(struct wl_client *client, struct wl_resourc uint32_t version = wl_resource_get_version(cm_res); if (!((cm->supported_color_features >> WESTON_COLOR_FEATURE_ICC) & 1)) { - wl_resource_post_error(cm_res, XX_COLOR_MANAGER_V4_ERROR_UNSUPPORTED_FEATURE, + wl_resource_post_error(cm_res, WP_COLOR_MANAGER_V1_ERROR_UNSUPPORTED_FEATURE, "creating ICC image descriptions is not supported"); return; } @@ -1105,7 +1229,7 @@ cm_new_image_description_creator_icc(struct wl_client *client, struct wl_resourc cm_creator_icc->icc_profile_fd = -1; cm_creator_icc->owner = - wl_resource_create(client, &xx_image_description_creator_icc_v4_interface, + wl_resource_create(client, &wp_image_description_creator_icc_v1_interface, version, cm_creator_icc_id); if (!cm_creator_icc->owner) goto err; @@ -1131,17 +1255,17 @@ cm_creator_params_error_to_protocol(struct weston_compositor *compositor, { switch(err) { case WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_INVALID_TF: - return XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_INVALID_TF; - case WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_INVALID_PRIMARIES: - return XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_INVALID_PRIMARIES; + return WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INVALID_TF; + case WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_INVALID_PRIMARIES_NAMED: + return WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INVALID_PRIMARIES_NAMED; case WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_INVALID_LUMINANCE: - return XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_INVALID_LUMINANCE; + return WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INVALID_LUMINANCE; case WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_INCOMPLETE_SET: - return XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_INCOMPLETE_SET; + return WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INCOMPLETE_SET; case WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_ALREADY_SET: - return XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET; + return WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET; case WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_UNSUPPORTED: - return XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_UNSUPPORTED_FEATURE; + return WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_UNSUPPORTED_FEATURE; case WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_CREATE_FAILED: case WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_CIE_XY_OUT_OF_RANGE: /* These are not protocol errors, but should result in graceful @@ -1192,7 +1316,7 @@ cm_creator_params_set_primaries_named(struct wl_client *client, struct wl_resour primaries_info = weston_color_primaries_info_from_protocol(primaries_named); if (!primaries_info) { wl_resource_post_error(resource, - XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_INVALID_PRIMARIES, + WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INVALID_PRIMARIES_NAMED, "invalid primaries named: %u", primaries_named); return; } @@ -1205,7 +1329,7 @@ cm_creator_params_set_primaries_named(struct wl_client *client, struct wl_resour /** * Set primaries for parametric-based image description creator object. * - * The primaries we receive from clients is multiplied by 10000. + * The primaries we receive from clients are multiplied by 1000000. */ static void cm_creator_params_set_primaries(struct wl_client *client, struct wl_resource *resource, @@ -1218,14 +1342,14 @@ cm_creator_params_set_primaries(struct wl_client *client, struct wl_resource *re wl_resource_get_user_data(resource); struct weston_color_gamut primaries; - primaries.primary[0].x = r_x / 10000.0f; - primaries.primary[0].y = r_y / 10000.0f; - primaries.primary[1].x = g_x / 10000.0f; - primaries.primary[1].y = g_y / 10000.0f; - primaries.primary[2].x = b_x / 10000.0f; - primaries.primary[2].y = b_y / 10000.0f; - primaries.white_point.x = w_x / 10000.0f; - primaries.white_point.y = w_y / 10000.0f; + primaries.primary[0].x = r_x / 1000000.0f; + primaries.primary[0].y = r_y / 1000000.0f; + primaries.primary[1].x = g_x / 1000000.0f; + primaries.primary[1].y = g_y / 1000000.0f; + primaries.primary[2].x = b_x / 1000000.0f; + primaries.primary[2].y = b_y / 1000000.0f; + primaries.white_point.x = w_x / 1000000.0f; + primaries.white_point.y = w_y / 1000000.0f; if (!weston_color_profile_param_builder_set_primaries(cm_creator_params->builder, &primaries)) @@ -1246,7 +1370,7 @@ cm_creator_params_set_tf_named(struct wl_client *client, struct wl_resource *res tf_info = weston_color_tf_info_from_protocol(tf_named); if (!tf_info) { wl_resource_post_error(resource, - XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_INVALID_TF, + WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INVALID_TF, "invalid tf named: %u", tf_named); return; } @@ -1295,7 +1419,7 @@ cm_creator_params_set_luminances(struct wl_client *client, struct wl_resource *r /** * Set mastering display primaries for parametric-based image description creator object. * - * The primaries we receive from clients is multiplied by 10000. + * The primaries we receive from clients are multiplied by 1000000. */ static void cm_creator_params_set_mastering_display_primaries(struct wl_client *client, @@ -1309,14 +1433,14 @@ cm_creator_params_set_mastering_display_primaries(struct wl_client *client, wl_resource_get_user_data(resource); struct weston_color_gamut primaries; - primaries.primary[0].x = r_x / 10000.0f; - primaries.primary[0].y = r_y / 10000.0f; - primaries.primary[1].x = g_x / 10000.0f; - primaries.primary[1].y = g_y / 10000.0f; - primaries.primary[2].x = b_x / 10000.0f; - primaries.primary[2].y = b_y / 10000.0f; - primaries.white_point.x = w_x / 10000.0f; - primaries.white_point.y = w_y / 10000.0f; + primaries.primary[0].x = r_x / 1000000.0f; + primaries.primary[0].y = r_y / 1000000.0f; + primaries.primary[1].x = g_x / 1000000.0f; + primaries.primary[1].y = g_y / 1000000.0f; + primaries.primary[2].x = b_x / 1000000.0f; + primaries.primary[2].y = b_y / 1000000.0f; + primaries.white_point.x = w_x / 1000000.0f; + primaries.white_point.y = w_y / 1000000.0f; if (!weston_color_profile_param_builder_set_target_primaries(cm_creator_params->builder, &primaries)) @@ -1407,7 +1531,7 @@ cm_creator_params_create(struct wl_client *client, struct wl_resource *resource, cm_creator_params->builder = NULL; if (cm_image_desc->cprof) { - xx_image_description_v4_send_ready(cm_image_desc->owner, + wp_image_description_v1_send_ready(cm_image_desc->owner, cm_image_desc->cprof->id); } else { protocol_err = cm_creator_params_error_to_protocol(compositor, err); @@ -1415,8 +1539,8 @@ cm_creator_params_create(struct wl_client *client, struct wl_resource *resource, wl_resource_post_error(cm_creator_params->owner, protocol_err, "%s", err_msg); else - xx_image_description_v4_send_failed(cm_image_desc->owner, - XX_IMAGE_DESCRIPTION_V4_CAUSE_UNSUPPORTED, + wp_image_description_v1_send_failed(cm_image_desc->owner, + WP_IMAGE_DESCRIPTION_V1_CAUSE_UNSUPPORTED, err_msg); free(err_msg); @@ -1448,7 +1572,7 @@ cm_creator_params_destructor(struct wl_resource *resource) free(cm_creator_params); } -static const struct xx_image_description_creator_params_v4_interface +static const struct wp_image_description_creator_params_v1_interface cm_creator_params_implementation = { .set_primaries_named = cm_creator_params_set_primaries_named, .set_primaries = cm_creator_params_set_primaries, @@ -1466,8 +1590,9 @@ cm_creator_params_implementation = { * Creates a parametric image description creator for the client. */ static void -cm_new_image_description_creator_params(struct wl_client *client, struct wl_resource *cm_res, - uint32_t cm_creator_params_id) +cm_create_image_description_creator_params(struct wl_client *client, + struct wl_resource *cm_res, + uint32_t cm_creator_params_id) { struct cm_creator_params *cm_creator_params; struct weston_compositor *compositor = wl_resource_get_user_data(cm_res); @@ -1475,7 +1600,7 @@ cm_new_image_description_creator_params(struct wl_client *client, struct wl_reso uint32_t version = wl_resource_get_version(cm_res); if (!((cm->supported_color_features >> WESTON_COLOR_FEATURE_PARAMETRIC) & 1)) { - wl_resource_post_error(cm_res, XX_COLOR_MANAGER_V4_ERROR_UNSUPPORTED_FEATURE, + wl_resource_post_error(cm_res, WP_COLOR_MANAGER_V1_ERROR_UNSUPPORTED_FEATURE, "creating parametric image descriptions " \ "is not supported"); return; @@ -1489,7 +1614,7 @@ cm_new_image_description_creator_params(struct wl_client *client, struct wl_reso weston_color_profile_param_builder_create(compositor); cm_creator_params->owner = - wl_resource_create(client, &xx_image_description_creator_params_v4_interface, + wl_resource_create(client, &wp_image_description_creator_params_v1_interface, version, cm_creator_params_id); if (!cm_creator_params->owner) goto err; @@ -1505,6 +1630,15 @@ err: wl_resource_post_no_memory(cm_res); } +static void +cm_create_windows_scrgb(struct wl_client *client, struct wl_resource *cm_res, + uint32_t image_description) +{ + wl_resource_post_error(cm_res, + WP_COLOR_MANAGER_V1_ERROR_UNSUPPORTED_FEATURE, + "creating windows scrgb is not supported"); +} + /** * Client will not use the color management object anymore, so we destroy its * resource. That should not affect the other objects in any way. @@ -1515,14 +1649,15 @@ cm_destroy(struct wl_client *client, struct wl_resource *cm_res) wl_resource_destroy(cm_res); } -static const struct xx_color_manager_v4_interface +static const struct wp_color_manager_v1_interface color_manager_implementation = { .destroy = cm_destroy, .get_output = cm_get_output, .get_surface = cm_get_surface, - .get_feedback_surface = cm_get_feedback_surface, - .new_icc_creator = cm_new_image_description_creator_icc, - .new_parametric_creator = cm_new_image_description_creator_params, + .get_surface_feedback = cm_get_surface_feedback, + .create_icc_creator = cm_create_image_description_creator_icc, + .create_parametric_creator = cm_create_image_description_creator_params, + .create_windows_scrgb = cm_create_windows_scrgb, }; /** @@ -1541,7 +1676,7 @@ bind_color_management(struct wl_client *client, void *data, uint32_t version, const struct weston_color_tf_info *tf; unsigned int i; - resource = wl_resource_create(client, &xx_color_manager_v4_interface, + resource = wl_resource_create(client, &wp_color_manager_v1_interface, version, id); if (!resource) { wl_client_post_no_memory(client); @@ -1556,7 +1691,7 @@ bind_color_management(struct wl_client *client, void *data, uint32_t version, if (!((cm->supported_color_features >> i) & 1)) continue; feature_info = weston_color_feature_info_from(compositor, i); - xx_color_manager_v4_send_supported_feature(resource, + wp_color_manager_v1_send_supported_feature(resource, feature_info->protocol_feature); } @@ -1565,7 +1700,7 @@ bind_color_management(struct wl_client *client, void *data, uint32_t version, if (!((cm->supported_rendering_intents >> i) & 1)) continue; render_intent = weston_render_intent_info_from(compositor, i); - xx_color_manager_v4_send_supported_intent(resource, + wp_color_manager_v1_send_supported_intent(resource, render_intent->protocol_intent); } @@ -1574,7 +1709,7 @@ bind_color_management(struct wl_client *client, void *data, uint32_t version, if (!((cm->supported_primaries_named >> i) & 1)) continue; primaries = weston_color_primaries_info_from(compositor, i); - xx_color_manager_v4_send_supported_primaries_named(resource, + wp_color_manager_v1_send_supported_primaries_named(resource, primaries->protocol_primaries); } @@ -1583,15 +1718,17 @@ bind_color_management(struct wl_client *client, void *data, uint32_t version, if (!((cm->supported_tf_named >> i) & 1)) continue; tf = weston_color_tf_info_from(compositor, i); - xx_color_manager_v4_send_supported_tf_named(resource, + wp_color_manager_v1_send_supported_tf_named(resource, tf->protocol_tf); } + + wp_color_manager_v1_send_done(resource); } /** Advertise color-management support * * Calling this initializes the color-management protocol support, so that - * xx_color_manager_v4_interface will be advertised to clients. Essentially it + * wp_color_manager_v1_interface will be advertised to clients. Essentially it * creates a global. Do not call this function multiple times in the * compositor's lifetime. There is no way to deinit explicitly, globals will be * reaped when the wl_display gets destroyed. @@ -1609,7 +1746,7 @@ weston_compositor_enable_color_management_protocol(struct weston_compositor *com WESTON_RENDER_INTENT_PERCEPTUAL); if (!wl_global_create(compositor->wl_display, - &xx_color_manager_v4_interface, + &wp_color_manager_v1_interface, version, compositor, bind_color_management)) return -1; diff --git a/libweston/color-management.h b/libweston/color-management.h index 1e2b6df01..5ae38198e 100644 --- a/libweston/color-management.h +++ b/libweston/color-management.h @@ -51,8 +51,20 @@ void weston_cm_send_primaries(struct cm_image_desc_info *cm_image_desc_info, const struct weston_color_gamut *color_gamut); +void +weston_cm_send_target_primaries(struct cm_image_desc_info *cm_image_desc_info, + const struct weston_color_gamut *color_gamut); + void weston_cm_send_tf_named(struct cm_image_desc_info *cm_image_desc_info, const struct weston_color_tf_info *tf_info); +void +weston_cm_send_luminances(struct cm_image_desc_info *cm_image_desc_info, + float min_lum, float max_lum, float ref_lum); + +void +weston_cm_send_target_luminances(struct cm_image_desc_info *cm_image_desc_info, + float min_lum, float max_lum); + #endif /* WESTON_COLOR_MANAGEMENT_H */ diff --git a/libweston/color-profile-param-builder.c b/libweston/color-profile-param-builder.c index 95b8b5612..7e7efbf9d 100644 --- a/libweston/color-profile-param-builder.c +++ b/libweston/color-profile-param-builder.c @@ -245,7 +245,7 @@ weston_color_profile_param_builder_set_primaries_named(struct weston_color_profi bool success = true; if (!((cm->supported_primaries_named >> primaries) & 1)) { - store_error(builder, WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_INVALID_PRIMARIES, + store_error(builder, WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_INVALID_PRIMARIES_NAMED, "named primaries %u not supported by the color manager", primaries); success = false; @@ -410,13 +410,6 @@ weston_color_profile_param_builder_set_primary_luminance(struct weston_color_pro success = false; } - if (max_lum < ref_lum) { - store_error(builder, WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_INVALID_LUMINANCE, - "primary reference luminance %f shouldn't be greater than max %f", - ref_lum, max_lum); - success = false; - } - if (min_lum >= ref_lum) { store_error(builder, WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_INVALID_LUMINANCE, "primary reference luminance %f shouldn't be lesser than or equal to min %f", @@ -505,8 +498,16 @@ bool weston_color_profile_param_builder_set_target_luminance(struct weston_color_profile_param_builder *builder, float min_lum, float max_lum) { + struct weston_color_manager *cm = builder->compositor->color_manager; bool success = true; + if (!((cm->supported_color_features >> WESTON_COLOR_FEATURE_SET_MASTERING_DISPLAY_PRIMARIES) & 1)) { + store_error(builder, WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_UNSUPPORTED, + "set_mastering_display_primaries not supported by " \ + "the color manager, so setting target luminance is not allowed"); + success = false; + } + if (builder->group_mask & WESTON_COLOR_PROFILE_PARAMS_TARGET_LUMINANCE) { store_error(builder, WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_ALREADY_SET, "target luminance was already set"); @@ -684,7 +685,7 @@ validate_maxcll(struct weston_color_profile_param_builder *builder) if (builder->params.target_min_luminance >= builder->params.maxCLL) store_error(builder, WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_INVALID_LUMINANCE, - "maxCLL (%f) should be greater or equal to target min luminance (%f)", + "maxCLL (%f) should be greater than target min luminance (%f)", builder->params.maxCLL, builder->params.target_min_luminance); if (builder->params.target_max_luminance < builder->params.maxCLL) @@ -701,7 +702,7 @@ validate_maxfall(struct weston_color_profile_param_builder *builder) if (builder->params.target_min_luminance >= builder->params.maxFALL) store_error(builder, WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_INVALID_LUMINANCE, - "maxFALL (%f) should be greater or equal to min luminance (%f)", + "maxFALL (%f) should be greater than min luminance (%f)", builder->params.maxFALL, builder->params.target_min_luminance); if (builder->params.target_max_luminance < builder->params.maxFALL) @@ -719,6 +720,13 @@ builder_validate_params(struct weston_color_profile_param_builder *builder) if (builder->group_mask & WESTON_COLOR_PROFILE_PARAMS_MAXFALL) validate_maxfall(builder); + if (builder->group_mask & WESTON_COLOR_PROFILE_PARAMS_MAXCLL && + builder->group_mask & WESTON_COLOR_PROFILE_PARAMS_MAXFALL && + builder->params.maxFALL > builder->params.maxCLL) + store_error(builder, WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_INVALID_LUMINANCE, + "maxFALL (%f) should not be greater than maxCLL (%f)", + builder->params.maxFALL, builder->params.maxCLL); + if (builder->group_mask & WESTON_COLOR_PROFILE_PARAMS_PRIMARIES) validate_color_gamut(builder, &builder->params.primaries, "primaries"); @@ -746,9 +754,14 @@ builder_complete_params(struct weston_color_profile_param_builder *builder) * protocol as well. */ if (builder->group_mask & WESTON_COLOR_PROFILE_PARAMS_TF) { switch(builder->params.tf_info->tf) { + case WESTON_TF_BT1886: + builder->params.reference_white_luminance = 100.0; + builder->params.min_luminance = 0.01; + builder->params.max_luminance = 100.0; + break; case WESTON_TF_ST2084_PQ: builder->params.reference_white_luminance = 203.0; - builder->params.min_luminance = 0.0; + builder->params.min_luminance = 0.005; builder->params.max_luminance = 10000.0; break; case WESTON_TF_HLG: @@ -761,29 +774,25 @@ builder_complete_params(struct weston_color_profile_param_builder *builder) } } } else { - /* Primary luminance is set, but PQ TF override them anyway - * (except reference white level). Also part of the CM&HDR - * protocol. */ + /* Primary luminance is set, but the CM&HDR protocol states that + * PQ TF should override max_lum with min_lum + 10000 cd/m². */ if ((builder->group_mask & WESTON_COLOR_PROFILE_PARAMS_TF) && - builder->params.tf_info->tf == WESTON_TF_ST2084_PQ) { - builder->params.min_luminance = 0.0; - builder->params.max_luminance = 10000.0; - } + builder->params.tf_info->tf == WESTON_TF_ST2084_PQ) + builder->params.max_luminance = + builder->params.min_luminance + 10000.0; } - /* - * If target luminance is not set, set it to negative. Same applies to - * maxCLL and maxFALL. - */ - + /* CM&HDR protocol states that if target luminance is not set, the + * target min and max luminances should have the same values as the + * primary min and max luminances. */ if (!(builder->group_mask & WESTON_COLOR_PROFILE_PARAMS_TARGET_LUMINANCE)) { - builder->params.target_min_luminance = -1.0f; - builder->params.target_max_luminance = -1.0f; + builder->params.target_min_luminance = builder->params.min_luminance; + builder->params.target_max_luminance = builder->params.max_luminance; } + /* If maxCLL and maxFALL are not set, set them to negative. */ if (!(builder->group_mask & WESTON_COLOR_PROFILE_PARAMS_MAXCLL)) builder->params.maxCLL = -1.0f; - if (!(builder->group_mask & WESTON_COLOR_PROFILE_PARAMS_MAXFALL)) builder->params.maxFALL = -1.0f; } diff --git a/libweston/color-properties.c b/libweston/color-properties.c index d9bbab7d1..812a6984a 100644 --- a/libweston/color-properties.c +++ b/libweston/color-properties.c @@ -45,38 +45,38 @@ static const struct weston_color_feature_info color_feature_info_table[] = { .feature = WESTON_COLOR_FEATURE_ICC, .desc = "Allow clients to use the new_icc_creator request " \ "from the CM&HDR protocol extension", - .protocol_feature = XX_COLOR_MANAGER_V4_FEATURE_ICC_V2_V4, + .protocol_feature = WP_COLOR_MANAGER_V1_FEATURE_ICC_V2_V4, }, { .feature = WESTON_COLOR_FEATURE_PARAMETRIC, .desc = "Allow clients to use the new_parametric_creator " \ "request from the CM&HDR protocol extension", - .protocol_feature = XX_COLOR_MANAGER_V4_FEATURE_PARAMETRIC, + .protocol_feature = WP_COLOR_MANAGER_V1_FEATURE_PARAMETRIC, }, { .feature = WESTON_COLOR_FEATURE_SET_PRIMARIES, .desc = "Allow clients to use the parametric set_primaries " \ "request from the CM&HDR protocol extension", - .protocol_feature = XX_COLOR_MANAGER_V4_FEATURE_SET_PRIMARIES, + .protocol_feature = WP_COLOR_MANAGER_V1_FEATURE_SET_PRIMARIES, }, { .feature = WESTON_COLOR_FEATURE_SET_TF_POWER, .desc = "Allow clients to use the parametric set_tf_power " \ "request from the CM&HDR protocol extension", - .protocol_feature = XX_COLOR_MANAGER_V4_FEATURE_SET_TF_POWER, + .protocol_feature = WP_COLOR_MANAGER_V1_FEATURE_SET_TF_POWER, }, { .feature = WESTON_COLOR_FEATURE_SET_LUMINANCES, .desc = "Allow clients to use the parametric set_luminances " \ "request from the CM&HDR protocol extension", - .protocol_feature = XX_COLOR_MANAGER_V4_FEATURE_SET_LUMINANCES, + .protocol_feature = WP_COLOR_MANAGER_V1_FEATURE_SET_LUMINANCES, }, { .feature = WESTON_COLOR_FEATURE_SET_MASTERING_DISPLAY_PRIMARIES, .desc = "Allow clients to use the parametric " \ "set_mastering_display_primaries request from the " \ "CM&HDR protocol extension", - .protocol_feature = XX_COLOR_MANAGER_V4_FEATURE_SET_MASTERING_DISPLAY_PRIMARIES, + .protocol_feature = WP_COLOR_MANAGER_V1_FEATURE_SET_MASTERING_DISPLAY_PRIMARIES, }, { .feature = WESTON_COLOR_FEATURE_EXTENDED_TARGET_VOLUME, @@ -85,7 +85,7 @@ static const struct weston_color_feature_info color_feature_info_table[] = { "primary color volume. This can only be supported when feature " \ "WESTON_COLOR_FEATURE_SET_MASTERING_DISPLAY_PRIMARIES " \ "is supported", - .protocol_feature = XX_COLOR_MANAGER_V4_FEATURE_EXTENDED_TARGET_VOLUME, + .protocol_feature = WP_COLOR_MANAGER_V1_FEATURE_EXTENDED_TARGET_VOLUME, }, }; @@ -93,35 +93,35 @@ static const struct weston_render_intent_info render_intent_info_table[] = { { .intent = WESTON_RENDER_INTENT_PERCEPTUAL, .desc = "Perceptual", - .protocol_intent = XX_COLOR_MANAGER_V4_RENDER_INTENT_PERCEPTUAL, + .protocol_intent = WP_COLOR_MANAGER_V1_RENDER_INTENT_PERCEPTUAL, LCMS_INTENT(INTENT_PERCEPTUAL), .bps = false, }, { .intent = WESTON_RENDER_INTENT_RELATIVE, .desc = "Media-relative colorimetric", - .protocol_intent = XX_COLOR_MANAGER_V4_RENDER_INTENT_RELATIVE, + .protocol_intent = WP_COLOR_MANAGER_V1_RENDER_INTENT_RELATIVE, LCMS_INTENT(INTENT_RELATIVE_COLORIMETRIC), .bps = false, }, { .intent = WESTON_RENDER_INTENT_SATURATION, .desc = "Saturation", - .protocol_intent = XX_COLOR_MANAGER_V4_RENDER_INTENT_SATURATION, + .protocol_intent = WP_COLOR_MANAGER_V1_RENDER_INTENT_SATURATION, LCMS_INTENT(INTENT_SATURATION), .bps = false, }, { .intent = WESTON_RENDER_INTENT_ABSOLUTE, .desc = "ICC-absolute colorimetric", - .protocol_intent = XX_COLOR_MANAGER_V4_RENDER_INTENT_ABSOLUTE, + .protocol_intent = WP_COLOR_MANAGER_V1_RENDER_INTENT_ABSOLUTE, LCMS_INTENT(INTENT_ABSOLUTE_COLORIMETRIC), .bps = false, }, { .intent = WESTON_RENDER_INTENT_RELATIVE_BPC, .desc = "Media-relative colorimetric + black point compensation", - .protocol_intent = XX_COLOR_MANAGER_V4_RENDER_INTENT_RELATIVE_BPC, + .protocol_intent = WP_COLOR_MANAGER_V1_RENDER_INTENT_RELATIVE_BPC, LCMS_INTENT(INTENT_RELATIVE_COLORIMETRIC), .bps = true, }, @@ -132,7 +132,7 @@ static const struct weston_color_primaries_info color_primaries_info_table[] = { .primaries = WESTON_PRIMARIES_CICP_SRGB, .desc = "Color primaries for the sRGB color space as defined by " \ "the BT.709 standard", - .protocol_primaries = XX_COLOR_MANAGER_V4_PRIMARIES_SRGB, + .protocol_primaries = WP_COLOR_MANAGER_V1_PRIMARIES_SRGB, .color_gamut = { .primary = { { 0.64, 0.33 }, /* RGB order */ { 0.30, 0.60 }, @@ -144,7 +144,7 @@ static const struct weston_color_primaries_info color_primaries_info_table[] = { { .primaries = WESTON_PRIMARIES_CICP_PAL_M, .desc = "Color primaries for PAL-M as defined by the BT.470 standard", - .protocol_primaries = XX_COLOR_MANAGER_V4_PRIMARIES_PAL_M, + .protocol_primaries = WP_COLOR_MANAGER_V1_PRIMARIES_PAL_M, .color_gamut = { .primary = { { 0.67, 0.33 }, /* RGB order */ { 0.21, 0.71 }, @@ -156,7 +156,7 @@ static const struct weston_color_primaries_info color_primaries_info_table[] = { { .primaries = WESTON_PRIMARIES_CICP_PAL, .desc = "Color primaries for PAL as defined by the BT.601 standard", - .protocol_primaries = XX_COLOR_MANAGER_V4_PRIMARIES_PAL, + .protocol_primaries = WP_COLOR_MANAGER_V1_PRIMARIES_PAL, .color_gamut = { .primary = { { 0.64, 0.33 }, /* RGB order */ { 0.29, 0.60 }, @@ -168,7 +168,7 @@ static const struct weston_color_primaries_info color_primaries_info_table[] = { { .primaries = WESTON_PRIMARIES_CICP_NTSC, .desc = "Color primaries for NTSC as defined by the BT.601 standard", - .protocol_primaries = XX_COLOR_MANAGER_V4_PRIMARIES_NTSC, + .protocol_primaries = WP_COLOR_MANAGER_V1_PRIMARIES_NTSC, .color_gamut = { .primary = { { 0.630, 0.340 }, /* RGB order */ { 0.310, 0.595 }, @@ -180,7 +180,7 @@ static const struct weston_color_primaries_info color_primaries_info_table[] = { { .primaries = WESTON_PRIMARIES_CICP_GENERIC_FILM, .desc = "Generic film with color filters using Illuminant C", - .protocol_primaries = XX_COLOR_MANAGER_V4_PRIMARIES_GENERIC_FILM, + .protocol_primaries = WP_COLOR_MANAGER_V1_PRIMARIES_GENERIC_FILM, .color_gamut = { .primary = { { 0.681, 0.319 }, /* RGB order */ { 0.243, 0.692 }, @@ -193,7 +193,7 @@ static const struct weston_color_primaries_info color_primaries_info_table[] = { .primaries = WESTON_PRIMARIES_CICP_BT2020, .desc = "Color primaries as defined by the BT.2020 and BT.2100 " \ "standard", - .protocol_primaries = XX_COLOR_MANAGER_V4_PRIMARIES_BT2020, + .protocol_primaries = WP_COLOR_MANAGER_V1_PRIMARIES_BT2020, .color_gamut = { .primary = { { 0.708, 0.292 }, /* RGB order */ { 0.170, 0.797 }, @@ -205,7 +205,7 @@ static const struct weston_color_primaries_info color_primaries_info_table[] = { { .primaries = WESTON_PRIMARIES_CICP_CIE1931_XYZ, .desc = "Color primaries of the full CIE 1931 XYZ color space", - .protocol_primaries = XX_COLOR_MANAGER_V4_PRIMARIES_CIE1931_XYZ, + .protocol_primaries = WP_COLOR_MANAGER_V1_PRIMARIES_CIE1931_XYZ, .color_gamut = { .primary = { { 1.0, 0.0 }, /* RGB order */ { 0.0, 1.0 }, @@ -218,7 +218,7 @@ static const struct weston_color_primaries_info color_primaries_info_table[] = { .primaries = WESTON_PRIMARIES_CICP_DCI_P3, .desc = "Color primaries of the DCI P3 color space as defined by " \ "the SMPTE RP 431 standard", - .protocol_primaries = XX_COLOR_MANAGER_V4_PRIMARIES_DCI_P3, + .protocol_primaries = WP_COLOR_MANAGER_V1_PRIMARIES_DCI_P3, .color_gamut = { .primary = { { 0.680, 0.320 }, /* RGB order */ { 0.265, 0.690 }, @@ -231,7 +231,7 @@ static const struct weston_color_primaries_info color_primaries_info_table[] = { .primaries = WESTON_PRIMARIES_CICP_DISPLAY_P3, .desc = "Color primaries of Display P3 variant of the DCI-P3 color " \ "space as defined by the SMPTE EG 432 standard", - .protocol_primaries = XX_COLOR_MANAGER_V4_PRIMARIES_DISPLAY_P3, + .protocol_primaries = WP_COLOR_MANAGER_V1_PRIMARIES_DISPLAY_P3, .color_gamut = { .primary = { { 0.680, 0.320 }, /* RGB order */ { 0.265, 0.690 }, @@ -244,7 +244,7 @@ static const struct weston_color_primaries_info color_primaries_info_table[] = { .primaries = WESTON_PRIMARIES_ADOBE_RGB, .desc = "Color primaries of the Adobe RGB color space as defined " \ "by the ISO 12640 standard", - .protocol_primaries = XX_COLOR_MANAGER_V4_PRIMARIES_ADOBE_RGB, + .protocol_primaries = WP_COLOR_MANAGER_V1_PRIMARIES_ADOBE_RGB, .color_gamut = { .primary = { { 0.64, 0.33 }, /* RGB order */ { 0.21, 0.71 }, @@ -257,87 +257,81 @@ static const struct weston_color_primaries_info color_primaries_info_table[] = { static const struct weston_color_tf_info color_tf_info_table[] = { { - .tf = WESTON_TF_LINEAR, - .desc = "Linear transfer function", - .protocol_tf = XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_LINEAR, + .tf = WESTON_TF_BT1886, + .desc = "BT.1886 transfer function", + .protocol_tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_BT1886, .count_parameters = 0, }, { .tf = WESTON_TF_GAMMA22, .desc = "Assumed display gamma 2.2 transfer function", - .protocol_tf = XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_GAMMA22, + .protocol_tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_GAMMA22, .count_parameters = 0, }, { .tf = WESTON_TF_GAMMA28, .desc = "Assumed display gamma 2.8 transfer function", - .protocol_tf = XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_GAMMA28, + .protocol_tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_GAMMA28, + .count_parameters = 0, + }, + { + .tf = WESTON_TF_EXT_LINEAR, + .desc = "Extended Linear transfer function", + .protocol_tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_EXT_LINEAR, .count_parameters = 0, }, { .tf = WESTON_TF_SRGB, .desc = "sRGB piece-wise transfer function", - .protocol_tf = XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_SRGB, + .protocol_tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB, .count_parameters = 0, }, { .tf = WESTON_TF_EXT_SRGB, .desc = "Extended sRGB piece-wise transfer function", - .protocol_tf = XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_EXT_SRGB, - .count_parameters = 0, - }, - { - .tf = WESTON_TF_BT709, - .desc = "BT.709 transfer function", - .protocol_tf = XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_BT709, - .count_parameters = 0, - }, - { - .tf = WESTON_TF_BT1361, - .desc = "BT.1361 extended transfer function", - .protocol_tf = XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_BT1361, + .protocol_tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_EXT_SRGB, .count_parameters = 0, }, { .tf = WESTON_TF_ST240, .desc = "SMPTE ST 240 transfer function", - .protocol_tf = XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_ST240, + .protocol_tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_ST240, .count_parameters = 0, }, { .tf = WESTON_TF_ST428, .desc = "SMPTE ST 428 transfer function", - .protocol_tf = XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_ST428, + .protocol_tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_ST428, .count_parameters = 0, }, { .tf = WESTON_TF_ST2084_PQ, .desc = "Perceptual quantizer transfer function", - .protocol_tf = XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_ST2084_PQ, + .protocol_tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_ST2084_PQ, .count_parameters = 0, }, { .tf = WESTON_TF_LOG_100, .desc = "Logarithmic 100:1 transfer function", - .protocol_tf = XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_LOG_100, + .protocol_tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_LOG_100, .count_parameters = 0, }, { .tf = WESTON_TF_LOG_316, .desc = "Logarithmic (100*Sqrt(10) : 1) transfer function", - .protocol_tf = XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_LOG_316, + .protocol_tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_LOG_316, .count_parameters = 0, }, { .tf = WESTON_TF_XVYCC, .desc = "IEC 61966-2-4 transfer function", - .protocol_tf = XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_XVYCC, + .protocol_tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_XVYCC, .count_parameters = 0, }, { .tf = WESTON_TF_HLG, .desc = "Hybrid log-gamma transfer function", - .protocol_tf = XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_HLG, + .protocol_tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_HLG, .count_parameters = 0, }, { diff --git a/libweston/color.h b/libweston/color.h index f5dd68a8e..043c59171 100644 --- a/libweston/color.h +++ b/libweston/color.h @@ -540,6 +540,21 @@ struct weston_color_manager { (*send_image_desc_info)(struct cm_image_desc_info *cm_image_desc_info, struct weston_color_profile *cprof_base); + /** Given a color profile, returns a reference to a profile that is + * guaranteed to be parametric and which is equivalent to the given + * profile. + * + * \param cprof_base The color profile. + * \param errmsg On success, untouched. On failure, a pointer to a + * string describing the error is stored here. The string must be + * free()'d. + * \return A reference to an equivalent parametric color profile, or + * NULL on failure. + */ + struct weston_color_profile * + (*get_parametric_color_profile)(struct weston_color_profile *cprof_base, + char **errmsg); + /** Destroy a color transform after refcount fell to zero */ void (*destroy_color_transform)(struct weston_color_transform *xform); diff --git a/libweston/compositor.c b/libweston/compositor.c index 0da681c8d..6ca1279dd 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -1042,7 +1042,7 @@ weston_surface_create(struct weston_compositor *compositor) surface->current_protection = WESTON_HDCP_DISABLE; surface->protection_mode = WESTON_SURFACE_PROTECTION_MODE_RELAXED; - wl_list_init(&surface->cm_feedback_surface_resource_list); + wl_list_init(&surface->cm_surface_feedback_resource_list); surface->cm_surface = NULL; /* The surfaces start with no color profile and render intent. It's up @@ -2758,7 +2758,7 @@ weston_surface_unref(struct weston_surface *surface) struct wl_resource *cb, *next; struct weston_view *ev, *nv; struct weston_pointer_constraint *constraint, *next_constraint; - struct wl_resource *cm_feedback_surface_res, *cm_feedback_surface_res_tmp; + struct wl_resource *cm_surface_feedback_res, *cm_surface_feedback_res_tmp; struct weston_paint_node *pnode, *pntmp; if (!surface) @@ -2814,12 +2814,12 @@ weston_surface_unref(struct weston_surface *surface) weston_color_profile_unref(surface->color_profile); weston_color_profile_unref(surface->preferred_color_profile); - wl_resource_for_each_safe(cm_feedback_surface_res, - cm_feedback_surface_res_tmp, - &surface->cm_feedback_surface_resource_list) { - wl_list_remove(wl_resource_get_link(cm_feedback_surface_res)); - wl_list_init(wl_resource_get_link(cm_feedback_surface_res)); - wl_resource_set_user_data(cm_feedback_surface_res, NULL); + wl_resource_for_each_safe(cm_surface_feedback_res, + cm_surface_feedback_res_tmp, + &surface->cm_surface_feedback_resource_list) { + wl_list_remove(wl_resource_get_link(cm_surface_feedback_res)); + wl_list_init(wl_resource_get_link(cm_surface_feedback_res)); + wl_resource_set_user_data(cm_surface_feedback_res, NULL); } if (surface->cm_surface) wl_resource_set_user_data(surface->cm_surface, NULL); diff --git a/protocol/color-management-v1.xml b/protocol/color-management-v1.xml deleted file mode 100644 index 17f217cee..000000000 --- a/protocol/color-management-v1.xml +++ /dev/null @@ -1,1453 +0,0 @@ - - - - Copyright 2019 Sebastian Wick - Copyright 2019 Erwin Burema - Copyright 2020 AMD - Copyright 2020-2024 Collabora, Ltd. - Copyright 2024 Xaver Hugl - - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the "Software"), - to deal in the Software without restriction, including without limitation - the rights to use, copy, modify, merge, publish, distribute, sublicense, - and/or sell copies of the Software, and to permit persons to whom the - Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice (including the next - paragraph) shall be included in all copies or substantial portions of the - Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - - - - The aim of the color management extension is to allow clients to know - the color properties of outputs, and to tell the compositor about the color - properties of their content on surfaces. Doing this enables a compositor - to perform automatic color management of content for different outputs - according to how content is intended to look like. - - The color properties are represented as an image description object which - is immutable after it has been created. A wl_output always has an - associated image description that clients can observe. A wl_surface - always has an associated preferred image description as a hint chosen by - the compositor that clients can also observe. Clients can set an image - description on a wl_surface to denote the color characteristics of the - surface contents. - - An image description includes SDR and HDR colorimetry and encoding, HDR - metadata, and viewing environment parameters. An image description does - not include the properties set through color-representation extension. - It is expected that the color-representation extension is used in - conjunction with the color management extension when necessary, - particularly with the YUV family of pixel formats. - - Recommendation ITU-T H.273 - "Coding-independent code points for video signal type identification" - shall be referred to as simply H.273 here. - - The color-and-hdr repository - (https://gitlab.freedesktop.org/pq/color-and-hdr) contains - background information on the protocol design and legacy color management. - It also contains a glossary, learning resources for digital color, tools, - samples and more. - - The terminology used in this protocol is based on common color science and - color encoding terminology where possible. The glossary in the color-and-hdr - repository shall be the authority on the definition of terms in this - protocol. - - - - - A global interface used for getting color management extensions for - wl_surface and wl_output objects, and for creating client defined image - description objects. The extension interfaces allow - getting the image description of outputs and setting the image - description of surfaces. - - - - - Destroy the xx_color_manager_v4 object. This does not affect any other - objects in any way. - - - - - - - - - - - See the ICC.1:2022 specification from the International Color Consortium - for more details about rendering intents. - - The principles of ICC defined rendering intents apply with all types of - image descriptions, not only those with ICC file profiles. - - Compositors must support the perceptual rendering intent. Other - rendering intents are optional. - - - - - - - - - - - - - - - - - - - - The compositor supports set_mastering_display_primaries request with a - target color volume fully contained inside the primary color volume. - - - - - The compositor additionally supports target color volumes that - extend outside of the primary color volume. - - This can only be advertised if feature set_mastering_display_primaries - is supported as well. - - - - - - - Named color primaries used to encode well-known sets of primaries. H.273 - is the authority, when it comes to the exact values of primaries and - authoritative specifications, where an equivalent code point exists. - - Descriptions do list the specifications for convenience. - - - - - Color primaries as defined by - - Rec. ITU-R BT.709-6 - - Rec. ITU-R BT.1361-0 conventional colour gamut system and extended - colour gamut system (historical) - - IEC 61966-2-1 sRGB or sYCC - - IEC 61966-2-4 - - Society of Motion Picture and Television Engineers (SMPTE) RP 177 - (1993) Annex B - Equivalent to H.273 ColourPrimaries code point 1. - - - - - Color primaries as defined by - - Rec. ITU-R BT.470-6 System M (historical) - - United States National Television System Committee 1953 - Recommendation for transmission standards for color television - - United States Federal Communications Commission (2003) Title 47 Code - of Federal Regulations 73.682 (a)(20) - Equivalent to H.273 ColourPrimaries code point 4. - - - - - Color primaries as defined by - - Rec. ITU-R BT.470-6 System B, G (historical) - - Rec. ITU-R BT.601-7 625 - - Rec. ITU-R BT.1358-0 625 (historical) - - Rec. ITU-R BT.1700-0 625 PAL and 625 SECAM - Equivalent to H.273 ColourPrimaries code point 5. - - - - - Color primaries as defined by - - Rec. ITU-R BT.601-7 525 - - Rec. ITU-R BT.1358-1 525 or 625 (historical) - - Rec. ITU-R BT.1700-0 NTSC - - SMPTE 170M (2004) - - SMPTE 240M (1999) (historical) - Equivalent to H.273 ColourPrimaries code point 6 and 7. - - - - - Color primaries as defined by H.273 for generic film. - Equivalent to H.273 ColourPrimaries code point 8. - - - - - Color primaries as defined by - - Rec. ITU-R BT.2020-2 - - Rec. ITU-R BT.2100-0 - Equivalent to H.273 ColourPrimaries code point 9. - - - - - Color primaries as defined as the maximum of the CIE 1931 XYZ color - space by - - SMPTE ST 428-1 - - (CIE 1931 XYZ as in ISO 11664-1) - Equivalent to H.273 ColourPrimaries code point 10. - - - - - Color primaries as defined by Digital Cinema System and published in - SMPTE RP 431-2 (2011). Equivalent to H.273 ColourPrimaries code point - 11. - - - - - Color primaries as defined by Digital Cinema System and published in - SMPTE EG 432-1 (2010). - Equivalent to H.273 ColourPrimaries code point 12. - - - - - Color primaries as defined by Adobe as "Adobe RGB" and later published - by ISO 12640-4 (2011). - - - - - - - Named transfer functions used to encode well-known transfer - characteristics. H.273 is the authority, when it comes to the exact - formulas and authoritative specifications, where an equivalent code - point exists. - - Descriptions do list the specifications for convenience. - - - - - Transfer characteristics as defined by - - Rec. ITU-R BT.709-6 - - Rec. ITU-R BT.1361-0 conventional colour gamut system (historical) - Equivalent to H.273 TransferCharacteristics code point 1, 6, 14, 15. - - - - - Transfer characteristics as defined by - - Rec. ITU-R BT.470-6 System M (historical) - - United States National Television System Committee 1953 - Recommendation for transmission standards for color television - - United States Federal Communications Commission (2003) Title 47 Code - of Federal Regulations 73.682 (a) (20) - - Rec. ITU-R BT.1700-0 625 PAL and 625 SECAM - Equivalent to H.273 TransferCharacteristics code point 4. - - - - - Transfer characteristics as defined by - - Rec. ITU-R BT.470-6 System B, G (historical) - Equivalent to H.273 TransferCharacteristics code point 5. - - - - - Transfer characteristics as defined by - - SMPTE ST 240 (1999) - Equivalent to H.273 TransferCharacteristics code point 7. - - - - - Linear transfer characteristics. - Equivalent to H.273 TransferCharacteristics code point 8. - - - - - Logarithmic transfer characteristic (100:1 range). - Equivalent to H.273 TransferCharacteristics code point 9. - - - - - Logarithmic transfer characteristic (100 * Sqrt(10) : 1 range). - Equivalent to H.273 TransferCharacteristics code point 10. - - - - - Transfer characteristics as defined by - - IEC 61966-2-4 - Equivalent to H.273 TransferCharacteristics code point 11. - - - - - Transfer characteristics as defined by - - Rec. ITU-R BT.1361-0 extended colour gamut system (historical) - Equivalent to H.273 TransferCharacteristics code point 12. - - - - - Transfer characteristics as defined by - - IEC 61966-2-1 sRGB - Equivalent to H.273 TransferCharacteristics code point 13 with - MatrixCoefficients set to 0. - - - - - Transfer characteristics as defined by - - IEC 61966-2-1 sYCC - Equivalent to H.273 TransferCharacteristics code point 13 with - MatrixCoefficients set to anything but 0. - - - - - Transfer characteristics as defined by - - SMPTE ST 2084 (2014) for 10-, 12-, 14- and 16-bit systems - - Rec. ITU-R BT.2100-2 perceptual quantization (PQ) system - Equivalent to H.273 TransferCharacteristics code point 16. - - This TF implies these default luminances - - primary color volume minimum: 0.005 cd/m² - - primary color volume maximum: 10000 cd/m² - - reference white: 203 cd/m² - - - - - Transfer characteristics as defined by - - SMPTE ST 428-1 (2019) - Equivalent to H.273 TransferCharacteristics code point 17. - - - - - Transfer characteristics as defined by - - ARIB STD-B67 (2015) - - Rec. ITU-R BT.2100-2 hybrid log-gamma (HLG) system - Equivalent to H.273 TransferCharacteristics code point 18. - - This TF implies these default luminances - - primary color volume minimum: 0.005 cd/m² - - primary color volume maximum: 1000 cd/m² - - reference white: 203 cd/m² - Note: HLG is a scene referred signal. All absolute luminance values - used here for HLG assume a 1000 cd/m² display. - - - - - - - This creates a new xx_color_management_output_v4 object for the - given wl_output. - - See the xx_color_management_output_v4 interface for more details. - - - - - - - - - If a xx_color_management_surface_v4 object already exists for the given - wl_surface, the protocol error surface_exists is raised. - - This creates a new color xx_color_management_surface_v4 object for the - given wl_surface. - - See the xx_color_management_surface_v4 interface for more details. - - - - - - - - - This creates a new color xx_color_management_feedback_surface_v4 object - for the given wl_surface. - - See the xx_color_management_feedback_surface_v4 interface for more - details. - - - - - - - - - Makes a new ICC-based image description creator object with all - properties initially unset. The client can then use the object's - interface to define all the required properties for an image description - and finally create a xx_image_description_v4 object. - - This request can be used when the compositor advertises - xx_color_manager_v4.feature.icc_v2_v4. - Otherwise this request raises the protocol error unsupported_feature. - - - - - - - - Makes a new parametric image description creator object with all - properties initially unset. The client can then use the object's - interface to define all the required properties for an image description - and finally create a xx_image_description_v4 object. - - This request can be used when the compositor advertises - xx_color_manager_v4.feature.parametric. - Otherwise this request raises the protocol error unsupported_feature. - - - - - - - - When this object is created, it shall immediately send this event once - for each rendering intent the compositor supports. - - - - - - - - When this object is created, it shall immediately send this event once - for each compositor supported feature listed in the enumeration. - - - - - - - - When this object is created, it shall immediately send this event once - for each named transfer function the compositor supports with the - parametric image description creator. - - - - - - - - When this object is created, it shall immediately send this event once - for each named set of primaries the compositor supports with the - parametric image description creator. - - - - - - - - - A xx_color_management_output_v4 describes the color properties of an - output. - - The xx_color_management_output_v4 is associated with the wl_output global - underlying the wl_output object. Therefore the client destroying the - wl_output object has no impact, but the compositor removing the output - global makes the xx_color_management_output_v4 object inert. - - - - - Destroy the color xx_color_management_output_v4 object. This does not - affect any remaining protocol objects. - - - - - - This event is sent whenever the image description of the output changed, - followed by one wl_output.done event common to output events across all - extensions. - - If the client wants to use the updated image description, it needs to do - get_image_description again, because image description objects are - immutable. - - - - - - This creates a new xx_image_description_v4 object for the current image - description of the output. There always is exactly one image description - active for an output so the client should destroy the image description - created by earlier invocations of this request. This request is usually - sent as a reaction to the image_description_changed event or when - creating a xx_color_management_output_v4 object. - - The image description of an output represents the color encoding the - output expects. There might be performance and power advantages, as well - as improved color reproduction, if a content update matches the image - description of the output it is being shown on. If a content update is - shown on any other output than the one it matches the image description - of, then the color reproduction on those outputs might be considerably - worse. - - The created xx_image_description_v4 object preserves the image - description of the output from the time the object was created. - - The resulting image description object allows get_information request. - - If this protocol object is inert, the resulting image description object - shall immediately deliver the xx_image_description_v4.failed event with - the no_output cause. - - If the interface version is inadequate for the output's image - description, meaning that the client does not support all the events - needed to deliver the crucial information, the resulting image - description object shall immediately deliver the - xx_image_description_v4.failed event with the low_version cause. - - Otherwise the object shall immediately deliver the ready event. - - - - - - - - - A xx_color_management_surface_v4 allows the client to set the color - space and HDR properties of a surface. - - If the wl_surface associated with the xx_color_management_surface_v4 is - destroyed, the xx_color_management_surface_v4 object becomes inert. - - - - - Destroy the xx_color_management_surface_v4 object and do the same as - unset_image_description. - - - - - - - - - - - - Set the image description of the underlying surface. The image - description and rendering intent are double-buffered state, see - wl_surface.commit. - - It is the client's responsibility to understand the image description - it sets on a surface, and to provide content that matches that image - description. Compositors might convert images to match their own or any - other image descriptions. - - Image description whose creation gracefully failed (received - xx_image_description_v4.failed) are forbidden in this request, and in - such case the protocol error image_description is raised. - - All image descriptions whose creation succeeded (received - xx_image_description_v4.ready) are allowed and must always be accepted - by the compositor. - - A rendering intent provides the client's preference on how content - colors should be mapped to each output. The render_intent value must - be one advertised by the compositor with - xx_color_manager_v4.render_intent event, otherwise the protocol error - render_intent is raised. - - By default, a surface does not have an associated image description - nor a rendering intent. The handling of color on such surfaces is - compositor implementation defined. Compositors should handle such - surfaces as sRGB but may handle them differently if they have specific - requirements. - - - - - - - - - This request removes any image description from the surface. See - set_image_description for how a compositor handles a surface without - an image description. This is double-buffered state, see - wl_surface.commit. - - - - - - - A xx_color_management_feedback_surface_v4 allows the client to get the - preferred color description of a surface. - - If the wl_surface associated with this object is destroyed, the - xx_color_management_feedback_surface_v4 object becomes inert. - - - - - Destroy the xx_color_management_feedback_surface_v4 object. - - - - - - - - - - - The preferred image description is the one which likely has the most - performance and/or quality benefits for the compositor if used by the - client for its wl_surface contents. This event is sent whenever the - compositor changes the wl_surface's preferred image description. - - This event is merely a notification. When the client wants to know - what the preferred image description is, it shall use the get_preferred - request. - - The preferred image description is not automatically used for anything. - It is only a hint, and clients may set any valid image description with - set_image_description but there might be performance and color accuracy - improvements by providing the wl_surface contents in the preferred - image description. Therefore clients that can, should render according - to the preferred image description - - - - - - If this protocol object is inert, the protocol error inert is raised. - - The preferred image description represents the compositor's preferred - color encoding for this wl_surface at the current time. There might be - performance and power advantages, as well as improved color - reproduction, if the image description of a content update matches the - preferred image description. - - This creates a new xx_image_description_v4 object for the currently - preferred image description for the wl_surface. The client should - stop using and destroy the image descriptions created by earlier - invocations of this request for the associated wl_surface. - This request is usually sent as a reaction to the preferred_changed - event or when creating a xx_color_management_feedback_surface_v4 object - if the client is capable of adapting to image descriptions. - - The created xx_image_description_v4 object preserves the preferred image - description of the wl_surface from the time the object was created. - - The resulting image description object allows get_information request. - - If the interface version is inadequate for the preferred image - description, meaning that the client does not support all the - events needed to deliver the crucial information, the resulting image - description object shall immediately deliver the - xx_image_description_v4.failed event with the low_version cause, - otherwise the object shall immediately deliver the ready event. - - - - - - - - - This type of object is used for collecting all the information required - to create a xx_image_description_v4 object from an ICC file. A complete - set of required parameters consists of these properties: - - ICC file - - Each required property must be set exactly once if the client is to create - an image description. The set requests verify that a property was not - already set. The create request verifies that all required properties are - set. There may be several alternative requests for setting each property, - and in that case the client must choose one of them. - - Once all properties have been set, the create request must be used to - create the image description object, destroying the creator in the - process. - - - - - - - - - - - - - - - Create an image description object based on the ICC information - previously set on this object. A compositor must parse the ICC data in - some undefined but finite amount of time. - - The completeness of the parameter set is verified. If the set is not - complete, the protocol error incomplete_set is raised. For the - definition of a complete set, see the description of this interface. - - If the particular combination of the information is not supported - by the compositor, the resulting image description object shall - immediately deliver the xx_image_description_v4.failed event with the - 'unsupported' cause. If a valid image description was created from the - information, the xx_image_description_v4.ready event will eventually - be sent instead. - - This request destroys the xx_image_description_creator_icc_v4 object. - - The resulting image description object does not allow get_information - request. - - - - - - - - Sets the ICC profile file to be used as the basis of the image - description. - - The data shall be found through the given fd at the given offset, having - the given length. The fd must seekable and readable. Violating these - requirements raises the bad_fd protocol error. - - If reading the data fails due to an error independent of the client, the - compositor shall send the xx_image_description_v4.failed event on the - created xx_image_description_v4 with the 'operating_system' cause. - - The maximum size of the ICC profile is 4 MB. If length is greater than - that or zero, the protocol error bad_size is raised. If offset + length - exceeds the file size, the protocol error out_of_file is raised. - - A compositor may read the file at any time starting from this request - and only until whichever happens first: - - If create request was issued, the xx_image_description_v4 object - delivers either failed or ready event; or - - if create request was not issued, this - xx_image_description_creator_icc_v4 object is destroyed. - - A compositor shall not modify the contents of the file, and the fd may - be sealed for writes and size changes. The client must ensure to its - best ability that the data does not change while the compositor is - reading it. - - The data must represent a valid ICC profile. The ICC profile version - must be 2 or 4, it must be a 3 channel profile and the class must be - Display or ColorSpace. Violating these requirements will not result in a - protocol error but will eventually send the - xx_image_description_v4.failed event on the created - xx_image_description_v4 with the 'unsupported' cause. - - See the International Color Consortium specification ICC.1:2022 for more - details about ICC profiles. - - If ICC file has already been set on this object, the protocol error - already_set is raised. - - - - - - - - - - - This type of object is used for collecting all the parameters required - to create a xx_image_description_v4 object. A complete set of required - parameters consists of these properties: - - transfer characteristic function (tf) - - chromaticities of primaries and white point (primary color volume) - - The following properties are optional and have a well-defined default - if not explicitly set: - - primary color volume luminance range - - reference white luminance level - - mastering display primaries and white point (target color volume) - - mastering luminance range - - maximum content light level - - maximum frame-average light level - - Each required property must be set exactly once if the client is to create - an image description. The set requests verify that a property was not - already set. The create request verifies that all required properties are - set. There may be several alternative requests for setting each property, - and in that case the client must choose one of them. - - Once all properties have been set, the create request must be used to - create the image description object, destroying the creator in the - process. - - - - - - - - - - - - - - - - - - Create an image description object based on the parameters previously - set on this object. - - The completeness of the parameter set is verified. If the set is not - complete, the protocol error incomplete_set is raised. For the - definition of a complete set, see the description of this interface. - - Also, the combination of the parameter set is verified. If the set is - not consistent, the protocol error inconsistent_set is raised. - - If the particular combination of the parameter set is not supported - by the compositor, the resulting image description object shall - immediately deliver the xx_image_description_v4.failed event with the - 'unsupported' cause. If a valid image description was created from the - parameter set, the xx_image_description_v4.ready event will eventually - be sent instead. - - This request destroys the xx_image_description_creator_params_v4 - object. - - The resulting image description object does not allow get_information - request. - - - - - - - - Sets the transfer characteristic using explicitly enumerated named - functions. - - When the resulting image description is attached to an image, the - content should be encoded and decoded according to the industry standard - practices for the transfer characteristic. - - Only names advertised with xx_color_manager_v4 event supported_tf_named - are allowed. Other values shall raise the protocol error invalid_tf. - - If transfer characteristic has already been set on this object, the - protocol error already_set is raised. - - - - - - - - Sets the color component transfer characteristic to a power curve with - the given exponent. This curve represents the conversion from electrical - to optical pixel or color values. - - When the resulting image description is attached to an image, the - content should be encoded with the inverse of the power curve. - - The curve exponent shall be multiplied by 10000 to get the argument eexp - value to carry the precision of 4 decimals. - - The curve exponent must be at least 1.0 and at most 10.0. Otherwise the - protocol error invalid_tf is raised. - - If transfer characteristic has already been set on this object, the - protocol error already_set is raised. - - This request can be used when the compositor advertises - xx_color_manager_v4.feature.set_tf_power. Otherwise this request raises - the protocol error unsupported_feature. - - - - - - - - Sets the color primaries and white point using explicitly named sets. - This describes the primary color volume which is the basis for color - value encoding. - - Only names advertised with xx_color_manager_v4 event - supported_primaries_named are allowed. Other values shall raise the - protocol error invalid_primaries. - - If primaries have already been set on this object, the protocol error - already_set is raised. - - - - - - - - Sets the color primaries and white point using CIE 1931 xy chromaticity - coordinates. This describes the primary color volume which is the basis - for color value encoding. - - Each coordinate value is multiplied by 10000 to get the argument value - to carry precision of 4 decimals. - - If primaries have already been set on this object, the protocol error - already_set is raised. - - This request can be used if the compositor advertises - xx_color_manager_v4.feature.set_primaries. Otherwise this request raises - the protocol error unsupported_feature. - - - - - - - - - - - - - - - Sets the primary color volume luminance range and the reference white - luminance level. - - The default luminances are - - primary color volume minimum: 0.2 cd/m² - - primary color volume maximum: 80 cd/m² - - reference white: 80 cd/m² - - Setting a named transfer characteristic can imply other default - luminances. - - The default luminances get overwritten when this request is used. - - 'min_lum' and 'max_lum' specify the minimum and maximum luminances of - the primary color volume as reproduced by the targeted display. - - 'reference_lum' specifies the luminance of the reference white as - reproduced by the targeted display, and reflects the targeted viewing - environment. - - Compositors should make sure that all content is anchored, meaning that - an input signal level of 'reference_lum' on one image description and - another input signal level of 'reference_lum' on another image - description should produce the same output level, even though the - 'reference_lum' on both image representations can be different. - - If 'max_lum' is less than the 'reference_lum', or 'reference_lum' is - less than or equal to 'min_lum', the protocol error invalid_luminance is - raised. - - The minimum luminance is multiplied by 10000 to get the argument - 'min_lum' value and carries precision of 4 decimals. The maximum - luminance and reference white luminance values are unscaled. - - If the primary color volume luminance range and the reference white - luminance level have already been set on this object, the protocol error - already_set is raised. - - This request can be used if the compositor advertises - xx_color_manager_v4.feature.set_luminances. Otherwise this request - raises the protocol error unsupported_feature. - - - - - - - - - - Provides the color primaries and white point of the mastering display - using CIE 1931 xy chromaticity coordinates. This is compatible with the - SMPTE ST 2086 definition of HDR static metadata. - - The mastering display primaries define the target color volume. - - If mastering display primaries are not explicitly set, the target color - volume is assumed to be equal to the primary color volume. - - The target color volume is defined by all tristimulus values between 0.0 - and 1.0 (inclusive) of the color space defined by the given mastering - display primaries and white point. The colorimetry is identical between - the container color space and the mastering display color space, - including that no chromatic adaptation is applied even if the white - points differ. - - The target color volume can exceed the primary color volume to allow for - a greater color volume with an existing color space definition (for - example scRGB). It can be smaller than the primary color volume to - minimize gamut and tone mapping distances for big color spaces (HDR - metadata). - - To make use of the entire target color volume a suitable pixel format - has to be chosen (e.g. floating point to exceed the primary color - volume, or abusing limited quantization range as with xvYCC). - - Each coordinate value is multiplied by 10000 to get the argument value - to carry precision of 4 decimals. - - If mastering display primaries have already been set on this object, the - protocol error already_set is raised. - - This request can be used if the compositor advertises - xx_color_manager_v4.feature.set_mastering_display_primaries. Otherwise - this request raises the protocol error unsupported_feature. The - advertisement implies support only for target color volumes fully - contained within the primary color volume. - - If a compositor additionally supports target color volume exceeding the - primary color volume, it must advertise - xx_color_manager_v4.feature.extended_target_volume. If a client uses - target color volume exceeding the primary color volume and the - compositor does not support it, the result is implementation defined. - Compositors are recommended to detect this case and fail the image - description gracefully, but it may as well result in color artifacts. - - - - - - - - - - - - - - - Sets the luminance range that was used during the content mastering - process as the minimum and maximum absolute luminance L. This is - compatible with the SMPTE ST 2086 definition of HDR static metadata. - - The mastering luminance range is undefined by default. - - If max L is less than or equal to min L, the protocol error - invalid_luminance is raised. - - Min L value is multiplied by 10000 to get the argument min_lum value - and carry precision of 4 decimals. Max L value is unscaled for max_lum. - - - - - - - - - Sets the maximum content light level (max_cll) as defined by CTA-861-H. - - This can only be set when set_tf_cicp is used to set the transfer - characteristic to Rec. ITU-R BT.2100-2 perceptual quantization system. - Otherwise, 'create' request shall raise inconsistent_set protocol - error. - - max_cll is undefined by default. - - - - - - - - Sets the maximum frame-average light level (max_fall) as defined by - CTA-861-H. - - This can only be set when set_tf_cicp is used to set the transfer - characteristic to Rec. ITU-R BT.2100-2 perceptual quantization system. - Otherwise, 'create' request shall raise inconsistent_set protocol error. - - max_fall is undefined by default. - - - - - - - - - An image description carries information about the color encoding used on - a surface when attached to a wl_surface via - xx_color_management_surface_v4.set_image_description. A compositor can use - this information to decode pixel values into colorimetrically meaningful - quantities. - - Note, that the xx_image_description_v4 object is not ready to be used - immediately after creation. The object eventually delivers either the - 'ready' or the 'failed' event, specified in all requests creating it. The - object is deemed "ready" after receiving the 'ready' event. - - An object which is not ready is illegal to use, it can only be destroyed. - Any other request in this interface shall result in the 'not_ready' - protocol error. Attempts to use an object which is not ready through other - interfaces shall raise protocol errors defined there. - - Once created and regardless of how it was created, a - xx_image_description_v4 object always refers to one fixed image - description. It cannot change after creation. - - - - - Destroy this object. It is safe to destroy an object which is not ready. - - Destroying a xx_image_description_v4 object has no side-effects, not - even if a xx_color_management_surface_v4.set_image_description has not - yet been followed by a wl_surface.commit. - - - - - - - - - - - - - - - - - - - - - - If creating a xx_image_description_v4 object fails for a reason that is - not defined as a protocol error, this event is sent. - - The requests that create image description objects define whether and - when this can occur. Only such creation requests can trigger this event. - This event cannot be triggered after the image description was - successfully formed. - - Once this event has been sent, the xx_image_description_v4 object will - never become ready and it can only be destroyed. - - - - - - - - - Once this event has been sent, the xx_image_description_v4 object is - deemed "ready". Ready objects can be used to send requests and can be - used through other interfaces. - - Every ready xx_image_description_v4 protocol object refers to an - underlying image description record in the compositor. Multiple protocol - objects may end up referring to the same record. Clients may identify - these "copies" by comparing their id numbers: if the numbers from two - protocol objects are identical, the protocol objects refer to the same - image description record. Two different image description records - cannot have the same id number simultaneously. The id number does not - change during the lifetime of the image description record. - - The id number is valid only as long as the protocol object is alive. If - all protocol objects referring to the same image description record are - destroyed, the id number may be recycled for a different image - description record. - - Image description id number is not a protocol object id. Zero is - reserved as an invalid id number. It shall not be possible for a client - to refer to an image description by its id number in protocol. The id - numbers might not be portable between Wayland connections. - - This identity allows clients to de-duplicate image description records - and avoid get_information request if they already have the image - description information. - - - - - - - - Creates a xx_image_description_info_v4 object which delivers the - information that makes up the image description. - - Not all image description protocol objects allow get_information - request. Whether it is allowed or not is defined by the request that - created the object. If get_information is not allowed, the protocol - error no_information is raised. - - - - - - - - - Sends all matching events describing an image description object exactly - once and finally sends the 'done' event. - - Once a xx_image_description_info_v4 object has delivered a 'done' event it - is automatically destroyed. - - Every xx_image_description_info_v4 created from the same - xx_image_description_v4 shall always return the exact same data. - - - - - Signals the end of information events and destroys the object. - - - - - - The icc argument provides a file descriptor to the client which may be - memory-mapped to provide the ICC profile matching the image description. - The fd is read-only, and if mapped then it must be mapped with - MAP_PRIVATE by the client. - - The ICC profile version and other details are determined by the - compositor. There is no provision for a client to ask for a specific - kind of a profile. - - - - - - - - - - Delivers the primary color volume primaries and white point using CIE - 1931 xy chromaticity coordinates. - - Each coordinate value is multiplied by 10000 to get the argument value - to carry precision of 4 decimals. - - - - - - - - - - - - - - - Delivers the primary color volume primaries and white point using an - explicitly enumerated named set. - - - - - - - - The color component transfer characteristic of this image description is - a pure power curve. This event provides the exponent of the power - function. This curve represents the conversion from electrical to - optical pixel or color values. - - The curve exponent has been multiplied by 10000 to get the argument eexp - value to carry the precision of 4 decimals. - - - - - - - - Delivers the transfer characteristic using an explicitly enumerated - named function. - - - - - - - - Delivers the primary color volume luminance range and the reference - white luminance level. - - The minimum luminance is multiplied by 10000 to get the argument - 'min_lum' value and carries precision of 4 decimals. The maximum - luminance and reference white luminance values are unscaled. - - - - - - - - - - Provides the color primaries and white point of the target color volume - using CIE 1931 xy chromaticity coordinates. This is compatible with the - SMPTE ST 2086 definition of HDR static metadata for mastering displays. - - While primary color volume is about how color is encoded, the target - color volume is the actually displayable color volume. If target color - volume is equal to the primary color volume, then this event is not - sent. - - Each coordinate value is multiplied by 10000 to get the argument value - to carry precision of 4 decimals. - - - - - - - - - - - - - - - Provides the luminance range that the image description is targeting as - the minimum and maximum absolute luminance L. This is compatible with - the SMPTE ST 2086 definition of HDR static metadata. - - This luminance range is only theoretical and may not correspond to the - luminance of light emitted on an actual display. - - Min L value is multiplied by 10000 to get the argument min_lum value and - carry precision of 4 decimals. Max L value is unscaled for max_lum. - - - - - - - - - Provides the targeted max_cll of the image description. max_cll is - defined by CTA-861-H. - - This luminance is only theoretical and may not correspond to the - luminance of light emitted on an actual display. - - - - - - - - Provides the targeted max_fall of the image description. max_fall is - defined by CTA-861-H. - - This luminance is only theoretical and may not correspond to the - luminance of light emitted on an actual display. - - - - - - diff --git a/protocol/meson.build b/protocol/meson.build index d1073541a..94887d97b 100644 --- a/protocol/meson.build +++ b/protocol/meson.build @@ -1,7 +1,7 @@ dep_scanner = dependency('wayland-scanner', native: true) prog_scanner = find_program(dep_scanner.get_variable(pkgconfig: 'wayland_scanner')) -dep_wp = dependency('wayland-protocols', version: '>= 1.33', +dep_wp = dependency('wayland-protocols', version: '>= 1.41', fallback: ['wayland-protocols', 'wayland_protocols']) dir_wp_base = dep_wp.get_variable(pkgconfig: 'pkgdatadir', internal: 'pkgdatadir') @@ -16,7 +16,7 @@ install_data( ) generated_protocols = [ - [ 'color-management-v1', 'internal' ], + [ 'color-management', 'staging', 'v1' ], [ 'fullscreen-shell', 'unstable', 'v1' ], [ 'fractional-scale', 'staging', 'v1' ], [ 'input-method', 'unstable', 'v1' ], diff --git a/tests/color-management-parametric-test.c b/tests/color-management-parametric-test.c index a3999ade6..346c447cf 100644 --- a/tests/color-management-parametric-test.c +++ b/tests/color-management-parametric-test.c @@ -49,7 +49,7 @@ enum error_point { }; struct image_description { - struct xx_image_description_v4 *xx_image_desc; + struct wp_image_description_v1 *wp_image_desc; enum image_description_status { CM_IMAGE_DESC_NOT_CREATED = 0, CM_IMAGE_DESC_READY, @@ -61,27 +61,29 @@ struct image_description { }; struct color_manager { - struct xx_color_manager_v4 *manager; + struct wp_color_manager_v1 *manager; /* Bitfield that holds what color features are supported. If enum - * xx_color_manager_v4_feature v is supported, bit v will be set + * wp_color_manager_v1_feature v is supported, bit v will be set * to 1. */ uint32_t supported_features; /* Bitfield that holds what rendering intents are supported. If enum - * xx_color_manager_v4_render_intent v is supported, bit v will be set + * wp_color_manager_v1_render_intent v is supported, bit v will be set * to 1. */ uint32_t supported_rendering_intents; /* Bitfield that holds what color primaries are supported. If enum - * xx_color_manager_v4_primaries v is supported, bit v will be set + * wp_color_manager_v1_primaries v is supported, bit v will be set * to 1. */ uint32_t supported_color_primaries; /* Bitfield that holds what transfer functions are supported. If enum - * xx_color_manager_v4_transfer_function v is supported, bit v will be + * wp_color_manager_v1_transfer_function v is supported, bit v will be * set to 1. */ uint32_t supported_tf; + + bool done; }; struct test_case { @@ -128,9 +130,9 @@ static const struct weston_color_gamut color_gamut_invalid_white_point = { static const struct test_case good_test_cases[] = { { /* sRGB primaries with sRGB TF; succeeds. */ - .primaries_named = XX_COLOR_MANAGER_V4_PRIMARIES_SRGB, + .primaries_named = WP_COLOR_MANAGER_V1_PRIMARIES_SRGB, .primaries = NULL, - .tf_named = XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_SRGB, + .tf_named = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB, .tf_power = NOT_SET, .primaries_min_lum = NOT_SET, .primaries_max_lum = NOT_SET, @@ -147,7 +149,7 @@ static const struct test_case good_test_cases[] = { /* Custom primaries with sRGB TF; succeeds. */ .primaries_named = NOT_SET, .primaries = &color_gamut_sRGB, - .tf_named = XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_SRGB, + .tf_named = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB, .tf_power = NOT_SET, .primaries_min_lum = NOT_SET, .primaries_max_lum = NOT_SET, @@ -164,7 +166,7 @@ static const struct test_case good_test_cases[] = { /* sRGB primaries, sRGB TF and valid luminance values; succeeds. */ .primaries_named = NOT_SET, .primaries = &color_gamut_sRGB, - .tf_named = XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_SRGB, + .tf_named = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB, .tf_power = NOT_SET, .primaries_min_lum = 0.5, .primaries_max_lum = 2000, @@ -179,7 +181,7 @@ static const struct test_case good_test_cases[] = { }, { /* sRGB primaries with custom power-law TF; succeeds. */ - .primaries_named = XX_COLOR_MANAGER_V4_PRIMARIES_SRGB, + .primaries_named = WP_COLOR_MANAGER_V1_PRIMARIES_SRGB, .primaries = NULL, .tf_named = NOT_SET, .tf_power = 2.4f, @@ -196,9 +198,9 @@ static const struct test_case good_test_cases[] = { }, { /* sRGB primaries, sRGB TF and valid target primaries; succeeds. */ - .primaries_named = XX_COLOR_MANAGER_V4_PRIMARIES_SRGB, + .primaries_named = WP_COLOR_MANAGER_V1_PRIMARIES_SRGB, .primaries = NULL, - .tf_named = XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_SRGB, + .tf_named = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB, .tf_power = NOT_SET, .primaries_min_lum = NOT_SET, .primaries_max_lum = NOT_SET, @@ -213,9 +215,9 @@ static const struct test_case good_test_cases[] = { }, { /* sRGB primaries, PQ TF and valid target luminance; succeeds. */ - .primaries_named = XX_COLOR_MANAGER_V4_PRIMARIES_SRGB, + .primaries_named = WP_COLOR_MANAGER_V1_PRIMARIES_SRGB, .primaries = NULL, - .tf_named = XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_ST2084_PQ, + .tf_named = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_ST2084_PQ, .tf_power = NOT_SET, .primaries_min_lum = NOT_SET, .primaries_max_lum = NOT_SET, @@ -230,9 +232,9 @@ static const struct test_case good_test_cases[] = { }, { /* sRGB primaries, PQ TF and valid max cll; succeeds. */ - .primaries_named = XX_COLOR_MANAGER_V4_PRIMARIES_SRGB, + .primaries_named = WP_COLOR_MANAGER_V1_PRIMARIES_SRGB, .primaries = NULL, - .tf_named = XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_ST2084_PQ, + .tf_named = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_ST2084_PQ, .tf_power = NOT_SET, .primaries_min_lum = NOT_SET, .primaries_max_lum = NOT_SET, @@ -247,9 +249,9 @@ static const struct test_case good_test_cases[] = { }, { /* sRGB primaries, PQ TF and valid max fall; succeeds. */ - .primaries_named = XX_COLOR_MANAGER_V4_PRIMARIES_SRGB, + .primaries_named = WP_COLOR_MANAGER_V1_PRIMARIES_SRGB, .primaries = NULL, - .tf_named = XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_ST2084_PQ, + .tf_named = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_ST2084_PQ, .tf_power = NOT_SET, .primaries_min_lum = NOT_SET, .primaries_max_lum = NOT_SET, @@ -265,9 +267,9 @@ static const struct test_case good_test_cases[] = { { /* sRGB primaries, PQ TF and valid target luminance, max fall and * max cll; succeeds. */ - .primaries_named = XX_COLOR_MANAGER_V4_PRIMARIES_SRGB, + .primaries_named = WP_COLOR_MANAGER_V1_PRIMARIES_SRGB, .primaries = NULL, - .tf_named = XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_ST2084_PQ, + .tf_named = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_ST2084_PQ, .tf_power = NOT_SET, .primaries_min_lum = NOT_SET, .primaries_max_lum = NOT_SET, @@ -286,25 +288,25 @@ static const struct test_case bad_test_cases[] = { { /* Invalid named primaries; protocol error. */ .primaries_named = BAD_ENUM, - .expected_error = XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_INVALID_PRIMARIES, + .expected_error = WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INVALID_PRIMARIES_NAMED, .error_point = ERROR_POINT_PRIMARIES_NAMED, }, { /* Invalid TF named; protocol error. */ - .primaries_named = XX_COLOR_MANAGER_V4_PRIMARIES_SRGB, + .primaries_named = WP_COLOR_MANAGER_V1_PRIMARIES_SRGB, .primaries = NULL, .tf_named = BAD_ENUM, - .expected_error = XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_INVALID_TF, + .expected_error = WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INVALID_TF, .error_point = ERROR_POINT_TF_NAMED, }, { /* Invalid power-law TF exponent (0.9 < 1.0, which is the minimum); * protocol error. */ - .primaries_named = XX_COLOR_MANAGER_V4_PRIMARIES_SRGB, + .primaries_named = WP_COLOR_MANAGER_V1_PRIMARIES_SRGB, .primaries = NULL, .tf_named = NOT_SET, .tf_power = 0.9f, - .expected_error = XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_INVALID_TF, + .expected_error = WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INVALID_TF, .error_point = ERROR_POINT_TF_POWER, }, { @@ -316,14 +318,14 @@ static const struct test_case bad_test_cases[] = { .primaries_min_lum = 50.0, .primaries_max_lum = 100, .primaries_ref_lum = 49, - .expected_error = XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_INVALID_LUMINANCE, + .expected_error = WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INVALID_LUMINANCE, .error_point = ERROR_POINT_PRIMARIES_LUM, }, { /* Invalid target luminance (min_lum == max_lum); protocol error. */ - .primaries_named = XX_COLOR_MANAGER_V4_PRIMARIES_SRGB, + .primaries_named = WP_COLOR_MANAGER_V1_PRIMARIES_SRGB, .primaries = NULL, - .tf_named = XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_ST2084_PQ, + .tf_named = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_ST2084_PQ, .tf_power = NOT_SET, .primaries_min_lum = NOT_SET, .primaries_max_lum = NOT_SET, @@ -333,15 +335,15 @@ static const struct test_case bad_test_cases[] = { .target_max_lum = 5, .target_max_cll = NOT_SET, .target_max_fall = NOT_SET, - .expected_error = XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_INVALID_LUMINANCE, + .expected_error = WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INVALID_LUMINANCE, .error_point = ERROR_POINT_TARGET_LUM, }, { /* Invalid max cll (max cll < min target luminance); * protocol error. */ - .primaries_named = XX_COLOR_MANAGER_V4_PRIMARIES_SRGB, + .primaries_named = WP_COLOR_MANAGER_V1_PRIMARIES_SRGB, .primaries = NULL, - .tf_named = XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_SRGB, + .tf_named = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB, .tf_power = NOT_SET, .primaries_min_lum = NOT_SET, .primaries_max_lum = NOT_SET, @@ -351,15 +353,15 @@ static const struct test_case bad_test_cases[] = { .target_max_lum = 7, .target_max_cll = 5, .target_max_fall = NOT_SET, - .expected_error = XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_INVALID_LUMINANCE, + .expected_error = WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INVALID_LUMINANCE, .error_point = ERROR_POINT_IMAGE_DESC, }, { /* Invalid max fall (max fall < min target luminance); * protocol error. */ - .primaries_named = XX_COLOR_MANAGER_V4_PRIMARIES_SRGB, + .primaries_named = WP_COLOR_MANAGER_V1_PRIMARIES_SRGB, .primaries = NULL, - .tf_named = XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_SRGB, + .tf_named = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB, .tf_power = NOT_SET, .primaries_min_lum = NOT_SET, .primaries_max_lum = NOT_SET, @@ -369,7 +371,7 @@ static const struct test_case bad_test_cases[] = { .target_max_lum = 7, .target_max_cll = NOT_SET, .target_max_fall = 5, - .expected_error = XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_INVALID_LUMINANCE, + .expected_error = WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INVALID_LUMINANCE, .error_point = ERROR_POINT_IMAGE_DESC, }, { @@ -387,7 +389,7 @@ static const struct test_case bad_test_cases[] = { .target_max_lum = NOT_SET, .target_max_cll = NOT_SET, .target_max_fall = NOT_SET, - .expected_error = XX_IMAGE_DESCRIPTION_V4_CAUSE_UNSUPPORTED, + .expected_error = WP_IMAGE_DESCRIPTION_V1_CAUSE_UNSUPPORTED, .error_point = ERROR_POINT_GRACEFUL_FAILURE, }, { @@ -405,15 +407,15 @@ static const struct test_case bad_test_cases[] = { .target_max_lum = NOT_SET, .target_max_cll = NOT_SET, .target_max_fall = NOT_SET, - .expected_error = XX_IMAGE_DESCRIPTION_V4_CAUSE_UNSUPPORTED, + .expected_error = WP_IMAGE_DESCRIPTION_V1_CAUSE_UNSUPPORTED, .error_point = ERROR_POINT_GRACEFUL_FAILURE, }, { /* Invalid custom target primaries (CIE XY value out of compositor * defined range); graceful failure. */ - .primaries_named = XX_COLOR_MANAGER_V4_PRIMARIES_SRGB, + .primaries_named = WP_COLOR_MANAGER_V1_PRIMARIES_SRGB, .primaries = NULL, - .tf_named = XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_SRGB, + .tf_named = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB, .tf_power = NOT_SET, .primaries_min_lum = NOT_SET, .primaries_max_lum = NOT_SET, @@ -423,15 +425,15 @@ static const struct test_case bad_test_cases[] = { .target_max_lum = NOT_SET, .target_max_cll = NOT_SET, .target_max_fall = NOT_SET, - .expected_error = XX_IMAGE_DESCRIPTION_V4_CAUSE_UNSUPPORTED, + .expected_error = WP_IMAGE_DESCRIPTION_V1_CAUSE_UNSUPPORTED, .error_point = ERROR_POINT_GRACEFUL_FAILURE, }, { /* Invalid custom target primaries (white point out of color gamut); * graceful failure. */ - .primaries_named = XX_COLOR_MANAGER_V4_PRIMARIES_SRGB, + .primaries_named = WP_COLOR_MANAGER_V1_PRIMARIES_SRGB, .primaries = NULL, - .tf_named = XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_SRGB, + .tf_named = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB, .tf_power = NOT_SET, .primaries_min_lum = NOT_SET, .primaries_max_lum = NOT_SET, @@ -441,45 +443,45 @@ static const struct test_case bad_test_cases[] = { .target_max_lum = NOT_SET, .target_max_cll = NOT_SET, .target_max_fall = NOT_SET, - .expected_error = XX_IMAGE_DESCRIPTION_V4_CAUSE_UNSUPPORTED, + .expected_error = WP_IMAGE_DESCRIPTION_V1_CAUSE_UNSUPPORTED, .error_point = ERROR_POINT_GRACEFUL_FAILURE, }, }; static void -set_primaries(struct xx_image_description_creator_params_v4 *image_desc_creator, +set_primaries(struct wp_image_description_creator_params_v1 *image_desc_creator, const struct weston_color_gamut *color_gamut) { - xx_image_description_creator_params_v4_set_primaries( + wp_image_description_creator_params_v1_set_primaries( image_desc_creator, - color_gamut->primary[0].x * 10000, - color_gamut->primary[0].y * 10000, - color_gamut->primary[1].x * 10000, - color_gamut->primary[1].y * 10000, - color_gamut->primary[2].x * 10000, - color_gamut->primary[2].y * 10000, - color_gamut->white_point.x * 10000, - color_gamut->white_point.y * 10000); + color_gamut->primary[0].x * 1000000, + color_gamut->primary[0].y * 1000000, + color_gamut->primary[1].x * 1000000, + color_gamut->primary[1].y * 1000000, + color_gamut->primary[2].x * 1000000, + color_gamut->primary[2].y * 1000000, + color_gamut->white_point.x * 1000000, + color_gamut->white_point.y * 1000000); } static void -set_mastering_display_primaries(struct xx_image_description_creator_params_v4 *image_desc_creator, +set_mastering_display_primaries(struct wp_image_description_creator_params_v1 *image_desc_creator, const struct weston_color_gamut *color_gamut) { - xx_image_description_creator_params_v4_set_mastering_display_primaries( + wp_image_description_creator_params_v1_set_mastering_display_primaries( image_desc_creator, - color_gamut->primary[0].x * 10000, - color_gamut->primary[0].y * 10000, - color_gamut->primary[1].x * 10000, - color_gamut->primary[1].y * 10000, - color_gamut->primary[2].x * 10000, - color_gamut->primary[2].y * 10000, - color_gamut->white_point.x * 10000, - color_gamut->white_point.y * 10000); + color_gamut->primary[0].x * 1000000, + color_gamut->primary[0].y * 1000000, + color_gamut->primary[1].x * 1000000, + color_gamut->primary[1].y * 1000000, + color_gamut->primary[2].x * 1000000, + color_gamut->primary[2].y * 1000000, + color_gamut->white_point.x * 1000000, + color_gamut->white_point.y * 1000000); } static void -image_desc_ready(void *data, struct xx_image_description_v4 *xx_image_description_v4, +image_desc_ready(void *data, struct wp_image_description_v1 *wp_image_description_v1, uint32_t identity) { struct image_description *image_desc = data; @@ -488,7 +490,7 @@ image_desc_ready(void *data, struct xx_image_description_v4 *xx_image_descriptio } static void -image_desc_failed(void *data, struct xx_image_description_v4 *xx_image_description_v4, +image_desc_failed(void *data, struct wp_image_description_v1 *wp_image_description_v1, uint32_t cause, const char *msg) { struct image_description *image_desc = data; @@ -500,21 +502,21 @@ image_desc_failed(void *data, struct xx_image_description_v4 *xx_image_descripti " cause: %u, msg: %s\n", cause, msg); } -static const struct xx_image_description_v4_listener +static const struct wp_image_description_v1_listener image_desc_iface = { .ready = image_desc_ready, .failed = image_desc_failed, }; static struct image_description * -image_description_create(struct xx_image_description_creator_params_v4 *image_desc_creator_param) +image_description_create(struct wp_image_description_creator_params_v1 *image_desc_creator_param) { struct image_description *image_desc = xzalloc(sizeof(*image_desc)); - image_desc->xx_image_desc = - xx_image_description_creator_params_v4_create(image_desc_creator_param); + image_desc->wp_image_desc = + wp_image_description_creator_params_v1_create(image_desc_creator_param); - xx_image_description_v4_add_listener(image_desc->xx_image_desc, + wp_image_description_v1_add_listener(image_desc->wp_image_desc, &image_desc_iface, image_desc); return image_desc; @@ -523,12 +525,12 @@ image_description_create(struct xx_image_description_creator_params_v4 *image_de static void image_description_destroy(struct image_description *image_desc) { - xx_image_description_v4_destroy(image_desc->xx_image_desc); + wp_image_description_v1_destroy(image_desc->wp_image_desc); free(image_desc); } static void -cm_supported_intent(void *data, struct xx_color_manager_v4 *xx_color_manager_v4, +cm_supported_intent(void *data, struct wp_color_manager_v1 *wp_color_manager_v1, uint32_t render_intent) { struct color_manager *cm = data; @@ -537,7 +539,7 @@ cm_supported_intent(void *data, struct xx_color_manager_v4 *xx_color_manager_v4, } static void -cm_supported_feature(void *data, struct xx_color_manager_v4 *xx_color_manager_v4, +cm_supported_feature(void *data, struct wp_color_manager_v1 *wp_color_manager_v1, uint32_t feature) { struct color_manager *cm = data; @@ -546,7 +548,7 @@ cm_supported_feature(void *data, struct xx_color_manager_v4 *xx_color_manager_v4 } static void -cm_supported_tf_named(void *data, struct xx_color_manager_v4 *xx_color_manager_v4, +cm_supported_tf_named(void *data, struct wp_color_manager_v1 *wp_color_manager_v1, uint32_t tf) { struct color_manager *cm = data; @@ -555,7 +557,7 @@ cm_supported_tf_named(void *data, struct xx_color_manager_v4 *xx_color_manager_v } static void -cm_supported_primaries_named(void *data, struct xx_color_manager_v4 *xx_color_manager_v4, +cm_supported_primaries_named(void *data, struct wp_color_manager_v1 *wp_color_manager_v1, uint32_t primaries) { struct color_manager *cm = data; @@ -563,12 +565,21 @@ cm_supported_primaries_named(void *data, struct xx_color_manager_v4 *xx_color_ma cm->supported_color_primaries |= (1 << primaries); } -static const struct xx_color_manager_v4_listener +static void +cm_done(void *data, struct wp_color_manager_v1 *wp_color_manager_v1) +{ + struct color_manager *cm = data; + + cm->done = true; +} + +static const struct wp_color_manager_v1_listener cm_iface = { .supported_intent = cm_supported_intent, .supported_feature = cm_supported_feature, .supported_tf_named = cm_supported_tf_named, .supported_primaries_named = cm_supported_primaries_named, + .done = cm_done, }; static void @@ -577,52 +588,54 @@ color_manager_init(struct color_manager *cm, struct client *client) memset(cm, 0, sizeof(*cm)); cm->manager = bind_to_singleton_global(client, - &xx_color_manager_v4_interface, + &wp_color_manager_v1_interface, 1); - xx_color_manager_v4_add_listener(cm->manager, &cm_iface, cm); + wp_color_manager_v1_add_listener(cm->manager, &cm_iface, cm); client_roundtrip(client); /* Weston supports all color features. */ - assert(cm->supported_features == ((1 << XX_COLOR_MANAGER_V4_FEATURE_ICC_V2_V4) | - (1 << XX_COLOR_MANAGER_V4_FEATURE_PARAMETRIC) | - (1 << XX_COLOR_MANAGER_V4_FEATURE_SET_PRIMARIES) | - (1 << XX_COLOR_MANAGER_V4_FEATURE_SET_LUMINANCES) | - (1 << XX_COLOR_MANAGER_V4_FEATURE_SET_TF_POWER) | - (1 << XX_COLOR_MANAGER_V4_FEATURE_SET_MASTERING_DISPLAY_PRIMARIES) | - (1 << XX_COLOR_MANAGER_V4_FEATURE_EXTENDED_TARGET_VOLUME))); + assert(cm->supported_features == ((1 << WP_COLOR_MANAGER_V1_FEATURE_ICC_V2_V4) | + (1 << WP_COLOR_MANAGER_V1_FEATURE_PARAMETRIC) | + (1 << WP_COLOR_MANAGER_V1_FEATURE_SET_PRIMARIES) | + (1 << WP_COLOR_MANAGER_V1_FEATURE_SET_LUMINANCES) | + (1 << WP_COLOR_MANAGER_V1_FEATURE_SET_TF_POWER) | + (1 << WP_COLOR_MANAGER_V1_FEATURE_SET_MASTERING_DISPLAY_PRIMARIES) | + (1 << WP_COLOR_MANAGER_V1_FEATURE_EXTENDED_TARGET_VOLUME))); /* Weston supports all rendering intents. */ - assert(cm->supported_rendering_intents == ((1 << XX_COLOR_MANAGER_V4_RENDER_INTENT_PERCEPTUAL) | - (1 << XX_COLOR_MANAGER_V4_RENDER_INTENT_RELATIVE) | - (1 << XX_COLOR_MANAGER_V4_RENDER_INTENT_SATURATION) | - (1 << XX_COLOR_MANAGER_V4_RENDER_INTENT_ABSOLUTE) | - (1 << XX_COLOR_MANAGER_V4_RENDER_INTENT_RELATIVE_BPC))); + assert(cm->supported_rendering_intents == ((1 << WP_COLOR_MANAGER_V1_RENDER_INTENT_PERCEPTUAL) | + (1 << WP_COLOR_MANAGER_V1_RENDER_INTENT_RELATIVE) | + (1 << WP_COLOR_MANAGER_V1_RENDER_INTENT_SATURATION) | + (1 << WP_COLOR_MANAGER_V1_RENDER_INTENT_ABSOLUTE) | + (1 << WP_COLOR_MANAGER_V1_RENDER_INTENT_RELATIVE_BPC))); /* Weston supports all primaries. */ - assert(cm->supported_color_primaries == ((1 << XX_COLOR_MANAGER_V4_PRIMARIES_SRGB) | - (1 << XX_COLOR_MANAGER_V4_PRIMARIES_PAL_M) | - (1 << XX_COLOR_MANAGER_V4_PRIMARIES_PAL) | - (1 << XX_COLOR_MANAGER_V4_PRIMARIES_NTSC) | - (1 << XX_COLOR_MANAGER_V4_PRIMARIES_GENERIC_FILM) | - (1 << XX_COLOR_MANAGER_V4_PRIMARIES_BT2020) | - (1 << XX_COLOR_MANAGER_V4_PRIMARIES_CIE1931_XYZ) | - (1 << XX_COLOR_MANAGER_V4_PRIMARIES_DCI_P3) | - (1 << XX_COLOR_MANAGER_V4_PRIMARIES_DISPLAY_P3) | - (1 << XX_COLOR_MANAGER_V4_PRIMARIES_ADOBE_RGB))); + assert(cm->supported_color_primaries == ((1 << WP_COLOR_MANAGER_V1_PRIMARIES_SRGB) | + (1 << WP_COLOR_MANAGER_V1_PRIMARIES_PAL_M) | + (1 << WP_COLOR_MANAGER_V1_PRIMARIES_PAL) | + (1 << WP_COLOR_MANAGER_V1_PRIMARIES_NTSC) | + (1 << WP_COLOR_MANAGER_V1_PRIMARIES_GENERIC_FILM) | + (1 << WP_COLOR_MANAGER_V1_PRIMARIES_BT2020) | + (1 << WP_COLOR_MANAGER_V1_PRIMARIES_CIE1931_XYZ) | + (1 << WP_COLOR_MANAGER_V1_PRIMARIES_DCI_P3) | + (1 << WP_COLOR_MANAGER_V1_PRIMARIES_DISPLAY_P3) | + (1 << WP_COLOR_MANAGER_V1_PRIMARIES_ADOBE_RGB))); /* Weston supports only a few transfer functions, and we make use of * them in our tests. */ - assert(cm->supported_tf == ((1 << XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_GAMMA22) | - (1 << XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_GAMMA28) | - (1 << XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_SRGB) | - (1 << XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_ST2084_PQ))); + assert(cm->supported_tf == ((1 << WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_GAMMA22) | + (1 << WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_GAMMA28) | + (1 << WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB) | + (1 << WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_ST2084_PQ))); + + assert(cm->done); } static void color_manager_fini(struct color_manager *cm) { - xx_color_manager_v4_destroy(cm->manager); + wp_color_manager_v1_destroy(cm->manager); } static enum test_result_code @@ -647,7 +660,7 @@ TEST_P(create_parametric_image_description, good_test_cases) { struct client *client; struct color_manager cm; - struct xx_image_description_creator_params_v4 *image_desc_creator_param = NULL; + struct wp_image_description_creator_params_v1 *image_desc_creator_param = NULL; const struct test_case *args = data; struct image_description *image_desc = NULL; @@ -659,26 +672,26 @@ TEST_P(create_parametric_image_description, good_test_cases) color_manager_init(&cm, client); image_desc_creator_param = - xx_color_manager_v4_new_parametric_creator(cm.manager); + wp_color_manager_v1_create_parametric_creator(cm.manager); if (args->primaries_named != NOT_SET) - xx_image_description_creator_params_v4_set_primaries_named(image_desc_creator_param, + wp_image_description_creator_params_v1_set_primaries_named(image_desc_creator_param, args->primaries_named); if (args->primaries) set_primaries(image_desc_creator_param, args->primaries); if (args->tf_named != NOT_SET) - xx_image_description_creator_params_v4_set_tf_named(image_desc_creator_param, + wp_image_description_creator_params_v1_set_tf_named(image_desc_creator_param, args->tf_named); if (args->tf_power != NOT_SET) - xx_image_description_creator_params_v4_set_tf_power(image_desc_creator_param, + wp_image_description_creator_params_v1_set_tf_power(image_desc_creator_param, args->tf_power * 10000); if (args->primaries_min_lum != NOT_SET && args->primaries_max_lum != NOT_SET && args->primaries_ref_lum != NOT_SET) - xx_image_description_creator_params_v4_set_luminances(image_desc_creator_param, + wp_image_description_creator_params_v1_set_luminances(image_desc_creator_param, args->primaries_min_lum * 10000, args->primaries_max_lum, args->primaries_ref_lum); @@ -687,16 +700,16 @@ TEST_P(create_parametric_image_description, good_test_cases) set_mastering_display_primaries(image_desc_creator_param, args->target_primaries); if (args->target_min_lum != NOT_SET && args->target_max_lum != NOT_SET) - xx_image_description_creator_params_v4_set_mastering_luminance(image_desc_creator_param, + wp_image_description_creator_params_v1_set_mastering_luminance(image_desc_creator_param, args->target_min_lum * 10000, args->target_max_lum); if (args->target_max_cll != NOT_SET) - xx_image_description_creator_params_v4_set_max_cll(image_desc_creator_param, + wp_image_description_creator_params_v1_set_max_cll(image_desc_creator_param, args->target_max_cll); if (args->target_max_fall != NOT_SET) - xx_image_description_creator_params_v4_set_max_fall(image_desc_creator_param, + wp_image_description_creator_params_v1_set_max_fall(image_desc_creator_param, args->target_max_fall); image_desc = image_description_create(image_desc_creator_param); @@ -715,7 +728,7 @@ TEST_P(fail_to_create_parametric_image_description, bad_test_cases) { struct client *client; struct color_manager cm; - struct xx_image_description_creator_params_v4 *image_desc_creator_param = NULL; + struct wp_image_description_creator_params_v1 *image_desc_creator_param = NULL; const struct test_case *args = data; struct image_description *image_desc = NULL; @@ -723,13 +736,13 @@ TEST_P(fail_to_create_parametric_image_description, bad_test_cases) color_manager_init(&cm, client); image_desc_creator_param = - xx_color_manager_v4_new_parametric_creator(cm.manager); + wp_color_manager_v1_create_parametric_creator(cm.manager); if (args->primaries_named != NOT_SET) - xx_image_description_creator_params_v4_set_primaries_named(image_desc_creator_param, + wp_image_description_creator_params_v1_set_primaries_named(image_desc_creator_param, args->primaries_named); if (args->error_point == ERROR_POINT_PRIMARIES_NAMED) { - expect_protocol_error(client, &xx_image_description_creator_params_v4_interface, + expect_protocol_error(client, &wp_image_description_creator_params_v1_interface, args->expected_error); goto out; } @@ -737,38 +750,38 @@ TEST_P(fail_to_create_parametric_image_description, bad_test_cases) if (args->primaries) set_primaries(image_desc_creator_param, args->primaries); if (args->error_point == ERROR_POINT_PRIMARIES) { - expect_protocol_error(client, &xx_image_description_creator_params_v4_interface, + expect_protocol_error(client, &wp_image_description_creator_params_v1_interface, args->expected_error); goto out; } if (args->tf_named != NOT_SET) - xx_image_description_creator_params_v4_set_tf_named(image_desc_creator_param, + wp_image_description_creator_params_v1_set_tf_named(image_desc_creator_param, args->tf_named); if (args->error_point == ERROR_POINT_TF_NAMED) { - expect_protocol_error(client, &xx_image_description_creator_params_v4_interface, + expect_protocol_error(client, &wp_image_description_creator_params_v1_interface, args->expected_error); goto out; } if (args->tf_power != NOT_SET) - xx_image_description_creator_params_v4_set_tf_power(image_desc_creator_param, + wp_image_description_creator_params_v1_set_tf_power(image_desc_creator_param, args->tf_power * 10000); if (args->error_point == ERROR_POINT_TF_POWER) { - expect_protocol_error(client, &xx_image_description_creator_params_v4_interface, + expect_protocol_error(client, &wp_image_description_creator_params_v1_interface, args->expected_error); goto out; } if (args->primaries_min_lum != NOT_SET && args->primaries_max_lum != NOT_SET && args->primaries_ref_lum != NOT_SET) - xx_image_description_creator_params_v4_set_luminances(image_desc_creator_param, + wp_image_description_creator_params_v1_set_luminances(image_desc_creator_param, args->primaries_min_lum * 10000, args->primaries_max_lum, args->primaries_ref_lum); if (args->error_point == ERROR_POINT_PRIMARIES_LUM) { - expect_protocol_error(client, &xx_image_description_creator_params_v4_interface, + expect_protocol_error(client, &wp_image_description_creator_params_v1_interface, args->expected_error); goto out; } @@ -781,17 +794,17 @@ TEST_P(fail_to_create_parametric_image_description, bad_test_cases) */ if (args->target_min_lum != NOT_SET && args->target_max_lum != NOT_SET) - xx_image_description_creator_params_v4_set_mastering_luminance(image_desc_creator_param, + wp_image_description_creator_params_v1_set_mastering_luminance(image_desc_creator_param, args->target_min_lum * 10000, args->target_max_lum); if (args->error_point == ERROR_POINT_TARGET_LUM) { - expect_protocol_error(client, &xx_image_description_creator_params_v4_interface, + expect_protocol_error(client, &wp_image_description_creator_params_v1_interface, args->expected_error); goto out; } if (args->target_max_cll != NOT_SET) - xx_image_description_creator_params_v4_set_max_cll(image_desc_creator_param, + wp_image_description_creator_params_v1_set_max_cll(image_desc_creator_param, args->target_max_cll); /** * The only possible failure for set_max_cll() is ALREADY_SET, but we test that @@ -799,7 +812,7 @@ TEST_P(fail_to_create_parametric_image_description, bad_test_cases) */ if (args->target_max_fall != NOT_SET) - xx_image_description_creator_params_v4_set_max_fall(image_desc_creator_param, + wp_image_description_creator_params_v1_set_max_fall(image_desc_creator_param, args->target_max_fall); /** * The only possible failure for set_max_fall() is ALREADY_SET, but we test that @@ -829,7 +842,7 @@ out: if (image_desc) image_description_destroy(image_desc); if (image_desc_creator_param) - xx_image_description_creator_params_v4_destroy(image_desc_creator_param); + wp_image_description_creator_params_v1_destroy(image_desc_creator_param); color_manager_fini(&cm); client_destroy(client); } @@ -838,21 +851,21 @@ TEST(set_primaries_named_twice) { struct client *client; struct color_manager cm; - struct xx_image_description_creator_params_v4 *image_desc_creator_param; + struct wp_image_description_creator_params_v1 *image_desc_creator_param; client = create_client(); color_manager_init(&cm, client); image_desc_creator_param = - xx_color_manager_v4_new_parametric_creator(cm.manager); - xx_image_description_creator_params_v4_set_primaries_named(image_desc_creator_param, - XX_COLOR_MANAGER_V4_PRIMARIES_SRGB); + wp_color_manager_v1_create_parametric_creator(cm.manager); + wp_image_description_creator_params_v1_set_primaries_named(image_desc_creator_param, + WP_COLOR_MANAGER_V1_PRIMARIES_SRGB); client_roundtrip(client); /* make sure connection is still valid */ - xx_image_description_creator_params_v4_set_primaries_named(image_desc_creator_param, - XX_COLOR_MANAGER_V4_PRIMARIES_SRGB); - expect_protocol_error(client, &xx_image_description_creator_params_v4_interface, - XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET); - xx_image_description_creator_params_v4_destroy(image_desc_creator_param); + wp_image_description_creator_params_v1_set_primaries_named(image_desc_creator_param, + WP_COLOR_MANAGER_V1_PRIMARIES_SRGB); + expect_protocol_error(client, &wp_image_description_creator_params_v1_interface, + WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET); + wp_image_description_creator_params_v1_destroy(image_desc_creator_param); color_manager_fini(&cm); client_destroy(client); @@ -862,19 +875,19 @@ TEST(set_primaries_twice) { struct client *client; struct color_manager cm; - struct xx_image_description_creator_params_v4 *image_desc_creator_param; + struct wp_image_description_creator_params_v1 *image_desc_creator_param; client = create_client(); color_manager_init(&cm, client); image_desc_creator_param = - xx_color_manager_v4_new_parametric_creator(cm.manager); + wp_color_manager_v1_create_parametric_creator(cm.manager); set_primaries(image_desc_creator_param, &color_gamut_sRGB); client_roundtrip(client); /* make sure connection is still valid */ set_primaries(image_desc_creator_param, &color_gamut_sRGB); - expect_protocol_error(client, &xx_image_description_creator_params_v4_interface, - XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET); - xx_image_description_creator_params_v4_destroy(image_desc_creator_param); + expect_protocol_error(client, &wp_image_description_creator_params_v1_interface, + WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET); + wp_image_description_creator_params_v1_destroy(image_desc_creator_param); color_manager_fini(&cm); client_destroy(client); @@ -884,20 +897,20 @@ TEST(set_primaries_then_primaries_named) { struct client *client; struct color_manager cm; - struct xx_image_description_creator_params_v4 *image_desc_creator_param; + struct wp_image_description_creator_params_v1 *image_desc_creator_param; client = create_client(); color_manager_init(&cm, client); image_desc_creator_param = - xx_color_manager_v4_new_parametric_creator(cm.manager); + wp_color_manager_v1_create_parametric_creator(cm.manager); set_primaries(image_desc_creator_param, &color_gamut_sRGB); client_roundtrip(client); /* make sure connection is still valid */ - xx_image_description_creator_params_v4_set_primaries_named(image_desc_creator_param, - XX_COLOR_MANAGER_V4_PRIMARIES_SRGB); - expect_protocol_error(client, &xx_image_description_creator_params_v4_interface, - XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET); - xx_image_description_creator_params_v4_destroy(image_desc_creator_param); + wp_image_description_creator_params_v1_set_primaries_named(image_desc_creator_param, + WP_COLOR_MANAGER_V1_PRIMARIES_SRGB); + expect_protocol_error(client, &wp_image_description_creator_params_v1_interface, + WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET); + wp_image_description_creator_params_v1_destroy(image_desc_creator_param); color_manager_fini(&cm); client_destroy(client); @@ -907,20 +920,20 @@ TEST(set_primaries_named_then_primaries) { struct client *client; struct color_manager cm; - struct xx_image_description_creator_params_v4 *image_desc_creator_param; + struct wp_image_description_creator_params_v1 *image_desc_creator_param; client = create_client(); color_manager_init(&cm, client); image_desc_creator_param = - xx_color_manager_v4_new_parametric_creator(cm.manager); - xx_image_description_creator_params_v4_set_primaries_named(image_desc_creator_param, - XX_COLOR_MANAGER_V4_PRIMARIES_SRGB); + wp_color_manager_v1_create_parametric_creator(cm.manager); + wp_image_description_creator_params_v1_set_primaries_named(image_desc_creator_param, + WP_COLOR_MANAGER_V1_PRIMARIES_SRGB); client_roundtrip(client); /* make sure connection is still valid */ set_primaries(image_desc_creator_param, &color_gamut_sRGB); - expect_protocol_error(client, &xx_image_description_creator_params_v4_interface, - XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET); - xx_image_description_creator_params_v4_destroy(image_desc_creator_param); + expect_protocol_error(client, &wp_image_description_creator_params_v1_interface, + WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET); + wp_image_description_creator_params_v1_destroy(image_desc_creator_param); color_manager_fini(&cm); client_destroy(client); @@ -930,21 +943,21 @@ TEST(set_tf_power_twice) { struct client *client; struct color_manager cm; - struct xx_image_description_creator_params_v4 *image_desc_creator_param; + struct wp_image_description_creator_params_v1 *image_desc_creator_param; client = create_client(); color_manager_init(&cm, client); image_desc_creator_param = - xx_color_manager_v4_new_parametric_creator(cm.manager); - xx_image_description_creator_params_v4_set_tf_power(image_desc_creator_param, + wp_color_manager_v1_create_parametric_creator(cm.manager); + wp_image_description_creator_params_v1_set_tf_power(image_desc_creator_param, 2.4 * 10000); client_roundtrip(client); /* make sure connection is still valid */ - xx_image_description_creator_params_v4_set_tf_power(image_desc_creator_param, + wp_image_description_creator_params_v1_set_tf_power(image_desc_creator_param, 2.4 * 10000); - expect_protocol_error(client, &xx_image_description_creator_params_v4_interface, - XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET); - xx_image_description_creator_params_v4_destroy(image_desc_creator_param); + expect_protocol_error(client, &wp_image_description_creator_params_v1_interface, + WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET); + wp_image_description_creator_params_v1_destroy(image_desc_creator_param); color_manager_fini(&cm); client_destroy(client); @@ -954,21 +967,21 @@ TEST(set_tf_named_twice) { struct client *client; struct color_manager cm; - struct xx_image_description_creator_params_v4 *image_desc_creator_param; + struct wp_image_description_creator_params_v1 *image_desc_creator_param; client = create_client(); color_manager_init(&cm, client); image_desc_creator_param = - xx_color_manager_v4_new_parametric_creator(cm.manager); - xx_image_description_creator_params_v4_set_tf_named(image_desc_creator_param, - XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_SRGB); + wp_color_manager_v1_create_parametric_creator(cm.manager); + wp_image_description_creator_params_v1_set_tf_named(image_desc_creator_param, + WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB); client_roundtrip(client); /* make sure connection is still valid */ - xx_image_description_creator_params_v4_set_tf_named(image_desc_creator_param, - XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_SRGB); - expect_protocol_error(client, &xx_image_description_creator_params_v4_interface, - XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET); - xx_image_description_creator_params_v4_destroy(image_desc_creator_param); + wp_image_description_creator_params_v1_set_tf_named(image_desc_creator_param, + WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB); + expect_protocol_error(client, &wp_image_description_creator_params_v1_interface, + WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET); + wp_image_description_creator_params_v1_destroy(image_desc_creator_param); color_manager_fini(&cm); client_destroy(client); @@ -978,21 +991,21 @@ TEST(set_tf_power_then_tf_named) { struct client *client; struct color_manager cm; - struct xx_image_description_creator_params_v4 *image_desc_creator_param; + struct wp_image_description_creator_params_v1 *image_desc_creator_param; client = create_client(); color_manager_init(&cm, client); image_desc_creator_param = - xx_color_manager_v4_new_parametric_creator(cm.manager); - xx_image_description_creator_params_v4_set_tf_power(image_desc_creator_param, + wp_color_manager_v1_create_parametric_creator(cm.manager); + wp_image_description_creator_params_v1_set_tf_power(image_desc_creator_param, 2.4 * 10000); client_roundtrip(client); /* make sure connection is still valid */ - xx_image_description_creator_params_v4_set_tf_named(image_desc_creator_param, - XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_SRGB); - expect_protocol_error(client, &xx_image_description_creator_params_v4_interface, - XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET); - xx_image_description_creator_params_v4_destroy(image_desc_creator_param); + wp_image_description_creator_params_v1_set_tf_named(image_desc_creator_param, + WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB); + expect_protocol_error(client, &wp_image_description_creator_params_v1_interface, + WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET); + wp_image_description_creator_params_v1_destroy(image_desc_creator_param); color_manager_fini(&cm); client_destroy(client); @@ -1002,21 +1015,21 @@ TEST(set_tf_named_then_tf_power) { struct client *client; struct color_manager cm; - struct xx_image_description_creator_params_v4 *image_desc_creator_param; + struct wp_image_description_creator_params_v1 *image_desc_creator_param; client = create_client(); color_manager_init(&cm, client); image_desc_creator_param = - xx_color_manager_v4_new_parametric_creator(cm.manager); - xx_image_description_creator_params_v4_set_tf_named(image_desc_creator_param, - XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_SRGB); + wp_color_manager_v1_create_parametric_creator(cm.manager); + wp_image_description_creator_params_v1_set_tf_named(image_desc_creator_param, + WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB); client_roundtrip(client); /* make sure connection is still valid */ - xx_image_description_creator_params_v4_set_tf_power(image_desc_creator_param, + wp_image_description_creator_params_v1_set_tf_power(image_desc_creator_param, 2.4 * 10000); - expect_protocol_error(client, &xx_image_description_creator_params_v4_interface, - XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET); - xx_image_description_creator_params_v4_destroy(image_desc_creator_param); + expect_protocol_error(client, &wp_image_description_creator_params_v1_interface, + WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET); + wp_image_description_creator_params_v1_destroy(image_desc_creator_param); color_manager_fini(&cm); client_destroy(client); @@ -1026,7 +1039,7 @@ TEST(set_luminance_twice) { struct client *client; struct color_manager cm; - struct xx_image_description_creator_params_v4 *image_desc_creator_param; + struct wp_image_description_creator_params_v1 *image_desc_creator_param; float min_lum = 0.5; float max_lum = 2000.0; float ref_lum = 300.0; @@ -1035,19 +1048,19 @@ TEST(set_luminance_twice) color_manager_init(&cm, client); image_desc_creator_param = - xx_color_manager_v4_new_parametric_creator(cm.manager); - xx_image_description_creator_params_v4_set_luminances(image_desc_creator_param, + wp_color_manager_v1_create_parametric_creator(cm.manager); + wp_image_description_creator_params_v1_set_luminances(image_desc_creator_param, min_lum * 10000, max_lum, ref_lum); client_roundtrip(client); /* make sure connection is still valid */ - xx_image_description_creator_params_v4_set_luminances(image_desc_creator_param, + wp_image_description_creator_params_v1_set_luminances(image_desc_creator_param, min_lum * 10000, max_lum, ref_lum); - expect_protocol_error(client, &xx_image_description_creator_params_v4_interface, - XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET); - xx_image_description_creator_params_v4_destroy(image_desc_creator_param); + expect_protocol_error(client, &wp_image_description_creator_params_v1_interface, + WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET); + wp_image_description_creator_params_v1_destroy(image_desc_creator_param); color_manager_fini(&cm); client_destroy(client); @@ -1057,19 +1070,19 @@ TEST(set_target_primaries_twice) { struct client *client; struct color_manager cm; - struct xx_image_description_creator_params_v4 *image_desc_creator_param; + struct wp_image_description_creator_params_v1 *image_desc_creator_param; client = create_client(); color_manager_init(&cm, client); image_desc_creator_param = - xx_color_manager_v4_new_parametric_creator(cm.manager); + wp_color_manager_v1_create_parametric_creator(cm.manager); set_mastering_display_primaries(image_desc_creator_param, &color_gamut_sRGB); client_roundtrip(client); /* make sure connection is still valid */ set_mastering_display_primaries(image_desc_creator_param, &color_gamut_sRGB); - expect_protocol_error(client, &xx_image_description_creator_params_v4_interface, - XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET); - xx_image_description_creator_params_v4_destroy(image_desc_creator_param); + expect_protocol_error(client, &wp_image_description_creator_params_v1_interface, + WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET); + wp_image_description_creator_params_v1_destroy(image_desc_creator_param); color_manager_fini(&cm); client_destroy(client); @@ -1079,7 +1092,7 @@ TEST(set_target_luminance_twice) { struct client *client; struct color_manager cm; - struct xx_image_description_creator_params_v4 *image_desc_creator_param; + struct wp_image_description_creator_params_v1 *image_desc_creator_param; float target_min_lum = 2.0f; float target_max_lum = 3.0f; @@ -1087,17 +1100,17 @@ TEST(set_target_luminance_twice) color_manager_init(&cm, client); image_desc_creator_param = - xx_color_manager_v4_new_parametric_creator(cm.manager); - xx_image_description_creator_params_v4_set_mastering_luminance(image_desc_creator_param, + wp_color_manager_v1_create_parametric_creator(cm.manager); + wp_image_description_creator_params_v1_set_mastering_luminance(image_desc_creator_param, target_min_lum * 10000, target_max_lum); client_roundtrip(client); /* make sure connection is still valid */ - xx_image_description_creator_params_v4_set_mastering_luminance(image_desc_creator_param, + wp_image_description_creator_params_v1_set_mastering_luminance(image_desc_creator_param, target_min_lum * 10000, target_max_lum); - expect_protocol_error(client, &xx_image_description_creator_params_v4_interface, - XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET); - xx_image_description_creator_params_v4_destroy(image_desc_creator_param); + expect_protocol_error(client, &wp_image_description_creator_params_v1_interface, + WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET); + wp_image_description_creator_params_v1_destroy(image_desc_creator_param); color_manager_fini(&cm); client_destroy(client); @@ -1107,19 +1120,19 @@ TEST(set_max_cll_twice) { struct client *client; struct color_manager cm; - struct xx_image_description_creator_params_v4 *image_desc_creator_param; + struct wp_image_description_creator_params_v1 *image_desc_creator_param; client = create_client(); color_manager_init(&cm, client); image_desc_creator_param = - xx_color_manager_v4_new_parametric_creator(cm.manager); - xx_image_description_creator_params_v4_set_max_cll(image_desc_creator_param, 5.0f); + wp_color_manager_v1_create_parametric_creator(cm.manager); + wp_image_description_creator_params_v1_set_max_cll(image_desc_creator_param, 5.0f); client_roundtrip(client); /* make sure connection is still valid */ - xx_image_description_creator_params_v4_set_max_cll(image_desc_creator_param, 5.0f); - expect_protocol_error(client, &xx_image_description_creator_params_v4_interface, - XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET); - xx_image_description_creator_params_v4_destroy(image_desc_creator_param); + wp_image_description_creator_params_v1_set_max_cll(image_desc_creator_param, 5.0f); + expect_protocol_error(client, &wp_image_description_creator_params_v1_interface, + WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET); + wp_image_description_creator_params_v1_destroy(image_desc_creator_param); color_manager_fini(&cm); client_destroy(client); @@ -1129,19 +1142,19 @@ TEST(set_max_fall_twice) { struct client *client; struct color_manager cm; - struct xx_image_description_creator_params_v4 *image_desc_creator_param; + struct wp_image_description_creator_params_v1 *image_desc_creator_param; client = create_client(); color_manager_init(&cm, client); image_desc_creator_param = - xx_color_manager_v4_new_parametric_creator(cm.manager); - xx_image_description_creator_params_v4_set_max_fall(image_desc_creator_param, 5.0f); + wp_color_manager_v1_create_parametric_creator(cm.manager); + wp_image_description_creator_params_v1_set_max_fall(image_desc_creator_param, 5.0f); client_roundtrip(client); /* make sure connection is still valid */ - xx_image_description_creator_params_v4_set_max_fall(image_desc_creator_param, 5.0f); - expect_protocol_error(client, &xx_image_description_creator_params_v4_interface, - XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET); - xx_image_description_creator_params_v4_destroy(image_desc_creator_param); + wp_image_description_creator_params_v1_set_max_fall(image_desc_creator_param, 5.0f); + expect_protocol_error(client, &wp_image_description_creator_params_v1_interface, + WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET); + wp_image_description_creator_params_v1_destroy(image_desc_creator_param); color_manager_fini(&cm); client_destroy(client); diff --git a/tests/color-management-test.c b/tests/color-management-test.c index 9c81db13e..701e23db5 100644 --- a/tests/color-management-test.c +++ b/tests/color-management-test.c @@ -44,6 +44,7 @@ enum image_descr_info_event { IMAGE_DESCR_INFO_EVENT_PRIMARIES, IMAGE_DESCR_INFO_EVENT_TF_NAMED, IMAGE_DESCR_INFO_EVENT_TF_POWER_EXP, + IMAGE_DESCR_INFO_EVENT_LUMINANCES, IMAGE_DESCR_INFO_EVENT_TARGET_PRIMARIES, IMAGE_DESCR_INFO_EVENT_TARGET_MAXCLL, IMAGE_DESCR_INFO_EVENT_TARGET_MAXFALL, @@ -65,7 +66,7 @@ const struct lcms_pipeline pipeline_sRGB = { }; struct image_description { - struct xx_image_description_v4 *xx_image_descr; + struct wp_image_description_v1 *wp_image_descr; enum image_description_status { CM_IMAGE_DESC_NOT_CREATED = 0, @@ -81,10 +82,11 @@ struct image_description { uint32_t icc_size; /* For parametric images descriptions. */ - enum xx_color_manager_v4_primaries primaries_named; + enum wp_color_manager_v1_primaries primaries_named; struct weston_color_gamut primaries; - enum xx_color_manager_v4_transfer_function tf_named; + enum wp_color_manager_v1_transfer_function tf_named; float tf_power; + float min_lum, max_lum, ref_lum; struct weston_color_gamut target_primaries; float target_min_lum, target_max_lum; float target_max_cll; @@ -92,7 +94,7 @@ struct image_description { }; struct image_description_info { - struct xx_image_description_info_v4 *xx_image_description_info; + struct wp_image_description_info_v1 *wp_image_description_info; struct image_description *image_descr; /* Bitfield that holds what events the compositor has sent us through @@ -102,11 +104,11 @@ struct image_description_info { }; struct color_manager { - struct xx_color_manager_v4 *manager; + struct wp_color_manager_v1 *manager; - struct xx_color_management_output_v4 *output; - struct xx_color_management_surface_v4 *surface; - struct xx_color_management_feedback_surface_v4 *feedback_surface; + struct wp_color_management_output_v1 *output; + struct wp_color_management_surface_v1 *surface; + struct wp_color_management_surface_feedback_v1 *surface_feedback; struct wl_list image_descr_list; /* image_description::link */ @@ -117,6 +119,8 @@ struct color_manager { /* Bitfield that holds what rendering intents are supported. If enum * supported_render_intent v is supported, bit v will be set to 1. */ uint32_t supported_rendering_intents; + + bool done; }; static struct image_description * @@ -131,12 +135,12 @@ static void image_description_destroy(struct image_description *image_descr) { wl_list_remove(&image_descr->link); - xx_image_description_v4_destroy(image_descr->xx_image_descr); + wp_image_description_v1_destroy(image_descr->wp_image_descr); free(image_descr); } static void -image_descr_ready(void *data, struct xx_image_description_v4 *xx_image_description_v4, +image_descr_ready(void *data, struct wp_image_description_v1 *wp_image_description_v1, uint32_t identity) { struct image_description *image_descr = data; @@ -145,7 +149,7 @@ image_descr_ready(void *data, struct xx_image_description_v4 *xx_image_descripti } static void -image_descr_failed(void *data, struct xx_image_description_v4 *xx_image_description_v4, +image_descr_failed(void *data, struct wp_image_description_v1 *wp_image_description_v1, uint32_t cause, const char *msg) { struct image_description *image_descr = data; @@ -156,7 +160,7 @@ image_descr_failed(void *data, struct xx_image_description_v4 *xx_image_descript " cause: %u, msg: %s\n", cause, msg); } -static const struct xx_image_description_v4_listener +static const struct wp_image_description_v1_listener image_descr_iface = { .ready = image_descr_ready, .failed = image_descr_failed, @@ -174,7 +178,7 @@ image_descr_info_received(struct image_description_info *image_descr_info, static void image_descr_info_primaries(void *data, - struct xx_image_description_info_v4 *xx_image_description_info_v4, + struct wp_image_description_info_v1 *wp_image_description_info_v1, int32_t r_x, int32_t r_y, int32_t g_x, int32_t g_y, int32_t b_x, int32_t b_y, int32_t w_x, int32_t w_y) { @@ -185,19 +189,19 @@ image_descr_info_primaries(void *data, image_descr_info_received(image_descr_info, IMAGE_DESCR_INFO_EVENT_PRIMARIES); - image_descr->primaries.primary[0].x = r_x / 10000.0; - image_descr->primaries.primary[0].y = r_y / 10000.0; - image_descr->primaries.primary[1].x = g_x / 10000.0; - image_descr->primaries.primary[1].y = g_y / 10000.0; - image_descr->primaries.primary[2].x = b_x / 10000.0; - image_descr->primaries.primary[2].y = b_y / 10000.0; - image_descr->primaries.white_point.x = w_x / 10000.0; - image_descr->primaries.white_point.y = w_y / 10000.0; + image_descr->primaries.primary[0].x = r_x / 1000000.0f; + image_descr->primaries.primary[0].y = r_y / 1000000.0f; + image_descr->primaries.primary[1].x = g_x / 1000000.0f; + image_descr->primaries.primary[1].y = g_y / 1000000.0f; + image_descr->primaries.primary[2].x = b_x / 1000000.0f; + image_descr->primaries.primary[2].y = b_y / 1000000.0f; + image_descr->primaries.white_point.x = w_x / 1000000.0f; + image_descr->primaries.white_point.y = w_y / 1000000.0f; } static void image_descr_info_primaries_named(void *data, - struct xx_image_description_info_v4 *xx_image_description_info_v4, + struct wp_image_description_info_v1 *wp_image_description_info_v1, uint32_t primaries) { struct image_description_info *image_descr_info = data; @@ -211,7 +215,7 @@ image_descr_info_primaries_named(void *data, static void image_descr_info_tf_named(void *data, - struct xx_image_description_info_v4 *xx_image_description_info_v4, + struct wp_image_description_info_v1 *wp_image_description_info_v1, uint32_t tf) { struct image_description_info *image_descr_info = data; @@ -225,7 +229,7 @@ image_descr_info_tf_named(void *data, static void image_descr_info_tf_power(void *data, - struct xx_image_description_info_v4 *xx_image_description_info_v4, + struct wp_image_description_info_v1 *wp_image_description_info_v1, uint32_t tf_power) { struct image_description_info *image_descr_info = data; @@ -237,9 +241,25 @@ image_descr_info_tf_power(void *data, image_descr->tf_power = tf_power / 10000.0; } +static void +image_descr_info_luminances(void *data, + struct wp_image_description_info_v1 *wp_image_description_info_v1, + uint32_t min_lum, uint32_t max_lum, uint32_t ref_lum) +{ + struct image_description_info *image_descr_info = data; + struct image_description *image_descr = image_descr_info->image_descr; + + image_descr_info_received(image_descr_info, + IMAGE_DESCR_INFO_EVENT_LUMINANCES); + + image_descr->min_lum = min_lum / 10000.0; + image_descr->max_lum = max_lum; + image_descr->ref_lum = ref_lum; +} + static void image_descr_info_target_primaries(void *data, - struct xx_image_description_info_v4 *xx_image_description_info_v4, + struct wp_image_description_info_v1 *wp_image_description_info_v1, int32_t r_x, int32_t r_y, int32_t g_x, int32_t g_y, int32_t b_x, int32_t b_y, int32_t w_x, int32_t w_y) { @@ -249,19 +269,19 @@ image_descr_info_target_primaries(void *data, image_descr_info_received(image_descr_info, IMAGE_DESCR_INFO_EVENT_TARGET_PRIMARIES); - image_descr->target_primaries.primary[0].x = r_x / 10000.0; - image_descr->target_primaries.primary[0].y = r_y / 10000.0; - image_descr->target_primaries.primary[1].x = g_x / 10000.0; - image_descr->target_primaries.primary[1].y = g_y / 10000.0; - image_descr->target_primaries.primary[2].x = b_x / 10000.0; - image_descr->target_primaries.primary[2].y = b_y / 10000.0; - image_descr->target_primaries.white_point.x = w_x / 10000.0; - image_descr->target_primaries.white_point.y = w_y / 10000.0; + image_descr->target_primaries.primary[0].x = r_x / 1000000.0f; + image_descr->target_primaries.primary[0].y = r_y / 1000000.0f; + image_descr->target_primaries.primary[1].x = g_x / 1000000.0f; + image_descr->target_primaries.primary[1].y = g_y / 1000000.0f; + image_descr->target_primaries.primary[2].x = b_x / 1000000.0f; + image_descr->target_primaries.primary[2].y = b_y / 1000000.0f; + image_descr->target_primaries.white_point.x = w_x / 1000000.0f; + image_descr->target_primaries.white_point.y = w_y / 1000000.0f; } static void image_descr_info_target_luminance(void *data, - struct xx_image_description_info_v4 *xx_image_description_info_v4, + struct wp_image_description_info_v1 *wp_image_description_info_v1, uint32_t min_lum, uint32_t max_lum) { struct image_description_info *image_descr_info = data; @@ -276,7 +296,7 @@ image_descr_info_target_luminance(void *data, static void image_descr_info_target_max_cll(void *data, - struct xx_image_description_info_v4 *xx_image_description_info_v4, + struct wp_image_description_info_v1 *wp_image_description_info_v1, uint32_t maxCLL) { struct image_description_info *image_descr_info = data; @@ -290,7 +310,7 @@ image_descr_info_target_max_cll(void *data, static void image_descr_info_target_max_fall(void *data, - struct xx_image_description_info_v4 *xx_image_description_info_v4, + struct wp_image_description_info_v1 *wp_image_description_info_v1, uint32_t maxFALL) { struct image_description_info *image_descr_info = data; @@ -304,7 +324,7 @@ image_descr_info_target_max_fall(void *data, static void image_descr_info_icc_file_event(void *data, - struct xx_image_description_info_v4 *xx_image_description_info_v4, + struct wp_image_description_info_v1 *wp_image_description_info_v1, int32_t icc_fd, uint32_t icc_size) { struct image_description_info *image_descr_info = data; @@ -337,6 +357,8 @@ are_events_received_valid(struct image_description_info *image_descr_info) * parameters make sense. */ bool received_primaries, received_primaries_named; bool received_tf_power, received_tf_named; + bool received_target_primaries; + bool received_lum, received_target_lum; /* Should have received the primaries somewhow. */ received_primaries_named = (events_received >> @@ -362,19 +384,19 @@ are_events_received_valid(struct image_description_info *image_descr_info) /* If we received tf named and exp power, they must match. */ if (received_tf_named && received_tf_power) { - if (image_descr->tf_named != XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_GAMMA22 && - image_descr->tf_named != XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_GAMMA28) { + if (image_descr->tf_named != WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_GAMMA22 && + image_descr->tf_named != WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_GAMMA28) { testlog(" Error: parametric image description tf " \ "named is not pure power-law, but still received " \ "tf power event\n"); return false; - } else if (image_descr->tf_named == XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_GAMMA22 && + } else if (image_descr->tf_named == WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_GAMMA22 && image_descr->tf_power != 2.2f) { testlog(" Error: parametric image description tf named " \ "is pure power-law 2.2, but tf power received is %f\n", image_descr->tf_power); return false; - } else if (image_descr->tf_named == XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_GAMMA28 && + } else if (image_descr->tf_named == WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_GAMMA28 && image_descr->tf_power != 2.8f) { testlog(" Error: parametric image description tf named " \ "is pure power-law 2.8, but tf power received is %f\n", @@ -383,20 +405,44 @@ are_events_received_valid(struct image_description_info *image_descr_info) } } - /* TODO: when target primaries, luminance, maxcll and maxfall are - * allowed? */ + /* We should receive luminance. */ + received_lum = (events_received >> + IMAGE_DESCR_INFO_EVENT_LUMINANCES) & 1; + if (!received_lum) { + testlog(" Error: parametric image description but no " \ + "luminances received\n"); + return false; + } + + /* We should receive target primaries. */ + received_target_primaries = (events_received >> + IMAGE_DESCR_INFO_EVENT_TARGET_PRIMARIES) & 1; + if (!received_target_primaries) { + testlog(" Error: parametric image description but no " \ + "target primaries received\n"); + return false; + } + + /* We should receive target luminance. */ + received_target_lum = (events_received >> + IMAGE_DESCR_INFO_EVENT_TARGET_LUMINANCE) & 1; + if (!received_target_lum) { + testlog(" Error: parametric image description but no " \ + "target luminances received\n"); + return false; + } return true; } static void image_descr_info_done(void *data, - struct xx_image_description_info_v4 *xx_image_description_info_v4) + struct wp_image_description_info_v1 *wp_image_description_info_v1) { struct image_description_info *image_descr_info = data; struct image_description *image_descr = image_descr_info->image_descr; - testlog("Image description info %p done:\n", xx_image_description_info_v4); + testlog("Image description info %p done:\n", wp_image_description_info_v1); assert(are_events_received_valid(image_descr_info)); @@ -459,12 +505,13 @@ image_descr_info_done(void *data, testlog(" Target maxFALL: %.4f\n", image_descr->target_max_fall); } -static const struct xx_image_description_info_v4_listener +static const struct wp_image_description_info_v1_listener image_descr_info_iface = { .primaries = image_descr_info_primaries, .primaries_named = image_descr_info_primaries_named, .tf_named = image_descr_info_tf_named, .tf_power = image_descr_info_tf_power, + .luminances = image_descr_info_luminances, .target_primaries = image_descr_info_target_primaries, .target_luminance = image_descr_info_target_luminance, .target_max_cll = image_descr_info_target_max_cll, @@ -474,7 +521,7 @@ image_descr_info_iface = { }; static void -cm_supported_intent(void *data, struct xx_color_manager_v4 *xx_color_manager_v4, +cm_supported_intent(void *data, struct wp_color_manager_v1 *wp_color_manager_v1, uint32_t render_intent) { struct color_manager *cm = data; @@ -483,7 +530,7 @@ cm_supported_intent(void *data, struct xx_color_manager_v4 *xx_color_manager_v4, } static void -cm_supported_feature(void *data, struct xx_color_manager_v4 *xx_color_manager_v4, +cm_supported_feature(void *data, struct wp_color_manager_v1 *wp_color_manager_v1, uint32_t feature) { struct color_manager *cm = data; @@ -492,7 +539,7 @@ cm_supported_feature(void *data, struct xx_color_manager_v4 *xx_color_manager_v4 } static void -cm_supported_tf_named(void *data, struct xx_color_manager_v4 *xx_color_manager_v4, +cm_supported_tf_named(void *data, struct wp_color_manager_v1 *wp_color_manager_v1, uint32_t tf_code) { /* only used to create image descriptions using parameters, which we @@ -500,19 +547,28 @@ cm_supported_tf_named(void *data, struct xx_color_manager_v4 *xx_color_manager_v } static void -cm_supported_primaries_named(void *data, struct xx_color_manager_v4 *xx_color_manager_v4, +cm_supported_primaries_named(void *data, struct wp_color_manager_v1 *wp_color_manager_v1, uint32_t primaries_code) { /* only used to create image descriptions using parameters, which we * won't do in this test file. */ } -static const struct xx_color_manager_v4_listener +static void +cm_done(void *data, struct wp_color_manager_v1 *wp_color_manager_v1) +{ + struct color_manager *cm = data; + + cm->done = true; +} + +static const struct wp_color_manager_v1_listener cm_iface = { .supported_intent = cm_supported_intent, .supported_feature = cm_supported_feature, .supported_tf_named = cm_supported_tf_named, .supported_primaries_named = cm_supported_primaries_named, + .done = cm_done, }; static void @@ -523,37 +579,39 @@ color_manager_init(struct color_manager *cm, struct client *client) wl_list_init(&cm->image_descr_list); cm->manager = bind_to_singleton_global(client, - &xx_color_manager_v4_interface, + &wp_color_manager_v1_interface, 1); - xx_color_manager_v4_add_listener(cm->manager, &cm_iface, cm); + wp_color_manager_v1_add_listener(cm->manager, &cm_iface, cm); - cm->output = xx_color_manager_v4_get_output(cm->manager, + cm->output = wp_color_manager_v1_get_output(cm->manager, client->output->wl_output); - cm->surface = xx_color_manager_v4_get_surface(cm->manager, + cm->surface = wp_color_manager_v1_get_surface(cm->manager, client->surface->wl_surface); - cm->feedback_surface = - xx_color_manager_v4_get_feedback_surface(cm->manager, + cm->surface_feedback = + wp_color_manager_v1_get_surface_feedback(cm->manager, client->surface->wl_surface); client_roundtrip(client); /* Weston supports all color features. */ - assert(cm->supported_features == ((1 << XX_COLOR_MANAGER_V4_FEATURE_ICC_V2_V4) | - (1 << XX_COLOR_MANAGER_V4_FEATURE_PARAMETRIC) | - (1 << XX_COLOR_MANAGER_V4_FEATURE_SET_PRIMARIES) | - (1 << XX_COLOR_MANAGER_V4_FEATURE_SET_TF_POWER) | - (1 << XX_COLOR_MANAGER_V4_FEATURE_SET_LUMINANCES) | - (1 << XX_COLOR_MANAGER_V4_FEATURE_SET_MASTERING_DISPLAY_PRIMARIES) | - (1 << XX_COLOR_MANAGER_V4_FEATURE_EXTENDED_TARGET_VOLUME))); + assert(cm->supported_features == ((1 << WP_COLOR_MANAGER_V1_FEATURE_ICC_V2_V4) | + (1 << WP_COLOR_MANAGER_V1_FEATURE_PARAMETRIC) | + (1 << WP_COLOR_MANAGER_V1_FEATURE_SET_PRIMARIES) | + (1 << WP_COLOR_MANAGER_V1_FEATURE_SET_TF_POWER) | + (1 << WP_COLOR_MANAGER_V1_FEATURE_SET_LUMINANCES) | + (1 << WP_COLOR_MANAGER_V1_FEATURE_SET_MASTERING_DISPLAY_PRIMARIES) | + (1 << WP_COLOR_MANAGER_V1_FEATURE_EXTENDED_TARGET_VOLUME))); /* Weston supports all rendering intents. */ - assert(cm->supported_rendering_intents == ((1 << XX_COLOR_MANAGER_V4_RENDER_INTENT_PERCEPTUAL) | - (1 << XX_COLOR_MANAGER_V4_RENDER_INTENT_RELATIVE) | - (1 << XX_COLOR_MANAGER_V4_RENDER_INTENT_SATURATION) | - (1 << XX_COLOR_MANAGER_V4_RENDER_INTENT_ABSOLUTE) | - (1 << XX_COLOR_MANAGER_V4_RENDER_INTENT_RELATIVE_BPC))); + assert(cm->supported_rendering_intents == ((1 << WP_COLOR_MANAGER_V1_RENDER_INTENT_PERCEPTUAL) | + (1 << WP_COLOR_MANAGER_V1_RENDER_INTENT_RELATIVE) | + (1 << WP_COLOR_MANAGER_V1_RENDER_INTENT_SATURATION) | + (1 << WP_COLOR_MANAGER_V1_RENDER_INTENT_ABSOLUTE) | + (1 << WP_COLOR_MANAGER_V1_RENDER_INTENT_RELATIVE_BPC))); + + assert(cm->done); } static void @@ -564,10 +622,10 @@ color_manager_fini(struct color_manager *cm) wl_list_for_each_safe(image_descr, tmp, &cm->image_descr_list, link) image_description_destroy(image_descr); - xx_color_management_output_v4_destroy(cm->output); - xx_color_management_surface_v4_destroy(cm->surface); - xx_color_management_feedback_surface_v4_destroy(cm->feedback_surface); - xx_color_manager_v4_destroy(cm->manager); + wp_color_management_output_v1_destroy(cm->output); + wp_color_management_surface_v1_destroy(cm->surface); + wp_color_management_surface_feedback_v1_destroy(cm->surface_feedback); + wp_color_manager_v1_destroy(cm->manager); } static struct image_description * @@ -575,10 +633,10 @@ get_output_image_description(struct color_manager *cm) { struct image_description *image_descr = image_description_create(); - image_descr->xx_image_descr = - xx_color_management_output_v4_get_image_description(cm->output); + image_descr->wp_image_descr = + wp_color_management_output_v1_get_image_description(cm->output); - xx_image_description_v4_add_listener(image_descr->xx_image_descr, + wp_image_description_v1_add_listener(image_descr->wp_image_descr, &image_descr_iface, image_descr); wl_list_insert(&cm->image_descr_list, &image_descr->link); @@ -591,10 +649,10 @@ get_surface_preferred_image_description(struct color_manager *cm) { struct image_description *image_descr = image_description_create(); - image_descr->xx_image_descr = - xx_color_management_feedback_surface_v4_get_preferred(cm->feedback_surface); + image_descr->wp_image_descr = + wp_color_management_surface_feedback_v1_get_preferred(cm->surface_feedback); - xx_image_description_v4_add_listener(image_descr->xx_image_descr, + wp_image_description_v1_add_listener(image_descr->wp_image_descr, &image_descr_iface, image_descr); wl_list_insert(&cm->image_descr_list, &image_descr->link); @@ -604,7 +662,7 @@ get_surface_preferred_image_description(struct color_manager *cm) static struct image_description * create_icc_based_image_description(struct color_manager *cm, - struct xx_image_description_creator_icc_v4 *image_descr_creator_icc, + struct wp_image_description_creator_icc_v1 *image_descr_creator_icc, const char *icc_path) { struct image_description *image_descr = image_description_create(); @@ -616,12 +674,12 @@ create_icc_based_image_description(struct color_manager *cm, assert(fstat(icc_fd, &st) == 0); - xx_image_description_creator_icc_v4_set_icc_file(image_descr_creator_icc, + wp_image_description_creator_icc_v1_set_icc_file(image_descr_creator_icc, icc_fd, 0, st.st_size); - image_descr->xx_image_descr = - xx_image_description_creator_icc_v4_create(image_descr_creator_icc); + image_descr->wp_image_descr = + wp_image_description_creator_icc_v1_create(image_descr_creator_icc); - xx_image_description_v4_add_listener(image_descr->xx_image_descr, + wp_image_description_v1_add_listener(image_descr->wp_image_descr, &image_descr_iface, image_descr); wl_list_insert(&cm->image_descr_list, &image_descr->link); @@ -695,7 +753,7 @@ TEST(smoke_test) static void image_descr_info_destroy(struct image_description_info *image_descr_info) { - xx_image_description_info_v4_destroy(image_descr_info->xx_image_description_info); + wp_image_description_info_v1_destroy(image_descr_info->wp_image_description_info); free(image_descr_info); } @@ -708,10 +766,10 @@ image_descr_get_information(struct image_description *image_descr) image_descr_info->image_descr = image_descr; - image_descr_info->xx_image_description_info = - xx_image_description_v4_get_information(image_descr->xx_image_descr); + image_descr_info->wp_image_description_info = + wp_image_description_v1_get_information(image_descr->wp_image_descr); - xx_image_description_info_v4_add_listener(image_descr_info->xx_image_description_info, + wp_image_description_info_v1_add_listener(image_descr_info->wp_image_description_info, &image_descr_info_iface, image_descr_info); @@ -778,14 +836,14 @@ TEST(create_image_description_before_setting_icc_file) { struct client *client; struct color_manager cm; - struct xx_image_description_creator_icc_v4 *image_descr_creator_icc; - struct xx_image_description_v4 *image_desc; + struct wp_image_description_creator_icc_v1 *image_descr_creator_icc; + struct wp_image_description_v1 *image_desc; client = create_client_and_test_surface(100, 100, 100, 100); color_manager_init(&cm, client); image_descr_creator_icc = - xx_color_manager_v4_new_icc_creator(cm.manager); + wp_color_manager_v1_create_icc_creator(cm.manager); /* Try creating image description based on ICC profile but without * setting the ICC file, what should fail. @@ -793,11 +851,11 @@ TEST(create_image_description_before_setting_icc_file) * We expect a protocol error from unknown object, because the * image_descr_creator_icc wl_proxy will get destroyed with the create * call below. It is a destructor request. */ - image_desc = xx_image_description_creator_icc_v4_create(image_descr_creator_icc); + image_desc = wp_image_description_creator_icc_v1_create(image_descr_creator_icc); expect_protocol_error(client, NULL, - XX_IMAGE_DESCRIPTION_CREATOR_ICC_V4_ERROR_INCOMPLETE_SET); + WP_IMAGE_DESCRIPTION_CREATOR_ICC_V1_ERROR_INCOMPLETE_SET); - xx_image_description_v4_destroy(image_desc); + wp_image_description_v1_destroy(image_desc); color_manager_fini(&cm); client_destroy(client); } @@ -806,7 +864,7 @@ TEST(set_unreadable_icc_fd) { struct client *client; struct color_manager cm; - struct xx_image_description_creator_icc_v4 *image_descr_creator_icc; + struct wp_image_description_creator_icc_v1 *image_descr_creator_icc; int32_t icc_fd; struct stat st; @@ -814,7 +872,7 @@ TEST(set_unreadable_icc_fd) color_manager_init(&cm, client); image_descr_creator_icc = - xx_color_manager_v4_new_icc_creator(cm.manager); + wp_color_manager_v1_create_icc_creator(cm.manager); /* The file is being open with WRITE, not READ permission. So the * compositor should complain. */ @@ -823,13 +881,13 @@ TEST(set_unreadable_icc_fd) assert(fstat(icc_fd, &st) == 0); /* Try setting the bad ICC file fd, it should fail. */ - xx_image_description_creator_icc_v4_set_icc_file(image_descr_creator_icc, + wp_image_description_creator_icc_v1_set_icc_file(image_descr_creator_icc, icc_fd, 0, st.st_size); - expect_protocol_error(client, &xx_image_description_creator_icc_v4_interface, - XX_IMAGE_DESCRIPTION_CREATOR_ICC_V4_ERROR_BAD_FD); + expect_protocol_error(client, &wp_image_description_creator_icc_v1_interface, + WP_IMAGE_DESCRIPTION_CREATOR_ICC_V1_ERROR_BAD_FD); close(icc_fd); - xx_image_description_creator_icc_v4_destroy(image_descr_creator_icc); + wp_image_description_creator_icc_v1_destroy(image_descr_creator_icc); color_manager_fini(&cm); client_destroy(client); } @@ -838,26 +896,26 @@ TEST(set_bad_icc_size_zero) { struct client *client; struct color_manager cm; - struct xx_image_description_creator_icc_v4 *image_descr_creator_icc; + struct wp_image_description_creator_icc_v1 *image_descr_creator_icc; int32_t icc_fd; client = create_client_and_test_surface(100, 100, 100, 100); color_manager_init(&cm, client); image_descr_creator_icc = - xx_color_manager_v4_new_icc_creator(cm.manager); + wp_color_manager_v1_create_icc_creator(cm.manager); icc_fd = open(srgb_icc_profile_path, O_RDONLY); assert(icc_fd >= 0); /* Try setting ICC file with a bad size, it should fail. */ - xx_image_description_creator_icc_v4_set_icc_file(image_descr_creator_icc, + wp_image_description_creator_icc_v1_set_icc_file(image_descr_creator_icc, icc_fd, 0, 0); - expect_protocol_error(client, &xx_image_description_creator_icc_v4_interface, - XX_IMAGE_DESCRIPTION_CREATOR_ICC_V4_ERROR_BAD_SIZE); + expect_protocol_error(client, &wp_image_description_creator_icc_v1_interface, + WP_IMAGE_DESCRIPTION_CREATOR_ICC_V1_ERROR_BAD_SIZE); close(icc_fd); - xx_image_description_creator_icc_v4_destroy(image_descr_creator_icc); + wp_image_description_creator_icc_v1_destroy(image_descr_creator_icc); color_manager_fini(&cm); client_destroy(client); } @@ -866,28 +924,28 @@ TEST(set_bad_icc_non_seekable) { struct client *client; struct color_manager cm; - struct xx_image_description_creator_icc_v4 *image_descr_creator_icc; + struct wp_image_description_creator_icc_v1 *image_descr_creator_icc; int32_t fds[2]; client = create_client_and_test_surface(100, 100, 100, 100); color_manager_init(&cm, client); image_descr_creator_icc = - xx_color_manager_v4_new_icc_creator(cm.manager); + wp_color_manager_v1_create_icc_creator(cm.manager); /* We need a non-seekable file, and pipes are non-seekable. */ assert(pipe(fds) >= 0); /* Pretend that it has a valid size of 1024 bytes. That still should * fail because the fd is non-seekable. */ - xx_image_description_creator_icc_v4_set_icc_file(image_descr_creator_icc, + wp_image_description_creator_icc_v1_set_icc_file(image_descr_creator_icc, fds[0], 0, 1024); - expect_protocol_error(client, &xx_image_description_creator_icc_v4_interface, - XX_IMAGE_DESCRIPTION_CREATOR_ICC_V4_ERROR_BAD_FD); + expect_protocol_error(client, &wp_image_description_creator_icc_v1_interface, + WP_IMAGE_DESCRIPTION_CREATOR_ICC_V1_ERROR_BAD_FD); close(fds[0]); close(fds[1]); - xx_image_description_creator_icc_v4_destroy(image_descr_creator_icc); + wp_image_description_creator_icc_v1_destroy(image_descr_creator_icc); color_manager_fini(&cm); client_destroy(client); } @@ -896,7 +954,7 @@ TEST(set_icc_twice) { struct client *client; struct color_manager cm; - struct xx_image_description_creator_icc_v4 *image_descr_creator_icc; + struct wp_image_description_creator_icc_v1 *image_descr_creator_icc; int32_t icc_fd; struct stat st; @@ -904,24 +962,24 @@ TEST(set_icc_twice) color_manager_init(&cm, client); image_descr_creator_icc = - xx_color_manager_v4_new_icc_creator(cm.manager); + wp_color_manager_v1_create_icc_creator(cm.manager); icc_fd = open(srgb_icc_profile_path, O_RDONLY); assert(icc_fd >= 0); assert(fstat(icc_fd, &st) == 0); - xx_image_description_creator_icc_v4_set_icc_file(image_descr_creator_icc, + wp_image_description_creator_icc_v1_set_icc_file(image_descr_creator_icc, icc_fd, 0, st.st_size); client_roundtrip(client); /* Set the ICC again, what should fail. */ - xx_image_description_creator_icc_v4_set_icc_file(image_descr_creator_icc, + wp_image_description_creator_icc_v1_set_icc_file(image_descr_creator_icc, icc_fd, 0, st.st_size); - expect_protocol_error(client, &xx_image_description_creator_icc_v4_interface, - XX_IMAGE_DESCRIPTION_CREATOR_ICC_V4_ERROR_ALREADY_SET); + expect_protocol_error(client, &wp_image_description_creator_icc_v1_interface, + WP_IMAGE_DESCRIPTION_CREATOR_ICC_V1_ERROR_ALREADY_SET); close(icc_fd); - xx_image_description_creator_icc_v4_destroy(image_descr_creator_icc); + wp_image_description_creator_icc_v1_destroy(image_descr_creator_icc); color_manager_fini(&cm); client_destroy(client); } @@ -930,7 +988,7 @@ TEST(create_icc_image_description_no_info) { struct client *client; struct color_manager cm; - struct xx_image_description_creator_icc_v4 *image_descr_creator_icc; + struct wp_image_description_creator_icc_v1 *image_descr_creator_icc; struct image_description *image_descr; struct image_description_info *image_descr_info; @@ -938,7 +996,7 @@ TEST(create_icc_image_description_no_info) color_manager_init(&cm, client); image_descr_creator_icc = - xx_color_manager_v4_new_icc_creator(cm.manager); + wp_color_manager_v1_create_icc_creator(cm.manager); /* Create image description based on ICC profile */ image_descr = create_icc_based_image_description(&cm, image_descr_creator_icc, @@ -948,8 +1006,8 @@ TEST(create_icc_image_description_no_info) /* Get image description information, and that should fail. Images * descriptions that we create do not accept this request. */ image_descr_info = image_descr_get_information(image_descr); - expect_protocol_error(client, &xx_image_description_v4_interface, - XX_IMAGE_DESCRIPTION_V4_ERROR_NO_INFORMATION); + expect_protocol_error(client, &wp_image_description_v1_interface, + WP_IMAGE_DESCRIPTION_V1_ERROR_NO_INFORMATION); image_descr_info_destroy(image_descr_info); color_manager_fini(&cm); @@ -960,14 +1018,14 @@ TEST(set_surface_image_description) { struct client *client; struct color_manager cm; - struct xx_image_description_creator_icc_v4 *image_descr_creator_icc; + struct wp_image_description_creator_icc_v1 *image_descr_creator_icc; struct image_description *image_descr; client = create_client_and_test_surface(100, 100, 100, 100); color_manager_init(&cm, client); image_descr_creator_icc = - xx_color_manager_v4_new_icc_creator(cm.manager); + wp_color_manager_v1_create_icc_creator(cm.manager); /* Create image description based on ICC profile */ image_descr = create_icc_based_image_description(&cm, image_descr_creator_icc, @@ -975,9 +1033,9 @@ TEST(set_surface_image_description) wait_until_image_description_ready(client, image_descr); /* Set surface image description */ - xx_color_management_surface_v4_set_image_description(cm.surface, - image_descr->xx_image_descr, - XX_COLOR_MANAGER_V4_RENDER_INTENT_PERCEPTUAL); + wp_color_management_surface_v1_set_image_description(cm.surface, + image_descr->wp_image_descr, + WP_COLOR_MANAGER_V1_RENDER_INTENT_PERCEPTUAL); client_roundtrip(client); color_manager_fini(&cm);