From 03cad2e46b82d62392778bba5c40ce62b74d321a Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Tue, 17 Jun 2025 14:22:45 +0300 Subject: [PATCH] color: weston_cm_send_tf() handles power-law The power-law TF uses a different protocol event than others. Adding support for it requires passing in the parameters. Now we have a single send function that handles all protocol TFs, not just those without parameters. Signed-off-by: Pekka Paalanen --- libweston/color-lcms/color-profile.c | 8 ++++--- libweston/color-management.c | 31 ++++++++++++++++++++++------ libweston/color-management.h | 4 ++-- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/libweston/color-lcms/color-profile.c b/libweston/color-lcms/color-profile.c index 7e01621d9..e742ebcdb 100644 --- a/libweston/color-lcms/color-profile.c +++ b/libweston/color-lcms/color-profile.c @@ -753,7 +753,6 @@ cmlcms_send_image_desc_info(struct cm_image_desc_info *cm_image_desc_info, struct weston_compositor *compositor = cm->base.compositor; struct cmlcms_color_profile *cprof = to_cmlcms_cprof(cprof_base); const struct weston_color_primaries_info *primaries_info; - const struct weston_color_tf_info *tf_info; /** * TODO: when we convert the stock sRGB profile to a parametric profile @@ -795,8 +794,11 @@ cmlcms_send_image_desc_info(struct cm_image_desc_info *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); + struct weston_color_tf tf = { + .info = weston_color_tf_info_from(compositor, WESTON_TF_GAMMA22), + .params = {}, + }; + weston_cm_send_tf(cm_image_desc_info, &tf); /* Primary luminance, default values from the protocol. */ weston_cm_send_luminances(cm_image_desc_info, 0.2, 80.0, 80.0); diff --git a/libweston/color-management.c b/libweston/color-management.c index 10cf7a305..79572cc1d 100644 --- a/libweston/color-management.c +++ b/libweston/color-management.c @@ -209,15 +209,34 @@ weston_cm_send_target_primaries(struct cm_image_desc_info *cm_image_desc_info, * 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 tf_info The tf_info object + * \param cm_image_desc_info The image description info object. + * \param tf The color transfer function to send. */ 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) +weston_cm_send_tf(struct cm_image_desc_info *cm_image_desc_info, + const struct weston_color_tf *tf) { - wp_image_description_info_v1_send_tf_named(cm_image_desc_info->owner, - tf_info->protocol_tf); + switch (tf->info->tf) { + case WESTON_TF_BT1886: + case WESTON_TF_GAMMA22: + case WESTON_TF_GAMMA28: + case WESTON_TF_SRGB: + case WESTON_TF_EXT_SRGB: + case WESTON_TF_ST240: + case WESTON_TF_ST428: + case WESTON_TF_ST2084_PQ: + case WESTON_TF_EXT_LINEAR: + case WESTON_TF_LOG_100: + case WESTON_TF_LOG_316: + case WESTON_TF_XVYCC: + case WESTON_TF_HLG: + wp_image_description_info_v1_send_tf_named(cm_image_desc_info->owner, + tf->info->protocol_tf); + break; + case WESTON_TF_POWER: + wp_image_description_info_v1_send_tf_power(cm_image_desc_info->owner, + tf->params[0]); + } } /** diff --git a/libweston/color-management.h b/libweston/color-management.h index 5ae38198e..0086e1207 100644 --- a/libweston/color-management.h +++ b/libweston/color-management.h @@ -56,8 +56,8 @@ 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); +weston_cm_send_tf(struct cm_image_desc_info *cm_image_desc_info, + const struct weston_color_tf *tf); void weston_cm_send_luminances(struct cm_image_desc_info *cm_image_desc_info,