Commit Graph

32 Commits

Author SHA1 Message Date
Matthias Clasen
ce92ce6d36 gdk: Add missing color state docs
Document the getters for oklab/okch.
2024-10-21 11:39:04 -04:00
Matthias Clasen
0170f8e261 Drop expandtab from vim modelines
This is already covered by our editorconfig.
2024-10-21 11:39:04 -04:00
Matthias Clasen
2a1b8c4fcc gdk: Add oklab and oklch color states
These are new default color states.

Tests for the tf and matrices included.
2024-10-04 20:37:09 -04:00
Matthias Clasen
4e9ebb5299 gdk: Add gdk_color_state_clamp()
Allows clamping values into the correct range to construct valid colors.
2024-08-17 18:12:23 +02:00
Matthias Clasen
0f85a40a25 colorstate: Plug a leak and allocate less
We don't need to allocate the matrices, but we do neet to free
the name of cicp color states.
2024-08-14 11:00:10 -04:00
Matthias Clasen
16ad1e428f colorstate: Don't leak names
The cicp colorstates allocate their names, so they should free
them too.
2024-08-14 11:00:10 -04:00
Benjamin Otte
3cd25516ab gdk: Improve GDK_DEBUG=linear
Keep a linear and a non-linear rendering colorstate around. That way, we
don't "return self;" from cicp colorstates and then end up with a cicp
ccs.
2024-08-14 08:30:40 +02:00
Jan Willem
85bcf9a366 docs: fix since annotation 2024-08-12 07:05:47 +00:00
Matthias Clasen
0f618ae29e Cosmetics 2024-08-11 16:31:35 -04:00
Matthias Clasen
202a51d9e3 Cosmetics 2024-08-10 22:41:31 -04:00
Matthias Clasen
03ef6a7719 colorstate: Drop xyz for now
Converting to and from xyz turns out to be more difficult than
expected, depending on what whitepoint you choose, And different
specs choose different whitepoints, so we can't directly map
css xyz to cicp xyz anyway.
2024-08-06 15:38:31 -04:00
Matthias Clasen
b8f12c5d28 cicp: Improve the docs
Fix some formatting issues, and document GdkCicpRange.
2024-07-29 11:17:13 -04:00
Matthias Clasen
50ea9450ea cicp: Fill in some more transfer functions
Handle gamma 2.2 and gamma 2.8.
2024-07-28 11:56:43 -04:00
Matthias Clasen
1373a7a6f0 Change the matrix implementation
Go from float[3][3] to float[9]. That is easier to manage in
static initialization.
2024-07-27 19:20:14 -04:00
Matthias Clasen
c9443dd04d Fix the hlg transfer function
Fix a bug in the formula, and enable hlg as a transfer function.

The tests are passing now.
2024-07-24 18:59:18 -06:00
Matthias Clasen
5f2e70df8e Drop hlg for now
For some reason, roundtrip tests  with the hlg tf are failing,
so we don't support it.
2024-07-24 17:53:12 -06:00
Matthias Clasen
a46bcc2755 Move transfer functions and matrices to a header
This way, we can write tests against them without static linking.
2024-07-24 16:45:21 -06:00
Matthias Clasen
fb10b61528 gdk: Add public api for cicp
Add a GdkCicpParams object that acts a bit like a builder for
cicp color states.
2024-07-24 16:45:21 -06:00
Matthias Clasen
d907c0a42e colorstate: Add cicp support
This adds machinery to create colorstate objects from cicp
tuples, as well as a function to return a cicp tuple for a
colorstate.

Still missing: a conversion shader for non-default colorstates.
2024-07-24 08:16:08 -06:00
Matthias Clasen
4255230e36 colorstate: Cosmetics
Document a private api.
2024-07-24 07:46:05 -06:00
Matthias Clasen
d8a0915ada colorstate: Slight reorg
Move the conversion functions out of the default section, since
we will reuse the conversion functions for cicp. No functional
changes.
2024-07-24 07:46:05 -06:00
Matthias Clasen
bbe552d6a8 Add gdk_color_state_get_convert_from
Our conversion machinery supports converting from any color
state to any default color state or back. Direct conversion
between two non-default color states isn't guaranteed. For
converting *to* a cicp color state, we need this function.
2024-07-24 07:46:05 -06:00
Matthias Clasen
54e5cc296f colorstate: Add rec2100-pq and rec2100-linear
These are wide-gamut, HDR colorstates that we will need for HDR support.
2024-07-13 15:11:07 -04:00
Matthias Clasen
2d69f35e0e colorstate: More details in the docs
Add links to srgb definitions and references.
2024-07-13 15:09:12 -04:00
Matthias Clasen
d0e2d9e2f4 colorstate: Small reorg
Introduce a helper macro.
2024-07-12 18:15:28 -04:00
Matthias Clasen
abb7e85260 colorstate: Consistent naming
Make the conversion functions use srgb_linear in their names, since
the name of the color state is srgb-linear.
2024-07-12 18:14:44 -04:00
Matthias Clasen
5cea9f9e17 Small doc fixes
Pointed out be Emmanuele Bassi.
2024-07-11 16:56:10 -04:00
Matthias Clasen
e1031ac5ad gdk: Add gdk_memory_format_convert_color_state
This allows in-place color state conversions.
2024-07-11 14:57:20 +02:00
Benjamin Otte
127b92e3db color_state: Make U8_SRGB the depth for COLOR_STATE_SRGB
This will only be used with linear compositing, so we force U8 when
we're not compositing linear.
2024-07-11 14:57:19 +02:00
Benjamin Otte
bdb6b10be8 colorstate: Add gdk_color_state_get_rendering_color_state()
Returns the linear color state that renderers should render in when
this is the target color state.

We disable this function unless linear compositing is enabled and just
return @self by default.
2024-07-11 14:57:19 +02:00
Benjamin Otte
7f9031eae8 colorstate: Add gdk_color_state_get_no_srgb_tf()
This function checks if the colorstate uses an sRGB transfer function
as final operation. In that case, it is suitable for use with GL_SRGB
(and the Vulkan equivalents).

We disable this function (by always returning NULL) unless linear
compositing is enabled, because this function is used to transition
textures and framebuffers to their linear counterparts.
2024-07-11 14:57:19 +02:00
Matthias Clasen
aa746bc0c8 gdk: Add GdkColorState
This is mostly an empty shell for now. We only have static instances
for srgb and srgb-linear, which we will use as markers during our
node processing.

In the future, this object may grow more instances, as well as the
ability to create them from and save them to icc profiles or cicp
data. And a color conversion API.
2024-07-11 14:57:19 +02:00