Commit Graph

11863 Commits

Author SHA1 Message Date
Benjamin Otte
76c1ea0449 Merge branch 'wip/smcv/gsize-is-guintptr' into 'main'
gdk: Codify the requirement that gsize is pointer-sized

See merge request GNOME/gtk!7514
2024-07-28 14:12:59 +00:00
Simon McVittie
a97f378d64 gdk: Codify the requirement that gsize is pointer-sized
This is widely assumed, but is not guaranteed by Standard C, and is
known to be false on CHERI architectures (which have 64-bit sizes and
128-bit tagged pointers). Add a static assertion to ensure that GTK
will not build on platforms where this assumption does not hold.

As discussed on GNOME/gtk!7510, if GTK switches from gsize to uintptr_t
as its representation of the underlying bits in a pointer, GTK maintainers
would prefer that to be done project-wide so that it's done consistently,
after which this static assertion could be removed.

At the time of writing, GLib makes the same assumption (GNOME/glib#2842),
but GLib contributors are gradually removing it (mostly by replacing gsize
with uintptr_t where a pointer-sized quantity is needed). Finishing
that work in GLib would be a prerequisite for being able to make GTK
work on the affected platforms.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-07-28 14:31:31 +01: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
a5aac30843 jpeg: Load grayscale as-is
We can handle grayscale textures just fine nowadays, so no need to
convert them to RGB.
2024-07-27 19:20:14 -04:00
Matthias Clasen
3149493679 jpeg: Set downloader color state explictly
This avoids surprises.
2024-07-27 19:02:59 -04:00
Benjamin Otte
ec489e673c wayland: Add preferred formats to the hash tables
So we don't look them up all the time.
2024-07-27 07:26:51 +02:00
Benjamin Otte
a904da12b7 wayland: Don't query preferred colorstate if we don't care
If there's no change callback connected, exit early, because all this
lot of work would be for invoking that callback.
2024-07-27 07:26:51 +02:00
Benjamin Otte
91865d172b wayland: Track color information identities
So we don't need to query them all the time.

Or so I thought, because I get different ones for the same colorstate.
Thx Mutter.
2024-07-27 07:26:51 +02:00
Benjamin Otte
adedb89779 wayland: Actually sync the colorstate with the compositor 2024-07-27 07:26:51 +02:00
Benjamin Otte
514dbcacd4 wayland: Actually query the preferred colorstate
We weren't doing that, so everything looked like it wanted SRGB.
2024-07-27 07:26:51 +02:00
Benjamin Otte
25c812fa87 wayland: Redo the image description code
Main changes:

1. Avoid invalid writes by not passing pointers to a GArray that
   realloc()s its data
2. Use a hash table to store image defs, instead of an array. This
   requires a custom hash/equal function
3. Make image desc computation sync, so that setting a cs always
   succeeds or always fails and doesn't depend on timing.
4. Add a few debug messages in failure paths. For lack of a category,
   they ended up in MISC.
2024-07-27 07:26:51 +02:00
Matthias Clasen
ea9f8b2f77 downloader: Add some docs
Mention the default format and color state.
2024-07-26 17:38:27 -04:00
Matthias Clasen
45c5b250b9 texture: Don't mess up color states
gdk_texture_download_surface was converting twice from the texture
color state to the target color state, with predictably bad results.
2024-07-26 17:27:20 -04:00
Matthias Clasen
f4b35093bd jpeg: Port to GdkMemoryTextureBuilder
This is in preparation for some color state handling.
2024-07-26 16:43:54 -04:00
Benjamin Otte
50403fbca8 wayland: Actually compare the right values
Wayland primaries/transfer functions aren't cicp values, so we can't
compare them.
2024-07-25 22:06:56 +02:00
Benjamin Otte
7de91d1777 wayland: We use v4 of the protocol 2024-07-25 22:06:56 +02:00
Benjamin Otte
0001562850 dmabuf: Fix Vulkan formats for P010 and friends
The P01x and P21x formats were swapped.
2024-07-25 18:53:55 +02: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
229edc5225 wayland: Normalize cicp values
We don't want to create multiple image descriptions for functionally
equivalent tuples.
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
64f4967867 png: Make loader use cicp api
This should make non-default color states work with our png
loading and saving machinery.
2024-07-24 08:16:08 -06:00
Matthias Clasen
c37fa3a895 wayland: Use cicp color states
This is entirely untested, and the Wayland protocol makes it very
annoying.
2024-07-24 08:16:08 -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
32b348776e memoryformat: Allow indirect conversions
If we don't have a direct conversion function between two
colorstates, go indirectly via rec2100-linear.
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
ebc4bb2363 wayland: Switch to v4 of the color management protocol 2024-07-23 23:37:00 -06:00
Matthias Clasen
23e4c788fa Merge branch 'dmabuf-formats-autoptr' into 'main'
gdkdmabufformats: Add autoptr definition

See merge request GNOME/gtk!7484
2024-07-23 19:48:01 +00:00
Marco Trevisan (Treviño)
e46e61643c gdkdmabufformats: Add autoptr definition 2024-07-23 19:55:47 +02:00
Jordan Petridis
cc5526e019
gdkvulkancontext: set the VkSemaphore to VK_NULL_HANDLE
Vulkan objects are integers on 32bit and it's failing when it's set to
just NULL.

```
../gdk/gdkvulkancontext.c:677:24: error: assignment to ‘VkSemaphore’ {aka ‘long long unsigned int’} from ‘void *’ makes integer from pointer without a cast [-Wint-conversion]
  677 |   priv->draw_semaphore = NULL;
```
2024-07-23 18:01:56 +02:00
Benjamin Otte
14a7b4b4b4 vulkan: Remove unused features
Now that we don't use the fancy features anymore, we don't need to
enable them.
And that also means we don't need an env var to disable it for testing.
2024-07-22 19:40:24 +02:00
Benjamin Otte
2e1686091f dmabuf: Make NULL the default colorstate in the builder
YUV dmabufs are not sRGB.

So instead of making the dmabuf builder have sRGB as the default
colorstate, add a NULL default option that makes the builder choose
the colorstate based on fourcc when build() is called.

If that happens, we pick sRGB usually, but for YUV we pick narrow range
BT601, like we did in versions before colorstates.
2024-07-22 14:54:05 +02:00
Benjamin Otte
496211727d vulkan: dmabufs require ycbcr
So make sure that GDK_VULKAN_DISABLE=ycbcr also disables dmabufs.
2024-07-22 01:28:39 +02:00
Carlos Garnacho
31a79fbd9f Merge branch 'main' into 'main'
Ignore grabbing tablet devices without pads or tools

See merge request GNOME/gtk!7470
2024-07-18 12:10:36 +00:00
Jie Liu
d8919311b1 Ignore grabbing tablet devices without pads or tools
Signed-off-by: Jie Liu <liujie01@kylinos.cn>
2024-07-18 18:19:26 +08:00
Benjamin Otte
619926ec83 dmabuf: fix mmap() calls
* We cannot map with offset, because offsets need to be page-size
  aligned. And our code doesn't expect an offset anyway.
* The error return value from mmap() is MAP_FAILED aka -1, not NULL aka
  0.
2024-07-18 04:33:14 +02:00
Benjamin Otte
1afb832ff0 dmabuf: Do a naive implementation of P010, P012 and P016
These are the common HDR formats, so we better have the baseline of
those.
2024-07-18 04:33:14 +02:00
Benjamin Otte
4966f8cdf8 vulkan: Add an acquire semaphore to frames
Vulkan requires us waiting on the image acquired from
vkAcquireNextImageKHR() before we start rendering to it, as that
function is allowed to return images that are still in use by the
compositor.
Because of that requirement, vkAcquireNextImageKHR() requires a
semaphore or fence to be passed that it can signal once it's done.

We now use a side channel to begin_frame() - calling
set_draw_semaphore() - to pass that semaphore so that the
vkAcquireNextImageKHR() call inside begin_frame() can use it, and then
we can wait on it later when we submit.

And yes, this is insanely convoluted, the Vulkan developers should
totally have thought about GTK's internal designs before coming up
with that idea.
2024-07-17 22:59:23 +02:00
Benjamin Otte
31e0ec71f2 png: Add color state support
When loading or saving png files, encode the CICP flags of the color
state into the PNG.

When loading, decode the CICP flags if available and detect the
colorstate they use.
If we do not support the cicp tags, we do not load the image.

So far, we ignore the ICC profiles.

Includes regeneration of nodeparse test *reference* output to include
the new tags we write to PNGs.
The original tests do not include those tags, so we implicitly test that
we read untagged files correctly.
2024-07-16 22:04:10 +02:00
Benjamin Otte
6c33afc13c png: Move texture data download further down
We only download the data when we actually need it for writing into the
PNG stream.

This allows modifying the download parameters (in particular color state
in the next commit) while writing out their settings, so the code for
selecting the right colorstate liives in only one place.

We have to be careful though, because the download now happens after the
setjmp(), so we need to make sure the error path handles both cases
without leaking: Where the download has happened and where it hasn't.
2024-07-16 22:03:48 +02:00
Benjamin Otte
03daf42fb5 png: Port to MemoryTextureBuilder 2024-07-16 22:03:46 +02:00
Matthias Clasen
b33b68ef75 dmabuf texture: color state support 2024-07-16 21:23:44 +02:00
Matthias Clasen
0ee8ca43d1 gl texture: color state support 2024-07-16 21:23:44 +02:00
Benjamin Otte
5e1c3c5d69 gdk: Add GdkMemoryTexture::color-state
This allows setting the color state of textures.
2024-07-16 21:23:44 +02:00
Benjamin Otte
3c8a93b972 gdk: Add GdkMemoryTextureBuilder
Same thing as dmabuf and GL texture builders. Preparation for adding
color state support to texture constructors.

As a bonus, we can now do update regions with memory textures.
2024-07-16 21:23:44 +02:00
Benjamin Otte
11543a229a texturedownloader: Add color state
... and plumb the color state through the downloading machinery, where
no matter what path it takes it ends up in
gdk_memory_convert_color_state() or gdk_memory_convert().

The 2nd of those has been expanded to optionally do colorstate
conversion when the 2 colorstates are different.
2024-07-16 21:23:44 +02:00
Robert Mader
b241fcd418 wayland/subsurface: Handle NULL-buffers in dmabuf_buffer_release
This happens when buffer creation fails in `get_dmabuf_wl_buffer()` and
we manually call `listener->release (data, NULL)`.

Fixes: 2478dd8322 ("subsurface: Split a function")
2024-07-16 01:43:15 +02:00