@ -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 , & param ) ;
xform = cmlcms_color_transform_get ( cm , & param ) ;
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 , & param ) ;
xform = cmlcms_color_transform_get ( cm , & param ) ;
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 , & param ) ;
/* 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 , & param ) ;
xform = cmlcms_color_transform_get ( cm , & param ) ;
if ( ! xform )