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 <vitaly.prosyak@amd.com>
dev
Vitaly Prosyak 3 years ago
parent 19f318692e
commit 19913366e8
  1. 74
      libweston/color-lcms/color-lcms.c
  2. 6
      libweston/color-lcms/color-lcms.h

@ -33,6 +33,57 @@
#include "color-lcms.h" #include "color-lcms.h"
#include "shared/helpers.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 static void
cmlcms_destroy_color_transform(struct weston_color_transform *xform_base) 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; struct cmlcms_color_transform *xform;
/* TODO: use output color profile */ setup_search_param(CMLCMS_CATEGORY_INPUT_TO_BLEND, surface, output,
if (output->color_profile) cm->sRGB_profile, &param);
return false;
xform = cmlcms_color_transform_get(cm, &param); xform = cmlcms_color_transform_get(cm, &param);
if (!xform) if (!xform)
@ -86,9 +136,8 @@ cmlcms_get_output_color_transform(struct weston_color_manager *cm_base,
}; };
struct cmlcms_color_transform *xform; struct cmlcms_color_transform *xform;
/* TODO: use output color profile */ setup_search_param(CMLCMS_CATEGORY_BLEND_TO_OUTPUT, NULL, output,
if (output->color_profile) cm->sRGB_profile, &param);
return false;
xform = cmlcms_color_transform_get(cm, &param); xform = cmlcms_color_transform_get(cm, &param);
if (!xform) 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) struct weston_color_transform **xform_out)
{ {
/* Assumes output color space is sRGB SDR */ /* Assumes output color space is sRGB SDR */
struct weston_color_manager_lcms *cm = get_cmlcms(cm_base);
/* TODO: use output color profile */ struct cmlcms_color_transform_search_param param = {};
if (output->color_profile)
return false; setup_search_param(CMLCMS_CATEGORY_INPUT_TO_OUTPUT, NULL, output,
cm->sRGB_profile, &param);
/* Identity transform */ /* Identity transform */
*xform_out = NULL; *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; struct cmlcms_color_transform *xform;
/* TODO: use output color profile */ setup_search_param(CMLCMS_CATEGORY_INPUT_TO_BLEND, NULL, output,
if (output->color_profile) cm->sRGB_profile, &param);
return false;
xform = cmlcms_color_transform_get(cm, &param); xform = cmlcms_color_transform_get(cm, &param);
if (!xform) if (!xform)

@ -143,6 +143,11 @@ enum cmlcms_color_transform_type {
struct cmlcms_color_transform_search_param { struct cmlcms_color_transform_search_param {
enum cmlcms_color_transform_type type; 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 { struct cmlcms_color_transform {
@ -165,7 +170,6 @@ struct cmlcms_color_transform {
* not used * not used
*/ */
cmsHTRANSFORM cmap_3dlut; cmsHTRANSFORM cmap_3dlut;
}; };
static inline struct cmlcms_color_transform * static inline struct cmlcms_color_transform *

Loading…
Cancel
Save