diff --git a/libweston/color-lcms/color-lcms.c b/libweston/color-lcms/color-lcms.c index d5fe847c..6356fe1f 100644 --- a/libweston/color-lcms/color-lcms.c +++ b/libweston/color-lcms/color-lcms.c @@ -32,6 +32,7 @@ #include "color.h" #include "color-lcms.h" +#include "color-properties.h" #include "shared/helpers.h" #include "shared/xalloc.h" @@ -50,18 +51,22 @@ cmlcms_category_name(enum cmlcms_category cat) return category_names[cat] ?: "[undocumented category value]"; } -static cmsUInt32Number +static const struct weston_render_intent_info * cmlcms_get_render_intent(enum cmlcms_category cat, struct weston_surface *surface, struct weston_output *output) { + const struct weston_render_intent_info *render_intent; + /* * 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; + render_intent = + weston_render_intent_info_from(output->compositor, + WESTON_RENDER_INTENT_RELATIVE); + return render_intent; } static struct cmlcms_color_profile * @@ -98,7 +103,7 @@ cmlcms_get_surface_color_transform(struct weston_color_manager *cm_base, .input_profile = get_cprof_or_stock_sRGB(cm, NULL /* TODO: surface->color_profile */), .output_profile = get_cprof_or_stock_sRGB(cm, output->color_profile), }; - param.intent_output = cmlcms_get_render_intent(param.category, + param.render_intent = cmlcms_get_render_intent(param.category, surface, output); xform = cmlcms_color_transform_get(cm, ¶m); @@ -133,7 +138,7 @@ cmlcms_get_blend_to_output_color_transform(struct weston_color_manager_lcms *cm, .input_profile = NULL, .output_profile = get_cprof_or_stock_sRGB(cm, output->color_profile), }; - param.intent_output = cmlcms_get_render_intent(param.category, + param.render_intent = cmlcms_get_render_intent(param.category, NULL, output); xform = cmlcms_color_transform_get(cm, ¶m); @@ -158,7 +163,7 @@ cmlcms_get_sRGB_to_output_color_transform(struct weston_color_manager_lcms *cm, .input_profile = cm->sRGB_profile, .output_profile = get_cprof_or_stock_sRGB(cm, output->color_profile), }; - param.intent_output = cmlcms_get_render_intent(param.category, + param.render_intent = cmlcms_get_render_intent(param.category, NULL, output); /* @@ -191,7 +196,7 @@ cmlcms_get_sRGB_to_blend_color_transform(struct weston_color_manager_lcms *cm, .input_profile = cm->sRGB_profile, .output_profile = get_cprof_or_stock_sRGB(cm, output->color_profile), }; - param.intent_output = cmlcms_get_render_intent(param.category, + param.render_intent = cmlcms_get_render_intent(param.category, NULL, output); xform = cmlcms_color_transform_get(cm, ¶m); diff --git a/libweston/color-lcms/color-lcms.h b/libweston/color-lcms/color-lcms.h index 20461fce..12d76701 100644 --- a/libweston/color-lcms/color-lcms.h +++ b/libweston/color-lcms/color-lcms.h @@ -146,7 +146,7 @@ struct cmlcms_color_transform_search_param { enum cmlcms_category category; struct cmlcms_color_profile *input_profile; struct cmlcms_color_profile *output_profile; - cmsUInt32Number intent_output; /* selected intent from output profile */ + const struct weston_render_intent_info *render_intent; }; struct cmlcms_color_transform { diff --git a/libweston/color-lcms/color-transform.c b/libweston/color-lcms/color-transform.c index 721d14b2..fba22ae4 100644 --- a/libweston/color-lcms/color-transform.c +++ b/libweston/color-lcms/color-transform.c @@ -33,6 +33,7 @@ #include "color.h" #include "color-curve-segments.h" #include "color-lcms.h" +#include "color-properties.h" #include "shared/helpers.h" #include "shared/string-helpers.h" #include "shared/xalloc.h" @@ -884,6 +885,7 @@ xform_realize_chain(struct cmlcms_color_transform *xform) cmsHPROFILE chain[5]; unsigned chain_len = 0; cmsHPROFILE extra = NULL; + cmsUInt32Number dwFlags; chain[chain_len++] = xform->search_key.input_profile->profile; chain[chain_len++] = output_profile->profile; @@ -920,13 +922,14 @@ xform_realize_chain(struct cmlcms_color_transform *xform) assert(xform->status == CMLCMS_TRANSFORM_FAILED); /* transform_factory() is invoked by this call. */ + dwFlags = xform->search_key.render_intent->bps ? cmsFLAGS_BLACKPOINTCOMPENSATION : 0; xform->cmap_3dlut = cmsCreateMultiprofileTransformTHR(xform->lcms_ctx, chain, chain_len, TYPE_RGB_FLT, TYPE_RGB_FLT, - xform->search_key.intent_output, - 0); + xform->search_key.render_intent->lcms_intent, + dwFlags); cmsCloseProfile(extra); if (!xform->cmap_3dlut) @@ -969,11 +972,11 @@ cmlcms_color_transform_search_param_string(const struct cmlcms_color_transform_s str_printf(&str, " catergory: %s\n" \ " input profile: %s\n" \ " output profile: %s\n" \ - " selected intent from output profile: %u\n", + " selected intent from output profile: %s\n", cmlcms_category_name(search_key->category), input_prof_desc, output_prof_desc, - search_key->intent_output); + search_key->render_intent->desc); abort_oom_if_null(str); @@ -1059,7 +1062,7 @@ transform_matches_params(const struct cmlcms_color_transform *xform, if (xform->search_key.category != param->category) return false; - if (xform->search_key.intent_output != param->intent_output || + 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) return false; diff --git a/libweston/color-properties.c b/libweston/color-properties.c new file mode 100644 index 00000000..ef42cad9 --- /dev/null +++ b/libweston/color-properties.c @@ -0,0 +1,388 @@ +/* + * Copyright 2023 Collabora, Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "config.h" + +#ifdef HAVE_LCMS +#include +#define LCMS_INTENT(x) .lcms_intent = (x) +#else +/* invalid value */ +#define LCMS_INTENT(x) .lcms_intent = 0xffffffff +#endif + +#include +#include +#include "shared/helpers.h" +#include "shared/weston-assert.h" + +#include "color-management-v1-server-protocol.h" + +static const struct weston_color_feature_info color_feature_info_table[] = { + { + .feature = WESTON_COLOR_FEATURE_ICC, + .desc = "Allow clients to use the new_icc_creator request " \ + "from the CM&HDR protocol extension", + .protocol_feature = XX_COLOR_MANAGER_V2_FEATURE_ICC_V2_V4, + }, + { + .feature = WESTON_COLOR_FEATURE_PARAMETRIC, + .desc = "Allow clients to use the new_parametric_creator " \ + "request from the CM&HDR protocol extension", + .protocol_feature = XX_COLOR_MANAGER_V2_FEATURE_PARAMETRIC, + }, + { + .feature = WESTON_COLOR_FEATURE_SET_PRIMARIES, + .desc = "Allow clients to use the parametric set_primaries " \ + "request from the CM&HDR protocol extension", + .protocol_feature = XX_COLOR_MANAGER_V2_FEATURE_SET_PRIMARIES, + }, + { + .feature = WESTON_COLOR_FEATURE_SET_TF_POWER, + .desc = "Allow clients to use the parametric set_tf_power " \ + "request from the CM&HDR protocol extension", + .protocol_feature = XX_COLOR_MANAGER_V2_FEATURE_SET_TF_POWER, + }, + { + .feature = WESTON_COLOR_FEATURE_SET_MASTERING_DISPLAY_PRIMARIES, + .desc = "Allow clients to use the parametric " \ + "set_mastering_display_primaries request from the " \ + "CM&HDR protocol extension", + .protocol_feature = XX_COLOR_MANAGER_V2_FEATURE_SET_MASTERING_DISPLAY_PRIMARIES, + }, + { + .feature = WESTON_COLOR_FEATURE_EXTENDED_TARGET_VOLUME, + .desc = "Allow clients to specify (through the CM&HDR protocol " \ + "extension) target color volumes that extend outside of the" \ + "primary color volume. This can only be supported when feature " \ + "WESTON_COLOR_FEATURE_SET_MASTERING_DISPLAY_PRIMARIES " \ + "is supported", + .protocol_feature = XX_COLOR_MANAGER_V2_FEATURE_EXTENDED_TARGET_VOLUME, + }, +}; + +static const struct weston_render_intent_info render_intent_info_table[] = { + { + .intent = WESTON_RENDER_INTENT_PERCEPTUAL, + .desc = "Perceptual", + .protocol_intent = XX_COLOR_MANAGER_V2_RENDER_INTENT_PERCEPTUAL, + LCMS_INTENT(INTENT_PERCEPTUAL), + .bps = false, + }, + { + .intent = WESTON_RENDER_INTENT_RELATIVE, + .desc = "Media-relative colorimetric", + .protocol_intent = XX_COLOR_MANAGER_V2_RENDER_INTENT_RELATIVE, + LCMS_INTENT(INTENT_RELATIVE_COLORIMETRIC), + .bps = false, + }, + { + .intent = WESTON_RENDER_INTENT_SATURATION, + .desc = "Saturation", + .protocol_intent = XX_COLOR_MANAGER_V2_RENDER_INTENT_SATURATION, + LCMS_INTENT(INTENT_SATURATION), + .bps = false, + }, + { + .intent = WESTON_RENDER_INTENT_ABSOLUTE, + .desc = "ICC-absolute colorimetric", + .protocol_intent = XX_COLOR_MANAGER_V2_RENDER_INTENT_ABSOLUTE, + LCMS_INTENT(INTENT_ABSOLUTE_COLORIMETRIC), + .bps = false, + }, + { + .intent = WESTON_RENDER_INTENT_RELATIVE_BPC, + .desc = "Media-relative colorimetric + black point compensation", + .protocol_intent = XX_COLOR_MANAGER_V2_RENDER_INTENT_RELATIVE_BPC, + LCMS_INTENT(INTENT_RELATIVE_COLORIMETRIC), + .bps = true, + }, +}; + +static const struct weston_color_primaries_info color_primaries_info_table[] = { + { + .primaries = WESTON_PRIMARIES_CICP_SRGB, + .desc = "Color primaries for the sRGB color space as defined by " \ + "the BT.709 standard", + .protocol_primaries = XX_COLOR_MANAGER_V2_PRIMARIES_SRGB, + .color_gamut = { + .primary = { { 0.64, 0.33 }, /* RGB order */ + { 0.30, 0.60 }, + { 0.15, 0.06 }, + }, + .white_point = { 0.3127, 0.3290 }, + }, + }, + { + .primaries = WESTON_PRIMARIES_CICP_PAL_M, + .desc = "Color primaries for PAL-M as defined by the BT.470 standard", + .protocol_primaries = XX_COLOR_MANAGER_V2_PRIMARIES_PAL_M, + .color_gamut = { + .primary = { { 0.67, 0.33 }, /* RGB order */ + { 0.21, 0.71 }, + { 0.14, 0.08 }, + }, + .white_point = { 0.3101, 0.3162 }, + }, + }, + { + .primaries = WESTON_PRIMARIES_CICP_PAL, + .desc = "Color primaries for PAL as defined by the BT.601 standard", + .protocol_primaries = XX_COLOR_MANAGER_V2_PRIMARIES_PAL, + .color_gamut = { + .primary = { { 0.64, 0.33 }, /* RGB order */ + { 0.29, 0.60 }, + { 0.15, 0.06 }, + }, + .white_point = { 0.3127, 0.3290 }, + }, + }, + { + .primaries = WESTON_PRIMARIES_CICP_NTSC, + .desc = "Color primaries for NTSC as defined by the BT.601 standard", + .protocol_primaries = XX_COLOR_MANAGER_V2_PRIMARIES_NTSC, + .color_gamut = { + .primary = { { 0.630, 0.340 }, /* RGB order */ + { 0.310, 0.595 }, + { 0.155, 0.070 }, + }, + .white_point = { 0.3127, 0.3290 }, + }, + }, + { + .primaries = WESTON_PRIMARIES_CICP_GENERIC_FILM, + .desc = "Generic film with color filters using Illuminant C", + .protocol_primaries = XX_COLOR_MANAGER_V2_PRIMARIES_GENERIC_FILM, + .color_gamut = { + .primary = { { 0.681, 0.319 }, /* RGB order */ + { 0.243, 0.692 }, + { 0.145, 0.049 }, + }, + .white_point = { 0.3101, 0.3162 }, + }, + }, + { + .primaries = WESTON_PRIMARIES_CICP_BT2020, + .desc = "Color primaries as defined by the BT.2020 and BT.2100 " \ + "standard", + .protocol_primaries = XX_COLOR_MANAGER_V2_PRIMARIES_BT2020, + .color_gamut = { + .primary = { { 0.708, 0.292 }, /* RGB order */ + { 0.170, 0.797 }, + { 0.131, 0.046 }, + }, + .white_point = { 0.3127, 0.3290 }, + }, + }, + { + .primaries = WESTON_PRIMARIES_CICP_CIE1931_XYZ, + .desc = "Color primaries of the full CIE 1931 XYZ color space", + .protocol_primaries = XX_COLOR_MANAGER_V2_PRIMARIES_CIE1931_XYZ, + .color_gamut = { + .primary = { { 1.0, 0.0 }, /* RGB order */ + { 0.0, 1.0 }, + { 0.0, 0.0 }, + }, + .white_point = { 0.3333, 0.3333 }, + }, + }, + { + .primaries = WESTON_PRIMARIES_CICP_DCI_P3, + .desc = "Color primaries of the DCI P3 color space as defined by " \ + "the SMPTE RP 431 standard", + .protocol_primaries = XX_COLOR_MANAGER_V2_PRIMARIES_DCI_P3, + .color_gamut = { + .primary = { { 0.680, 0.320 }, /* RGB order */ + { 0.265, 0.690 }, + { 0.150, 0.060 }, + }, + .white_point = { 0.314, 0.351 }, + }, + }, + { + .primaries = WESTON_PRIMARIES_CICP_DISPLAY_P3, + .desc = "Color primaries of Display P3 variant of the DCI-P3 color " \ + "space as defined by the SMPTE EG 432 standard", + .protocol_primaries = XX_COLOR_MANAGER_V2_PRIMARIES_DISPLAY_P3, + .color_gamut = { + .primary = { { 0.680, 0.320 }, /* RGB order */ + { 0.265, 0.690 }, + { 0.150, 0.060 }, + }, + .white_point = { 0.3127, 0.3290 }, + }, + }, + { + .primaries = WESTON_PRIMARIES_ADOBE_RGB, + .desc = "Color primaries of the Adobe RGB color space as defined " \ + "by the ISO 12640 standard", + .protocol_primaries = XX_COLOR_MANAGER_V2_PRIMARIES_ADOBE_RGB, + .color_gamut = { + .primary = { { 0.64, 0.33 }, /* RGB order */ + { 0.21, 0.71 }, + { 0.15, 0.06 }, + }, + .white_point = { 0.3127, 0.3290 }, + }, + }, +}; + +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, + }, + { + .tf = WESTON_TF_GAMMA22, + .desc = "Assumed display gamma 2.2 transfer function", + .protocol_tf = XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_GAMMA22, + }, + { + .tf = WESTON_TF_GAMMA28, + .desc = "Assumed display gamma 2.8 transfer function", + .protocol_tf = XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_GAMMA28, + }, + { + .tf = WESTON_TF_SRGB, + .desc = "sRGB piece-wise transfer function", + .protocol_tf = XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_SRGB, + }, + { + .tf = WESTON_TF_EXT_SRGB, + .desc = "Extended sRGB piece-wise transfer function", + .protocol_tf = XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_EXT_SRGB, + }, + { + .tf = WESTON_TF_BT709, + .desc = "BT.709 transfer function", + .protocol_tf = XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_BT709, + }, + { + .tf = WESTON_TF_BT1361, + .desc = "BT.1361 extended transfer function", + .protocol_tf = XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_BT1361, + }, + { + .tf = WESTON_TF_ST240, + .desc = "SMPTE ST 240 transfer function", + .protocol_tf = XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_ST240, + }, + { + .tf = WESTON_TF_ST428, + .desc = "SMPTE ST 428 transfer function", + .protocol_tf = XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_ST428, + }, + { + .tf = WESTON_TF_ST2084_PQ, + .desc = "Perceptual quantizer transfer function", + .protocol_tf = XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_ST2084_PQ, + }, + { + .tf = WESTON_TF_LOG_100, + .desc = "Logarithmic 100:1 transfer function", + .protocol_tf = XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_LOG_100, + }, + { + .tf = WESTON_TF_LOG_316, + .desc = "Logarithmic (100*Sqrt(10) : 1) transfer function", + .protocol_tf = XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_LOG_316, + }, + { + .tf = WESTON_TF_XVYCC, + .desc = "IEC 61966-2-4 transfer function", + .protocol_tf = XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_XVYCC, + }, + { + .tf = WESTON_TF_HLG, + .desc = "Hybrid log-gamma transfer function", + .protocol_tf = XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_HLG, + }, +}; + +WL_EXPORT const struct weston_color_feature_info * +weston_color_feature_info_from(struct weston_compositor *compositor, + enum weston_color_feature feature) +{ + unsigned int i; + + for (i = 0; i < ARRAY_LENGTH(color_feature_info_table); i++) + if (color_feature_info_table[i].feature == feature) + return &color_feature_info_table[i]; + + weston_assert_not_reached(compositor, "unknown color feature"); +} + +WL_EXPORT const struct weston_render_intent_info * +weston_render_intent_info_from(struct weston_compositor *compositor, + enum weston_render_intent intent) +{ + unsigned int i; + + for (i = 0; i < ARRAY_LENGTH(render_intent_info_table); i++) + if (render_intent_info_table[i].intent == intent) + return &render_intent_info_table[i]; + + weston_assert_not_reached(compositor, "unknown render intent"); +} + +WL_EXPORT const struct weston_render_intent_info * +weston_render_intent_info_from_protocol(struct weston_compositor *compositor, + uint32_t protocol_intent) +{ + unsigned int i; + + for (i = 0; i < ARRAY_LENGTH(render_intent_info_table); i++) + if (render_intent_info_table[i].protocol_intent == protocol_intent) + return &render_intent_info_table[i]; + + return NULL; +} + +WL_EXPORT const struct weston_color_primaries_info * +weston_color_primaries_info_from(struct weston_compositor *compositor, + enum weston_color_primaries primaries) +{ + unsigned int i; + + for (i = 0; i < ARRAY_LENGTH(color_primaries_info_table); i++) + if (color_primaries_info_table[i].primaries == primaries) + return &color_primaries_info_table[i]; + + weston_assert_not_reached(compositor, "unknown primaries"); +} + +WL_EXPORT const struct weston_color_tf_info * +weston_color_tf_info_from(struct weston_compositor *compositor, + enum weston_transfer_function tf) +{ + unsigned int i; + + for (i = 0; i < ARRAY_LENGTH(color_tf_info_table); i++) + if (color_tf_info_table[i].tf == tf) + return &color_tf_info_table[i]; + + weston_assert_not_reached(compositor, "unknown tf"); +} diff --git a/libweston/color-properties.h b/libweston/color-properties.h new file mode 100644 index 00000000..4156971b --- /dev/null +++ b/libweston/color-properties.h @@ -0,0 +1,173 @@ +/* + * Copyright 2023 Collabora, Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef WESTON_COLOR_CHARACTERISTICS_H +#define WESTON_COLOR_CHARACTERISTICS_H + +#include +#include + +#include + +struct weston_compositor; + +/** + * Color features. + */ +enum weston_color_feature { + WESTON_COLOR_FEATURE_ICC = 0, + WESTON_COLOR_FEATURE_PARAMETRIC, + WESTON_COLOR_FEATURE_SET_PRIMARIES, + WESTON_COLOR_FEATURE_SET_TF_POWER, + WESTON_COLOR_FEATURE_SET_MASTERING_DISPLAY_PRIMARIES, + WESTON_COLOR_FEATURE_EXTENDED_TARGET_VOLUME, +}; + +/** + * Rendering intents. + */ +enum weston_render_intent { + WESTON_RENDER_INTENT_PERCEPTUAL = 0, + WESTON_RENDER_INTENT_RELATIVE, + WESTON_RENDER_INTENT_SATURATION, + WESTON_RENDER_INTENT_ABSOLUTE, + 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; + + /** String describing the feature. */ + const char *desc; + + /** CM&HDR protocol extension value representing the feature. */ + uint32_t protocol_feature; +}; + +struct weston_render_intent_info { + /** Our internal representation of the intents. */ + enum weston_render_intent intent; + + /* String describing the intent. */ + const char *desc; + + /** CM&HDR protocol extension value representing the intent. */ + uint32_t protocol_intent; + + /** LittleCMS representation. */ + uint32_t lcms_intent; + + /** Black-point compensation? */ + 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; + + /** Raw values for the primaries. */ + struct weston_color_gamut color_gamut; + + /** String describing the primaries. */ + const char *desc; + + /** CM&HDR protocol extension value representing the primaries. */ + uint32_t protocol_primaries; +}; + +struct weston_color_tf_info { + /** Our internal representation for the tf. */ + enum weston_transfer_function tf; + + /** String describing the tf. */ + const char *desc; + + /** CM&HDR protocol extension value representing the tf. */ + uint32_t protocol_tf; +}; + +const struct weston_color_feature_info * +weston_color_feature_info_from(struct weston_compositor *compositor, + enum weston_color_feature feature); + +const struct weston_render_intent_info * +weston_render_intent_info_from(struct weston_compositor *compositor, + enum weston_render_intent intent); + +const struct weston_render_intent_info * +weston_render_intent_info_from_protocol(struct weston_compositor *compositor, + uint32_t protocol_intent); + +const struct weston_color_primaries_info * +weston_color_primaries_info_from(struct weston_compositor *compositor, + enum weston_color_primaries primaries); + +const struct weston_color_tf_info * +weston_color_tf_info_from(struct weston_compositor *compositor, + enum weston_transfer_function tf); + +#endif /* WESTON_COLOR_CHARACTERISTICS_H */ diff --git a/libweston/meson.build b/libweston/meson.build index 8951675a..b2528c1c 100644 --- a/libweston/meson.build +++ b/libweston/meson.build @@ -14,6 +14,7 @@ srcs_libweston = [ 'bindings.c', 'clipboard.c', 'color.c', + 'color-properties.c', 'color-noop.c', 'compositor.c', 'content-protection.c',