Commit Graph

72839 Commits

Author SHA1 Message Date
Matthias Clasen
0806fafbab widget-factory: Add an hdr image example
This uses the heif loader to show an image in
the 'color profile' notebook. The current image
isn't a very good HDR example, and should be
replaced by a more suitable image.
2022-05-11 15:01:09 -04:00
Matthias Clasen
c58606d116 Add a quick-and-dirty heif loading test
This uses libheif to load an image and produce
a texture. If the image has more than 8 bits of
chroma or luma, the texture will be 16bit.
2022-05-11 15:01:09 -04:00
Matthias Clasen
76d0edf64a Add gdk_color_profile_new_from_cicp
This is a bit preliminary, and does not handle hdr
profiles yet.
2022-05-11 15:01:09 -04:00
Matthias Clasen
9e48af467d gsk: Add FIXME
Point out where we should do colorspace conversion
in a shader.
2022-05-11 14:54:53 -04:00
Matthias Clasen
d52552b480 wip: update testsuite for changed compositing 2022-05-10 22:24:26 -04:00
Matthias Clasen
a0c72902f8 gsk: Serialize textures as tiff
This is better than png in that it allows us to
preserve floating point data without going to uin16.
2022-05-10 22:24:26 -04:00
Matthias Clasen
3d9d762998 gsk: Add profile in gsk_renderer_render_texture
Make gsk_renderer_render_texture produce a texture
that has the correct color profile attached. This
fixes the rendering of node files in the node editor.
2022-05-10 09:10:25 -04:00
Matthias Clasen
7a1fc3f259 ci: Squash a compiler warning 2022-05-10 09:10:25 -04:00
Matthias Clasen
e623007759 gsk: Fix a formatting mishap 2022-05-10 09:10:25 -04:00
Matthias Clasen
e9d54b4938 gltexture: Improve the docs a bit 2022-05-10 09:10:25 -04:00
Matthias Clasen
007777d891 colorprofile: fix up the docs a bit 2022-05-10 09:10:25 -04:00
Matthias Clasen
49fc1b5440 gdk: Introduce GdkColor
GdkColor represents a color in the real world, by combining a color
profile, an alpha valueand N component values.

gsk_render_node_draw() has been ported to use GdkColor when rendering,
which makes it so the rendering happens in a color-managed way when a
color profile has been attached to the target.
2022-05-10 09:10:25 -04:00
Matthias Clasen
5877711717 media: Use the new GL texture constructor
Use GdkGLTextureFlags in the gstreamer backend
to tell gsk that the buffers are unpremultiplied,
non-linear sRGB.
2022-05-10 09:10:25 -04:00
Matthias Clasen
5ca041c137 glarea: Use the new GL texture constructor
This lets us avoid doing the flipping in snapshot.
We can just tell gsk to do it for us.
2022-05-10 09:10:25 -04:00
Matthias Clasen
1d9af571a5 gsk: Use GL texture information
Use the flags and color profile information from
GL textures to figure out what conversions we need
to do on them.
2022-05-10 09:10:25 -04:00
Matthias Clasen
bf0f7dddc5 API: Add a new constructor for GL textures
Add a constructor that lets us provide more information
about the content of a GL texture, such as the color
profile, and whether it is premultiplied or flipped.
2022-05-10 09:10:25 -04:00
Matthias Clasen
13cdd37aa6 gsk: Support flipping gl textures
Add upside-down flipping to the list of supported
conversions when handling GL textures.
2022-05-10 09:10:25 -04:00
Matthias Clasen
3d52678635 gsk: Do texture conversions in shaders
Do linearization and premultiplication of textures
in a shader after uploading the unconverted data.
This moves move work from the cpu to the gpu.

Conversions between other colorspaces are still
done with lcms on the cpu.
2022-05-10 09:10:25 -04:00
Matthias Clasen
6d42ad564a gsk: Refactor a bit 2022-05-10 09:10:25 -04:00
Matthias Clasen
c068bd2452 gsk: Fix caching of textures 2022-05-10 09:10:25 -04:00
Matthias Clasen
3f496dbfd3 cairo: Use stem darkening for glyphs
This involves tweaking a freetype driver property
directly, since cairo font options don't cover this.

So the code is a bit ugly, but it does make text
appear darker.
2022-05-10 09:10:25 -04:00
Matthias Clasen
b46724de0f gsk: Use stem darkening for glyphs
This involves tweaking a freetype driver property
directly, since cairo font options don't cover this.

So the code is a bit ugly, but it does make text
appear darker.
2022-05-10 09:10:25 -04:00
Matthias Clasen
8fd17568f0 gsk: Linearize gl textures
GL textures are typically in non-linear sRGB,
and in that case, we need to linearize them.
2022-05-10 09:10:25 -04:00
Matthias Clasen
c4a5b72a5f gsk: Linearize colors too
Convert all the GdkRGBA colors that we have
in render nodes to linear sRGB before using
them. This brings the rendering back in line
with what cairo produces, except for the video.
2022-05-10 09:10:25 -04:00
Matthias Clasen
4ada2fe69c gsk: Apply gamma to frames
Use a shader to go from linear sRGB to sRGB when
we are done with a frame.
2022-05-10 09:10:25 -04:00
Matthias Clasen
4ec1fa0a25 gsk: Upload textures in linear sRGB
We want to do compositing in a linear colorspace,
so convert textures to linear sRGB before uploading.

Currently, this causes images to come out dark, since
we don't have a way to tell the compositor that our
framebuffer is linear, so it assumes a gamma that we
don't provide.
2022-05-10 09:10:25 -04:00
Benjamin Otte
06db24b4e1 gdk: Add GDK_DEBUG=srgb
Disables gdk_surface_set_color_profile() for backends and forces
sRGB.

