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>
This commit is contained in:
Leandro Ribeiro 2024-04-15 17:43:44 -03:00 committed by Pekka Paalanen
parent 29e3af7ba2
commit c10ca00e10

View File

@ -51,7 +51,10 @@ struct cm_image_desc {
struct wl_resource *owner; struct wl_resource *owner;
struct weston_color_manager *cm; 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; struct weston_color_profile *cprof;
/* Depending how the image description is created, the protocol states /* Depending how the image description is created, the protocol states
@ -252,6 +255,14 @@ image_description_get_information(struct wl_client *client,
return; 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 /* Depending how the image description is created, the protocol states
* that get_information() request should be invalid. */ * that get_information() request should be invalid. */
if (!cm_image_desc->supports_get_info) { if (!cm_image_desc->supports_get_info) {
@ -584,6 +595,15 @@ cm_surface_set_image_description(struct wl_client *client,
return; 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; cm = cm_image_desc->cm;
render_intent = weston_render_intent_info_from_protocol(surface->compositor, render_intent = weston_render_intent_info_from_protocol(surface->compositor,