28 case feature_icc_v2_v4:
29 mFeatures |= Feature::ICC;
31 case feature_parametric:
32 mFeatures |= Feature::Parametric;
34 case feature_set_primaries:
35 mFeatures |= Feature::SetPrimaries;
37 case feature_set_tf_power:
38 mFeatures |= Feature::PowerTransferFunction;
40 case feature_set_luminances:
41 mFeatures |= Feature::SetLuminances;
43 case feature_set_mastering_display_primaries:
44 mFeatures |= Feature::SetMasteringDisplayPrimaries;
46 case feature_extended_target_volume:
47 mFeatures |= Feature::ExtendedTargetVolume;
79 if (!(mFeatures & Feature::Parametric))
82 constexpr std::array primaryMapping = {
83 std::make_pair(QColorSpace::Primaries::SRgb, primaries_srgb),
84 std::make_pair(QColorSpace::Primaries::AdobeRgb, primaries_adobe_rgb),
85 std::make_pair(QColorSpace::Primaries::DciP3D65, primaries_display_p3),
86 std::make_pair(QColorSpace::Primaries::Bt2020, primaries_bt2020),
88 const auto primary = std::find_if(primaryMapping.begin(), primaryMapping.end(), [&colorspace](
const auto &pair) {
89 return pair.first == colorspace.primaries();
91 if (!(supportedFeatures() & Feature::SetPrimaries) && (primary == primaryMapping.end() || !supportsNamedPrimary(primary->second)))
94 constexpr std::array tfMapping = {
95 std::make_pair(QColorSpace::TransferFunction::Linear, transfer_function_linear),
96 std::make_pair(QColorSpace::TransferFunction::SRgb, transfer_function_srgb),
97 std::make_pair(QColorSpace::TransferFunction::St2084, transfer_function_st2084_pq),
98 std::make_pair(QColorSpace::TransferFunction::Hlg, transfer_function_hlg),
100 const auto tfIt = std::find_if(tfMapping.begin(), tfMapping.end(), [&colorspace](
const auto &pair) {
101 return pair.first == colorspace.transferFunction();
103 auto transferFunction = tfIt == tfMapping.end() ? std::nullopt : std::make_optional(tfIt->second);
104 if (colorspace.transferFunction() == QColorSpace::TransferFunction::Gamma) {
105 if (qFuzzyCompare(colorspace.gamma(), 2.2f) && supportsTransferFunction(transfer_function_gamma22))
106 transferFunction = transfer_function_gamma22;
107 else if (qFuzzyCompare(colorspace.gamma(), 2.8f) && supportsTransferFunction(transfer_function_gamma28))
108 transferFunction = transfer_function_gamma28;
109 if (!transferFunction && !(mFeatures & Feature::PowerTransferFunction))
111 }
else if (!transferFunction) {
115 auto creator = new_parametric_creator();
116 if (primary != primaryMapping.end()) {
117 xx_image_description_creator_params_v4_set_primaries_named(creator, primary->second);
119 const auto primaries = colorspace.primaryPoints();
120 xx_image_description_creator_params_v4_set_primaries(creator,
121 std::round(10'000 * primaries.redPoint.x()), std::round(10'000 * primaries.redPoint.y()),
122 std::round(10'000 * primaries.greenPoint.x()), std::round(10'000 * primaries.greenPoint.y()),
123 std::round(10'000 * primaries.bluePoint.x()), std::round(10'000 * primaries.bluePoint.y()),
124 std::round(10'000 * primaries.whitePoint.x()), std::round(10'000 * primaries.whitePoint.y())
127 if (transferFunction) {
128 xx_image_description_creator_params_v4_set_tf_named(creator, *transferFunction);
130 Q_ASSERT(colorspace.transferFunction() == QColorSpace::TransferFunction::Gamma);
131 xx_image_description_creator_params_v4_set_tf_power(creator, std::round(colorspace.gamma() * 10'000));
133 return std::make_unique<ImageDescription>(xx_image_description_creator_params_v4_create(creator));
159 mContainerRed = QPointF(r_x, r_y) / 10'000.0;
160 mContainerGreen = QPointF(g_x, g_y) / 10'000.0;
161 mContainerBlue = QPointF(b_x, b_y) / 10'000.0;
162 mContainerWhite = QPointF(w_x, w_y) / 10'000.0;
179 mTargetRed = QPointF(r_x, r_y) / 10'000.0;
180 mTargetGreen = QPointF(g_x, g_y) / 10'000.0;
181 mTargetBlue = QPointF(b_x, b_y) / 10'000.0;
182 mTargetWhite = QPointF(w_x, w_y) / 10'000.0;