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 <KisColorimetryUtils.h>
11
12
14{
15 using namespace KisColorimetryUtils;
16
25
29 transfer_function_gamma22 = 2, // supported by KDE
31 transfer_function_ext_linear = 5, // supported by KDE
32 transfer_function_srgb = 9, // supported by KDE, but broken and deprecated
34 transfer_function_st2084_pq = 11, // supported by KDE
36 };
37
38 enum class RenderIntent {
39 render_intent_perceptual = 0, // perceptual
40 render_intent_relative = 1, // media-relative colorimetric
41 render_intent_saturation = 2, // saturation
42 render_intent_absolute = 3, // ICC-absolute colorimetric
43 render_intent_relative_bpc = 4, // media-relative colorimetric + black point compensation
44 };
45
46 struct KRITASURFACECOLORMANAGEMENTAPI_EXPORT Luminance : boost::equality_comparable<Luminance> {
47 Luminance() = default;
48 Luminance(uint32_t minLuminanceArg, uint32_t maxLuminanceArg, uint32_t referenceLuminanceArg)
49 : minLuminance(minLuminanceArg)
50 , maxLuminance(maxLuminanceArg)
51 , referenceLuminance(referenceLuminanceArg)
52 {
53 }
54
55 uint32_t minLuminance = 2000; // (cd/m^2) * 10000
56 uint32_t maxLuminance = 80; // (cd/m^2)
57 uint32_t referenceLuminance = 80; // (cd/m^2)
58
59 bool operator==(const Luminance &other) const {
60 return minLuminance == other.minLuminance &&
61 maxLuminance == other.maxLuminance &&
62 referenceLuminance == other.referenceLuminance;
63 }
64
70 return { minLuminance, referenceLuminance, referenceLuminance };
71 }
72 };
73
74 struct KRITASURFACECOLORMANAGEMENTAPI_EXPORT MasteringLuminance : boost::equality_comparable<MasteringLuminance> {
75 MasteringLuminance() = default;
76 MasteringLuminance(uint32_t minLuminanceArg, uint32_t maxLuminanceArg)
77 : minLuminance(minLuminanceArg)
78 , maxLuminance(maxLuminanceArg)
79 {}
80
81 uint32_t minLuminance = 2000; // (cd/m^2) * 10000
82 uint32_t maxLuminance = 80; // (cd/m^2)
83
85 return {rhs.minLuminance, rhs.maxLuminance};
86 }
87
88 bool operator==(const MasteringLuminance &other) const {
89 return minLuminance == other.minLuminance &&
90 maxLuminance == other.maxLuminance;
91 }
92 };
93
94 struct KRITASURFACECOLORMANAGEMENTAPI_EXPORT ColorSpace : boost::equality_comparable<ColorSpace> {
95 std::variant<NamedPrimaries, Colorimetry> primaries;
96 // named transfer function or <exponent * 10000>
97 std::variant<NamedTransferFunction, uint32_t> transferFunction;
98 std::optional<Luminance> luminance;
99
100 bool operator==(const ColorSpace &other) const {
101 return primaries == other.primaries &&
102 transferFunction == other.transferFunction &&
103 luminance == other.luminance;
104 }
105
106 bool isHDR() const {
107 return luminance && luminance->maxLuminance > luminance->referenceLuminance;
108 }
109 };
110
111 struct KRITASURFACECOLORMANAGEMENTAPI_EXPORT MasteringInfo : boost::equality_comparable<MasteringInfo> {
112 Colorimetry primaries = Colorimetry::BT709;
114 std::optional<uint32_t> maxCll;
115 std::optional<uint32_t> maxFall;
116
117 bool operator==(const MasteringInfo &other) const {
118 return primaries == other.primaries &&
119 luminance == other.luminance &&
120 maxCll == other.maxCll &&
121 maxFall == other.maxFall;
122 }
123 };
124
125 struct KRITASURFACECOLORMANAGEMENTAPI_EXPORT SurfaceDescription : boost::equality_comparable<SurfaceDescription> {
127 std::optional<MasteringInfo> masteringInfo;
128
129 bool operator==(const SurfaceDescription &other) const {
130 return colorSpace == other.colorSpace &&
131 masteringInfo == other.masteringInfo;
132 }
133
134 QString makeTextReport() const;
135 };
136
137 KRITASURFACECOLORMANAGEMENTAPI_EXPORT QDebug operator<<(QDebug debug, const NamedPrimaries &value);
138 KRITASURFACECOLORMANAGEMENTAPI_EXPORT QDebug operator<<(QDebug debug, const NamedTransferFunction &value);
139 KRITASURFACECOLORMANAGEMENTAPI_EXPORT QDebug operator<<(QDebug debug, const Luminance &value);
140 KRITASURFACECOLORMANAGEMENTAPI_EXPORT QDebug operator<<(QDebug debug, const MasteringLuminance &value);
141 KRITASURFACECOLORMANAGEMENTAPI_EXPORT QDebug operator<<(QDebug debug, const ColorSpace &value);
142 KRITASURFACECOLORMANAGEMENTAPI_EXPORT QDebug operator<<(QDebug debug, const MasteringInfo &value);
143 KRITASURFACECOLORMANAGEMENTAPI_EXPORT QDebug operator<<(QDebug debug, const SurfaceDescription &value);
144 KRITASURFACECOLORMANAGEMENTAPI_EXPORT QDebug operator<<(QDebug debug, const RenderIntent &value);
145}
146
147#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