Debian Codegraph @

plugins/platforms/wayland/waylandcolormanagement/KisWaylandSurfaceColorimetry.h

raw symbols SCIP
1 /*
2 * SPDX-FileCopyrightText: 2025 Dmitry Kazakov <[email protected]>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 #ifndef KISWAYLANDSURFACECOLORIMETRY_H
7 #define KISWAYLANDSURFACECOLORIMETRY_H
8
9 #include <surfacecolormanagement/KisSurfaceColorimetry.h>
10 #include <qwayland-color-management-v1.h>
11
12 namespace KisSurfaceColorimetry
13 {
14
15 struct WaylandPrimaries : boost::equality_comparable<WaylandPrimaries> {
16 using xy = KisColorimetryUtils::xy;
17 using Colorimetry = KisColorimetryUtils::Colorimetry;
18
19 xy red;
20 xy green;
21 xy blue;
22 xy white;
23
24 bool operator==(const WaylandPrimaries &other) const {
25 return red == other.red &&
26 green == other.green &&
27 blue == other.blue &&
28 white == other.white;
29 }
30
31 Colorimetry toColorimetry() const {
32 return Colorimetry(red, green, blue, white);
33 }
34
35 static WaylandPrimaries fromColorimetry(const Colorimetry &colorimetry) {
36 WaylandPrimaries result;
37
38 result.red = colorimetry.red().toxy();
39 result.green = colorimetry.green().toxy();
40 result.blue = colorimetry.blue().toxy();
41 result.white = colorimetry.white().toxy();
42
43 return result;
44 }
45 };
46
47
48 inline KisColorimetryUtils::xy xyFromWaylandXy(int32_t x, int32_t y) {
49 return {x / 1'000'000.0, y / 1'000'000.0};
50 }
51
52 inline std::pair<int32_t, int32_t> waylandXyFromXy(KisColorimetryUtils::xy value) {
53 return {std::rint(value.x * 1'000'000.0), std::rint(value.y * 1'000'000.0)};
54 }
55
56
57 struct WaylandSurfaceDescription : boost::equality_comparable<WaylandSurfaceDescription>
58 {
59 using transfer_function = QtWayland::wp_color_manager_v1::transfer_function;
60 using primaries = QtWayland::wp_color_manager_v1::primaries;
61
62 std::optional<uint32_t> tfGamma;
63 std::optional<transfer_function> tfNamed;
64
65 std::optional<WaylandPrimaries> container;
66 std::optional<primaries> namedContainer;
67
68 std::optional<WaylandPrimaries> target;
69
70 std::optional<KisSurfaceColorimetry::Luminance> luminances;
71 std::optional<KisSurfaceColorimetry::MasteringLuminance> masteringLuminance;
72
73 std::optional<uint32_t> targetMaxCLL;
74 std::optional<uint32_t> targetMaxFALL;
75
76 bool iccFileIsPresent = false;
77
78 bool operator==(const WaylandSurfaceDescription &other) const {
79 return tfGamma == other.tfGamma &&
80 tfNamed == other.tfNamed &&
81 container == other.container &&
82 namedContainer == other.namedContainer &&
83 target == other.target &&
84 luminances == other.luminances &&
85 masteringLuminance == other.masteringLuminance &&
86 targetMaxCLL == other.targetMaxCLL &&
87 targetMaxFALL == other.targetMaxFALL &&
88 iccFileIsPresent == other.iccFileIsPresent;
89
90 }
91
92 SurfaceDescription toSurfaceDescription() const;
93 static WaylandSurfaceDescription fromSurfaceDescription(const SurfaceDescription &desc);
94 };
95
96 QDebug operator<<(QDebug dbg, const WaylandPrimaries &points);
97 QDebug operator<<(QDebug dbg, const WaylandSurfaceDescription &data);
98
99 QtWayland::wp_color_manager_v1::primaries primariesKritaToWayland(KisSurfaceColorimetry::NamedPrimaries primaries);
100 QtWayland::wp_color_manager_v1::transfer_function transferFunctionKritaToWayland(KisSurfaceColorimetry::NamedTransferFunction transferFunction);
101 QtWayland::wp_color_manager_v1::render_intent renderIntentKritaToWayland(KisSurfaceColorimetry::RenderIntent intent);
102
103 }
104
105 QDebug operator<<(QDebug debug, QtWayland::wp_color_manager_v1::primaries p);
106 QDebug operator<<(QDebug debug, QtWayland::wp_color_manager_v1::feature f);
107 QDebug operator<<(QDebug debug, QtWayland::wp_color_manager_v1::render_intent ri);
108 QDebug operator<<(QDebug debug, QtWayland::wp_color_manager_v1::transfer_function tf);
109
110 #endif /* KISWAYLANDSURFACECOLORIMETRY_H */