diff options
author | Leandro Ribeiro <leandro.ribeiro@collabora.com> | 2024-04-15 17:43:44 -0300 |
---|---|---|
committer | Pekka Paalanen <pq@iki.fi> | 2024-04-26 12:11:17 +0000 |
commit | c10ca00e10847045803de92292baf2cf7e7f7e13 (patch) | |
tree | 233f75e5cfe2b7c5a6d88ea497be2d934fa3d786 | |
parent | 29e3af7ba201f146eb037b98f1cf87868012dc7d (diff) |
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 <leandro.ribeiro@collabora.com>
-rw-r--r-- | libweston/color-management.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/libweston/color-management.c b/libweston/color-management.c index cc3d50fb..bbeb2a26 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, |