diff --git a/src/core/colorspace.cpp b/src/core/colorspace.cpp index 7bd7e4333e..8f936fe157 100644 --- a/src/core/colorspace.cpp +++ b/src/core/colorspace.cpp @@ -173,21 +173,84 @@ static const Colorimetry BT709 = Colorimetry{ QVector2D{0.15, 0.06}, QVector2D{0.3127, 0.3290}, }; - +static const Colorimetry PAL_M = Colorimetry{ + QVector2D{0.67, 0.33}, + QVector2D{0.21, 0.71}, + QVector2D{0.14, 0.08}, + QVector2D{0.310, 0.316}, +}; +static const Colorimetry PAL = Colorimetry{ + QVector2D{0.640, 0.330}, + QVector2D{0.290, 0.600}, + QVector2D{0.150, 0.060}, + QVector2D{0.3127, 0.3290}, +}; +static const Colorimetry NTSC = Colorimetry{ + QVector2D{0.630, 0.340}, + QVector2D{0.310, 0.595}, + QVector2D{0.155, 0.070}, + QVector2D{0.3127, 0.3290}, +}; +static const Colorimetry GenericFilm = Colorimetry{ + QVector2D{0.243, 0.692}, + QVector2D{0.145, 0.049}, + QVector2D{0.681, 0.319}, + QVector2D{0.310, 0.316}, +}; static const Colorimetry BT2020 = Colorimetry{ QVector2D{0.708, 0.292}, QVector2D{0.170, 0.797}, QVector2D{0.131, 0.046}, QVector2D{0.3127, 0.3290}, }; +static const Colorimetry CIEXYZ = Colorimetry{ + QVector2D{1.0, 0.0}, + QVector2D{0.0, 1.0}, + QVector2D(0.0, 0.0), + QVector2D(1 / 3.0, 1 / 3.0), +}; +static const Colorimetry DCIP3 = Colorimetry{ + QVector2D{0.680, 0.320}, + QVector2D{0.265, 0.690}, + QVector2D{0.150, 0.060}, + QVector2D{0.314, 0.351}, +}; +static const Colorimetry DisplayP3 = Colorimetry{ + QVector2D{0.680, 0.320}, + QVector2D{0.265, 0.690}, + QVector2D{0.150, 0.060}, + QVector2D{0.3127, 0.3290}, +}; +static const Colorimetry AdobeRGB = Colorimetry{ + QVector2D{0.6400, 0.3300}, + QVector2D{0.2100, 0.7100}, + QVector2D{0.1500, 0.0600}, + QVector2D{0.3127, 0.3290}, +}; const Colorimetry &Colorimetry::fromName(NamedColorimetry name) { switch (name) { case NamedColorimetry::BT709: return BT709; + case NamedColorimetry::PAL_M: + return PAL_M; + case NamedColorimetry::PAL: + return PAL; + case NamedColorimetry::NTSC: + return NTSC; + case NamedColorimetry::GenericFilm: + return GenericFilm; case NamedColorimetry::BT2020: return BT2020; + case NamedColorimetry::CIEXYZ: + return CIEXYZ; + case NamedColorimetry::DCIP3: + return DCIP3; + case NamedColorimetry::DisplayP3: + return DisplayP3; + case NamedColorimetry::AdobeRGB: + return AdobeRGB; } Q_UNREACHABLE(); } diff --git a/src/core/colorspace.h b/src/core/colorspace.h index fcf92cb2a2..1942f3e6e5 100644 --- a/src/core/colorspace.h +++ b/src/core/colorspace.h @@ -32,7 +32,15 @@ enum class RenderingIntent { enum class NamedColorimetry { BT709, + PAL_M, + PAL, + NTSC, + GenericFilm, BT2020, + CIEXYZ, + DCIP3, + DisplayP3, + AdobeRGB }; /** diff --git a/src/wayland/xx_colormanagement_v4.cpp b/src/wayland/xx_colormanagement_v4.cpp index d285af0363..e49c5aa316 100644 --- a/src/wayland/xx_colormanagement_v4.cpp +++ b/src/wayland/xx_colormanagement_v4.cpp @@ -28,7 +28,15 @@ void XXColorManagerV4::xx_color_manager_v4_bind_resource(Resource *resource) send_supported_feature(resource->handle, feature::feature_set_luminances); send_supported_primaries_named(resource->handle, primaries::primaries_srgb); + send_supported_primaries_named(resource->handle, primaries::primaries_pal_m); + send_supported_primaries_named(resource->handle, primaries::primaries_pal); + send_supported_primaries_named(resource->handle, primaries::primaries_ntsc); + send_supported_primaries_named(resource->handle, primaries::primaries_generic_film); send_supported_primaries_named(resource->handle, primaries::primaries_bt2020); + send_supported_primaries_named(resource->handle, primaries::primaries_cie1931_xyz); + send_supported_primaries_named(resource->handle, primaries::primaries_dci_p3); + send_supported_primaries_named(resource->handle, primaries::primaries_display_p3); + send_supported_primaries_named(resource->handle, primaries::primaries_adobe_rgb); send_supported_tf_named(resource->handle, transfer_function::transfer_function_gamma22); send_supported_tf_named(resource->handle, transfer_function::transfer_function_srgb); @@ -252,14 +260,37 @@ void XXColorParametricCreatorV4::xx_image_description_creator_params_v4_set_prim return; } switch (primaries) { - case XX_COLOR_MANAGER_V4_PRIMARIES_SRGB: + case QtWaylandServer::xx_color_manager_v4::primaries::primaries_srgb: m_colorimetry = Colorimetry::fromName(NamedColorimetry::BT709); return; - case XX_COLOR_MANAGER_V4_PRIMARIES_BT2020: + case QtWaylandServer::xx_color_manager_v4::primaries::primaries_pal_m: + m_colorimetry = Colorimetry::fromName(NamedColorimetry::PAL_M); + return; + case QtWaylandServer::xx_color_manager_v4::primaries::primaries_pal: + m_colorimetry = Colorimetry::fromName(NamedColorimetry::PAL); + return; + case QtWaylandServer::xx_color_manager_v4::primaries::primaries_ntsc: + m_colorimetry = Colorimetry::fromName(NamedColorimetry::NTSC); + return; + case QtWaylandServer::xx_color_manager_v4::primaries::primaries_generic_film: + m_colorimetry = Colorimetry::fromName(NamedColorimetry::GenericFilm); + return; + case QtWaylandServer::xx_color_manager_v4::primaries::primaries_bt2020: m_colorimetry = Colorimetry::fromName(NamedColorimetry::BT2020); return; + case QtWaylandServer::xx_color_manager_v4::primaries::primaries_cie1931_xyz: + m_colorimetry = Colorimetry::fromName(NamedColorimetry::CIEXYZ); + return; + case QtWaylandServer::xx_color_manager_v4::primaries::primaries_dci_p3: + m_colorimetry = Colorimetry::fromName(NamedColorimetry::DCIP3); + return; + case QtWaylandServer::xx_color_manager_v4::primaries::primaries_display_p3: + m_colorimetry = Colorimetry::fromName(NamedColorimetry::DisplayP3); + return; + case QtWaylandServer::xx_color_manager_v4::primaries::primaries_adobe_rgb: + m_colorimetry = Colorimetry::fromName(NamedColorimetry::AdobeRGB); + return; default: - // TODO add more named primaries wl_resource_post_error(resource->handle, error::error_invalid_primaries, "unsupported named primaries"); } }