From f671fea7b938731d4979bfeb4d2eee02b9ddaa8c Mon Sep 17 00:00:00 2001 From: Joan Torres Date: Fri, 13 Sep 2024 13:01:39 +0200 Subject: [PATCH] wayland/color-management: Add support for NTSC primaries Part-of: --- clutter/clutter/clutter-color-state.c | 11 +++++++++++ clutter/clutter/clutter-color-state.h | 1 + src/wayland/meta-wayland-color-management.c | 8 ++++++++ 3 files changed, 20 insertions(+) diff --git a/clutter/clutter/clutter-color-state.c b/clutter/clutter/clutter-color-state.c index e99295a3c..d5dc29248 100644 --- a/clutter/clutter/clutter-color-state.c +++ b/clutter/clutter/clutter-color-state.c @@ -134,6 +134,8 @@ clutter_colorspace_to_string (ClutterColorspace colorspace) return "sRGB"; case CLUTTER_COLORSPACE_BT2020: return "BT.2020"; + case CLUTTER_COLORSPACE_NTSC: + return "NTSC"; } g_assert_not_reached (); @@ -614,6 +616,13 @@ static const ClutterPrimaries srgb_primaries = { .w_x = 0.3127f, .w_y = 0.3290f, }; +static const ClutterPrimaries ntsc_primaries = { + .r_x = 0.63f, .r_y = 0.34f, + .g_x = 0.31f, .g_y = 0.595f, + .b_x = 0.155f, .b_y = 0.07f, + .w_x = 0.3127f, .w_y = 0.3290f, +}; + static const ClutterPrimaries bt2020_primaries = { .r_x = 0.708f, .r_y = 0.292f, .g_x = 0.170f, .g_y = 0.797f, @@ -628,6 +637,8 @@ clutter_colorspace_to_primaries (ClutterColorspace colorspace) { case CLUTTER_COLORSPACE_SRGB: return &srgb_primaries; + case CLUTTER_COLORSPACE_NTSC: + return &ntsc_primaries; case CLUTTER_COLORSPACE_BT2020: return &bt2020_primaries; } diff --git a/clutter/clutter/clutter-color-state.h b/clutter/clutter/clutter-color-state.h index e77047ff7..5be5bbd9c 100644 --- a/clutter/clutter/clutter-color-state.h +++ b/clutter/clutter/clutter-color-state.h @@ -36,6 +36,7 @@ typedef enum { CLUTTER_COLORSPACE_SRGB, CLUTTER_COLORSPACE_BT2020, + CLUTTER_COLORSPACE_NTSC, } ClutterColorspace; typedef enum diff --git a/src/wayland/meta-wayland-color-management.c b/src/wayland/meta-wayland-color-management.c index 344a161b3..22bdd92e1 100644 --- a/src/wayland/meta-wayland-color-management.c +++ b/src/wayland/meta-wayland-color-management.c @@ -234,6 +234,10 @@ wayland_primaries_to_clutter (enum xx_color_manager_v4_primaries primaries, colorimetry->type = CLUTTER_COLORIMETRY_TYPE_COLORSPACE; colorimetry->colorspace = CLUTTER_COLORSPACE_BT2020; return TRUE; + case XX_COLOR_MANAGER_V4_PRIMARIES_NTSC: + colorimetry->type = CLUTTER_COLORIMETRY_TYPE_COLORSPACE; + colorimetry->colorspace = CLUTTER_COLORSPACE_NTSC; + return TRUE; default: return FALSE; } @@ -248,6 +252,8 @@ clutter_colorspace_to_wayland (ClutterColorspace colorspace) return XX_COLOR_MANAGER_V4_PRIMARIES_SRGB; case CLUTTER_COLORSPACE_BT2020: return XX_COLOR_MANAGER_V4_PRIMARIES_BT2020; + case CLUTTER_COLORSPACE_NTSC: + return XX_COLOR_MANAGER_V4_PRIMARIES_NTSC; } g_assert_not_reached (); } @@ -1441,6 +1447,8 @@ color_manager_send_supported_events (struct wl_resource *resource) XX_COLOR_MANAGER_V4_PRIMARIES_SRGB); xx_color_manager_v4_send_supported_primaries_named (resource, XX_COLOR_MANAGER_V4_PRIMARIES_BT2020); + xx_color_manager_v4_send_supported_primaries_named (resource, + XX_COLOR_MANAGER_V4_PRIMARIES_NTSC); } static const struct xx_color_manager_v4_interface