From 19913366e84b794cd63fa7c8ec00045b7edbacd8 Mon Sep 17 00:00:00 2001 From: Vitaly Prosyak Date: Wed, 29 Sep 2021 18:11:10 -0400 Subject: [PATCH] color-lcms: add new fields for transform search parameter Add to search parameter cmlcms_category, input and output profiles, and render intent for output which would be used for both profiles. Add common function setup_search_param for every category. Signed-off-by: Vitaly Prosyak --- libweston/color-lcms/color-lcms.c | 74 ++++++++++++++++++++++++++----- libweston/color-lcms/color-lcms.h | 6 ++- 2 files changed, 67 insertions(+), 13 deletions(-) diff --git a/libweston/color-lcms/color-lcms.c b/libweston/color-lcms/color-lcms.c index 6e9d9fa5..e50e0bfd 100644 --- a/libweston/color-lcms/color-lcms.c +++ b/libweston/color-lcms/color-lcms.c @@ -33,6 +33,57 @@ #include "color-lcms.h" #include "shared/helpers.h" +static cmsUInt32Number +cmlcms_get_render_intent(enum cmlcms_category cat, + struct weston_surface *surface, + struct weston_output *output) +{ + /* + * TODO: Take into account client provided content profile, + * output profile, and the category of the wanted color + * transformation. + */ + cmsUInt32Number intent = INTENT_RELATIVE_COLORIMETRIC; + return intent; +} + +static void +setup_search_param(enum cmlcms_category cat, + struct weston_surface *surface, + struct weston_output *output, + struct cmlcms_color_profile *stock_sRGB_profile, + struct cmlcms_color_transform_search_param *search_param) +{ + struct cmlcms_color_profile *input_profile = NULL; + struct cmlcms_color_profile *output_profile = NULL; + + /* + * TODO: un-comment when declare color_profile in struct weston_surface + */ + /* if (surface && surface->color_profile) + input_profile = get_cprof(surface->color_profile); */ + if (output && output->color_profile) + output_profile = get_cprof(output->color_profile); + + search_param->category = cat; + switch (cat) { + case CMLCMS_CATEGORY_INPUT_TO_BLEND: + case CMLCMS_CATEGORY_INPUT_TO_OUTPUT: + search_param->input_profile = + input_profile ? input_profile : stock_sRGB_profile; + search_param->output_profile = + output_profile ? output_profile : stock_sRGB_profile; + break; + case CMLCMS_CATEGORY_BLEND_TO_OUTPUT: + search_param->output_profile = + output_profile ? output_profile : stock_sRGB_profile; + break; + } + search_param->intent_output = cmlcms_get_render_intent(cat, surface, + output); +} + + static void cmlcms_destroy_color_transform(struct weston_color_transform *xform_base) { @@ -57,9 +108,8 @@ cmlcms_get_surface_color_transform(struct weston_color_manager *cm_base, }; struct cmlcms_color_transform *xform; - /* TODO: use output color profile */ - if (output->color_profile) - return false; + setup_search_param(CMLCMS_CATEGORY_INPUT_TO_BLEND, surface, output, + cm->sRGB_profile, ¶m); xform = cmlcms_color_transform_get(cm, ¶m); if (!xform) @@ -86,9 +136,8 @@ cmlcms_get_output_color_transform(struct weston_color_manager *cm_base, }; struct cmlcms_color_transform *xform; - /* TODO: use output color profile */ - if (output->color_profile) - return false; + setup_search_param(CMLCMS_CATEGORY_BLEND_TO_OUTPUT, NULL, output, + cm->sRGB_profile, ¶m); xform = cmlcms_color_transform_get(cm, ¶m); if (!xform) @@ -104,10 +153,12 @@ cmlcms_get_sRGB_to_output_color_transform(struct weston_color_manager *cm_base, struct weston_color_transform **xform_out) { /* Assumes output color space is sRGB SDR */ + struct weston_color_manager_lcms *cm = get_cmlcms(cm_base); - /* TODO: use output color profile */ - if (output->color_profile) - return false; + struct cmlcms_color_transform_search_param param = {}; + + setup_search_param(CMLCMS_CATEGORY_INPUT_TO_OUTPUT, NULL, output, + cm->sRGB_profile, ¶m); /* Identity transform */ *xform_out = NULL; @@ -127,9 +178,8 @@ cmlcms_get_sRGB_to_blend_color_transform(struct weston_color_manager *cm_base, }; struct cmlcms_color_transform *xform; - /* TODO: use output color profile */ - if (output->color_profile) - return false; + setup_search_param(CMLCMS_CATEGORY_INPUT_TO_BLEND, NULL, output, + cm->sRGB_profile, ¶m); xform = cmlcms_color_transform_get(cm, ¶m); if (!xform) diff --git a/libweston/color-lcms/color-lcms.h b/libweston/color-lcms/color-lcms.h index eb34847c..fabaeadb 100644 --- a/libweston/color-lcms/color-lcms.h +++ b/libweston/color-lcms/color-lcms.h @@ -143,6 +143,11 @@ enum cmlcms_color_transform_type { struct cmlcms_color_transform_search_param { enum cmlcms_color_transform_type type; + + enum cmlcms_category category; + struct cmlcms_color_profile *input_profile; + struct cmlcms_color_profile *output_profile; + cmsUInt32Number intent_output; /* selected intent from output profile */ }; struct cmlcms_color_transform { @@ -165,7 +170,6 @@ struct cmlcms_color_transform { * not used */ cmsHTRANSFORM cmap_3dlut; - }; static inline struct cmlcms_color_transform *