Krita Source Code Documentation
Loading...
Searching...
No Matches
KisSurfaceColorimetry.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2025 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6#ifndef KISSURFACECOLORIMETRY_H
7#define KISSURFACECOLORIMETRY_H
8
9#include <boost/operators.hpp>
10#include <KoColorimetryUtils.h>
11#include <kritasurfacecolormanagementapi_export.h>
12
13
15{
16 using namespace KoColorimetryUtils;
17
26
30 transfer_function_gamma22 = 2, // supported by KDE
32 transfer_function_ext_linear = 5, // supported by KDE
33 transfer_function_srgb = 9, // supported by KDE, but broken and deprecated
35 transfer_function_st2084_pq = 11, // supported by KDE
37 };
38
39 enum class RenderIntent {
40 render_intent_perceptual = 0, // perceptual
41 render_intent_relative = 1, // media-relative colorimetric
42 render_intent_saturation = 2, // saturation
43 render_intent_absolute = 3, // ICC-absolute colorimetric
44 render_intent_relative_bpc = 4, // media-relative colorimetric + black point compensation
45 };
46
47 struct KRITASURFACECOLORMANAGEMENTAPI_EXPORT Luminance : boost::equality_comparable<Luminance> {
48 Luminance() = default;
49 Luminance(uint32_t minLuminanceArg, uint32_t maxLuminanceArg, uint32_t referenceLuminanceArg)
50 : minLuminance(minLuminanceArg)
51 , maxLuminance(maxLuminanceArg)
52 , referenceLuminance(referenceLuminanceArg)
53 {
54 }
55
56 uint32_t minLuminance = 2000; // (cd/m^2) * 10000
57 uint32_t maxLuminance = 80; // (cd/m^2)
58 uint32_t referenceLuminance = 80; // (cd/m^2)
59
60 bool operator==(const Luminance &other) const {
61 return minLuminance == other.minLuminance &&
62 maxLuminance == other.maxLuminance &&
63 referenceLuminance == other.referenceLuminance;
64 }
65
71 return { minLuminance, referenceLuminance, referenceLuminance };
72 }
73 };
74
75 struct KRITASURFACECOLORMANAGEMENTAPI_EXPORT MasteringLuminance : boost::equality_comparable<MasteringLuminance> {
76 MasteringLuminance() = default;
77 MasteringLuminance(uint32_t minLuminanceArg, uint32_t maxLuminanceArg)
78 : minLuminance(minLuminanceArg)
79 , maxLuminance(maxLuminanceArg)
80 {}
81
82 uint32_t minLuminance = 2000; // (cd/m^2) * 10000
83 uint32_t maxLuminance = 80; // (cd/m^2)
84
86 return {rhs.minLuminance, rhs.maxLuminance};
87 }
88
89 bool operator==(const MasteringLuminance &other) const {
90 return minLuminance == other.minLuminance &&
91 maxLuminance == other.maxLuminance;
92 }
93 };
94
95 struct KRITASURFACECOLORMANAGEMENTAPI_EXPORT ColorSpace : boost::equality_comparable<ColorSpace> {
96 std::variant<NamedPrimaries, Colorimetry> primaries;
97 // named transfer function or <exponent * 10000>
98 std::variant<NamedTransferFunction, uint32_t> transferFunction;
99 std::optional<Luminance> luminance;
100
101 bool operator==(const ColorSpace &other) const {
102 return primaries == other.primaries &&
103 transferFunction == other.transferFunction &&
104 luminance == other.luminance;
105 }
106
107 bool isHDR() const {
108 return luminance && luminance->maxLuminance > luminance->referenceLuminance;
109 }
110 };
111
112 struct KRITASURFACECOLORMANAGEMENTAPI_EXPORT MasteringInfo : boost::equality_comparable<MasteringInfo> {
113 Colorimetry primaries = Colorimetry::BT709;
115 std::optional<uint32_t> maxCll;
116 std::optional<uint32_t> maxFall;
117
118 bool operator==(const MasteringInfo &other) const {
119 return primaries == other.primaries &&
120 luminance == other.luminance &&
121 maxCll == other.maxCll &&
122 maxFall == other.maxFall;
123 }
124 };
125
126 struct KRITASURFACECOLORMANAGEMENTAPI_EXPORT SurfaceDescription : boost::equality_comparable<SurfaceDescription> {
128 std::optional<MasteringInfo> masteringInfo;
129
130 bool operator==(const SurfaceDescription &other) const {
131 return colorSpace == other.colorSpace &&
132 masteringInfo == other.masteringInfo;
133 }
134
135 QString makeTextReport() const;
136 };
137
138 KRITASURFACECOLORMANAGEMENTAPI_EXPORT QDebug operator<<(QDebug debug, const NamedPrimaries &value);
139 KRITASURFACECOLORMANAGEMENTAPI_EXPORT QDebug operator<<(QDebug debug, const NamedTransferFunction &value);
140 KRITASURFACECOLORMANAGEMENTAPI_EXPORT QDebug operator<<(QDebug debug, const Luminance &value);
141 KRITASURFACECOLORMANAGEMENTAPI_EXPORT QDebug operator<<(QDebug debug, const MasteringLuminance &value);
142 KRITASURFACECOLORMANAGEMENTAPI_EXPORT QDebug operator<<(QDebug debug, const ColorSpace &value);
143 KRITASURFACECOLORMANAGEMENTAPI_EXPORT QDebug operator<<(QDebug debug, const MasteringInfo &value);
144 KRITASURFACECOLORMANAGEMENTAPI_EXPORT QDebug operator<<(QDebug debug, const SurfaceDescription &value);
145 KRITASURFACECOLORMANAGEMENTAPI_EXPORT QDebug operator<<(QDebug debug, const RenderIntent &value);
146}
147
148#endif /* KISSURFACECOLORIMETRY_H */
float value(const T *src, size_t ch)
QDebug operator<<(QDebug debug, const xy &value)
std::optional< Luminance > luminance
std::variant< NamedPrimaries, Colorimetry > primaries
bool operator==(const ColorSpace &other) const
std::variant< NamedTransferFunction, uint32_t > transferFunction
bool operator==(const Luminance &other) const
Luminance(uint32_t minLuminanceArg, uint32_t maxLuminanceArg, uint32_t referenceLuminanceArg)
bool operator==(const MasteringInfo &other) const
bool operator==(const MasteringLuminance &other) const
static MasteringLuminance fromLuminance(const Luminance &rhs)
MasteringLuminance(uint32_t minLuminanceArg, uint32_t maxLuminanceArg)
bool operator==(const SurfaceDescription &other) const