Skip to content
Commits on Source (7)
......@@ -73,6 +73,7 @@ struct weston_point2d_device_normalized {
double y;
};
struct weston_compositor;
struct weston_surface;
struct weston_buffer;
struct shell_surface;
......@@ -84,6 +85,7 @@ struct linux_dmabuf_buffer;
struct weston_recorder;
struct weston_pointer_constraint;
struct ro_anonymous_file;
struct weston_color_profile_param_builder;
struct weston_color_profile;
struct weston_color_transform;
struct pixel_format_info;
......@@ -311,6 +313,108 @@ struct weston_CIExy {
float y;
};
/** Chromaticity coordinates and white point that defines the color gamut */
struct weston_color_gamut {
struct weston_CIExy primary[3]; /* RGB order */
struct weston_CIExy white_point;
};
/** Color primaries known by libweston */
enum weston_color_primaries {
WESTON_PRIMARIES_CICP_SRGB = 0,
WESTON_PRIMARIES_CICP_PAL_M,
WESTON_PRIMARIES_CICP_PAL,
WESTON_PRIMARIES_CICP_NTSC,
WESTON_PRIMARIES_CICP_GENERIC_FILM,
WESTON_PRIMARIES_CICP_BT2020,
WESTON_PRIMARIES_CICP_CIE1931_XYZ,
WESTON_PRIMARIES_CICP_DCI_P3,
WESTON_PRIMARIES_CICP_DISPLAY_P3,
WESTON_PRIMARIES_ADOBE_RGB,
};
/** Transfer functions known by libweston */
enum weston_transfer_function {
WESTON_TF_LINEAR = 0,
WESTON_TF_GAMMA22,
WESTON_TF_GAMMA28,
WESTON_TF_SRGB,
WESTON_TF_EXT_SRGB,
WESTON_TF_BT709,
WESTON_TF_BT1361,
WESTON_TF_ST240,
WESTON_TF_ST428,
WESTON_TF_ST2084_PQ,
WESTON_TF_LOG_100,
WESTON_TF_LOG_316,
WESTON_TF_XVYCC,
WESTON_TF_HLG,
WESTON_TF_POWER,
};
/** Error codes that the color profile parameters functions may return. */
enum weston_color_profile_param_builder_error {
WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_INVALID_TF = 0,
WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_INVALID_PRIMARIES,
WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_INVALID_TARGET_PRIMARIES,
WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_CIE_XY_OUT_OF_RANGE,
WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_INVALID_LUMINANCE,
WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_INCONSISTENT_LUMINANCES,
WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_INCONSISTENT_SET,
WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_INCOMPLETE_SET,
WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_ALREADY_SET,
WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_UNSUPPORTED,
};
struct weston_color_profile_param_builder *
weston_color_profile_param_builder_create(struct weston_compositor *compositor);
void
weston_color_profile_param_builder_destroy(struct weston_color_profile_param_builder *builder);
bool
weston_color_profile_param_builder_get_error(struct weston_color_profile_param_builder *builder,
enum weston_color_profile_param_builder_error *err,
char **err_msg);
bool
weston_color_profile_param_builder_set_primaries(struct weston_color_profile_param_builder *builder,
const struct weston_color_gamut *primaries);
bool
weston_color_profile_param_builder_set_primaries_named(struct weston_color_profile_param_builder *builder,
enum weston_color_primaries primaries);
bool
weston_color_profile_param_builder_set_tf_named(struct weston_color_profile_param_builder *builder,
enum weston_transfer_function tf);
bool
weston_color_profile_param_builder_set_tf_power_exponent(struct weston_color_profile_param_builder *builder,
float power_exponent);
bool
weston_color_profile_param_builder_set_target_primaries(struct weston_color_profile_param_builder *builder,
const struct weston_color_gamut *target_primaries);
bool
weston_color_profile_param_builder_set_target_luminance(struct weston_color_profile_param_builder *builder,
float min_luminance, float max_luminance);
bool
weston_color_profile_param_builder_set_maxFALL(struct weston_color_profile_param_builder *builder,
float maxFALL);
bool
weston_color_profile_param_builder_set_maxCLL(struct weston_color_profile_param_builder *builder,
float maxCLL);
struct weston_color_profile *
weston_color_profile_param_builder_create_color_profile(struct weston_color_profile_param_builder *builder,
const char *name_part,
enum weston_color_profile_param_builder_error *err,
char **err_msg);
enum weston_color_characteristics_groups {
/** weston_color_characteristics::primary is set */
WESTON_COLOR_CHARACTERISTICS_GROUP_PRIMARIES = 0x01,
......
......@@ -491,6 +491,7 @@ weston_color_manager_create(struct weston_compositor *compositor)
cm->base.destroy_color_profile = cmlcms_destroy_color_profile;
cm->base.ref_stock_sRGB_color_profile = cmlcms_ref_stock_sRGB_color_profile;
cm->base.get_color_profile_from_icc = cmlcms_get_color_profile_from_icc;
cm->base.get_color_profile_from_params = cmlcms_get_color_profile_from_params;
cm->base.send_image_desc_info = cmlcms_send_image_desc_info;
cm->base.destroy_color_transform = cmlcms_destroy_color_transform;
cm->base.get_surface_color_transform = cmlcms_get_surface_color_transform;
......@@ -506,6 +507,21 @@ weston_color_manager_create(struct weston_compositor *compositor)
(1 << WESTON_RENDER_INTENT_RELATIVE) |
(1 << WESTON_RENDER_INTENT_RELATIVE_BPC);
/* We support all primaries named. */
cm->base.supported_primaries_named = (1 << WESTON_PRIMARIES_CICP_SRGB) |
(1 << WESTON_PRIMARIES_CICP_PAL_M) |
(1 << WESTON_PRIMARIES_CICP_PAL) |
(1 << WESTON_PRIMARIES_CICP_NTSC) |
(1 << WESTON_PRIMARIES_CICP_GENERIC_FILM) |
(1 << WESTON_PRIMARIES_CICP_BT2020) |
(1 << WESTON_PRIMARIES_CICP_CIE1931_XYZ) |
(1 << WESTON_PRIMARIES_CICP_DCI_P3) |
(1 << WESTON_PRIMARIES_CICP_DISPLAY_P3) |
(1 << WESTON_PRIMARIES_ADOBE_RGB);
/* We still don't support any tf named. */
cm->base.supported_tf_named = 0;
wl_list_init(&cm->color_transform_list);
wl_list_init(&cm->color_profile_list);
......
......@@ -93,17 +93,30 @@ struct cmlcms_output_profile_extract {
struct lcmsProfilePtr vcgt;
};
/**
* Profile type, based on what was used to create it.
*/
enum cmlcms_profile_type {
CMLCMS_PROFILE_TYPE_ICC = 0, /* created with ICC profile. */
CMLCMS_PROFILE_TYPE_PARAMS, /* created with color parameters. */
};
struct cmlcms_color_profile {
struct weston_color_profile base;
enum cmlcms_profile_type type;
/* struct weston_color_manager_lcms::color_profile_list */
struct wl_list link;
struct lcmsProfilePtr profile;
struct cmlcms_md5_sum md5sum;
/* Only for CMLCMS_PROFILE_TYPE_ICC */
struct {
struct lcmsProfilePtr profile;
struct cmlcms_md5_sum md5sum;
struct ro_anonymous_file *prof_rofile;
} icc;
/* Only for profiles created from an ICC file. */
struct ro_anonymous_file *prof_rofile;
/* Only for CMLCMS_PROFILE_TYPE_PARAMS */
struct weston_color_profile_params *params;
/* Populated only when profile used as output profile */
struct cmlcms_output_profile_extract extract;
......@@ -153,6 +166,13 @@ cmlcms_get_color_profile_from_icc(struct weston_color_manager *cm,
struct weston_color_profile **cprof_out,
char **errmsg);
bool
cmlcms_get_color_profile_from_params(struct weston_color_manager *cm_base,
const struct weston_color_profile_params *params,
const char *name_part,
struct weston_color_profile **cprof_out,
char **errmsg);
bool
cmlcms_send_image_desc_info(struct cm_image_desc_info *cm_image_desc_info,
struct weston_color_profile *cprof_base);
......
......@@ -285,17 +285,28 @@ ensure_output_profile_extract(struct cmlcms_color_profile *cprof,
unsigned int num_points,
const char **err_msg)
{
struct weston_compositor *compositor = cprof->base.cm->compositor;
bool ret;
/* Everything already computed */
if (cprof->extract.eotf.p)
return true;
ret = ensure_output_profile_extract_icc(&cprof->extract, lcms_ctx,
cprof->profile, num_points, err_msg);
if (ret)
weston_assert_ptr(cprof->base.cm->compositor, cprof->extract.eotf.p);
switch (cprof->type) {
case CMLCMS_PROFILE_TYPE_ICC:
ret = ensure_output_profile_extract_icc(&cprof->extract, lcms_ctx,
cprof->icc.profile, num_points,
err_msg);
if (ret)
weston_assert_ptr(compositor, cprof->extract.eotf.p);
break;
case CMLCMS_PROFILE_TYPE_PARAMS:
/* TODO: need to address this when we create param profiles. */
ret = false;
break;
default:
weston_assert_not_reached(compositor, "unknown profile type");
}
return ret;
}
......@@ -337,7 +348,10 @@ cmlcms_find_color_profile_by_md5(const struct weston_color_manager_lcms *cm,
struct cmlcms_color_profile *cprof;
wl_list_for_each(cprof, &cm->color_profile_list, link) {
if (memcmp(cprof->md5sum.bytes,
if (cprof->type != CMLCMS_PROFILE_TYPE_ICC)
continue;
if (memcmp(cprof->icc.md5sum.bytes,
md5sum->bytes, sizeof(md5sum->bytes)) == 0)
return cprof;
}
......@@ -345,11 +359,42 @@ cmlcms_find_color_profile_by_md5(const struct weston_color_manager_lcms *cm,
return NULL;
}
static struct cmlcms_color_profile *
cmlcms_find_color_profile_by_params(const struct weston_color_manager_lcms *cm,
const struct weston_color_profile_params *params)
{
struct cmlcms_color_profile *cprof;
/* Ensure no uninitialized data inside struct to make memcmp work. */
static_assert(sizeof(*params) ==
2 * sizeof(float) * 2 * 4 + /* primaries, target_primaries */
sizeof(params->primaries_info) +
sizeof(params->tf_info) +
sizeof(params->tf_params) +
sizeof(params->min_luminance) +
sizeof(params->max_luminance) +
sizeof(params->maxCLL) +
sizeof(params->maxFALL),
"struct weston_color_profile_params must not contain implicit padding");
wl_list_for_each(cprof, &cm->color_profile_list, link) {
if (cprof->type != CMLCMS_PROFILE_TYPE_PARAMS)
continue;
if (memcmp(cprof->params, params, sizeof(*params)) == 0)
return cprof;
}
return NULL;
}
char *
cmlcms_color_profile_print(const struct cmlcms_color_profile *cprof)
{
char *str;
/* TODO: also print cprof->params for parametric profiles. */
str_printf(&str, " description: %s\n", cprof->base.description);
abort_oom_if_null(str);
......@@ -371,8 +416,8 @@ cmlcms_color_profile_create(struct weston_color_manager_lcms *cm,
weston_color_profile_init(&cprof->base, &cm->base);
cprof->base.description = desc;
cprof->profile = profile;
cmsGetHeaderProfileID(profile.p, cprof->md5sum.bytes);
cprof->icc.profile = profile;
cmsGetHeaderProfileID(profile.p, cprof->icc.md5sum.bytes);
wl_list_insert(&cm->color_profile_list, &cprof->link);
weston_log_scope_printf(cm->profiles_scope,
......@@ -394,11 +439,25 @@ cmlcms_color_profile_destroy(struct cmlcms_color_profile *cprof)
cmsCloseProfile(cprof->extract.vcgt.p);
cmsCloseProfile(cprof->extract.inv_eotf.p);
cmsCloseProfile(cprof->extract.eotf.p);
cmsCloseProfile(cprof->profile.p);
/* Only profiles created from ICC files have these. */
if (cprof->prof_rofile)
os_ro_anonymous_file_destroy(cprof->prof_rofile);
switch (cprof->type) {
case CMLCMS_PROFILE_TYPE_ICC:
cmsCloseProfile(cprof->icc.profile.p);
/**
* TODO: drop this if when we convert the stock sRGB profile to
* a parametric one. When we do that, all ICC profiles will have
* their ro_anonymous_file, so we won't have to check.
*/
if (cprof->icc.prof_rofile)
os_ro_anonymous_file_destroy(cprof->icc.prof_rofile);
break;
case CMLCMS_PROFILE_TYPE_PARAMS:
free(cprof->params);
break;
default:
weston_assert_not_reached(cm->base.compositor,
"unknown profile type");
}
weston_log_scope_printf(cm->profiles_scope, "Destroyed color profile p%u. " \
"Description: %s\n", cprof->base.id, cprof->base.description);
......@@ -477,6 +536,8 @@ cmlcms_create_stock_profile(struct weston_color_manager_lcms *cm)
if (!cm->sRGB_profile)
goto err_close;
cm->sRGB_profile->type = CMLCMS_PROFILE_TYPE_ICC;
if (!ensure_output_profile_extract(cm->sRGB_profile, cm->lcms_ctx,
cmlcms_reasonable_1D_points(), &err_msg))
goto err_close;
......@@ -514,6 +575,7 @@ cmlcms_get_color_profile_from_icc(struct weston_color_manager *cm_base,
struct weston_color_manager_lcms *cm = to_cmlcms(cm_base);
struct lcmsProfilePtr profile;
struct cmlcms_md5_sum md5sum;
struct ro_anonymous_file *prof_rofile = NULL;
struct cmlcms_color_profile *cprof = NULL;
char *desc = NULL;
......@@ -552,18 +614,23 @@ cmlcms_get_color_profile_from_icc(struct weston_color_manager *cm_base,
if (!desc)
goto err_close;
prof_rofile = os_ro_anonymous_file_create(icc_len, icc_data);
if (!prof_rofile)
goto err_close;
cprof = cmlcms_color_profile_create(cm, profile, desc, errmsg);
if (!cprof)
goto err_close;
cprof->prof_rofile = os_ro_anonymous_file_create(icc_len, icc_data);
if (!cprof->prof_rofile)
goto err_close;
cprof->type = CMLCMS_PROFILE_TYPE_ICC;
cprof->icc.prof_rofile = prof_rofile;
*cprof_out = &cprof->base;
return true;
err_close:
if (prof_rofile)
os_ro_anonymous_file_destroy(prof_rofile);
if (cprof)
cmlcms_color_profile_destroy(cprof);
free(desc);
......@@ -571,6 +638,62 @@ err_close:
return false;
}
bool
cmlcms_get_color_profile_from_params(struct weston_color_manager *cm_base,
const struct weston_color_profile_params *params,
const char *name_part,
struct weston_color_profile **cprof_out,
char **errmsg)
{
struct weston_color_manager_lcms *cm = to_cmlcms(cm_base);
struct cmlcms_color_profile *cprof;
char *desc;
char *str;
/* TODO: add a helper similar to cmlcms_color_profile_create() but for
* parametric color profiles. For now this just creates a cprof
* boilerplate, just to help us to imagine how things would work.
*
* The color profile that this function creates is invalid and we won't
* be able to do anything useful with that.
*/
cprof = cmlcms_find_color_profile_by_params(cm, params);
if (cprof) {
*cprof_out = weston_color_profile_ref(&cprof->base);
return true;
}
cprof = xzalloc(sizeof(*cprof));
cprof->type = CMLCMS_PROFILE_TYPE_PARAMS;
cprof->params = xzalloc(sizeof(*cprof->params));
memcpy(cprof->params, params, sizeof(*params));
str_printf(&desc, "Parametric (%s): %s, %s",
name_part,
params->primaries_info ? params->primaries_info->desc :
"custom primaries",
params->tf_info->desc);
weston_color_profile_init(&cprof->base, &cm->base);
cprof->base.description = desc;
wl_list_insert(&cm->color_profile_list, &cprof->link);
weston_log_scope_printf(cm->profiles_scope,
"New color profile: p%u. WARNING: this is a " \
"boilerplate color profile. We still do not fully " \
"support creating color profiles from params\n",
cprof->base.id);
str = cmlcms_color_profile_print(cprof);
weston_log_scope_printf(cm->profiles_scope, "%s", str);
free(str);
*cprof_out = &cprof->base;
return true;
}
bool
cmlcms_send_image_desc_info(struct cm_image_desc_info *cm_image_desc_info,
struct weston_color_profile *cprof_base)
......@@ -583,18 +706,24 @@ cmlcms_send_image_desc_info(struct cm_image_desc_info *cm_image_desc_info,
int32_t fd;
uint32_t len;
if (cprof->prof_rofile) {
/**
* TODO: when we convert the stock sRGB profile to a parametric profile
* instead of an ICC one, we'll be able to change the if/else below to
* a switch/case.
*/
if (cprof->type == CMLCMS_PROFILE_TYPE_ICC && cprof != cm->sRGB_profile) {
/* ICC-based color profile, so just send the ICC file fd. If we
* get an error (negative fd), the helper will send the proper
* error to the client. */
fd = os_ro_anonymous_file_get_fd(cprof->prof_rofile,
fd = os_ro_anonymous_file_get_fd(cprof->icc.prof_rofile,
RO_ANONYMOUS_FILE_MAPMODE_PRIVATE);
if (fd < 0) {
weston_cm_send_icc_file(cm_image_desc_info, -1, 0);
return false;
}
len = os_ro_anonymous_file_size(cprof->prof_rofile);
len = os_ro_anonymous_file_size(cprof->icc.prof_rofile);
weston_assert_uint32_gt(compositor, len, 0);
weston_cm_send_icc_file(cm_image_desc_info, fd, len);
......
......@@ -1225,6 +1225,12 @@ xform_realize_chain(struct cmlcms_color_transform *xform)
struct lcmsProfilePtr extra = { NULL };
cmsUInt32Number dwFlags;
/* TODO: address this when we implement param color profiles.*/
if (output_profile->type == CMLCMS_PROFILE_TYPE_PARAMS ||
(xform->search_key.input_profile &&
xform->search_key.input_profile->type == CMLCMS_PROFILE_TYPE_PARAMS))
return false;
render_intent = xform->search_key.render_intent;
/*
......@@ -1239,8 +1245,8 @@ xform_realize_chain(struct cmlcms_color_transform *xform)
switch (xform->search_key.category) {
case CMLCMS_CATEGORY_INPUT_TO_BLEND:
chain[chain_len++] = xform->search_key.input_profile->profile;
chain[chain_len++] = output_profile->profile;
chain[chain_len++] = xform->search_key.input_profile->icc.profile;
chain[chain_len++] = output_profile->icc.profile;
chain[chain_len++] = output_profile->extract.eotf;
break;
case CMLCMS_CATEGORY_BLEND_TO_OUTPUT:
......@@ -1254,8 +1260,8 @@ xform_realize_chain(struct cmlcms_color_transform *xform)
WESTON_RENDER_INTENT_ABSOLUTE);
break;
case CMLCMS_CATEGORY_INPUT_TO_OUTPUT:
chain[chain_len++] = xform->search_key.input_profile->profile;
chain[chain_len++] = output_profile->profile;
chain[chain_len++] = xform->search_key.input_profile->icc.profile;
chain[chain_len++] = output_profile->icc.profile;
if (output_profile->extract.vcgt.p)
chain[chain_len++] = output_profile->extract.vcgt;
break;
......
......@@ -135,6 +135,17 @@ cmnoop_get_color_profile_from_icc(struct weston_color_manager *cm,
return false;
}
static bool
cmnoop_get_color_profile_from_params(struct weston_color_manager *cm,
const struct weston_color_profile_params *params,
const char *name_part,
struct weston_color_profile **cprof_out,
char **errmsg)
{
*errmsg = xstrdup("parametric profiles are unsupported.");
return false;
}
static void
cmnoop_destroy_color_transform(struct weston_color_transform *xform)
{
......@@ -256,6 +267,7 @@ weston_color_manager_noop_create(struct weston_compositor *compositor)
cm->base.destroy_color_profile = cmnoop_destroy_color_profile;
cm->base.ref_stock_sRGB_color_profile = cmnoop_ref_stock_sRGB_color_profile;
cm->base.get_color_profile_from_icc = cmnoop_get_color_profile_from_icc;
cm->base.get_color_profile_from_params = cmnoop_get_color_profile_from_params;
cm->base.send_image_desc_info = NULL;
cm->base.destroy_color_transform = cmnoop_destroy_color_transform;
cm->base.get_surface_color_transform = cmnoop_get_surface_color_transform;
......@@ -264,6 +276,8 @@ weston_color_manager_noop_create(struct weston_compositor *compositor)
/* We don't support anything related to the CM&HDR protocol extension */
cm->base.supported_color_features = 0;
cm->base.supported_rendering_intents = 0;
cm->base.supported_primaries_named = 0;
cm->base.supported_tf_named = 0;
return &cm->base;
}
This diff is collapsed.
......@@ -40,6 +40,11 @@
#include "color-management-v1-server-protocol.h"
enum tf_has_parameters {
YES_PARAMETERS = true,
NO_PARAMETERS = false,
};
static const struct weston_color_feature_info color_feature_info_table[] = {
{
.feature = WESTON_COLOR_FEATURE_ICC,
......@@ -254,72 +259,91 @@ static const struct weston_color_tf_info color_tf_info_table[] = {
.tf = WESTON_TF_LINEAR,
.desc = "Linear transfer function",
.protocol_tf = XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_LINEAR,
.has_parameters = NO_PARAMETERS,
},
{
.tf = WESTON_TF_GAMMA22,
.desc = "Assumed display gamma 2.2 transfer function",
.protocol_tf = XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_GAMMA22,
.has_parameters = NO_PARAMETERS,
},
{
.tf = WESTON_TF_GAMMA28,
.desc = "Assumed display gamma 2.8 transfer function",
.protocol_tf = XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_GAMMA28,
.has_parameters = NO_PARAMETERS,
},
{
.tf = WESTON_TF_SRGB,
.desc = "sRGB piece-wise transfer function",
.protocol_tf = XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_SRGB,
.has_parameters = NO_PARAMETERS,
},
{
.tf = WESTON_TF_EXT_SRGB,
.desc = "Extended sRGB piece-wise transfer function",
.protocol_tf = XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_EXT_SRGB,
.has_parameters = NO_PARAMETERS,
},
{
.tf = WESTON_TF_BT709,
.desc = "BT.709 transfer function",
.protocol_tf = XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_BT709,
.has_parameters = NO_PARAMETERS,
},
{
.tf = WESTON_TF_BT1361,
.desc = "BT.1361 extended transfer function",
.protocol_tf = XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_BT1361,
.has_parameters = NO_PARAMETERS,
},
{
.tf = WESTON_TF_ST240,
.desc = "SMPTE ST 240 transfer function",
.protocol_tf = XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_ST240,
.has_parameters = NO_PARAMETERS,
},
{
.tf = WESTON_TF_ST428,
.desc = "SMPTE ST 428 transfer function",
.protocol_tf = XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_ST428,
.has_parameters = NO_PARAMETERS,
},
{
.tf = WESTON_TF_ST2084_PQ,
.desc = "Perceptual quantizer transfer function",
.protocol_tf = XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_ST2084_PQ,
.has_parameters = NO_PARAMETERS,
},
{
.tf = WESTON_TF_LOG_100,
.desc = "Logarithmic 100:1 transfer function",
.protocol_tf = XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_LOG_100,
.has_parameters = NO_PARAMETERS,
},
{
.tf = WESTON_TF_LOG_316,
.desc = "Logarithmic (100*Sqrt(10) : 1) transfer function",
.protocol_tf = XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_LOG_316,
.has_parameters = NO_PARAMETERS,
},
{
.tf = WESTON_TF_XVYCC,
.desc = "IEC 61966-2-4 transfer function",
.protocol_tf = XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_XVYCC,
.has_parameters = NO_PARAMETERS,
},
{
.tf = WESTON_TF_HLG,
.desc = "Hybrid log-gamma transfer function",
.protocol_tf = XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_HLG,
.has_parameters = NO_PARAMETERS,
},
{
.tf = WESTON_TF_POWER,
.desc = "Parameterized power-law transfer function",
.has_parameters = YES_PARAMETERS,
},
};
WL_EXPORT const struct weston_color_feature_info *
......
......@@ -56,42 +56,6 @@ enum weston_render_intent {
WESTON_RENDER_INTENT_RELATIVE_BPC,
};
/**
* Color primaries.
*/
enum weston_color_primaries {
WESTON_PRIMARIES_CICP_SRGB = 0,
WESTON_PRIMARIES_CICP_PAL_M,
WESTON_PRIMARIES_CICP_PAL,
WESTON_PRIMARIES_CICP_NTSC,
WESTON_PRIMARIES_CICP_GENERIC_FILM,
WESTON_PRIMARIES_CICP_BT2020,
WESTON_PRIMARIES_CICP_CIE1931_XYZ,
WESTON_PRIMARIES_CICP_DCI_P3,
WESTON_PRIMARIES_CICP_DISPLAY_P3,
WESTON_PRIMARIES_ADOBE_RGB,
};
/**
* Transfer functions.
*/
enum weston_transfer_function {
WESTON_TF_LINEAR = 0,
WESTON_TF_GAMMA22,
WESTON_TF_GAMMA28,
WESTON_TF_SRGB,
WESTON_TF_EXT_SRGB,
WESTON_TF_BT709,
WESTON_TF_BT1361,
WESTON_TF_ST240,
WESTON_TF_ST428,
WESTON_TF_ST2084_PQ,
WESTON_TF_LOG_100,
WESTON_TF_LOG_316,
WESTON_TF_XVYCC,
WESTON_TF_HLG,
};
struct weston_color_feature_info {
/** Our internal representation for the features. */
enum weston_color_feature feature;
......@@ -120,11 +84,6 @@ struct weston_render_intent_info {
bool bps;
};
struct weston_color_gamut {
struct weston_CIExy primary[3]; /* RGB order */
struct weston_CIExy white_point;
};
struct weston_color_primaries_info {
/** Our internal representation for the primaries. */
enum weston_color_primaries primaries;
......@@ -148,6 +107,11 @@ struct weston_color_tf_info {
/** CM&HDR protocol extension value representing the tf. */
uint32_t protocol_tf;
/* The protocol also has support for parameterized functions, i.e.
* certain known functions that clients can define passing arbitrary
* parameters. */
bool has_parameters;
};
const struct weston_color_feature_info *
......
......@@ -127,6 +127,30 @@ struct weston_color_profile {
uint32_t id;
};
/** Parameters that define a parametric color profile */
struct weston_color_profile_params {
/* Primary color volume; always set. */
struct weston_color_gamut primaries;
/* Primary color volume by enumeration; optional, may be NULL. */
const struct weston_color_primaries_info *primaries_info;
/* Encoding transfer characteristic by enumeration; always set. */
const struct weston_color_tf_info *tf_info;
/* Transfer characteristic's parameters; depends on tf_info. */
float tf_params[10];
/* Target color volume; always set. */
struct weston_color_gamut target_primaries;
/* Luminance parameters cd/m²; negative when not set */
float min_luminance, max_luminance;
float maxCLL;
float maxFALL;
};
/** Type or formula for a curve */
enum weston_color_curve_type {
/** Identity function, no-op */
......@@ -410,6 +434,22 @@ struct weston_color_manager {
*/
uint32_t supported_rendering_intents;
/**
* Supported primaries named from Wayland CM&HDR protocol extension.
*
* If v (v being enum weston_color_primaries v) is a supported
* primaries named, the bit v of this will be set to 1.
*/
uint32_t supported_primaries_named;
/**
* Supported tf named from Wayland CM&HDR protocol extension.
*
* If v (v being enum weston_transfer_function v) is a supported
* tf named, the bit v of this will be set to 1.
*/
uint32_t supported_tf_named;
/** Initialize color manager */
bool
(*init)(struct weston_color_manager *cm);
......@@ -455,6 +495,29 @@ struct weston_color_manager {
struct weston_color_profile **cprof_out,
char **errmsg);
/** Create a color profile from parameters
*
* \param cm The color manager.
* \param params The struct weston_color_profile_params with the params.
* \param name_part A string to be used in describing the profile.
* \param cprof_out On success, the created object is returned here.
* On failure, untouched.
* \param errmsg On success, untouched. On failure, a pointer to a
* string describing the error is stored here. The string must be
* free()'d.
* \return True on success, false on failure.
*
* This may return a new reference to an existing color profile if
* that profile is identical to the one that would be created, apart
* from name_part.
*/
bool
(*get_color_profile_from_params)(struct weston_color_manager *cm,
const struct weston_color_profile_params *params,
const char *name_part,
struct weston_color_profile **cprof_out,
char **errmsg);
/** Send image description to clients.
*
* \param cm_image_desc_info The image description info object
......
......@@ -18,6 +18,7 @@ srcs_libweston = [
'color-properties.c',
'color-management.c',
'color-noop.c',
'color-profile-param-builder.c',
'compositor.c',
'content-protection.c',
'data-device.c',
......