Krita Source Code Documentation
Loading...
Searching...
No Matches
KisSurfaceColorimetry.cpp
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
8
9#include <QDebug>
10
12
13QDebug operator<<(QDebug debug, const NamedPrimaries &value) {
14 QDebugStateSaver saver(debug);
15 debug.nospace() << "NamedPrimaries(";
16 switch (value) {
18 debug.nospace() << "primaries_unknown";
19 break;
21 debug.nospace() << "primaries_srgb";
22 break;
24 debug.nospace() << "primaries_bt2020";
25 break;
27 debug.nospace() << "primaries_dci_p3";
28 break;
30 debug.nospace() << "primaries_display_p3";
31 break;
33 debug.nospace() << "primaries_adobe_rgb";
34 break;
35 }
36 debug.nospace() << ")";
37 return debug;
38}
39
40QDebug operator<<(QDebug debug, const NamedTransferFunction &value) {
41 QDebugStateSaver saver(debug);
42 debug.nospace() << "NamedTransferFunction(";
43 switch (value) {
45 debug.nospace() << "transfer_function_unknown";
46 break;
48 debug.nospace() << "transfer_function_bt1886";
49 break;
51 debug.nospace() << "transfer_function_gamma22";
52 break;
54 debug.nospace() << "transfer_function_gamma28";
55 break;
57 debug.nospace() << "transfer_function_ext_linear";
58 break;
60 debug.nospace() << "transfer_function_srgb";
61 break;
63 debug.nospace() << "transfer_function_ext_srgb";
64 break;
66 debug.nospace() << "transfer_function_st2084_pq";
67 break;
69 debug.nospace() << "transfer_function_st428";
70 break;
71 }
72 debug.nospace() << ")";
73 return debug;
74}
75
76QDebug operator<<(QDebug debug, const Luminance &value) {
77 QDebugStateSaver saver(debug);
78 debug.nospace() << "Luminance(minLuminance: " << value.minLuminance
79 << ", maxLuminance: " << value.maxLuminance
80 << ", referenceLuminance: " << value.referenceLuminance << ")";
81 return debug;
82}
83
84QDebug operator<<(QDebug debug, const MasteringLuminance &value) {
85 QDebugStateSaver saver(debug);
86 debug.nospace() << "MasteringLuminance(minLuminance: " << value.minLuminance
87 << ", maxLuminance: " << value.maxLuminance << ")";
88 return debug;
89}
90
91QDebug operator<<(QDebug debug, const ColorSpace &value) {
92 QDebugStateSaver saver(debug);
93
94 debug.nospace() << "ColorSpace(";
95 std::visit([&] (auto &&v) {debug.nospace() << "primaries: " << v; }, value.primaries);
96 std::visit([&] (auto &&v) {debug.nospace() << ", transferFunction: " << v; }, value.transferFunction);
97 if (value.luminance) {
98 debug.nospace() << ", luminance: " << value.luminance;
99 } else {
100 debug.nospace() << ", luminance: " << "<none>";
101 }
102 debug.nospace() << ")";
103 return debug;
104}
105
106QDebug operator<<(QDebug debug, const MasteringInfo &value) {
107 QDebugStateSaver saver(debug);
108 debug.nospace() << "MasteringInfo(primaries: " << value.primaries
109 << ", luminance: " << value.luminance;
110 if (value.maxCll) {
111 debug.nospace() << ", maxCll: " << *value.maxCll;
112 }
113 if (value.maxFall) {
114 debug.nospace() << ", maxFall: " << *value.maxFall;
115 }
116 debug.nospace() << ")";
117 return debug;
118}
119
120QDebug operator<<(QDebug debug, const SurfaceDescription &value) {
121 QDebugStateSaver saver(debug);
122 debug.nospace() << "SurfaceDescription(colorSpace: " << value.colorSpace;
123 if (value.masteringInfo) {
124 debug.nospace() << ", masteringInfo: " << *value.masteringInfo;
125 }
126 debug.nospace() << ")";
127 return debug;
128}
129
131 QDebugStateSaver saver(debug);
132 debug.nospace() << "RenderIntent(";
133 switch (value) {
135 debug.nospace() << "render_intent_perceptual";
136 break;
138 debug.nospace() << "render_intent_relative";
139 break;
141 debug.nospace() << "render_intent_saturation";
142 break;
144 debug.nospace() << "render_intent_absolute";
145 break;
147 debug.nospace() << "render_intent_relative_bpc";
148 break;
149 }
150 debug.nospace() << ")";
151 return debug;
152}
153
155{
156 QString report;
157 QDebug str(&report);
158
159 str << " Color Space:" << Qt::endl;
160
161 if (std::holds_alternative<KisSurfaceColorimetry::NamedPrimaries>(this->colorSpace.primaries)) {
162 str << " Primaries: " << std::get<KisSurfaceColorimetry::NamedPrimaries>(this->colorSpace.primaries) << Qt::endl;
163 } else {
164 auto col = std::get<KisSurfaceColorimetry::Colorimetry>(this->colorSpace.primaries);
165 str << " Primaries: " << Qt::endl;
166 str << " Red: " << col.red().toxy() << Qt::endl;
167 str << " Green: " << col.green().toxy() << Qt::endl;
168 str << " Blue: " << col.blue().toxy() << Qt::endl;
169 str << " White: " << col.white().toxy() << Qt::endl;
170 }
171
172 if (std::holds_alternative<KisSurfaceColorimetry::NamedTransferFunction>(this->colorSpace.transferFunction)) {
173 str << " Transfer Function: " << std::get<KisSurfaceColorimetry::NamedTransferFunction>(this->colorSpace.transferFunction) << Qt::endl;
174 } else {
175 const uint32_t rawValue = std::get<uint32_t>(this->colorSpace.transferFunction);
176 str << " Transfer Function (gamma): " << rawValue << "(" << qreal(rawValue) / 10000.0 << ")" << Qt::endl;
177 }
178
179 if (this->colorSpace.luminance) {
180 str << " Luminance: " << *this->colorSpace.luminance << Qt::endl;
181 } else {
182 str << " Luminance: " << "<none>" << Qt::endl;
183 }
184
185 if (this->masteringInfo) {
186 str << " Mastering Info:" << Qt::endl;
187 auto col = this->masteringInfo->primaries;
188 str << " Primaries: " << Qt::endl;
189 str << " Red: " << col.red().toxy() << Qt::endl;
190 str << " Green: " << col.green().toxy() << Qt::endl;
191 str << " Blue: " << col.blue().toxy() << Qt::endl;
192 str << " White: " << col.white().toxy() << Qt::endl;
193 str << " Luminance: " << this->masteringInfo->luminance << Qt::endl;
194 str << " Max CLL: " << (this->masteringInfo->maxCll ? QString::number(*this->masteringInfo->maxCll) : "<none>") << Qt::endl;
195 str << " Max FALL: " << (this->masteringInfo->maxFall ? QString::number(*this->masteringInfo->maxFall) : "<none>") << Qt::endl;
196 } else {
197 str << " Mastering Info: <none>" << Qt::endl;
198 }
199
200 return report;
201}
202
203} // namespace KisSurfaceColorimetry
204
205/* KISSURFACECOLORIMETRY_H */
float value(const T *src, size_t ch)
qreal v
QDebug operator<<(QDebug debug, const xy &value)
std::optional< Luminance > luminance
std::variant< NamedPrimaries, Colorimetry > primaries
std::variant< NamedTransferFunction, uint32_t > transferFunction