mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2026-05-05 13:28:07 +02:00
color-lcms: call it a color transform recipe
I've been wanting a better name than search_param. In the future they are not always search parameters when we have to replace the input profile with another one for sRGB power-2.2 decoding purposes. I think "recipe" describes this struct well: it's the list of ingredients to cook a color transformation from. This patch is purely renaming things. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This commit is contained in:
parent
67cfcaa0ac
commit
3999d685bc
3 changed files with 45 additions and 45 deletions
|
|
@ -94,14 +94,14 @@ cmlcms_get_surface_color_transform(struct weston_color_manager *cm_base,
|
|||
{
|
||||
struct weston_color_manager_lcms *cm = to_cmlcms(cm_base);
|
||||
struct cmlcms_color_transform *xform;
|
||||
struct cmlcms_color_transform_search_param param = {
|
||||
struct cmlcms_color_transform_recipe recipe = {
|
||||
.category = CMLCMS_CATEGORY_INPUT_TO_BLEND,
|
||||
.input_profile = to_cprof_or_stock_sRGB(cm, surface->color_profile),
|
||||
.output_profile = to_cprof_or_stock_sRGB(cm, output->color_profile),
|
||||
.render_intent = render_intent_from_surface_or_default(cm, surface),
|
||||
};
|
||||
|
||||
xform = cmlcms_color_transform_get(cm, ¶m);
|
||||
xform = cmlcms_color_transform_get(cm, &recipe);
|
||||
if (!xform)
|
||||
return false;
|
||||
|
||||
|
|
@ -128,14 +128,14 @@ cmlcms_get_blend_to_output_color_transform(struct weston_color_manager_lcms *cm,
|
|||
struct weston_color_transform **xform_out)
|
||||
{
|
||||
struct cmlcms_color_transform *xform;
|
||||
struct cmlcms_color_transform_search_param param = {
|
||||
struct cmlcms_color_transform_recipe recipe = {
|
||||
.category = CMLCMS_CATEGORY_BLEND_TO_OUTPUT,
|
||||
.input_profile = NULL,
|
||||
.output_profile = to_cprof_or_stock_sRGB(cm, output->color_profile),
|
||||
.render_intent = NULL,
|
||||
};
|
||||
|
||||
xform = cmlcms_color_transform_get(cm, ¶m);
|
||||
xform = cmlcms_color_transform_get(cm, &recipe);
|
||||
if (!xform)
|
||||
return false;
|
||||
|
||||
|
|
@ -149,7 +149,7 @@ cmlcms_get_sRGB_to_output_color_transform(struct weston_color_manager_lcms *cm,
|
|||
struct weston_color_transform **xform_out)
|
||||
{
|
||||
struct cmlcms_color_transform *xform;
|
||||
struct cmlcms_color_transform_search_param param = {
|
||||
struct cmlcms_color_transform_recipe recipe = {
|
||||
.category = CMLCMS_CATEGORY_INPUT_TO_OUTPUT,
|
||||
.input_profile = cm->sRGB_profile,
|
||||
.output_profile = to_cprof_or_stock_sRGB(cm, output->color_profile),
|
||||
|
|
@ -160,8 +160,8 @@ cmlcms_get_sRGB_to_output_color_transform(struct weston_color_manager_lcms *cm,
|
|||
* Create a color transformation when output profile is not stock
|
||||
* sRGB profile.
|
||||
*/
|
||||
if (param.output_profile != cm->sRGB_profile) {
|
||||
xform = cmlcms_color_transform_get(cm, ¶m);
|
||||
if (recipe.output_profile != cm->sRGB_profile) {
|
||||
xform = cmlcms_color_transform_get(cm, &recipe);
|
||||
if (!xform)
|
||||
return false;
|
||||
*xform_out = &xform->base;
|
||||
|
|
@ -178,14 +178,14 @@ cmlcms_get_sRGB_to_blend_color_transform(struct weston_color_manager_lcms *cm,
|
|||
struct weston_color_transform **xform_out)
|
||||
{
|
||||
struct cmlcms_color_transform *xform;
|
||||
struct cmlcms_color_transform_search_param param = {
|
||||
struct cmlcms_color_transform_recipe recipe = {
|
||||
.category = CMLCMS_CATEGORY_INPUT_TO_BLEND,
|
||||
.input_profile = cm->sRGB_profile,
|
||||
.output_profile = to_cprof_or_stock_sRGB(cm, output->color_profile),
|
||||
.render_intent = render_intent_from_surface_or_default(cm, NULL),
|
||||
};
|
||||
|
||||
xform = cmlcms_color_transform_get(cm, ¶m);
|
||||
xform = cmlcms_color_transform_get(cm, &recipe);
|
||||
if (!xform)
|
||||
return false;
|
||||
|
||||
|
|
@ -332,7 +332,7 @@ transforms_scope_new_sub(struct weston_log_subscription *subs, void *data)
|
|||
wl_list_for_each(xform, &cm->color_transform_list, link) {
|
||||
weston_log_subscription_printf(subs, "Color transformation t%u:\n", xform->base.id);
|
||||
|
||||
str = cmlcms_color_transform_search_param_string(&xform->search_key);
|
||||
str = cmlcms_color_transform_recipe_string(&xform->search_key);
|
||||
weston_log_subscription_printf(subs, "%s", str);
|
||||
free(str);
|
||||
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ void
|
|||
cmlcms_destroy_color_profile(struct weston_color_profile *cprof_base);
|
||||
|
||||
|
||||
struct cmlcms_color_transform_search_param {
|
||||
struct cmlcms_color_transform_recipe {
|
||||
enum cmlcms_category category;
|
||||
struct cmlcms_color_profile *input_profile;
|
||||
struct cmlcms_color_profile *output_profile;
|
||||
|
|
@ -203,7 +203,7 @@ struct cmlcms_color_transform {
|
|||
/* weston_color_manager_lcms::color_transform_list */
|
||||
struct wl_list link;
|
||||
|
||||
struct cmlcms_color_transform_search_param search_key;
|
||||
struct cmlcms_color_transform_recipe search_key;
|
||||
|
||||
/**
|
||||
* Cached data used when we can't translate the curves into parametric
|
||||
|
|
@ -241,13 +241,13 @@ to_cmlcms_xform(struct weston_color_transform *xform_base)
|
|||
|
||||
struct cmlcms_color_transform *
|
||||
cmlcms_color_transform_get(struct weston_color_manager_lcms *cm,
|
||||
const struct cmlcms_color_transform_search_param *param);
|
||||
const struct cmlcms_color_transform_recipe *recipe);
|
||||
|
||||
void
|
||||
cmlcms_color_transform_destroy(struct cmlcms_color_transform *xform);
|
||||
|
||||
char *
|
||||
cmlcms_color_transform_search_param_string(const struct cmlcms_color_transform_search_param *search_key);
|
||||
cmlcms_color_transform_recipe_string(const struct cmlcms_color_transform_recipe *recipe);
|
||||
|
||||
struct cmlcms_color_profile *
|
||||
ref_cprof(struct cmlcms_color_profile *cprof);
|
||||
|
|
|
|||
|
|
@ -1349,7 +1349,7 @@ failed:
|
|||
}
|
||||
|
||||
char *
|
||||
cmlcms_color_transform_search_param_string(const struct cmlcms_color_transform_search_param *search_key)
|
||||
cmlcms_color_transform_recipe_string(const struct cmlcms_color_transform_recipe *recipe)
|
||||
{
|
||||
const char *input_prof_desc = "none";
|
||||
unsigned input_prof_id = 0;
|
||||
|
|
@ -1358,24 +1358,24 @@ cmlcms_color_transform_search_param_string(const struct cmlcms_color_transform_s
|
|||
const char *intent_desc = "none";
|
||||
char *str;
|
||||
|
||||
if (search_key->input_profile) {
|
||||
input_prof_desc = search_key->input_profile->base.description;
|
||||
input_prof_id = search_key->input_profile->base.id;
|
||||
if (recipe->input_profile) {
|
||||
input_prof_desc = recipe->input_profile->base.description;
|
||||
input_prof_id = recipe->input_profile->base.id;
|
||||
}
|
||||
|
||||
if (search_key->output_profile) {
|
||||
output_prof_desc = search_key->output_profile->base.description;
|
||||
output_prof_id = search_key->output_profile->base.id;
|
||||
if (recipe->output_profile) {
|
||||
output_prof_desc = recipe->output_profile->base.description;
|
||||
output_prof_id = recipe->output_profile->base.id;
|
||||
}
|
||||
|
||||
if (search_key->render_intent)
|
||||
intent_desc = search_key->render_intent->desc;
|
||||
if (recipe->render_intent)
|
||||
intent_desc = recipe->render_intent->desc;
|
||||
|
||||
str_printf(&str, " category: %s\n" \
|
||||
" input profile p%u: %s\n" \
|
||||
" output profile p%u: %s\n" \
|
||||
" render intent: %s\n",
|
||||
cmlcms_category_name(search_key->category),
|
||||
cmlcms_category_name(recipe->category),
|
||||
input_prof_id, input_prof_desc,
|
||||
output_prof_id, output_prof_desc,
|
||||
intent_desc);
|
||||
|
|
@ -1562,7 +1562,7 @@ xform_to_shaper_plus_3dlut(struct weston_color_transform *xform_base,
|
|||
|
||||
static struct cmlcms_color_transform *
|
||||
cmlcms_color_transform_create(struct weston_color_manager_lcms *cm,
|
||||
const struct cmlcms_color_transform_search_param *search_param)
|
||||
const struct cmlcms_color_transform_recipe *recipe)
|
||||
{
|
||||
struct cmlcms_color_transform *xform;
|
||||
const char *err_msg = NULL;
|
||||
|
|
@ -1572,17 +1572,17 @@ cmlcms_color_transform_create(struct weston_color_manager_lcms *cm,
|
|||
weston_color_transform_init(&xform->base, &cm->base);
|
||||
wl_list_init(&xform->link);
|
||||
xform->base.to_shaper_plus_3dlut = xform_to_shaper_plus_3dlut;
|
||||
xform->search_key = *search_param;
|
||||
xform->search_key.input_profile = ref_cprof(search_param->input_profile);
|
||||
xform->search_key.output_profile = ref_cprof(search_param->output_profile);
|
||||
xform->search_key = *recipe;
|
||||
xform->search_key.input_profile = ref_cprof(recipe->input_profile);
|
||||
xform->search_key.output_profile = ref_cprof(recipe->output_profile);
|
||||
|
||||
weston_log_scope_printf(cm->transforms_scope,
|
||||
"New color transformation: t%u\n", xform->base.id);
|
||||
str = cmlcms_color_transform_search_param_string(&xform->search_key);
|
||||
str = cmlcms_color_transform_recipe_string(&xform->search_key);
|
||||
weston_log_scope_printf(cm->transforms_scope, "%s", str);
|
||||
free(str);
|
||||
|
||||
if (!ensure_output_profile_extract(search_param->output_profile, cm->lcms_ctx,
|
||||
if (!ensure_output_profile_extract(recipe->output_profile, cm->lcms_ctx,
|
||||
cmlcms_reasonable_1D_points(), &err_msg))
|
||||
goto error;
|
||||
|
||||
|
|
@ -1613,15 +1613,15 @@ error:
|
|||
}
|
||||
|
||||
static bool
|
||||
transform_matches_params(const struct cmlcms_color_transform *xform,
|
||||
const struct cmlcms_color_transform_search_param *param)
|
||||
transform_matches_recipe(const struct cmlcms_color_transform *xform,
|
||||
const struct cmlcms_color_transform_recipe *recipe)
|
||||
{
|
||||
if (xform->search_key.category != param->category)
|
||||
if (xform->search_key.category != recipe->category)
|
||||
return false;
|
||||
|
||||
if (xform->search_key.render_intent != param->render_intent ||
|
||||
xform->search_key.output_profile != param->output_profile ||
|
||||
xform->search_key.input_profile != param->input_profile)
|
||||
if (xform->search_key.render_intent != recipe->render_intent ||
|
||||
xform->search_key.output_profile != recipe->output_profile ||
|
||||
xform->search_key.input_profile != recipe->input_profile)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
@ -1629,31 +1629,31 @@ transform_matches_params(const struct cmlcms_color_transform *xform,
|
|||
|
||||
struct cmlcms_color_transform *
|
||||
cmlcms_color_transform_get(struct weston_color_manager_lcms *cm,
|
||||
const struct cmlcms_color_transform_search_param *param)
|
||||
const struct cmlcms_color_transform_recipe *recipe)
|
||||
{
|
||||
struct cmlcms_color_transform *xform;
|
||||
|
||||
weston_assert_ptr_not_null(cm->base.compositor, param->output_profile);
|
||||
switch (param->category) {
|
||||
weston_assert_ptr_not_null(cm->base.compositor, recipe->output_profile);
|
||||
switch (recipe->category) {
|
||||
case CMLCMS_CATEGORY_BLEND_TO_OUTPUT:
|
||||
weston_assert_ptr_null(cm->base.compositor, param->render_intent);
|
||||
weston_assert_ptr_null(cm->base.compositor, param->input_profile);
|
||||
weston_assert_ptr_null(cm->base.compositor, recipe->render_intent);
|
||||
weston_assert_ptr_null(cm->base.compositor, recipe->input_profile);
|
||||
break;
|
||||
case CMLCMS_CATEGORY_INPUT_TO_OUTPUT:
|
||||
case CMLCMS_CATEGORY_INPUT_TO_BLEND:
|
||||
weston_assert_ptr_not_null(cm->base.compositor, param->render_intent);
|
||||
weston_assert_ptr_not_null(cm->base.compositor, param->input_profile);
|
||||
weston_assert_ptr_not_null(cm->base.compositor, recipe->render_intent);
|
||||
weston_assert_ptr_not_null(cm->base.compositor, recipe->input_profile);
|
||||
break;
|
||||
}
|
||||
|
||||
wl_list_for_each(xform, &cm->color_transform_list, link) {
|
||||
if (transform_matches_params(xform, param)) {
|
||||
if (transform_matches_recipe(xform, recipe)) {
|
||||
weston_color_transform_ref(&xform->base);
|
||||
return xform;
|
||||
}
|
||||
}
|
||||
|
||||
xform = cmlcms_color_transform_create(cm, param);
|
||||
xform = cmlcms_color_transform_create(cm, recipe);
|
||||
if (!xform)
|
||||
weston_log("color-lcms error: failed to create a color transformation.\n");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue