From 2aca058b69b62bf2b46aa068cff8f4972ffd31c7 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Tue, 17 Jun 2025 14:43:04 +0300 Subject: [PATCH] color: add weston_cm_send_parametric_info() Implementation of sending the protocol info events for an arbitrary parametric image description. Signed-off-by: Pekka Paalanen --- libweston/color-lcms/color-profile.c | 11 ++++----- libweston/color-management.c | 34 ++++++++++++++++++++++++++++ libweston/color-management.h | 4 ++++ 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/libweston/color-lcms/color-profile.c b/libweston/color-lcms/color-profile.c index e742ebcdb..01c0d032e 100644 --- a/libweston/color-lcms/color-profile.c +++ b/libweston/color-lcms/color-profile.c @@ -763,13 +763,10 @@ cmlcms_send_image_desc_info(struct cm_image_desc_info *cm_image_desc_info, if (cprof->type == CMLCMS_PROFILE_TYPE_ICC && cprof != cm->sRGB_profile) { return cmlcms_send_icc_info(cm_image_desc_info, cprof); } else { - /* TODO: we still don't support parametric color profiles that - * are not the stock one. This should change when we start - * advertising parametric image description support in our - * color-management protocol implementation. */ - if (cprof != cm->sRGB_profile) - weston_assert_not_reached(compositor, "we don't support parametric " \ - "cprof's that are not the stock sRGB one"); + if (cprof != cm->sRGB_profile) { + weston_cm_send_parametric_info(cm_image_desc_info, cprof->params); + return true; + } /* Stock sRGB color profile. TODO: when we add support for * parametric color profiles, the stock sRGB will be crafted diff --git a/libweston/color-management.c b/libweston/color-management.c index 79572cc1d..8996401ea 100644 --- a/libweston/color-management.c +++ b/libweston/color-management.c @@ -280,6 +280,40 @@ weston_cm_send_target_luminances(struct cm_image_desc_info *cm_image_desc_info, max_lum); } +/** + * Send complete parametric image description information to the client. + */ +WL_EXPORT void +weston_cm_send_parametric_info(struct cm_image_desc_info *cm_image_desc_info, + const struct weston_color_profile_params *par) +{ + if (par->primaries_info) + weston_cm_send_primaries_named(cm_image_desc_info, par->primaries_info); + weston_cm_send_primaries(cm_image_desc_info, &par->primaries); + weston_cm_send_target_primaries(cm_image_desc_info, &par->target_primaries); + + weston_cm_send_tf(cm_image_desc_info, &par->tf); + + weston_cm_send_luminances(cm_image_desc_info, par->min_luminance, + par->max_luminance, par->reference_white_luminance); + + if (par->target_min_luminance >= 0.0f && par->target_max_luminance >= 0.0f) { + weston_cm_send_target_luminances(cm_image_desc_info, + par->target_min_luminance, + par->target_max_luminance); + } + + if (par->maxCLL > 0.0f) { + wp_image_description_info_v1_send_target_max_cll(cm_image_desc_info->owner, + par->maxCLL); + } + + if (par->maxFALL > 0.0f) { + wp_image_description_info_v1_send_target_max_fall(cm_image_desc_info->owner, + par->maxFALL); + } +} + /** * Destroy an image description info object. */ diff --git a/libweston/color-management.h b/libweston/color-management.h index 0086e1207..d83ed39c4 100644 --- a/libweston/color-management.h +++ b/libweston/color-management.h @@ -67,4 +67,8 @@ void weston_cm_send_target_luminances(struct cm_image_desc_info *cm_image_desc_info, float min_lum, float max_lum); +void +weston_cm_send_parametric_info(struct cm_image_desc_info *cm_image_desc_info, + const struct weston_color_profile_params *par); + #endif /* WESTON_COLOR_MANAGEMENT_H */