wayland/xx colormanagement: add all the missing color spaces

This commit is contained in:
Xaver Hugl 2024-08-13 18:47:14 +02:00
parent f3d4778bc9
commit 16ff6d777a
3 changed files with 106 additions and 4 deletions

View file

@ -173,21 +173,84 @@ static const Colorimetry BT709 = Colorimetry{
QVector2D{0.15, 0.06}, QVector2D{0.15, 0.06},
QVector2D{0.3127, 0.3290}, 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{ static const Colorimetry BT2020 = Colorimetry{
QVector2D{0.708, 0.292}, QVector2D{0.708, 0.292},
QVector2D{0.170, 0.797}, QVector2D{0.170, 0.797},
QVector2D{0.131, 0.046}, QVector2D{0.131, 0.046},
QVector2D{0.3127, 0.3290}, 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) const Colorimetry &Colorimetry::fromName(NamedColorimetry name)
{ {
switch (name) { switch (name) {
case NamedColorimetry::BT709: case NamedColorimetry::BT709:
return 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: case NamedColorimetry::BT2020:
return 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(); Q_UNREACHABLE();
} }

View file

@ -32,7 +32,15 @@ enum class RenderingIntent {
enum class NamedColorimetry { enum class NamedColorimetry {
BT709, BT709,
PAL_M,
PAL,
NTSC,
GenericFilm,
BT2020, BT2020,
CIEXYZ,
DCIP3,
DisplayP3,
AdobeRGB
}; };
/** /**

View file

@ -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_feature(resource->handle, feature::feature_set_luminances);
send_supported_primaries_named(resource->handle, primaries::primaries_srgb); 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_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_gamma22);
send_supported_tf_named(resource->handle, transfer_function::transfer_function_srgb); 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; return;
} }
switch (primaries) { switch (primaries) {
case XX_COLOR_MANAGER_V4_PRIMARIES_SRGB: case QtWaylandServer::xx_color_manager_v4::primaries::primaries_srgb:
m_colorimetry = Colorimetry::fromName(NamedColorimetry::BT709); m_colorimetry = Colorimetry::fromName(NamedColorimetry::BT709);
return; 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); m_colorimetry = Colorimetry::fromName(NamedColorimetry::BT2020);
return; 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: default:
// TODO add more named primaries
wl_resource_post_error(resource->handle, error::error_invalid_primaries, "unsupported named primaries"); wl_resource_post_error(resource->handle, error::error_invalid_primaries, "unsupported named primaries");
} }
} }