Debian Codegraph @

gdk/gdkcolorstate.c

raw symbols SCIP
1 /* gdkcolorstate.c
2 *
3 * Copyright 2024 Matthias Clasen
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #include "config.h"cxx . . $ `<file>/build/config.h`/
20
21 #define GDK_COLOR_STATE_IMPLcxx . . $ `gdk/gdkcolorstate.c:21:9`!
22 #include "gdkcolorstateprivate.h"cxx . . $ `<file>/gdk/gdkcolorstateprivate.h`/
23
24 #include <math.h>
25
26 #include "gdkcolordefs.h"cxx . . $ `<file>/gdk/gdkcolordefs.h`/
27
28 #include <glib/gi18n-lib.h>
29
30 /**
31 * GdkColorState:
32 *
33 * Provides information to interpret colors and pixels in a variety of ways.
34 *
35 * They are also known as
36 * [*color spaces*](https://en.wikipedia.org/wiki/Color_space).
37 *
38 * Crucially, GTK knows how to convert colors from one color
39 * state to another.
40 *
41 * `GdkColorState` objects are immutable and therefore threadsafe.
42 *
43 * Since: 4.16
44 */
45
46 G_DEFINE_BOXED_TYPEcxx . . $ `<external>/9567554376676449156/gtype.h:2440:9`! (GdkColorState, gdk_color_state,
47 gdk_color_state_ref, gdk_color_state_unref);
48
49 /* {{{ Public API */
50
51 /**
52 * gdk_color_state_ref:
53 * @self: a `GdkColorState`
54 *
55 * Increase the reference count of @self.
56 *
57 * Returns: the object that was passed in
58 *
59 * Since: 4.16
60 */
61 GdkColorStatecxx . . $ GdkColorState# *
62 (gdk_color_state_refcxx . . $ gdk_color_state_ref(8feb2ce0a46ae897).) (GdkColorStatecxx . . $ GdkColorState# *self)
63 {
64 return _gdk_color_state_refcxx . . $ _gdk_color_state_ref(8feb2ce0a46ae897). (self);
65 }
66
67 /**
68 * gdk_color_state_unref:
69 * @self:a `GdkColorState`
70 *
71 * Decrease the reference count of @self.
72 *
73 * Unless @self is static, it will be freed
74 * when the reference count reaches zero.
75 *
76 * Since: 4.16
77 */
78 void
79 (gdk_color_state_unrefcxx . . $ gdk_color_state_unref(1604aa7719ab6e66).) (GdkColorStatecxx . . $ GdkColorState# *self)
80 {
81 _gdk_color_state_unrefcxx . . $ _gdk_color_state_unref(1604aa7719ab6e66). (self);
82 }
83
84 /**
85 * gdk_color_state_get_srgb:
86 *
87 * Returns the color state object representing the sRGB color space.
88 *
89 * This color state uses the primaries defined by BT.709-6 and the transfer function
90 * defined by IEC 61966-2-1.
91 *
92 * It is equivalent to the [Cicp](class.CicpParams.html) tuple 1/13/0/1.
93 *
94 * See e.g. [the CSS Color Module](https://www.w3.org/TR/css-color-4/#predefined-sRGB)
95 * for details about this colorstate.
96 *
97 * Returns: the color state object for sRGB
98 *
99 * Since: 4.16
100 */
101 GdkColorStatecxx . . $ GdkColorState# *
102 gdk_color_state_get_srgbcxx . . $ gdk_color_state_get_srgb(6b7eb4f7c55a0dc3). (void)
103 {
104 return GDK_COLOR_STATE_SRGBcxx . . $ `gdk/gdkcolorstateprivate.h:87:9`!;
105 }
106
107 /**
108 * gdk_color_state_get_srgb_linear:
109 *
110 * Returns the color state object representing the linearized sRGB color space.
111 *
112 * This color state uses the primaries defined by BT.709-6 and a linear transfer function.
113 *
114 * It is equivalent to the [Cicp](class.CicpParams.html) tuple 1/8/0/1.
115 *
116 * See e.g. [the CSS Color Module](https://www.w3.org/TR/css-color-4/#predefined-sRGB-linear)
117 * for details about this colorstate.
118 *
119 * Returns: the color state object for linearized sRGB
120 *
121 * Since: 4.16
122 */
123 GdkColorStatecxx . . $ GdkColorState# *
124 gdk_color_state_get_srgb_linearcxx . . $ gdk_color_state_get_srgb_linear(6b7eb4f7c55a0dc3). (void)
125 {
126 return GDK_COLOR_STATE_SRGB_LINEARcxx . . $ `gdk/gdkcolorstateprivate.h:88:9`!;
127 }
128
129 /**
130 * gdk_color_state_get_rec2100_pq:
131 *
132 * Returns the color state object representing the rec2100-pq color space.
133 *
134 * This color state uses the primaries defined by BT.2020-2 and BT.2100-0 and the transfer
135 * function defined by SMPTE ST 2084 and BT.2100-2.
136 *
137 * It is equivalent to the [Cicp](class.CicpParams.html) tuple 9/16/0/1.
138 *
139 * See e.g. [the CSS HDR Module](https://drafts.csswg.org/css-color-hdr/#valdef-color-rec2100-pq)
140 * for details about this colorstate.
141 *
142 * Returns: the color state object for rec2100-pq
143 *
144 * Since: 4.16
145 */
146 GdkColorStatecxx . . $ GdkColorState# *
147 gdk_color_state_get_rec2100_pqcxx . . $ gdk_color_state_get_rec2100_pq(6b7eb4f7c55a0dc3). (void)
148 {
149 return GDK_COLOR_STATE_REC2100_PQcxx . . $ `gdk/gdkcolorstateprivate.h:89:9`!;
150 }
151
152 /**
153 * gdk_color_state_get_rec2100_linear:
154 *
155 * Returns the color state object representing the linear rec2100 color space.
156 *
157 * This color state uses the primaries defined by BT.2020-2 and BT.2100-0 and a linear
158 * transfer function.
159 *
160 * It is equivalent to the [Cicp](class.CicpParams.html) tuple 9/8/0/1.
161 *
162 * See e.g. [the CSS HDR Module](https://drafts.csswg.org/css-color-hdr/#valdef-color-rec2100-linear)
163 * for details about this colorstate.
164 *
165 * Returns: the color state object for linearized rec2100
166 *
167 * Since: 4.16
168 */
169 GdkColorStatecxx . . $ GdkColorState# *
170 gdk_color_state_get_rec2100_linearcxx . . $ gdk_color_state_get_rec2100_linear(6b7eb4f7c55a0dc3). (void)
171 {
172 return GDK_COLOR_STATE_REC2100_LINEARcxx . . $ `gdk/gdkcolorstateprivate.h:90:9`!;
173 }
174
175 /**
176 * gdk_color_state_get_oklab:
177 *
178 * Returns the color state object representing the oklab color space.
179 *
180 * This is a perceptually uniform color state.
181 *
182 * Returns: the color state object for oklab
183 *
184 * Since: 4.18
185 */
186 GdkColorStatecxx . . $ GdkColorState# *
187 gdk_color_state_get_oklabcxx . . $ gdk_color_state_get_oklab(6b7eb4f7c55a0dc3). (void)
188 {
189 return GDK_COLOR_STATE_OKLABcxx . . $ `gdk/gdkcolorstateprivate.h:91:9`!;
190 }
191
192 /**
193 * gdk_color_state_get_oklch:
194 *
195 * Returns the color state object representing the oklch color space.
196 *
197 * This is the polar variant of oklab, in which the hue is encoded as
198 * a polar coordinate.
199 *
200 * Returns: the color state object for oklch
201 *
202 * Since: 4.18
203 */
204 GdkColorStatecxx . . $ GdkColorState# *
205 gdk_color_state_get_oklchcxx . . $ gdk_color_state_get_oklch(6b7eb4f7c55a0dc3). (void)
206 {
207 return GDK_COLOR_STATE_OKLCHcxx . . $ `gdk/gdkcolorstateprivate.h:92:9`!;
208 }
209
210 /**
211 * gdk_color_state_equal:
212 * @self: a `GdkColorState`
213 * @other: another `GdkColorStatee`
214 *
215 * Compares two `GdkColorStates` for equality.
216 *
217 * Note that this function is not guaranteed to be perfect and two objects
218 * describing the same color state may compare not equal. However, different
219 * color states will never compare equal.
220 *
221 * Returns: %TRUE if the two color states compare equal
222 *
223 * Since: 4.16
224 */
225 gbooleancxx . . $ gboolean#
226 (gdk_color_state_equalcxx . . $ gdk_color_state_equal(2491eb58a6eb4a60).) (GdkColorStatecxx . . $ GdkColorState# *self,
227 GdkColorStatecxx . . $ GdkColorState# *other)
228 {
229 return _gdk_color_state_equalcxx . . $ _gdk_color_state_equal(2491eb58a6eb4a60). (self, other);
230 }
231
232 /**
233 * gdk_color_state_equivalent:
234 * @self: a `GdkColorState`
235 * @other: another `GdkColorStatee`
236 *
237 * Compares two `GdkColorStates` for equivalence.
238 *
239 * Two objects that represent the same color state should be equivalent,
240 * even though they may not be equal in the sense of [[email protected]].
241 *
242 * Returns: %TRUE if the two color states are equivalent
243 *
244 * Since: 4.20
245 */
246 gbooleancxx . . $ gboolean#
247 (gdk_color_state_equivalentcxx . . $ gdk_color_state_equivalent(2491eb58a6eb4a60).) (GdkColorStatecxx . . $ GdkColorState# *self,
248 GdkColorStatecxx . . $ GdkColorState# *other)
249 {
250 return _gdk_color_state_equivalentcxx . . $ _gdk_color_state_equivalent(2491eb58a6eb4a60). (self, other);
251 }
252
253 /**
254 * gdk_color_state_create_cicp_params:
255 * @self: a `GdkColorState`
256 *
257 * Create a [[email protected]] representing the colorstate.
258 *
259 * It is not guaranteed that every `GdkColorState` can be
260 * represented with Cicp parameters. If that is the case,
261 * this function returns `NULL`.
262 *
263 * Returns: (transfer full) (nullable): A new [[email protected]]
264 *
265 * Since: 4.16
266 */
267 GdkCicpParamscxx . . $ GdkCicpParams# *
268 gdk_color_state_create_cicp_paramscxx . . $ gdk_color_state_create_cicp_params(d2481154bc049e2d). (GdkColorStatecxx . . $ GdkColorState# *self)
269 {
270 const GdkCicpcxx . . $ GdkCicp# *cicp = gdk_color_state_get_cicpcxx . . $ gdk_color_state_get_cicp(a81b5b46de96dec1). (self);
271
272 if (cicp)
273 return gdk_cicp_params_new_for_cicpcxx . . $ gdk_cicp_params_new_for_cicp(d4314b29da1b79d). (cicp);
274
275 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
276 }
277
278 /* }}} */
279 /* {{{ Conversion functions */
280
281 typedef float (* GdkTransferFunccxx . . $ GdkTransferFunc#) (float v);
282 typedef void (* GdkConvertFunccxx . . $ GdkConvertFunc#) (GdkColorStatecxx . . $ GdkColorState# *self,
283 float values[4]);
284 typedef const float GdkColorMatrixcxx . . $ GdkColorMatrix#[9];
285
286 #define IDENTITYcxx . . $ `gdk/gdkcolorstate.c:286:9`! ((float*)0)
287 #define NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`! ((GdkTransferFunc)0)
288
289 #define CONVERT_FUNCcxx . . $ `gdk/gdkcolorstate.c:289:9`!(name) \
290 static void \
291 gdk_convert_ ## name (GdkColorState *self, \
292 float (*values)[4], \
293 gsize n_values) \
294 { \
295 for (gsize i = 0; i < n_values; i++) \
296 { \
297 name (self, values[i]); \
298 } \
299 }
300
301 #define TRANSFORMcxx . . $ `gdk/gdkcolorstate.c:301:9`!(name, eotf, matrix, nonlinear, matrix2, oetf) \
302 static inline void \
303 name (GdkColorState *self, \
304 float values[4]) \
305 { \
306 if (eotf != NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!) \
307 { \
308 values[0] = eotf (values[0]); \
309 values[1] = eotf (values[1]); \
310 values[2] = eotf (values[2]); \
311 } \
312 if (matrix != IDENTITYcxx . . $ `gdk/gdkcolorstate.c:286:9`!) \
313 { \
314 float res[3]; \
315 res[0] = matrix[0] * values[0] + matrix[1] * values[1] + matrix[2] * values[2]; \
316 res[1] = matrix[3] * values[0] + matrix[4] * values[1] + matrix[5] * values[2]; \
317 res[2] = matrix[6] * values[0] + matrix[7] * values[1] + matrix[8] * values[2]; \
318 values[0] = res[0]; \
319 values[1] = res[1]; \
320 values[2] = res[2]; \
321 } \
322 if (nonlinear != NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!) \
323 { \
324 values[0] = nonlinear (values[0]); \
325 values[1] = nonlinear (values[1]); \
326 values[2] = nonlinear (values[2]); \
327 } \
328 if (matrix2 != IDENTITYcxx . . $ `gdk/gdkcolorstate.c:286:9`!) \
329 { \
330 float res[3]; \
331 res[0] = matrix2[0] * values[0] + matrix2[1] * values[1] + matrix2[2] * values[2]; \
332 res[1] = matrix2[3] * values[0] + matrix2[4] * values[1] + matrix2[5] * values[2]; \
333 res[2] = matrix2[6] * values[0] + matrix2[7] * values[1] + matrix2[8] * values[2]; \
334 values[0] = res[0]; \
335 values[1] = res[1]; \
336 values[2] = res[2]; \
337 } \
338 if (oetf != NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!) \
339 { \
340 values[0] = oetf (values[0]); \
341 values[1] = oetf (values[1]); \
342 values[2] = oetf (values[2]); \
343 } \
344 } \
345 CONVERT_FUNC (name)
346
347 #define TRANSFORM_PAIRcxx . . $ `gdk/gdkcolorstate.c:347:9`!(name, func1, func2) \
348 static inline void \
349 name (GdkColorState *self, \
350 float values[4]) \
351 { \
352 func1 (self, values); \
353 func2 (self, values); \
354 } \
355 CONVERT_FUNC (name)
356
357 TRANSFORMcxx . . $ `gdk/gdkcolorstate.c:301:9`!(srgb_to_srgb_linear, srgb_eotf, IDENTITYcxx . . $ `gdk/gdkcolorstate.c:286:9`!, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!, IDENTITYcxx . . $ `gdk/gdkcolorstate.c:286:9`!, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!)
358 TRANSFORMcxx . . $ `gdk/gdkcolorstate.c:301:9`!(srgb_linear_to_srgb, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!, IDENTITYcxx . . $ `gdk/gdkcolorstate.c:286:9`!, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!, IDENTITYcxx . . $ `gdk/gdkcolorstate.c:286:9`!, srgb_oetf)
359 TRANSFORMcxx . . $ `gdk/gdkcolorstate.c:301:9`!(rec2100_pq_to_rec2100_linear, pq_eotf, IDENTITYcxx . . $ `gdk/gdkcolorstate.c:286:9`!, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!, IDENTITYcxx . . $ `gdk/gdkcolorstate.c:286:9`!, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!)
360 TRANSFORMcxx . . $ `gdk/gdkcolorstate.c:301:9`!(rec2100_linear_to_rec2100_pq, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!, IDENTITYcxx . . $ `gdk/gdkcolorstate.c:286:9`!, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!, IDENTITYcxx . . $ `gdk/gdkcolorstate.c:286:9`!, pq_oetf)
361 TRANSFORMcxx . . $ `gdk/gdkcolorstate.c:301:9`!(srgb_linear_to_rec2100_linear, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!, srgb_to_rec2020, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!, IDENTITYcxx . . $ `gdk/gdkcolorstate.c:286:9`!, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!)
362 TRANSFORMcxx . . $ `gdk/gdkcolorstate.c:301:9`!(rec2100_linear_to_srgb_linear, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!, rec2020_to_srgb, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!, IDENTITYcxx . . $ `gdk/gdkcolorstate.c:286:9`!, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!)
363 TRANSFORMcxx . . $ `gdk/gdkcolorstate.c:301:9`!(srgb_to_rec2100_linear, srgb_eotf, srgb_to_rec2020, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!, IDENTITYcxx . . $ `gdk/gdkcolorstate.c:286:9`!, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!)
364 TRANSFORMcxx . . $ `gdk/gdkcolorstate.c:301:9`!(rec2100_pq_to_srgb_linear, pq_eotf, rec2020_to_srgb, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!, IDENTITYcxx . . $ `gdk/gdkcolorstate.c:286:9`!, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!)
365 TRANSFORMcxx . . $ `gdk/gdkcolorstate.c:301:9`!(srgb_linear_to_rec2100_pq, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!, srgb_to_rec2020, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!, IDENTITYcxx . . $ `gdk/gdkcolorstate.c:286:9`!, pq_oetf)
366 TRANSFORMcxx . . $ `gdk/gdkcolorstate.c:301:9`!(rec2100_linear_to_srgb, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!, rec2020_to_srgb, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!, IDENTITYcxx . . $ `gdk/gdkcolorstate.c:286:9`!, srgb_oetf)
367 TRANSFORMcxx . . $ `gdk/gdkcolorstate.c:301:9`!(srgb_to_rec2100_pq, srgb_eotf, srgb_to_rec2020, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!, IDENTITYcxx . . $ `gdk/gdkcolorstate.c:286:9`!, pq_oetf)
368 TRANSFORMcxx . . $ `gdk/gdkcolorstate.c:301:9`!(rec2100_pq_to_srgb, pq_eotf, rec2020_to_srgb, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!, IDENTITYcxx . . $ `gdk/gdkcolorstate.c:286:9`!, srgb_oetf)
369
370 TRANSFORMcxx . . $ `gdk/gdkcolorstate.c:301:9`!(oklab_to_srgb_linear, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!, oklab_to_lms, from_oklab_nl, lms_to_srgb, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!)
371 TRANSFORMcxx . . $ `gdk/gdkcolorstate.c:301:9`!(oklab_to_srgb, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!, oklab_to_lms, from_oklab_nl, lms_to_srgb, srgb_oetf)
372 TRANSFORMcxx . . $ `gdk/gdkcolorstate.c:301:9`!(oklab_to_rec2100_linear, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!, oklab_to_lms, from_oklab_nl, lms_to_rec2020, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!)
373 TRANSFORMcxx . . $ `gdk/gdkcolorstate.c:301:9`!(oklab_to_rec2100_pq, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!, oklab_to_lms, from_oklab_nl, lms_to_rec2020, pq_oetf)
374 TRANSFORMcxx . . $ `gdk/gdkcolorstate.c:301:9`!(srgb_linear_to_oklab, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!, srgb_to_lms, to_oklab_nl, lms_to_oklab, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!)
375 TRANSFORMcxx . . $ `gdk/gdkcolorstate.c:301:9`!(srgb_to_oklab, srgb_eotf, srgb_to_lms, to_oklab_nl, lms_to_oklab, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!)
376 TRANSFORMcxx . . $ `gdk/gdkcolorstate.c:301:9`!(rec2100_linear_to_oklab, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!, rec2020_to_lms, to_oklab_nl, lms_to_oklab, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!)
377 TRANSFORMcxx . . $ `gdk/gdkcolorstate.c:301:9`!(rec2100_pq_to_oklab, pq_eotf, rec2020_to_lms, to_oklab_nl, lms_to_oklab, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!)
378
379 #define DEG_TO_RADcxx . . $ `gdk/gdkcolorstate.c:379:9`!(x) ((x) * G_PIcxx . . $ `<external>/10787549987161854489/gtypes.h:201:9`! / 180)
380 #define RAD_TO_DEGcxx . . $ `gdk/gdkcolorstate.c:380:9`!(x) ((x) * 180 / G_PIcxx . . $ `<external>/10787549987161854489/gtypes.h:201:9`!)
381
382 static inline void
383 _sincosfcxx . . $ _sincosf(118562ebef133905). (float angle,
384 float *out_s,
385 float *out_c)
386 {
387 #ifdef HAVE_SINCOSFcxx . . $ `build/config.h:80:9`!
388 sincosf (angle, out_s, out_c);
389 #else
390 *out_s = sinf (angle);
391 *out_c = cosf (angle);
392 #endif
393 }
394
395 static void
396 oklch_to_oklabcxx . . $ oklch_to_oklab(cb7d8dbd61965ab3). (GdkColorStatecxx . . $ GdkColorState# *self,
397 float values[4])
398 {
399 float L, C, H, a, b;
400
401 L = values[0];
402 C = values[1];
403 H = values[2];
404
405 _sincosfcxx . . $ _sincosf(118562ebef133905). (DEG_TO_RADcxx . . $ `gdk/gdkcolorstate.c:379:9`! (H), &b, &a);
406 a *= C;
407 b *= C;
408
409 values[0] = L;
410 values[1] = a;
411 values[2] = b;
412 }
413
414 static void
415 oklab_to_oklchcxx . . $ oklab_to_oklch(cb7d8dbd61965ab3). (GdkColorStatecxx . . $ GdkColorState# *self,
416 float values[4])
417 {
418 float L, a, b, C, H;
419
420 L = values[0];
421 a = values[1];
422 b = values[2];
423
424 C = hypotf (a, b);
425 H = RAD_TO_DEGcxx . . $ `gdk/gdkcolorstate.c:380:9`! (atan2 (b, a));
426
427 H = fmod (H, 360);
428 if (H < 0)
429 H += 360;
430
431 values[0] = L;
432 values[1] = C;
433 values[2] = H;
434 }
435
436 TRANSFORM_PAIRcxx . . $ `gdk/gdkcolorstate.c:347:9`! (srgb_to_oklch, srgb_to_oklab, oklab_to_oklch)
437 TRANSFORM_PAIRcxx . . $ `gdk/gdkcolorstate.c:347:9`! (srgb_linear_to_oklch, srgb_linear_to_oklab, oklab_to_oklch)
438 TRANSFORM_PAIRcxx . . $ `gdk/gdkcolorstate.c:347:9`! (rec2100_pq_to_oklch, rec2100_pq_to_oklab, oklab_to_oklch)
439 TRANSFORM_PAIRcxx . . $ `gdk/gdkcolorstate.c:347:9`! (rec2100_linear_to_oklch, rec2100_linear_to_oklab, oklab_to_oklch)
440 TRANSFORM_PAIRcxx . . $ `gdk/gdkcolorstate.c:347:9`! (oklch_to_srgb, oklch_to_oklab, oklab_to_srgb)
441 TRANSFORM_PAIRcxx . . $ `gdk/gdkcolorstate.c:347:9`! (oklch_to_srgb_linear, oklch_to_oklab, oklab_to_srgb_linear)
442 TRANSFORM_PAIRcxx . . $ `gdk/gdkcolorstate.c:347:9`! (oklch_to_rec2100_pq, oklch_to_oklab, oklab_to_rec2100_pq)
443 TRANSFORM_PAIRcxx . . $ `gdk/gdkcolorstate.c:347:9`! (oklch_to_rec2100_linear, oklch_to_oklab, oklab_to_rec2100_linear)
444
445 /* }}} */
446 /* {{{ Default implementation */
447 /* {{{ Vfuncs */
448
449 static gbooleancxx . . $ gboolean#
450 gdk_default_color_state_equalcxx . . $ gdk_default_color_state_equal(2491eb58a6eb4a60). (GdkColorStatecxx . . $ GdkColorState# *self,
451 GdkColorStatecxx . . $ GdkColorState# *other)
452 {
453 return self == other;
454 }
455
456 static const char *
457 gdk_default_color_state_get_namecxx . . $ gdk_default_color_state_get_name(5247ad7030db0d80). (GdkColorStatecxx . . $ GdkColorState# *color_state)
458 {
459 GdkDefaultColorStatecxx . . $ GdkDefaultColorState# *self = (GdkDefaultColorStatecxx . . $ GdkDefaultColorState# *) color_state;
460
461 return self->namecxx . . $ _GdkDefaultColorState#name.;
462 }
463
464 static GdkColorStatecxx . . $ GdkColorState# *
465 gdk_default_color_state_get_no_srgb_tfcxx . . $ gdk_default_color_state_get_no_srgb_tf(8feb2ce0a46ae897). (GdkColorStatecxx . . $ GdkColorState# *color_state)
466 {
467 GdkDefaultColorStatecxx . . $ GdkDefaultColorState# *self = (GdkDefaultColorStatecxx . . $ GdkDefaultColorState# *) color_state;
468
469 return self->no_srgbcxx . . $ _GdkDefaultColorState#no_srgb.;
470 }
471
472 static GdkFloatColorConvertcxx . . $ GdkFloatColorConvert#
473 gdk_default_color_state_get_convert_tocxx . . $ gdk_default_color_state_get_convert_to(6b29540b4c677ef8). (GdkColorStatecxx . . $ GdkColorState# *color_state,
474 GdkColorStatecxx . . $ GdkColorState# *target)
475 {
476 GdkDefaultColorStatecxx . . $ GdkDefaultColorState# *self = (GdkDefaultColorStatecxx . . $ GdkDefaultColorState# *) color_state;
477
478 if (GDK_IS_DEFAULT_COLOR_STATEcxx . . $ `gdk/gdkcolorstateprivate.h:95:9`! (target))
479 return self->convert_tocxx . . $ _GdkDefaultColorState#convert_to.[GDK_DEFAULT_COLOR_STATE_IDcxx . . $ `gdk/gdkcolorstateprivate.h:97:9`! (target)];
480
481 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
482 }
483
484 static GdkFloatColorConvertcxx . . $ GdkFloatColorConvert#
485 gdk_default_color_state_get_convert_fromcxx . . $ gdk_default_color_state_get_convert_from(6b29540b4c677ef8). (GdkColorStatecxx . . $ GdkColorState# *color_state,
486 GdkColorStatecxx . . $ GdkColorState# *source)
487 {
488 /* This is ok because the default-to-default conversion functions
489 * don't use the passed colorstate at all.
490 */
491 return gdk_default_color_state_get_convert_tocxx . . $ gdk_default_color_state_get_convert_to(6b29540b4c677ef8). (source, color_state);
492 }
493
494 static const GdkCicpcxx . . $ GdkCicp# *
495 gdk_default_color_state_get_cicpcxx . . $ gdk_default_color_state_get_cicp(a81b5b46de96dec1). (GdkColorStatecxx . . $ GdkColorState# *color_state)
496 {
497 GdkDefaultColorStatecxx . . $ GdkDefaultColorState# *self = (GdkDefaultColorStatecxx . . $ GdkDefaultColorState# *) color_state;
498
499 if (self->cicpcxx . . $ _GdkDefaultColorState#cicp..color_primariescxx . . $ _GdkCicp#color_primaries. == 0)
500 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
501
502 return &self->cicpcxx . . $ _GdkDefaultColorState#cicp.;
503 }
504
505 /* }}} */
506
507 static const
508 GdkColorStateClasscxx . . $ GdkColorStateClass# GDK_DEFAULT_COLOR_STATE_CLASScxx . . $ GDK_DEFAULT_COLOR_STATE_CLASS. = {
509 .free = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, /* crash here if this ever happens */
510 .equal = gdk_default_color_state_equalcxx . . $ gdk_default_color_state_equal(2491eb58a6eb4a60).,
511 .get_name = gdk_default_color_state_get_namecxx . . $ gdk_default_color_state_get_name(5247ad7030db0d80).,
512 .get_no_srgb_tf = gdk_default_color_state_get_no_srgb_tfcxx . . $ gdk_default_color_state_get_no_srgb_tf(8feb2ce0a46ae897).,
513 .get_convert_to = gdk_default_color_state_get_convert_tocxx . . $ gdk_default_color_state_get_convert_to(6b29540b4c677ef8).,
514 .get_convert_from = gdk_default_color_state_get_convert_fromcxx . . $ gdk_default_color_state_get_convert_from(6b29540b4c677ef8).,
515 .get_cicp = gdk_default_color_state_get_cicpcxx . . $ gdk_default_color_state_get_cicp(a81b5b46de96dec1).,
516 };
517
518 GdkDefaultColorStatecxx . . $ GdkDefaultColorState# gdk_default_color_statescxx . . $ gdk_default_color_states.[] = {
519 [GDK_COLOR_STATE_ID_SRGBcxx . . $ GDK_COLOR_STATE_ID_SRGB.] = {
520 .parent = {
521 .klass = &GDK_DEFAULT_COLOR_STATE_CLASScxx . . $ GDK_DEFAULT_COLOR_STATE_CLASS.,
522 .ref_count = 0,
523 .depth = GDK_MEMORY_U8_SRGBcxx . . $ GDK_MEMORY_U8_SRGB.,
524 .hue_channel = GDK_COLOR_CHANNEL_ALPHAcxx . . $ GDK_COLOR_CHANNEL_ALPHA.,
525 .rendering_color_state = GDK_COLOR_STATE_SRGBcxx . . $ `gdk/gdkcolorstateprivate.h:87:9`!,
526 .rendering_color_state_linear = GDK_COLOR_STATE_SRGB_LINEARcxx . . $ `gdk/gdkcolorstateprivate.h:88:9`!,
527 },
528 .name = "srgb",
529 .no_srgb = GDK_COLOR_STATE_SRGB_LINEARcxx . . $ `gdk/gdkcolorstateprivate.h:88:9`!,
530 .convert_to = {
531 [GDK_COLOR_STATE_ID_SRGB_LINEARcxx . . $ GDK_COLOR_STATE_ID_SRGB_LINEAR.] = gdk_convert_srgb_to_srgb_linearcxx . . $ gdk_convert_srgb_to_srgb_linear(e7c77eef68eb920e).,
532 [GDK_COLOR_STATE_ID_REC2100_PQcxx . . $ GDK_COLOR_STATE_ID_REC2100_PQ.] = gdk_convert_srgb_to_rec2100_pqcxx . . $ gdk_convert_srgb_to_rec2100_pq(e7c77eef68eb920e).,
533 [GDK_COLOR_STATE_ID_REC2100_LINEARcxx . . $ GDK_COLOR_STATE_ID_REC2100_LINEAR.] = gdk_convert_srgb_to_rec2100_linearcxx . . $ gdk_convert_srgb_to_rec2100_linear(e7c77eef68eb920e).,
534 },
535 .cicp = { 1, 13, 0, 1 },
536 },
537 [GDK_COLOR_STATE_ID_SRGB_LINEARcxx . . $ GDK_COLOR_STATE_ID_SRGB_LINEAR.] = {
538 .parent = {
539 .klass = &GDK_DEFAULT_COLOR_STATE_CLASScxx . . $ GDK_DEFAULT_COLOR_STATE_CLASS.,
540 .ref_count = 0,
541 .depth = GDK_MEMORY_U8cxx . . $ GDK_MEMORY_U8.,
542 .hue_channel = GDK_COLOR_CHANNEL_ALPHAcxx . . $ GDK_COLOR_CHANNEL_ALPHA.,
543 .rendering_color_state = GDK_COLOR_STATE_SRGB_LINEARcxx . . $ `gdk/gdkcolorstateprivate.h:88:9`!,
544 .rendering_color_state_linear = GDK_COLOR_STATE_SRGB_LINEARcxx . . $ `gdk/gdkcolorstateprivate.h:88:9`!,
545 },
546 .name = "srgb-linear",
547 .no_srgb = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
548 .convert_to = {
549 [GDK_COLOR_STATE_ID_SRGBcxx . . $ GDK_COLOR_STATE_ID_SRGB.] = gdk_convert_srgb_linear_to_srgbcxx . . $ gdk_convert_srgb_linear_to_srgb(e7c77eef68eb920e).,
550 [GDK_COLOR_STATE_ID_REC2100_PQcxx . . $ GDK_COLOR_STATE_ID_REC2100_PQ.] = gdk_convert_srgb_linear_to_rec2100_pqcxx . . $ gdk_convert_srgb_linear_to_rec2100_pq(e7c77eef68eb920e).,
551 [GDK_COLOR_STATE_ID_REC2100_LINEARcxx . . $ GDK_COLOR_STATE_ID_REC2100_LINEAR.] = gdk_convert_srgb_linear_to_rec2100_linearcxx . . $ gdk_convert_srgb_linear_to_rec2100_linear(e7c77eef68eb920e).,
552 },
553 .cicp = { 1, 8, 0, 1 },
554 },
555 [GDK_COLOR_STATE_ID_REC2100_PQcxx . . $ GDK_COLOR_STATE_ID_REC2100_PQ.] = {
556 .parent = {
557 .klass = &GDK_DEFAULT_COLOR_STATE_CLASScxx . . $ GDK_DEFAULT_COLOR_STATE_CLASS.,
558 .ref_count = 0,
559 .depth = GDK_MEMORY_FLOAT16cxx . . $ GDK_MEMORY_FLOAT16.,
560 .hue_channel = GDK_COLOR_CHANNEL_ALPHAcxx . . $ GDK_COLOR_CHANNEL_ALPHA.,
561 .rendering_color_state = GDK_COLOR_STATE_REC2100_PQcxx . . $ `gdk/gdkcolorstateprivate.h:89:9`!,
562 .rendering_color_state_linear = GDK_COLOR_STATE_REC2100_LINEARcxx . . $ `gdk/gdkcolorstateprivate.h:90:9`!,
563 },
564 .name = "rec2100-pq",
565 .no_srgb = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
566 .convert_to = {
567 [GDK_COLOR_STATE_ID_SRGBcxx . . $ GDK_COLOR_STATE_ID_SRGB.] = gdk_convert_rec2100_pq_to_srgbcxx . . $ gdk_convert_rec2100_pq_to_srgb(e7c77eef68eb920e).,
568 [GDK_COLOR_STATE_ID_SRGB_LINEARcxx . . $ GDK_COLOR_STATE_ID_SRGB_LINEAR.] = gdk_convert_rec2100_pq_to_srgb_linearcxx . . $ gdk_convert_rec2100_pq_to_srgb_linear(e7c77eef68eb920e).,
569 [GDK_COLOR_STATE_ID_REC2100_LINEARcxx . . $ GDK_COLOR_STATE_ID_REC2100_LINEAR.] = gdk_convert_rec2100_pq_to_rec2100_linearcxx . . $ gdk_convert_rec2100_pq_to_rec2100_linear(e7c77eef68eb920e).,
570 },
571 .cicp = { 9, 16, 0, 1 },
572 },
573 [GDK_COLOR_STATE_ID_REC2100_LINEARcxx . . $ GDK_COLOR_STATE_ID_REC2100_LINEAR.] = {
574 .parent = {
575 .klass = &GDK_DEFAULT_COLOR_STATE_CLASScxx . . $ GDK_DEFAULT_COLOR_STATE_CLASS.,
576 .ref_count = 0,
577 .depth = GDK_MEMORY_FLOAT16cxx . . $ GDK_MEMORY_FLOAT16.,
578 .hue_channel = GDK_COLOR_CHANNEL_ALPHAcxx . . $ GDK_COLOR_CHANNEL_ALPHA.,
579 .rendering_color_state = GDK_COLOR_STATE_REC2100_LINEARcxx . . $ `gdk/gdkcolorstateprivate.h:90:9`!,
580 .rendering_color_state_linear = GDK_COLOR_STATE_REC2100_LINEARcxx . . $ `gdk/gdkcolorstateprivate.h:90:9`!,
581 },
582 .name = "rec2100-linear",
583 .no_srgb = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
584 .convert_to = {
585 [GDK_COLOR_STATE_ID_SRGBcxx . . $ GDK_COLOR_STATE_ID_SRGB.] = gdk_convert_rec2100_linear_to_srgbcxx . . $ gdk_convert_rec2100_linear_to_srgb(e7c77eef68eb920e).,
586 [GDK_COLOR_STATE_ID_SRGB_LINEARcxx . . $ GDK_COLOR_STATE_ID_SRGB_LINEAR.] = gdk_convert_rec2100_linear_to_srgb_linearcxx . . $ gdk_convert_rec2100_linear_to_srgb_linear(e7c77eef68eb920e).,
587 [GDK_COLOR_STATE_ID_REC2100_PQcxx . . $ GDK_COLOR_STATE_ID_REC2100_PQ.] = gdk_convert_rec2100_linear_to_rec2100_pqcxx . . $ gdk_convert_rec2100_linear_to_rec2100_pq(e7c77eef68eb920e).,
588 },
589 .cicp = { 9, 8, 0, 1 },
590 },
591 };
592
593 G_STATIC_ASSERTcxx . . $ `<external>/12741050725406041920/gmacros.h:910:9`! (G_N_ELEMENTScxx . . $ `<external>/12741050725406041920/gmacros.h:993:9`! (gdk_default_color_states) == GDK_COLOR_STATE_N_IDS);
594
595 static gbooleancxx . . $ gboolean#
596 gdk_builtin_color_state_equalcxx . . $ gdk_builtin_color_state_equal(2491eb58a6eb4a60). (GdkColorStatecxx . . $ GdkColorState# *self,
597 GdkColorStatecxx . . $ GdkColorState# *other)
598 {
599 return self == other;
600 }
601
602 static const char *
603 gdk_builtin_color_state_get_namecxx . . $ gdk_builtin_color_state_get_name(5247ad7030db0d80). (GdkColorStatecxx . . $ GdkColorState# *color_state)
604 {
605 GdkBuiltinColorStatecxx . . $ GdkBuiltinColorState# *self = (GdkBuiltinColorStatecxx . . $ GdkBuiltinColorState# *) color_state;
606
607 return self->namecxx . . $ _GdkBuiltinColorState#name.;
608 }
609
610 /*<private>
611 * gdk_color_state_get_hue_channel:
612 * @self: the color state
613 * @out_channel: (out caller-allocates): the channel
614 *
615 * Checks if the color state has a hue channel and returns it if
616 * there is one.
617 *
618 * Unlike other channels, hue channels are periodic, so they may
619 * need different treatment in various places.
620 *
621 * Returns: true if the color state has a hue channel
622 **/
623 gbooleancxx . . $ gboolean#
624 gdk_color_state_get_hue_channelcxx . . $ gdk_color_state_get_hue_channel(356e0806e6b1c1f9). (GdkColorStatecxx . . $ GdkColorState# *self,
625 GdkColorChannelcxx . . $ GdkColorChannel# *out_channel)
626 {
627 if (self->hue_channelcxx . . $ _GdkColorState#hue_channel. == GDK_COLOR_CHANNEL_ALPHAcxx . . $ GDK_COLOR_CHANNEL_ALPHA.)
628 return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
629
630 *out_channel = self->hue_channelcxx . . $ _GdkColorState#hue_channel.;
631 return TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!;
632 }
633
634 static GdkColorStatecxx . . $ GdkColorState# *
635 gdk_builtin_color_state_get_no_srgb_tfcxx . . $ gdk_builtin_color_state_get_no_srgb_tf(8feb2ce0a46ae897). (GdkColorStatecxx . . $ GdkColorState# *color_state)
636 {
637 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
638 }
639
640 static GdkFloatColorConvertcxx . . $ GdkFloatColorConvert#
641 gdk_builtin_color_state_get_convert_tocxx . . $ gdk_builtin_color_state_get_convert_to(6b29540b4c677ef8). (GdkColorStatecxx . . $ GdkColorState# *color_state,
642 GdkColorStatecxx . . $ GdkColorState# *target)
643 {
644 GdkBuiltinColorStatecxx . . $ GdkBuiltinColorState# *self = (GdkBuiltinColorStatecxx . . $ GdkBuiltinColorState# *) color_state;
645
646 if (GDK_IS_DEFAULT_COLOR_STATEcxx . . $ `gdk/gdkcolorstateprivate.h:95:9`! (target))
647 return self->convert_tocxx . . $ _GdkBuiltinColorState#convert_to.[GDK_DEFAULT_COLOR_STATE_IDcxx . . $ `gdk/gdkcolorstateprivate.h:97:9`! (target)];
648
649 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
650 }
651
652 static GdkFloatColorConvertcxx . . $ GdkFloatColorConvert#
653 gdk_builtin_color_state_get_convert_fromcxx . . $ gdk_builtin_color_state_get_convert_from(6b29540b4c677ef8). (GdkColorStatecxx . . $ GdkColorState# *color_state,
654 GdkColorStatecxx . . $ GdkColorState# *source)
655 {
656 GdkBuiltinColorStatecxx . . $ GdkBuiltinColorState# *self = (GdkBuiltinColorStatecxx . . $ GdkBuiltinColorState# *) color_state;
657
658 if (GDK_IS_DEFAULT_COLOR_STATEcxx . . $ `gdk/gdkcolorstateprivate.h:95:9`! (source))
659 return self->convert_fromcxx . . $ _GdkBuiltinColorState#convert_from.[GDK_DEFAULT_COLOR_STATE_IDcxx . . $ `gdk/gdkcolorstateprivate.h:97:9`! (source)];
660
661 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
662 }
663
664 static const GdkCicpcxx . . $ GdkCicp# *
665 gdk_builtin_color_state_get_cicpcxx . . $ gdk_builtin_color_state_get_cicp(a81b5b46de96dec1). (GdkColorStatecxx . . $ GdkColorState# *color_state)
666 {
667 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
668 }
669
670 /* }}} */
671
672 static const
673 GdkColorStateClasscxx . . $ GdkColorStateClass# GDK_BUILTIN_COLOR_STATE_CLASScxx . . $ GDK_BUILTIN_COLOR_STATE_CLASS. = {
674 .free = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, /* crash here if this ever happens */
675 .equal = gdk_builtin_color_state_equalcxx . . $ gdk_builtin_color_state_equal(2491eb58a6eb4a60).,
676 .get_name = gdk_builtin_color_state_get_namecxx . . $ gdk_builtin_color_state_get_name(5247ad7030db0d80).,
677 .get_no_srgb_tf = gdk_builtin_color_state_get_no_srgb_tfcxx . . $ gdk_builtin_color_state_get_no_srgb_tf(8feb2ce0a46ae897).,
678 .get_convert_to = gdk_builtin_color_state_get_convert_tocxx . . $ gdk_builtin_color_state_get_convert_to(6b29540b4c677ef8).,
679 .get_convert_from = gdk_builtin_color_state_get_convert_fromcxx . . $ gdk_builtin_color_state_get_convert_from(6b29540b4c677ef8).,
680 .get_cicp = gdk_builtin_color_state_get_cicpcxx . . $ gdk_builtin_color_state_get_cicp(a81b5b46de96dec1).,
681 };
682
683 GdkBuiltinColorStatecxx . . $ GdkBuiltinColorState# gdk_builtin_color_statescxx . . $ gdk_builtin_color_states.[] = {
684 [GDK_BUILTIN_COLOR_STATE_ID_OKLABcxx . . $ GDK_BUILTIN_COLOR_STATE_ID_OKLAB.] = {
685 .parent = {
686 .klass = &GDK_BUILTIN_COLOR_STATE_CLASScxx . . $ GDK_BUILTIN_COLOR_STATE_CLASS.,
687 .ref_count = 0,
688 .depth = GDK_MEMORY_FLOAT16cxx . . $ GDK_MEMORY_FLOAT16.,
689 .hue_channel = GDK_COLOR_CHANNEL_ALPHAcxx . . $ GDK_COLOR_CHANNEL_ALPHA.,
690 .rendering_color_state = GDK_COLOR_STATE_SRGBcxx . . $ `gdk/gdkcolorstateprivate.h:87:9`!,
691 },
692 .name = "oklab",
693 .convert_to = {
694 [GDK_COLOR_STATE_ID_SRGBcxx . . $ GDK_COLOR_STATE_ID_SRGB.] = gdk_convert_oklab_to_srgbcxx . . $ gdk_convert_oklab_to_srgb(e7c77eef68eb920e).,
695 [GDK_COLOR_STATE_ID_SRGB_LINEARcxx . . $ GDK_COLOR_STATE_ID_SRGB_LINEAR.] = gdk_convert_oklab_to_srgb_linearcxx . . $ gdk_convert_oklab_to_srgb_linear(e7c77eef68eb920e).,
696 [GDK_COLOR_STATE_ID_REC2100_PQcxx . . $ GDK_COLOR_STATE_ID_REC2100_PQ.] = gdk_convert_oklab_to_rec2100_pqcxx . . $ gdk_convert_oklab_to_rec2100_pq(e7c77eef68eb920e).,
697 [GDK_COLOR_STATE_ID_REC2100_LINEARcxx . . $ GDK_COLOR_STATE_ID_REC2100_LINEAR.] = gdk_convert_oklab_to_rec2100_linearcxx . . $ gdk_convert_oklab_to_rec2100_linear(e7c77eef68eb920e).,
698 },
699 .convert_from = {
700 [GDK_COLOR_STATE_ID_SRGBcxx . . $ GDK_COLOR_STATE_ID_SRGB.] = gdk_convert_srgb_to_oklabcxx . . $ gdk_convert_srgb_to_oklab(e7c77eef68eb920e).,
701 [GDK_COLOR_STATE_ID_SRGB_LINEARcxx . . $ GDK_COLOR_STATE_ID_SRGB_LINEAR.] = gdk_convert_srgb_linear_to_oklabcxx . . $ gdk_convert_srgb_linear_to_oklab(e7c77eef68eb920e).,
702 [GDK_COLOR_STATE_ID_REC2100_PQcxx . . $ GDK_COLOR_STATE_ID_REC2100_PQ.] = gdk_convert_rec2100_pq_to_oklabcxx . . $ gdk_convert_rec2100_pq_to_oklab(e7c77eef68eb920e).,
703 [GDK_COLOR_STATE_ID_REC2100_LINEARcxx . . $ GDK_COLOR_STATE_ID_REC2100_LINEAR.] = gdk_convert_rec2100_linear_to_oklabcxx . . $ gdk_convert_rec2100_linear_to_oklab(e7c77eef68eb920e).,
704 },
705 },
706 [GDK_BUILTIN_COLOR_STATE_ID_OKLCHcxx . . $ GDK_BUILTIN_COLOR_STATE_ID_OKLCH.] = {
707 .parent = {
708 .klass = &GDK_BUILTIN_COLOR_STATE_CLASScxx . . $ GDK_BUILTIN_COLOR_STATE_CLASS.,
709 .ref_count = 0,
710 .depth = GDK_MEMORY_FLOAT16cxx . . $ GDK_MEMORY_FLOAT16.,
711 .hue_channel = GDK_COLOR_CHANNEL_BLUEcxx . . $ GDK_COLOR_CHANNEL_BLUE.,
712 .rendering_color_state = GDK_COLOR_STATE_SRGBcxx . . $ `gdk/gdkcolorstateprivate.h:87:9`!,
713 },
714 .name = "oklch",
715 .convert_to = {
716 [GDK_COLOR_STATE_ID_SRGBcxx . . $ GDK_COLOR_STATE_ID_SRGB.] = gdk_convert_oklch_to_srgbcxx . . $ gdk_convert_oklch_to_srgb(e7c77eef68eb920e).,
717 [GDK_COLOR_STATE_ID_SRGB_LINEARcxx . . $ GDK_COLOR_STATE_ID_SRGB_LINEAR.] = gdk_convert_oklch_to_srgb_linearcxx . . $ gdk_convert_oklch_to_srgb_linear(e7c77eef68eb920e).,
718 [GDK_COLOR_STATE_ID_REC2100_PQcxx . . $ GDK_COLOR_STATE_ID_REC2100_PQ.] = gdk_convert_oklch_to_rec2100_pqcxx . . $ gdk_convert_oklch_to_rec2100_pq(e7c77eef68eb920e).,
719 [GDK_COLOR_STATE_ID_REC2100_LINEARcxx . . $ GDK_COLOR_STATE_ID_REC2100_LINEAR.] = gdk_convert_oklch_to_rec2100_linearcxx . . $ gdk_convert_oklch_to_rec2100_linear(e7c77eef68eb920e).,
720 },
721 .convert_from = {
722 [GDK_COLOR_STATE_ID_SRGBcxx . . $ GDK_COLOR_STATE_ID_SRGB.] = gdk_convert_srgb_to_oklchcxx . . $ gdk_convert_srgb_to_oklch(e7c77eef68eb920e).,
723 [GDK_COLOR_STATE_ID_SRGB_LINEARcxx . . $ GDK_COLOR_STATE_ID_SRGB_LINEAR.] = gdk_convert_srgb_linear_to_oklchcxx . . $ gdk_convert_srgb_linear_to_oklch(e7c77eef68eb920e).,
724 [GDK_COLOR_STATE_ID_REC2100_PQcxx . . $ GDK_COLOR_STATE_ID_REC2100_PQ.] = gdk_convert_rec2100_pq_to_oklchcxx . . $ gdk_convert_rec2100_pq_to_oklch(e7c77eef68eb920e).,
725 [GDK_COLOR_STATE_ID_REC2100_LINEARcxx . . $ GDK_COLOR_STATE_ID_REC2100_LINEAR.] = gdk_convert_rec2100_linear_to_oklchcxx . . $ gdk_convert_rec2100_linear_to_oklch(e7c77eef68eb920e).,
726 },
727 },
728 };
729
730 /* }}} */
731 /* {{{ Cicp implementation */
732
733 typedef struct _GdkCicpColorStatecxx . . $ _GdkCicpColorState# GdkCicpColorStatecxx . . $ GdkCicpColorState#;
734 struct _GdkCicpColorStatecxx . . $ _GdkCicpColorState#
735 {
736 GdkColorStatecxx . . $ GdkColorState# parentcxx . . $ _GdkCicpColorState#parent.;
737
738 GdkColorStatecxx . . $ GdkColorState# *no_srgbcxx . . $ _GdkCicpColorState#no_srgb.;
739
740 char *namecxx . . $ _GdkCicpColorState#name.;
741
742 GdkTransferFunccxx . . $ GdkTransferFunc# eotfcxx . . $ _GdkCicpColorState#eotf.;
743 GdkTransferFunccxx . . $ GdkTransferFunc# oetfcxx . . $ _GdkCicpColorState#oetf.;
744
745 float to_srgbcxx . . $ _GdkCicpColorState#to_srgb.[9];
746 float to_rec2020cxx . . $ _GdkCicpColorState#to_rec2020.[9];
747 float from_srgbcxx . . $ _GdkCicpColorState#from_srgb.[9];
748 float from_rec2020cxx . . $ _GdkCicpColorState#from_rec2020.[9];
749
750 const float *from_yuvcxx . . $ _GdkCicpColorState#from_yuv.;
751 const float *to_yuvcxx . . $ _GdkCicpColorState#to_yuv.;
752
753 GdkCicpcxx . . $ GdkCicp# cicpcxx . . $ _GdkCicpColorState#cicp.;
754 };
755
756 /* {{{ Conversion functions */
757
758 #define TRANSFORM_FROM_CICPcxx . . $ `gdk/gdkcolorstate.c:758:9`!(name, matrix, oetf) \
759 static void \
760 name (GdkColorState *color_state, \
761 float (*values)[4], \
762 gsize n_values) \
763 { \
764 GdkCicpColorState *self = (GdkCicpColorState *) color_state; \
765 \
766 transform_from_cicp (self, oetf, self->matrix, values, n_values); \
767 }
768
769 static void
770 transform_from_cicpcxx . . $ transform_from_cicp(65fd944219ff4cf). (GdkCicpColorStatecxx . . $ GdkCicpColorState# *self,
771 GdkTransferFunccxx . . $ GdkTransferFunc# oetf,
772 float matrix[9],
773 float (*values)[4],
774 gsizecxx . . $ gsize# n_values)
775 {
776 for (gsizecxx . . $ gsize# i = 0; i < n_values; i++)
777 {
778 if (self->cicpcxx . . $ _GdkCicpColorState#cicp..rangecxx . . $ _GdkCicp#range. == GDK_CICP_RANGE_NARROWcxx . . $ GDK_CICP_RANGE_NARROW.)
779 {
780 values[i][0] = CLAMPcxx . . $ `<external>/12741050725406041920/gmacros.h:984:9`! ((values[i][0] - 16.0/255.0) * 255.0 / 224.0, 0.0, 1.0);
781 values[i][1] = CLAMPcxx . . $ `<external>/12741050725406041920/gmacros.h:984:9`! ((values[i][1] - 16.0/255.0) * 255.0 / 219.0, 0.0, 1.0);
782 values[i][2] = CLAMPcxx . . $ `<external>/12741050725406041920/gmacros.h:984:9`! ((values[i][2] - 16.0/255.0) * 255.0 / 224.0, 0.0, 1.0);
783 }
784 if (self->from_yuvcxx . . $ _GdkCicpColorState#from_yuv.)
785 {
786 float res[3];
787 values[i][0] -= 0.5;
788 values[i][2] -= 0.5;
789 res[0] = self->from_yuvcxx . . $ _GdkCicpColorState#from_yuv.[0] * values[i][0] + self->from_yuvcxx . . $ _GdkCicpColorState#from_yuv.[1] * values[i][1] + self->from_yuvcxx . . $ _GdkCicpColorState#from_yuv.[2] * values[i][2];
790 res[1] = self->from_yuvcxx . . $ _GdkCicpColorState#from_yuv.[3] * values[i][0] + self->from_yuvcxx . . $ _GdkCicpColorState#from_yuv.[4] * values[i][1] + self->from_yuvcxx . . $ _GdkCicpColorState#from_yuv.[5] * values[i][2];
791 res[2] = self->from_yuvcxx . . $ _GdkCicpColorState#from_yuv.[6] * values[i][0] + self->from_yuvcxx . . $ _GdkCicpColorState#from_yuv.[7] * values[i][1] + self->from_yuvcxx . . $ _GdkCicpColorState#from_yuv.[8] * values[i][2];
792 values[i][0] = res[0];
793 values[i][1] = res[1];
794 values[i][2] = res[2];
795 }
796 if (self->eotfcxx . . $ _GdkCicpColorState#eotf. != NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!)
797 {
798 values[i][0] = self->eotfcxx . . $ _GdkCicpColorState#eotf. (values[i][0]);
799 values[i][1] = self->eotfcxx . . $ _GdkCicpColorState#eotf. (values[i][1]);
800 values[i][2] = self->eotfcxx . . $ _GdkCicpColorState#eotf. (values[i][2]);
801 }
802 if (matrix != IDENTITYcxx . . $ `gdk/gdkcolorstate.c:286:9`!)
803 {
804 float res[3];
805 res[0] = matrix[0] * values[i][0] + matrix[1] * values[i][1] + matrix[2] * values[i][2];
806 res[1] = matrix[3] * values[i][0] + matrix[4] * values[i][1] + matrix[5] * values[i][2];
807 res[2] = matrix[6] * values[i][0] + matrix[7] * values[i][1] + matrix[8] * values[i][2];
808 values[i][0] = res[0];
809 values[i][1] = res[1];
810 values[i][2] = res[2];
811 }
812 if (oetf != NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!)
813 {
814 values[i][0] = oetf (values[i][0]);
815 values[i][1] = oetf (values[i][1]);
816 values[i][2] = oetf (values[i][2]);
817 }
818 }
819 }
820
821 #define TRANSFORM_TO_CICPcxx . . $ `gdk/gdkcolorstate.c:821:9`!(name, eotf, matrix) \
822 static void \
823 name (GdkColorState *color_state, \
824 float (*values)[4], \
825 gsize n_values) \
826 { \
827 GdkCicpColorState *self = (GdkCicpColorState *) color_state; \
828 \
829 transform_to_cicp (self, eotf, self->matrix, values, n_values); \
830 }
831
832 static void
833 transform_to_cicpcxx . . $ transform_to_cicp(65fd944219ff4cf). (GdkCicpColorStatecxx . . $ GdkCicpColorState# *self,
834 GdkTransferFunccxx . . $ GdkTransferFunc# eotf,
835 float matrix[9],
836 float (*values)[4],
837 gsizecxx . . $ gsize# n_values)
838 {
839 for (gsizecxx . . $ gsize# i = 0; i < n_values; i++)
840 {
841 if (eotf != NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!)
842 {
843 values[i][0] = eotf (values[i][0]);
844 values[i][1] = eotf (values[i][1]);
845 values[i][2] = eotf (values[i][2]);
846 }
847 if (matrix != IDENTITYcxx . . $ `gdk/gdkcolorstate.c:286:9`!)
848 {
849 float res[3];
850 res[0] = matrix[0] * values[i][0] + matrix[1] * values[i][1] + matrix[2] * values[i][2];
851 res[1] = matrix[3] * values[i][0] + matrix[4] * values[i][1] + matrix[5] * values[i][2];
852 res[2] = matrix[6] * values[i][0] + matrix[7] * values[i][1] + matrix[8] * values[i][2];
853 values[i][0] = res[0];
854 values[i][1] = res[1];
855 values[i][2] = res[2];
856 }
857 else
858 {
859 float tmp = values[i][2];
860 values[i][2] = values[i][0];
861 values[i][0] = values[i][1];
862 values[i][1] = tmp;
863 }
864 if (self->oetfcxx . . $ _GdkCicpColorState#oetf. != NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!)
865 {
866 values[i][0] = self->oetfcxx . . $ _GdkCicpColorState#oetf. (values[i][0]);
867 values[i][1] = self->oetfcxx . . $ _GdkCicpColorState#oetf. (values[i][1]);
868 values[i][2] = self->oetfcxx . . $ _GdkCicpColorState#oetf. (values[i][2]);
869 }
870 if (self->to_yuvcxx . . $ _GdkCicpColorState#to_yuv.)
871 {
872 float res[3];
873 res[0] = self->to_yuvcxx . . $ _GdkCicpColorState#to_yuv.[0] * values[i][0] + self->to_yuvcxx . . $ _GdkCicpColorState#to_yuv.[1] * values[i][1] + self->to_yuvcxx . . $ _GdkCicpColorState#to_yuv.[2] * values[i][2];
874 res[1] = self->to_yuvcxx . . $ _GdkCicpColorState#to_yuv.[3] * values[i][0] + self->to_yuvcxx . . $ _GdkCicpColorState#to_yuv.[4] * values[i][1] + self->to_yuvcxx . . $ _GdkCicpColorState#to_yuv.[5] * values[i][2];
875 res[2] = self->to_yuvcxx . . $ _GdkCicpColorState#to_yuv.[6] * values[i][0] + self->to_yuvcxx . . $ _GdkCicpColorState#to_yuv.[7] * values[i][1] + self->to_yuvcxx . . $ _GdkCicpColorState#to_yuv.[8] * values[i][2];
876 values[i][0] = res[0] + 0.5;
877 values[i][1] = res[1];
878 values[i][2] = res[2] + 0.5;
879 }
880 values[i][0] = CLAMPcxx . . $ `<external>/12741050725406041920/gmacros.h:984:9`! (values[i][0], 0.0, 1.0);
881 values[i][1] = CLAMPcxx . . $ `<external>/12741050725406041920/gmacros.h:984:9`! (values[i][1], 0.0, 1.0);
882 values[i][2] = CLAMPcxx . . $ `<external>/12741050725406041920/gmacros.h:984:9`! (values[i][2], 0.0, 1.0);
883 if (self->cicpcxx . . $ _GdkCicpColorState#cicp..rangecxx . . $ _GdkCicp#range. == GDK_CICP_RANGE_NARROWcxx . . $ GDK_CICP_RANGE_NARROW.)
884 {
885 values[i][0] = values[i][0] * 224.0 / 255.0 + 16.0 / 255.0;
886 values[i][1] = values[i][1] * 219.0 / 255.0 + 16.0 / 255.0;
887 values[i][2] = values[i][2] * 224.0 / 255.0 + 16.0 / 255.0;
888 }
889 }
890 }
891
892 TRANSFORM_FROM_CICPcxx . . $ `gdk/gdkcolorstate.c:758:9`!(gdk_convert_cicp_to_srgb, to_srgb, srgb_oetf)
893 TRANSFORM_FROM_CICPcxx . . $ `gdk/gdkcolorstate.c:758:9`!(gdk_convert_cicp_to_srgb_linear, to_srgb, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!)
894 TRANSFORM_FROM_CICPcxx . . $ `gdk/gdkcolorstate.c:758:9`!(gdk_convert_cicp_to_rec2100_pq, to_rec2020, pq_oetf)
895 TRANSFORM_FROM_CICPcxx . . $ `gdk/gdkcolorstate.c:758:9`!(gdk_convert_cicp_to_rec2100_linear, to_rec2020, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!)
896
897 TRANSFORM_TO_CICPcxx . . $ `gdk/gdkcolorstate.c:821:9`!(gdk_convert_cicp_from_srgb, srgb_eotf, from_srgb)
898 TRANSFORM_TO_CICPcxx . . $ `gdk/gdkcolorstate.c:821:9`!(gdk_convert_cicp_from_srgb_linear, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!, from_srgb)
899 TRANSFORM_TO_CICPcxx . . $ `gdk/gdkcolorstate.c:821:9`!(gdk_convert_cicp_from_rec2100_pq, pq_eotf, from_rec2020)
900 TRANSFORM_TO_CICPcxx . . $ `gdk/gdkcolorstate.c:821:9`!(gdk_convert_cicp_from_rec2100_linear, NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!, from_rec2020)
901
902 /* }}} */
903 /* {{{ Vfuncs */
904
905 static void
906 gdk_cicp_color_state_freecxx . . $ gdk_cicp_color_state_free(1604aa7719ab6e66). (GdkColorStatecxx . . $ GdkColorState# *cs)
907 {
908 GdkCicpColorStatecxx . . $ GdkCicpColorState# *self = (GdkCicpColorStatecxx . . $ GdkCicpColorState# *) cs;
909
910 g_freecxx . . $ g_free(5d22bdacc48458e8). (self->namecxx . . $ _GdkCicpColorState#name.);
911
912 if (self->no_srgbcxx . . $ _GdkCicpColorState#no_srgb.)
913 gdk_color_state_unrefcxx . . $ `gdk/gdkcolorstateprivate.h:151:9`! (self->no_srgb);
914
915 g_freecxx . . $ g_free(5d22bdacc48458e8). (self);
916 }
917
918 static gbooleancxx . . $ gboolean#
919 gdk_cicp_color_state_equalcxx . . $ gdk_cicp_color_state_equal(2491eb58a6eb4a60). (GdkColorStatecxx . . $ GdkColorState# *self,
920 GdkColorStatecxx . . $ GdkColorState# *other)
921 {
922 GdkCicpColorStatecxx . . $ GdkCicpColorState# *cs1 = (GdkCicpColorStatecxx . . $ GdkCicpColorState# *) self;
923 GdkCicpColorStatecxx . . $ GdkCicpColorState# *cs2 = (GdkCicpColorStatecxx . . $ GdkCicpColorState# *) other;
924
925 return gdk_cicp_equalcxx . . $ gdk_cicp_equal(177334471ad58715). (&cs1->cicpcxx . . $ _GdkCicpColorState#cicp., &cs2->cicpcxx . . $ _GdkCicpColorState#cicp.);
926 }
927
928 static const char *
929 gdk_cicp_color_state_get_namecxx . . $ gdk_cicp_color_state_get_name(5247ad7030db0d80). (GdkColorStatecxx . . $ GdkColorState# *self)
930 {
931 GdkCicpColorStatecxx . . $ GdkCicpColorState# *cs = (GdkCicpColorStatecxx . . $ GdkCicpColorState# *) self;
932
933 return cs->namecxx . . $ _GdkCicpColorState#name.;
934 }
935
936 static GdkColorStatecxx . . $ GdkColorState# *
937 gdk_cicp_color_state_get_no_srgb_tfcxx . . $ gdk_cicp_color_state_get_no_srgb_tf(8feb2ce0a46ae897). (GdkColorStatecxx . . $ GdkColorState# *self)
938 {
939 GdkCicpColorStatecxx . . $ GdkCicpColorState# *cs = (GdkCicpColorStatecxx . . $ GdkCicpColorState# *) self;
940
941 return cs->no_srgbcxx . . $ _GdkCicpColorState#no_srgb.;
942 }
943
944 static GdkFloatColorConvertcxx . . $ GdkFloatColorConvert#
945 gdk_cicp_color_state_get_convert_tocxx . . $ gdk_cicp_color_state_get_convert_to(6b29540b4c677ef8). (GdkColorStatecxx . . $ GdkColorState# *self,
946 GdkColorStatecxx . . $ GdkColorState# *target)
947 {
948 if (!GDK_IS_DEFAULT_COLOR_STATEcxx . . $ `gdk/gdkcolorstateprivate.h:95:9`! (target))
949 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
950
951 switch (GDK_DEFAULT_COLOR_STATE_IDcxx . . $ `gdk/gdkcolorstateprivate.h:97:9`! (target))
952 {
953 case GDK_COLOR_STATE_ID_SRGBcxx . . $ GDK_COLOR_STATE_ID_SRGB.:
954 return gdk_convert_cicp_to_srgbcxx . . $ gdk_convert_cicp_to_srgb(e7c77eef68eb920e).;
955 case GDK_COLOR_STATE_ID_SRGB_LINEARcxx . . $ GDK_COLOR_STATE_ID_SRGB_LINEAR.:
956 return gdk_convert_cicp_to_srgb_linearcxx . . $ gdk_convert_cicp_to_srgb_linear(e7c77eef68eb920e).;
957 case GDK_COLOR_STATE_ID_REC2100_PQcxx . . $ GDK_COLOR_STATE_ID_REC2100_PQ.:
958 return gdk_convert_cicp_to_rec2100_pqcxx . . $ gdk_convert_cicp_to_rec2100_pq(e7c77eef68eb920e).;
959 case GDK_COLOR_STATE_ID_REC2100_LINEARcxx . . $ GDK_COLOR_STATE_ID_REC2100_LINEAR.:
960 return gdk_convert_cicp_to_rec2100_linearcxx . . $ gdk_convert_cicp_to_rec2100_linear(e7c77eef68eb920e).;
961
962 case GDK_COLOR_STATE_N_IDScxx . . $ GDK_COLOR_STATE_N_IDS.:
963 default:
964 g_assert_not_reachedcxx . . $ `<external>/15287032793271088244/gtestutils.h:274:9`! ();
965 }
966
967 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
968 }
969
970 static GdkFloatColorConvertcxx . . $ GdkFloatColorConvert#
971 gdk_cicp_color_state_get_convert_fromcxx . . $ gdk_cicp_color_state_get_convert_from(6b29540b4c677ef8). (GdkColorStatecxx . . $ GdkColorState# *self,
972 GdkColorStatecxx . . $ GdkColorState# *source)
973 {
974 if (!GDK_IS_DEFAULT_COLOR_STATEcxx . . $ `gdk/gdkcolorstateprivate.h:95:9`! (source))
975 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
976
977 switch (GDK_DEFAULT_COLOR_STATE_IDcxx . . $ `gdk/gdkcolorstateprivate.h:97:9`! (source))
978 {
979 case GDK_COLOR_STATE_ID_SRGBcxx . . $ GDK_COLOR_STATE_ID_SRGB.:
980 return gdk_convert_cicp_from_srgbcxx . . $ gdk_convert_cicp_from_srgb(e7c77eef68eb920e).;
981 case GDK_COLOR_STATE_ID_SRGB_LINEARcxx . . $ GDK_COLOR_STATE_ID_SRGB_LINEAR.:
982 return gdk_convert_cicp_from_srgb_linearcxx . . $ gdk_convert_cicp_from_srgb_linear(e7c77eef68eb920e).;
983 case GDK_COLOR_STATE_ID_REC2100_PQcxx . . $ GDK_COLOR_STATE_ID_REC2100_PQ.:
984 return gdk_convert_cicp_from_rec2100_pqcxx . . $ gdk_convert_cicp_from_rec2100_pq(e7c77eef68eb920e).;
985 case GDK_COLOR_STATE_ID_REC2100_LINEARcxx . . $ GDK_COLOR_STATE_ID_REC2100_LINEAR.:
986 return gdk_convert_cicp_from_rec2100_linearcxx . . $ gdk_convert_cicp_from_rec2100_linear(e7c77eef68eb920e).;
987
988 case GDK_COLOR_STATE_N_IDScxx . . $ GDK_COLOR_STATE_N_IDS.:
989 default:
990 g_assert_not_reachedcxx . . $ `<external>/15287032793271088244/gtestutils.h:274:9`! ();
991 }
992
993 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
994 }
995
996 static const GdkCicpcxx . . $ GdkCicp# *
997 gdk_cicp_color_state_get_cicpcxx . . $ gdk_cicp_color_state_get_cicp(a81b5b46de96dec1). (GdkColorStatecxx . . $ GdkColorState# *color_state)
998 {
999 GdkCicpColorStatecxx . . $ GdkCicpColorState# *self = (GdkCicpColorStatecxx . . $ GdkCicpColorState# *) color_state;
1000
1001 return &self->cicpcxx . . $ _GdkCicpColorState#cicp.;
1002 }
1003
1004 /* }}} */
1005
1006 static const
1007 GdkColorStateClasscxx . . $ GdkColorStateClass# GDK_CICP_COLOR_STATE_CLASScxx . . $ GDK_CICP_COLOR_STATE_CLASS. = {
1008 .free = gdk_cicp_color_state_freecxx . . $ gdk_cicp_color_state_free(1604aa7719ab6e66).,
1009 .equal = gdk_cicp_color_state_equalcxx . . $ gdk_cicp_color_state_equal(2491eb58a6eb4a60).,
1010 .get_name = gdk_cicp_color_state_get_namecxx . . $ gdk_cicp_color_state_get_name(5247ad7030db0d80).,
1011 .get_no_srgb_tf = gdk_cicp_color_state_get_no_srgb_tfcxx . . $ gdk_cicp_color_state_get_no_srgb_tf(8feb2ce0a46ae897).,
1012 .get_convert_to = gdk_cicp_color_state_get_convert_tocxx . . $ gdk_cicp_color_state_get_convert_to(6b29540b4c677ef8).,
1013 .get_convert_from = gdk_cicp_color_state_get_convert_fromcxx . . $ gdk_cicp_color_state_get_convert_from(6b29540b4c677ef8).,
1014 .get_cicp = gdk_cicp_color_state_get_cicpcxx . . $ gdk_cicp_color_state_get_cicp(a81b5b46de96dec1).,
1015 };
1016
1017 static inline float *
1018 multiplycxx . . $ multiply(1e277b3d767caff3). (float res[9],
1019 const float m1[9],
1020 const float m2[9])
1021 {
1022 #define IDXcxx . . $ `gdk/gdkcolorstate.c:1022:9`!(i,j) 3*i+j
1023 for (int i = 0; i < 3; i++)
1024 for (int j = 0; j < 3; j++)
1025 res[IDXcxx . . $ `gdk/gdkcolorstate.c:1022:9`!(i,j)] = m1[IDXcxx . . $ `gdk/gdkcolorstate.c:1022:9`!(i,0)] * m2[IDXcxx . . $ `gdk/gdkcolorstate.c:1022:9`!(0,j)]
1026 + m1[IDXcxx . . $ `gdk/gdkcolorstate.c:1022:9`!(i,1)] * m2[IDXcxx . . $ `gdk/gdkcolorstate.c:1022:9`!(1,j)]
1027 + m1[IDXcxx . . $ `gdk/gdkcolorstate.c:1022:9`!(i,2)] * m2[IDXcxx . . $ `gdk/gdkcolorstate.c:1022:9`!(2,j)];
1028
1029 return res;
1030 }
1031
1032 GdkColorStatecxx . . $ GdkColorState# *
1033 gdk_color_state_new_for_cicpcxx . . $ gdk_color_state_new_for_cicp(95753207f9c0d5a3). (const GdkCicpcxx . . $ GdkCicp# *cicp,
1034 GErrorcxx . . $ GError# **error)
1035 {
1036 GdkCicpColorStatecxx . . $ GdkCicpColorState# *self;
1037 GdkTransferFunccxx . . $ GdkTransferFunc# eotf;
1038 GdkTransferFunccxx . . $ GdkTransferFunc# oetf;
1039 gconstpointercxx . . $ gconstpointer# to_xyz;
1040 gconstpointercxx . . $ gconstpointer# from_xyz;
1041 gconstpointercxx . . $ gconstpointer# to_yuv = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
1042 gconstpointercxx . . $ gconstpointer# from_yuv = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
1043
1044 if (cicp->color_primariescxx . . $ _GdkCicp#color_primaries. == 2 ||
1045 cicp->transfer_functioncxx . . $ _GdkCicp#transfer_function. == 2 ||
1046 cicp->matrix_coefficientscxx . . $ _GdkCicp#matrix_coefficients. == 2)
1047 {
1048 g_set_errorcxx . . $ g_set_error(ca0c191bc68fc328). (error,
1049 G_IO_ERRORcxx . . $ `<external>/13894955190784973534/gioerror.h:42:9`!, G_IO_ERROR_FAILEDcxx . . $ G_IO_ERROR_FAILED.,
1050 _cxx . . $ `<external>/16453136837583379545/gi18n-lib.h:32:10`!("cicp: Unspecified parameters not supported"));
1051 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
1052 }
1053
1054 for (guintcxx . . $ guint# i = 0; i < GDK_COLOR_STATE_N_IDScxx . . $ GDK_COLOR_STATE_N_IDS.; i++)
1055 {
1056 if (gdk_cicp_equalcxx . . $ gdk_cicp_equal(177334471ad58715). (cicp, &gdk_default_color_statescxx . . $ gdk_default_color_states.[i].cicpcxx . . $ _GdkDefaultColorState#cicp.))
1057 return (GdkColorStatecxx . . $ GdkColorState# *) &gdk_default_color_statescxx . . $ gdk_default_color_states.[i];
1058 }
1059
1060 switch (cicp->transfer_functioncxx . . $ _GdkCicp#transfer_function.)
1061 {
1062 case 1:
1063 case 6:
1064 case 14:
1065 case 15:
1066 eotf = bt709_eotfcxx . . $ bt709_eotf(fbcf3211dfe1bfd1).;
1067 oetf = bt709_oetfcxx . . $ bt709_oetf(fbcf3211dfe1bfd1).;
1068 break;
1069 case 4:
1070 eotf = gamma22_eotfcxx . . $ gamma22_eotf(fbcf3211dfe1bfd1).;
1071 oetf = gamma22_oetfcxx . . $ gamma22_oetf(fbcf3211dfe1bfd1).;
1072 break;
1073 case 5:
1074 eotf = gamma28_eotfcxx . . $ gamma28_eotf(fbcf3211dfe1bfd1).;
1075 oetf = gamma28_oetfcxx . . $ gamma28_oetf(fbcf3211dfe1bfd1).;
1076 break;
1077 case 8:
1078 eotf = NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!;
1079 oetf = NONEcxx . . $ `gdk/gdkcolorstate.c:287:9`!;
1080 break;
1081 case 13:
1082 eotf = srgb_eotfcxx . . $ srgb_eotf(fbcf3211dfe1bfd1).;
1083 oetf = srgb_oetfcxx . . $ srgb_oetf(fbcf3211dfe1bfd1).;
1084 break;
1085 case 16:
1086 eotf = pq_eotfcxx . . $ pq_eotf(fbcf3211dfe1bfd1).;
1087 oetf = pq_oetfcxx . . $ pq_oetf(fbcf3211dfe1bfd1).;
1088 break;
1089 case 18:
1090 eotf = hlg_eotfcxx . . $ hlg_eotf(fbcf3211dfe1bfd1).;
1091 oetf = hlg_oetfcxx . . $ hlg_oetf(fbcf3211dfe1bfd1).;
1092 break;
1093 default:
1094 g_set_errorcxx . . $ g_set_error(ca0c191bc68fc328). (error,
1095 G_IO_ERRORcxx . . $ `<external>/13894955190784973534/gioerror.h:42:9`!, G_IO_ERROR_FAILEDcxx . . $ G_IO_ERROR_FAILED.,
1096 _cxx . . $ `<external>/16453136837583379545/gi18n-lib.h:32:10`!("cicp: Transfer function %u not supported"),
1097 cicp->transfer_functioncxx . . $ _GdkCicp#transfer_function.);
1098 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
1099 }
1100
1101 switch (cicp->color_primariescxx . . $ _GdkCicp#color_primaries.)
1102 {
1103 case 1:
1104 to_xyz = srgb_to_xyzcxx . . $ srgb_to_xyz.;
1105 from_xyz = xyz_to_srgbcxx . . $ xyz_to_srgb.;
1106 break;
1107 case 5:
1108 to_xyz = pal_to_xyzcxx . . $ pal_to_xyz.;
1109 from_xyz = xyz_to_palcxx . . $ xyz_to_pal.;
1110 break;
1111 case 6:
1112 case 7:
1113 to_xyz = ntsc_to_xyzcxx . . $ ntsc_to_xyz.;
1114 from_xyz = xyz_to_ntsccxx . . $ xyz_to_ntsc.;
1115 break;
1116 case 9:
1117 to_xyz = rec2020_to_xyzcxx . . $ rec2020_to_xyz.;
1118 from_xyz = xyz_to_rec2020cxx . . $ xyz_to_rec2020.;
1119 break;
1120 case 12:
1121 to_xyz = p3_to_xyzcxx . . $ p3_to_xyz.;
1122 from_xyz = xyz_to_p3cxx . . $ xyz_to_p3.;
1123 break;
1124 default:
1125 g_set_errorcxx . . $ g_set_error(ca0c191bc68fc328). (error,
1126 G_IO_ERRORcxx . . $ `<external>/13894955190784973534/gioerror.h:42:9`!, G_IO_ERROR_FAILEDcxx . . $ G_IO_ERROR_FAILED.,
1127 _cxx . . $ `<external>/16453136837583379545/gi18n-lib.h:32:10`!("cicp: Color primaries %u not supported"),
1128 cicp->color_primariescxx . . $ _GdkCicp#color_primaries.);
1129 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
1130 }
1131
1132 switch (cicp->matrix_coefficientscxx . . $ _GdkCicp#matrix_coefficients.)
1133 {
1134 case 0:
1135 to_yuv = IDENTITYcxx . . $ `gdk/gdkcolorstate.c:286:9`!;
1136 from_yuv = IDENTITYcxx . . $ `gdk/gdkcolorstate.c:286:9`!;
1137 break;
1138 case 1:
1139 to_yuv = rgb_to_bt709cxx . . $ rgb_to_bt709.;
1140 from_yuv = bt709_to_rgbcxx . . $ bt709_to_rgb.;
1141 break;
1142 case 5:
1143 case 6:
1144 to_yuv = rgb_to_bt601cxx . . $ rgb_to_bt601.;
1145 from_yuv = bt601_to_rgbcxx . . $ bt601_to_rgb.;
1146 break;
1147 case 9:
1148 to_yuv = rgb_to_bt2020cxx . . $ rgb_to_bt2020.;
1149 from_yuv = bt2020_to_rgbcxx . . $ bt2020_to_rgb.;
1150 break;
1151 default:
1152 g_set_errorcxx . . $ g_set_error(ca0c191bc68fc328). (error,
1153 G_IO_ERRORcxx . . $ `<external>/13894955190784973534/gioerror.h:42:9`!, G_IO_ERROR_FAILEDcxx . . $ G_IO_ERROR_FAILED.,
1154 _cxx . . $ `<external>/16453136837583379545/gi18n-lib.h:32:10`!("cicp: Matrix coefficients %u, %s not supported"),
1155 cicp->matrix_coefficientscxx . . $ _GdkCicp#matrix_coefficients.,
1156 cicp->rangecxx . . $ _GdkCicp#range. == GDK_CICP_RANGE_NARROWcxx . . $ GDK_CICP_RANGE_NARROW. ? "narrow" : "full");
1157 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
1158 }
1159
1160 self = g_new0cxx . . $ `<external>/1123956534522462559/gmem.h:335:9`! (GdkCicpColorState, 1);
1161
1162 self->parentcxx . . $ _GdkCicpColorState#parent..klasscxx . . $ _GdkColorState#klass. = &GDK_CICP_COLOR_STATE_CLASScxx . . $ GDK_CICP_COLOR_STATE_CLASS.;
1163 self->parentcxx . . $ _GdkCicpColorState#parent..ref_countcxx . . $ _GdkColorState#ref_count. = 1;
1164
1165 /* sRGB is special-cased by being a default colorstate */
1166 self->parentcxx . . $ _GdkCicpColorState#parent..rendering_color_statecxx . . $ _GdkColorState#rendering_color_state. = GDK_COLOR_STATE_REC2100_PQcxx . . $ `gdk/gdkcolorstateprivate.h:89:9`!;
1167 self->parentcxx . . $ _GdkCicpColorState#parent..rendering_color_state_linearcxx . . $ _GdkColorState#rendering_color_state_linear. = GDK_COLOR_STATE_REC2100_LINEARcxx . . $ `gdk/gdkcolorstateprivate.h:90:9`!;
1168
1169 self->parentcxx . . $ _GdkCicpColorState#parent..depthcxx . . $ _GdkColorState#depth. = GDK_MEMORY_FLOAT16cxx . . $ GDK_MEMORY_FLOAT16.;
1170 self->parentcxx . . $ _GdkCicpColorState#parent..hue_channelcxx . . $ _GdkColorState#hue_channel. = GDK_COLOR_CHANNEL_ALPHAcxx . . $ GDK_COLOR_CHANNEL_ALPHA.;
1171
1172 memcpycxx . . $ memcpy(cc817cb175f282d). (&self->cicpcxx . . $ _GdkCicpColorState#cicp., cicp, sizeof (GdkCicpcxx . . $ GdkCicp#));
1173
1174 self->to_yuvcxx . . $ _GdkCicpColorState#to_yuv. = to_yuv;
1175 self->from_yuvcxx . . $ _GdkCicpColorState#from_yuv. = from_yuv;
1176
1177 self->eotfcxx . . $ _GdkCicpColorState#eotf. = eotf;
1178 self->oetfcxx . . $ _GdkCicpColorState#oetf. = oetf;
1179
1180 multiplycxx . . $ multiply(1e277b3d767caff3). (self->to_srgbcxx . . $ _GdkCicpColorState#to_srgb., xyz_to_srgbcxx . . $ xyz_to_srgb., to_xyz);
1181 multiplycxx . . $ multiply(1e277b3d767caff3). (self->to_rec2020cxx . . $ _GdkCicpColorState#to_rec2020., xyz_to_rec2020cxx . . $ xyz_to_rec2020., to_xyz);
1182 multiplycxx . . $ multiply(1e277b3d767caff3). (self->from_srgbcxx . . $ _GdkCicpColorState#from_srgb., from_xyz, srgb_to_xyzcxx . . $ srgb_to_xyz.);
1183 multiplycxx . . $ multiply(1e277b3d767caff3). (self->from_rec2020cxx . . $ _GdkCicpColorState#from_rec2020., from_xyz, rec2020_to_xyzcxx . . $ rec2020_to_xyz.);
1184
1185 self->namecxx . . $ _GdkCicpColorState#name. = g_strdup_printfcxx . . $ g_strdup_printf(a849077ff1b8d812). ("cicp-%u/%u/%u/%u",
1186 cicp->color_primariescxx . . $ _GdkCicp#color_primaries.,
1187 cicp->transfer_functioncxx . . $ _GdkCicp#transfer_function.,
1188 cicp->matrix_coefficientscxx . . $ _GdkCicp#matrix_coefficients.,
1189 cicp->rangecxx . . $ _GdkCicp#range.);
1190
1191 if (cicp->transfer_functioncxx . . $ _GdkCicp#transfer_function. == 13)
1192 {
1193 self->no_srgbcxx . . $ _GdkCicpColorState#no_srgb. = gdk_color_state_new_for_cicpcxx . . $ gdk_color_state_new_for_cicp(95753207f9c0d5a3). (&(GdkCicpcxx . . $ GdkCicp#) {
1194 cicp->color_primariescxx . . $ _GdkCicp#color_primaries.,
1195 8,
1196 cicp->matrix_coefficientscxx . . $ _GdkCicp#matrix_coefficients.,
1197 cicp->rangecxx . . $ _GdkCicp#range. },
1198 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
1199 }
1200
1201 return (GdkColorStatecxx . . $ GdkColorState# *) self;
1202 }
1203
1204 /* }}} */
1205 /* {{{ Private API */
1206
1207 /*<private>
1208 * gdk_color_state_get_name:
1209 * @self: a colorstate
1210 *
1211 * Returns the name of @self.
1212 *
1213 * This is *not* a translated, user-visible string.
1214 *
1215 * Returns: (transfer none): a name for representing the color state
1216 * in diagnostic output
1217 */
1218 const char *
1219 gdk_color_state_get_namecxx . . $ gdk_color_state_get_name(5247ad7030db0d80). (GdkColorStatecxx . . $ GdkColorState# *self)
1220 {
1221 return self->klasscxx . . $ _GdkColorState#klass.->get_namecxx . . $ _GdkColorStateClass#get_name. (self);
1222 }
1223
1224 /*<private>
1225 * gdk_color_state_get_no_srgb_tf:
1226 * @self: a colorstate
1227 *
1228 * This function checks if the colorstate uses an sRGB transfer function
1229 * as final operation. In that case, it is suitable for use with GL_SRGB
1230 * (and the Vulkan equivalents).
1231 *
1232 * If it is suitable, the colorstate without the transfer function is
1233 * returned. Otherwise, this function returns NULL.
1234 *
1235 * Returns: (transfer none): the colorstate without sRGB transfer function.
1236 **/
1237 GdkColorStatecxx . . $ GdkColorState# *
1238 gdk_color_state_get_no_srgb_tfcxx . . $ gdk_color_state_get_no_srgb_tf(8feb2ce0a46ae897). (GdkColorStatecxx . . $ GdkColorState# *self)
1239 {
1240 if (!GDK_DEBUG_CHECKcxx . . $ `gdk/gdkdebugprivate.h:136:9`! (LINEAR))
1241 return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
1242
1243 return self->klasscxx . . $ _GdkColorState#klass.->get_no_srgb_tfcxx . . $ _GdkColorStateClass#get_no_srgb_tf. (self);
1244 }
1245
1246 GdkColorStatecxx . . $ GdkColorState# *
1247 gdk_color_state_yuvcxx . . $ gdk_color_state_yuv(6b7eb4f7c55a0dc3). (void)
1248 {
1249 static GdkColorStatecxx . . $ GdkColorState# *yuv_cs;
1250
1251 if (g_once_init_enter_pointercxx . . $ `<external>/457917468643292165/gthread.h:283:10`! (&yuv_cs))
1252 {
1253 GdkColorStatecxx . . $ GdkColorState# *cs;
1254
1255 cs = gdk_color_state_new_for_cicpcxx . . $ gdk_color_state_new_for_cicp(95753207f9c0d5a3). (&(GdkCicpcxx . . $ GdkCicp#) { 1, 13, 5, 0 }, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
1256 g_assertcxx . . $ `<external>/15287032793271088244/gtestutils.h:275:9`! (cs);
1257
1258 g_once_init_leave_pointercxx . . $ `<external>/457917468643292165/gthread.h:290:10`! (&yuv_cs, cs);
1259 }
1260
1261 return yuv_cs;
1262 }
1263
1264 /* }}} */
1265
1266 /* vim:set foldmethod=marker: */