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 <pekka.paalanen@collabora.com>
This commit is contained in:
Pekka Paalanen 2025-06-17 14:22:45 +03:00 committed by Leandro Ribeiro
parent 0dcae1a963
commit 03cad2e46b
3 changed files with 32 additions and 11 deletions

View file

@ -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);

View file

@ -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]);
}
}
/**

View file

@ -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,