Krita Source Code Documentation
Loading...
Searching...
No Matches
KisWaylandSurfaceColorimetry.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 KISWAYLANDSURFACECOLORIMETRY_H
7#define KISWAYLANDSURFACECOLORIMETRY_H
8
10#include <qwayland-color-management-v1.h>
11
13{
14
15struct WaylandPrimaries : boost::equality_comparable<WaylandPrimaries> {
18
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
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
48inline KisColorimetryUtils::xy xyFromWaylandXy(int32_t x, int32_t y) {
49 return {x / 1'000'000.0, y / 1'000'000.0};
50}
51
52inline 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
57struct 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 &&
83 target == other.target &&
84 luminances == other.luminances &&
86 targetMaxCLL == other.targetMaxCLL &&
89
90 }
91
94};
95
96QDebug operator<<(QDebug dbg, const WaylandPrimaries &points);
97QDebug operator<<(QDebug dbg, const WaylandSurfaceDescription &data);
98
99QtWayland::wp_color_manager_v1::primaries primariesKritaToWayland(KisSurfaceColorimetry::NamedPrimaries primaries);
100QtWayland::wp_color_manager_v1::transfer_function transferFunctionKritaToWayland(KisSurfaceColorimetry::NamedTransferFunction transferFunction);
101QtWayland::wp_color_manager_v1::render_intent renderIntentKritaToWayland(KisSurfaceColorimetry::RenderIntent intent);
102
103}
104
105QDebug operator<<(QDebug debug, QtWayland::wp_color_manager_v1::primaries p);
106QDebug operator<<(QDebug debug, QtWayland::wp_color_manager_v1::feature f);
107QDebug operator<<(QDebug debug, QtWayland::wp_color_manager_v1::render_intent ri);
108QDebug operator<<(QDebug debug, QtWayland::wp_color_manager_v1::transfer_function tf);
109
110#endif /* KISWAYLANDSURFACECOLORIMETRY_H */
float value(const T *src, size_t ch)
const Params2D p
QDebug operator<<(QDebug debug, QtWayland::wp_color_manager_v1::primaries p)
QDebug operator<<(QDebug debug, const xy &value)
KisColorimetryUtils::xy xyFromWaylandXy(int32_t x, int32_t y)
QtWayland::wp_color_manager_v1::render_intent renderIntentKritaToWayland(KisSurfaceColorimetry::RenderIntent intent)
std::pair< int32_t, int32_t > waylandXyFromXy(KisColorimetryUtils::xy value)
QtWayland::wp_color_manager_v1::primaries primariesKritaToWayland(KisSurfaceColorimetry::NamedPrimaries primaries)
QtWayland::wp_color_manager_v1::transfer_function transferFunctionKritaToWayland(KisSurfaceColorimetry::NamedTransferFunction transferFunction)
static WaylandPrimaries fromColorimetry(const Colorimetry &colorimetry)
bool operator==(const WaylandPrimaries &other) const
std::optional< KisSurfaceColorimetry::Luminance > luminances
std::optional< KisSurfaceColorimetry::MasteringLuminance > masteringLuminance
QtWayland::wp_color_manager_v1::primaries primaries
static WaylandSurfaceDescription fromSurfaceDescription(const SurfaceDescription &desc)
QtWayland::wp_color_manager_v1::transfer_function transfer_function
bool operator==(const WaylandSurfaceDescription &other) const