This does not change any GSK renderers, it just turns off any backends
trying to hand us color profiles.
2022-05-10 09:10:25 -04:00
Benjamin Otte
41527b50ab Add crude color management impl for cairo 2022-05-10 09:10:25 -04:00
Matthias Clasen
f8157abd4b Fixes for gdk_memory_txture_new_subtexture
There were several mistakes here.
2022-05-10 09:10:25 -04:00
Benjamin Otte
46a4a31cbc x11: Implement support for color profiles
Stole the implementation from eog.

This doesn't yet update the profile when it changes though.
2022-05-10 09:10:25 -04:00
Matthias Clasen
5750de1e46 Support color profiles in pixbufs
When creating a GdkTexture from a GdkPixbuf,
see if it has an icc profile attached, and if
so, use it.
2022-05-10 09:10:25 -04:00
Benjamin Otte
aef5f3b837 widget-factory: Add tests for loading color profiles
I figured out how to generate them, yay:

  cmsHPROFILE lcms_profile;
  cmsToneCurve *curve[3];

  curve[0] = cmsBuildParametricToneCurve (NULL, 4, (double[5]) { 1.0, 0, 0, 0, 0 });
  curve[1] = cmsBuildParametricToneCurve (NULL, 4, (double[5]) { 2.4, 255.0 / 15 / 1.055, 0.055 / 1.055, 0, 15./255 });
  curve[2] = cmsBuildGamma (NULL, 2.4);
  lcms_profile = cmsCreateRGBProfile (&(cmsCIExyY) {
                                        0.3127, 0.3290, 1.0
                                      },
                                      &(cmsCIExyYTRIPLE) {
                                        { 0.6400, 0.3300, 1.0 },
                                        { 0.3000, 0.6000, 1.0 },
                                        { 0.1500, 0.0600, 1.0 }
                                      },
                                      curve);

  cmsSaveProfileToFile (lcms_profile, "foo.icc");

  cmsFreeToneCurveTriple (curve);
  cmsCloseProfile (lcms_profile);
2022-05-10 09:10:25 -04:00
Benjamin Otte
6d8f12ae48 colorprofile: Implement a global transform cache
Speeds up things by a factor of 10x, so seems like a good idea.

The cache is never purges, we might want to fix that.
2022-05-10 09:10:25 -04:00
Benjamin Otte
46e7509cf7 memoryformat: Optimize more
Make the formats allow converting to an lcms-compatible format and
then use a cmsTransform to convert between them.

Note that mixing RGBA and non-RGBA formats doesn't seem to work, so we
force all our RGB-only formats to convert to a RGBA format.
2022-05-10 09:10:25 -04:00
Benjamin Otte
2b5cbf5369 memoryformat: Do some gdk_memory_convert() massaging
* Add name support to the formats
* Add profiler mark to gdk_memory_convert()
* Split up the different branches of conversion
* Use memcpy for straight copies
2022-05-10 09:10:25 -04:00
Matthias Clasen
73bed6adc3 gsk: Avoid cairo in icon upload
Use the new memory texture magic
2022-05-10 09:10:25 -04:00
Matthias Clasen
c8fce2c35d tiff: Add color profile support
Apply an embedded icc profile when loading tiff
images, and save associated icc profile information
when saving tiff images.
2022-05-10 09:10:25 -04:00
Benjamin Otte
feb6721848 png: Handle color profiles 2022-05-10 09:10:24 -04:00
Matthias Clasen
cd13109f85 gdk: Take a profile in gdk_memory_texture_from_texture
This will let us do profile conversions at the
same time.

Update all callers.
2022-05-10 09:10:24 -04:00
Benjamin Otte
d79c7b14ff gdk: Take a profile in gdk_texture_download_surface
This way, the resulting surface can contain the pixels
in the desired color profile.
2022-05-10 09:10:24 -04:00
Matthias Clasen
007631fe1b gdk: Take a profile in gdk_texture_do_download
Allow specifying a color profile in addition to
a memory format when downloading.
2022-05-10 09:10:24 -04:00
Matthias Clasen
15cce98a31 memoryformat: Take a color profile when converting 2022-05-10 09:10:24 -04:00
Benjamin Otte
7aaaf65d6c API: Add color profile get/set for cairo
Add a centralized place to attach color profiles to.

Nothing uses that information yet, but all the backends do set it.
2022-05-10 09:10:24 -04:00
Benjamin Otte
2c96391bd2 API: Add GdkSurface::color-profile
Unused so far, but there's a private setter for backends and a public
readable property for code.
2022-05-10 09:10:24 -04:00
Matthias Clasen
03ed9592a7 gtk-demo: Add a color profile demo
This is using test images from http://displaycal.net/.
2022-05-10 09:10:24 -04:00
Benjamin Otte
85437edf3d widget-factory: Add gradient rendering test
Test how GTK draws gradients, by adding an sRGB and a linear colorspace
gradient and draw one with CSS.

Have a look which one (if any) matches.
2022-05-10 09:10:24 -04:00
Benjamin Otte
dbc0574d2e jpeg: Add color profile support 2022-05-10 09:10:24 -04:00
Benjamin Otte
5eda3eee87 API: Add gdk_memory_texture_new_with_color_profile()
A version of gdk_memory_texture_new() that allows passing a color
profile. The old version t assumes sRGB.
2022-05-10 09:10:24 -04:00
Benjamin Otte
4ac6fb72fc API: Add a GdkTexture::color-profile property
Returns the associated color profile. For now, this is always sRGB.
2022-05-10 09:10:24 -04:00
Benjamin Otte
7cd6256add API: Add GdkColorProfile
The code doesn't do anything yet, this is just the boilerplate.
2022-05-10 09:10:24 -04:00