From c10ca00e10847045803de92292baf2cf7e7f7e13 Mon Sep 17 00:00:00 2001 From: Leandro Ribeiro Date: Mon, 15 Apr 2024 17:43:44 -0300 Subject: [PATCH] color: handle image description that are not ready This patch is for our CM&HDR protocol extension implementation. When a client requests to create an image description, it can only start using that after receiving the 'ready' event. The compositor may take the time it needs to create the backing color profile for such image description. But nothing guarantees that clients will do the right thing. This fixes some issues for not well behaved clients and also documents how we handle image description that are not ready. Signed-off-by: Leandro Ribeiro --- libweston/color-management.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/libweston/color-management.c b/libweston/color-management.c index cc3d50fb9..bbeb2a266 100644 --- a/libweston/color-management.c +++ b/libweston/color-management.c @@ -51,7 +51,10 @@ struct cm_image_desc { struct wl_resource *owner; struct weston_color_manager *cm; - /* Reference to the color profile that it is backing up. */ + /* Reference to the color profile that it is backing up. An image + * description without a cprof is valid, and that simply means that it + * isn't ready (i.e. we didn't send the 'ready' event because we are + * still in the process of creating the color profile). */ struct weston_color_profile *cprof; /* Depending how the image description is created, the protocol states @@ -252,6 +255,14 @@ image_description_get_information(struct wl_client *client, return; } + /* Invalid image description for this request, as it isn't ready yet. */ + if (!cm_image_desc->cprof) { + wl_resource_post_error(cm_image_desc_res, + XX_IMAGE_DESCRIPTION_V2_ERROR_NOT_READY, + "image description not ready yet"); + return; + } + /* Depending how the image description is created, the protocol states * that get_information() request should be invalid. */ if (!cm_image_desc->supports_get_info) { @@ -584,6 +595,15 @@ cm_surface_set_image_description(struct wl_client *client, return; } + /* Invalid image description for this request, as it isn't ready yet. */ + if (!cm_image_desc->cprof) { + /* 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); + return; + } + cm = cm_image_desc->cm; render_intent = weston_render_intent_info_from_protocol(surface->compositor,