Commit Graph

11721 Commits

Author SHA1 Message Date
Emilio Cobos Álvarez
5ceb9a7692 [gtk4/wayland] Fix GdkMonitor sizes on Mutter without fractional scaling.
This fixes a problem that is apparent in
https://bugzilla.mozilla.org/show_bug.cgi?id=1869724, but that also
reproduces on any GTK application as described in
https://bugzilla.mozilla.org/show_bug.cgi?id=1869724#c16.

xdg_output sizes might be physical if the compositor doesn't scale them,
it seems. So to report the correct logical geometry in GDK pixels, we
need to detect this case. We do this by checking whether the wl_output
size matches the xdg_output size.
2024-01-30 20:10:36 -05:00
Benjamin Otte
216dbf1e88 Merge branch 'wip/otte/dmabuf-disjoint' into 'main'
dmabuf: Fix disjoint detection

See merge request GNOME/gtk!6830
2024-01-30 18:17:33 +00:00
Luca Bacci
57dde7e877 GdkWin32: Implement GdkDrawContext::empty_frame() vfunc 2024-01-30 16:23:28 +01:00
Benjamin Otte
9581d060d2 dmabuf: Fix disjoint detection
According to the Mesa developers, the correct way to determine
disjointness is to check the actual inode of the fd because dup()ing can
cause these duplications to happen when planes are carelessly copied or
when planes are sent over dbus or other unix sockets.

Related: https://bugs.webkit.org/show_bug.cgi?id=267578
2024-01-30 15:19:34 +01:00
Matthias Clasen
ead1b36afd Merge branch 'macos-empty-frame' into 'main'
[macos] Add callbacks for Gdk.DrawContext.empty_frame

See merge request GNOME/gtk!6819
2024-01-30 01:06:14 +00:00
Benjamin Otte
1ffa01b38a Merge branch 'contentview-step1-finished' into 'main'
[macos] Use system shadow on macOS

Closes #6255

See merge request GNOME/gtk!6785
2024-01-29 18:09:33 +00:00
Matthias Clasen
f5308dfbec wayland: Commit empty frames if needed
If we have outstanding double-buffered state (other than the
buffer itself), commit a frame even if its 'empty'.
2024-01-28 11:44:16 -05:00
Matthias Clasen
1097e1349c wayland: Add a way to check if a surface is dirty
We keep various pieces of double-buffered state on our side,
and then explicitly sync it over to the Wayland side.

Add a function to find out if we have any.
2024-01-28 11:44:16 -05:00
Arjan Molenaar
c17ac8c599 Add empty callbacks for Gdk.DrawContext.empty_frame on macOS 2024-01-27 15:34:59 +01:00
Matthias Clasen
f90e77d173 gdk: Enable fractional scaling for GL by default
The ngl renderer has good support for fractional scaling, so we
can enable this by default now.

If you are using the gl renderer, you can disable fractional
scaling with the

GDK_DEBUG=gl-no-fractional

environment variable.
2024-01-25 14:41:04 -05:00
Arjan Molenaar
6e7893d527 Let GdkDisplay decide if shadows should be drawn
Replace the `#ifdef` blocks by a backend call.
2024-01-25 12:09:10 +01:00
Matthias Clasen
83230766b2 Avoid a strdup
Not that it matters, but it looks cleaner that way.
2024-01-23 00:08:15 -05:00
Matthias Clasen
2c1562630d Revert an accidental change
This snuck in with some recent cleanups.
2024-01-23 00:07:23 -05:00
Paul Rouget
a6ce506714 [macos] Use FullSizeContent for CSD 2024-01-22 16:22:36 +01:00
Matthias Clasen
f779832861 Tweak profiling strings
Capitalize our mark names, and use GTK as category.

The justification is: it looks better in sysprof.
2024-01-21 14:02:08 -05:00
Matthias Clasen
6e8a70ada1 Drop gdk_gl_context_has_bgra
This private api turned out to be more problematic than useful,
and it isn't used anymore.
2024-01-21 08:29:33 -05:00
Carlos Garnacho
070f3a61ac gdk/wayland: Bail out on titlebar gestures with no seat
This API might be called programmatically at a time that there's no
seats, handle this situation by returning FALSE in the GDK API.

Related: https://gitlab.gnome.org/GNOME/gtk/-/issues/6335
2024-01-20 01:27:27 +01:00
Carlos Garnacho
022347fa85 gdk/wayland: Avoid activation paths with no seats
When a toplevel is focused programmatically and there is no
underlying seat, we cannot attempt to focus it with no
focus to be obtained, nor serials serials to use.

Related: https://gitlab.gnome.org/GNOME/gtk/-/issues/6335
2024-01-20 01:27:27 +01:00
Matthias Clasen
dbee1a8160 dnd: Use standard cursor names
The css spec doesn't cover the fringe 'ask' feature of DND, but
apart from that, we should use the names in the spec.

Fixes: #6337
2024-01-16 19:45:53 -05:00
Benjamin Otte
d97767014c gl: BGRA formats need a different internal format
In GLES, BGRA is still done by GL_EXT_texture_format_BGRA8888 which is
an extension that is older than GLES 2.0.

And back then, internal formats had to be specified unsized. And when
that was changed with GLES3, nobody updated the extension.
However, on OpenGL, this extension doesn't exist, and internal formats
need to be sized.

So let's use different internal formats depending on GL version.

Fixes #6333
2024-01-16 20:35:20 +01:00
Benjamin Otte
2f974a1f5a gl: Split internal format for GdkMemoryFormat into GL/GLES
This commit just duplicates the struct.

It's separate because it's just a bunch of boilerplate.
2024-01-16 20:35:20 +01:00
Benjamin Otte
4e2c7d5eb0 gl: Require GL/GLES flag when looking up memory formats
This code just adds the argument to the function and fixes all callers.

It's separate because it's just a bunch of boilerplate.
2024-01-16 20:35:20 +01:00
Maximiliano Sandoval
f57300b924
Use GDK_NO_MODIFIER_MASK in default prop values 2024-01-13 01:30:02 +01:00
Emilio Cobos Álvarez
2f5278a139
[gtk4/wayland] Infer edge constraints from tiled edges.
This is the Gtk4 version of !6742, which fixes the same bug as described
there.
2024-01-12 22:40:22 +01:00
Matthias Clasen
7ad7c0d8c1 Merge branch 'switch-shapes' into 'main'
switch: Follow "switch-shapes" setting

Closes #5354

See merge request GNOME/gtk!6731
2024-01-11 19:19:58 +00:00
Florian Müllner
bf0120f73d switch: Follow "show-status-shapes" setting
Whether or not switches include shapes to indicate their ON/OFF
state is currently controlled by the stylesheet (in particular
the HighContrast style).

However there are use cases for both using the HighContrast style
without shapes, and for using shapes with the regular stylesheet,
so follow the newly added "show-status-shapes" setting instead.

https://gitlab.gnome.org/GNOME/gtk/-/issues/5354
2024-01-11 01:33:16 +01:00
Florian Müllner
b8a61f7899 wayland/display: Don't notify "icon-theme" on high-contrast changes
Since commit c3706ea9ec, the "high-contrast" setting no longer
forces the "HighContrast" icon theme.
2024-01-10 15:46:46 +01:00
Peter Hutterer
04870fc1a1 gdk/wayland: Reset cursor_is_default on proximity out
For tablet tools if we have NULL cursor, we use the default cursor
instead. This provides us with a tablet cursor when an application never
sets the cursor.

However, on proximity out when we clear said cursor we also
need to toggle off cursor_is_default, otherwise on the next proximity in
we assume we already have a cursor and never update it again.

This leads to an invisible cursor over GTK application when the tablet
tool is brought into proximity over the widget (but not when moving into
the widget from the outside).

Closes: #6312
2024-01-10 00:25:01 +00:00
Spencer Burris
f3ec58d290 Add missing space to warning 2024-01-09 16:57:26 -07:00
Matthias Clasen
59578c6d18 Fix typos throughout
These were pointed out by codespell.
2024-01-07 20:44:05 -05:00
Matthias Clasen
7bf8669d97 gdk: Cosmetics 2024-01-07 19:31:01 -05:00
Benjamin Otte
7830535c04 vulkan: Guard dmabuf code with HAVE_DMABUF 2024-01-07 15:07:15 +01:00
Benjamin Otte
543c7ae52a vulkan: Disable gdk_surface_create_vulkan_context()
... and deprecate it.

It will now always return NULL and error out.

We do not want to expose any Vulkan internals in the public API.
2024-01-07 14:47:22 +01:00
Benjamin Otte
3ac50b81f2 vulkan: Make gdk_display_create_vulkan_context() take a surface
This is so we can deprecate gdk_surface_create_vulkan_context() which is
public API in the next commit.
2024-01-07 14:47:22 +01:00
Benjamin Otte
6bac377fa5 gdk: Don't include vulkan.h in public API anymore 2024-01-07 14:47:22 +01:00
Benjamin Otte
b486588883 dmabuf: Use gsk_renderer_realize_for_display()
We want to use the correct display when realizing our dmabuf
downloaders.

It's a good thing that the inspector doesn't use dmabufs, isn't it?
2024-01-07 14:47:22 +01:00
Benjamin Otte
d21467e2e8 gdk: Remove all VulkanContext API
All API for GdkVulkanContext gets removed here. It was experimental and
it's not a good API. So get rid of it.
2024-01-07 14:47:22 +01:00
Benjamin Otte
1dbd74e181 Merge branch 'wip/otte/gpu' into 'main'
Add new unified renderer

See merge request GNOME/gtk!6588
2024-01-07 07:44:16 +00:00
Benjamin Otte
03cd652063 gpu: Disable the ubershader when shaders aren't nonuniform
If shaders don't support nonuniform indexing, we emulate it via if/else
ladders (or switch ladders) which get inlined by the GLSL compiles and
massively blow up the code.

And that makes compilation of the shaders take minutes and results in
shader code that isn't necessarily faster.

So we disable it on GL entirely and on Vulkan if the required features
aren't available.

As it's only an optimization and does not fall back to Cairo anymore,
this should be fine.
2024-01-07 08:18:36 +01:00
Benjamin Otte
64e5c76323 png: Don't set a size limit when saving
gdk_texture_save_to_png_bytes() cannot fail, so ensure that it doesn't.

Testsuite has been updated to check for this case.

Note that we do not load the PNG file that we generate here.
Loading is a lot more scary than saving after all.
If people want to load oversized PNG files, they should use a real PNG
loader.
2024-01-07 07:22:53 +01:00
Benjamin Otte
cb5c994cd9 rgba: Add a few macros
... and use them.

Those macros hopefully make code more readable.
2024-01-07 07:22:52 +01:00
Benjamin Otte
93d681ae77 vulkan: Add a Vulkan downloader
This is using the Vulkan renderer.

It also allows claiming support for all the formats that only Vulkan
supports, but that neither GL nor native mmap can handle.
2024-01-07 07:22:52 +01:00
Benjamin Otte
62d917eb08 vulkan: Use vulkan feature flags for incremental present
I did it because it unifies the code.

But it also gains the benefit of being debuggable because it can
now be turned off via GDK_VULKAN_SKIP=incremental-present
2024-01-07 07:22:52 +01:00
Benjamin Otte
d4c4e4bbc5 gpu: sync dmabufs via semaphores
This ensures both that we signal a semaphore for a dmabuf when we export
an image and that we import semaphores for dmabufs and wait on them.

Fixes Vulkan node-editor displaying the Vulkan renderer in the sidebar.
2024-01-07 07:22:52 +01:00
Benjamin Otte
38c0e2bdf6 gpu: Update the pipeline cache
When a new shader was compiled, queue a save of the pipeline cache.
2024-01-07 07:22:52 +01:00
Benjamin Otte
96e579501f gpu: Add GDK_VULKAN_SKIP env var
The variable forces skipping of optional Vulkan features. This is useful
for testing.

Also debug-print the features in use.
2024-01-07 07:22:51 +01:00
Benjamin Otte
7dcb7d7d0f gpu: Add Vulkan feature flags for more advanced features
Code continues if those features aren't available, buit is probably
broken.
2024-01-07 07:22:51 +01:00
Benjamin Otte
ee93f88268 vulkan: Add support for enumerating dmabuf formats
This code does not add a downloader, so we do not claim support for all
the new formats.

It just queries the formats. But this can be used to import dmabufs
directly into the Vulkaan renderer.
2024-01-07 07:22:51 +01:00
Benjamin Otte
223d1343de gpu: Add GdkDisplay::vulkan_features
use it to collect the optional features we are interested in and turn
them on only if available.

For now we add the dmabuf features, but we don't use them yet.
2024-01-07 07:22:51 +01:00
Benjamin Otte
e3c70645f9 vulkan: Turn Vulkan instances into init/ref/unref
This is not yet used.
2024-01-07 07:22:49 +01:00
Matthias Clasen
99844c8ccf rect: Annotate some functions as pure
gdk_rectangle_equal and gdk_rectangle_contains_point are pure.
2024-01-06 17:18:18 -05:00
Matthias Clasen
3f513f3cc7 x11: Add a forgotten empty_frame implementation
This was causing warnings when using GLX.
2024-01-06 09:36:25 -05:00
Matthias Clasen
854910cc17 gdk: Make a warning more useful
We can just print out what is missing where, instead of a riddle.
2024-01-06 09:36:25 -05:00
Matthias Clasen
6227592dfa docs: Fix: gdk->gtk and gdk->gsk links
gi-docgen can only generate links for dependencies, so we have
to manually expand to a relative url here.

fixup
2024-01-05 14:57:07 -05:00
Benjamin Otte
825c97be6c glcontext: Mark RGB16F as not renderable
According to EXT_color_buffer_half_float it should be renderable, but it
fails to glGenerateMipmap() with Mesa 23.3 so just pretend it's not
renderable until that is fixed.

Fixes CI from failing.
2024-01-03 16:05:25 +01:00
Benjamin Otte
25f99f35f6 glcontext: RGB32F is not renderable
I naively assumed the EXT_color_buffer_float and
EXT_color_buffer_half_float extensions would mirror each other, but they
do not. The float extension explicitly excludes RGB32F from the
renderable formats.
2024-01-03 16:05:25 +01:00
Benjamin Otte
b719f3bd60 glcontext: Fix a mixup of flags
I swapped RENDERABLE and FILTERABLE when building this table.
2024-01-03 16:05:25 +01:00
Matthias Clasen
726d5b25e8 Merge branch 'bilelmoussaoui/add-missing-annotations' into 'main'
gi: Add missing Since annotations

See merge request GNOME/gtk!6701
2024-01-03 13:35:44 +00:00
Bilal Elmoussaoui
2cd550cdbc gi: Add missing Since annotations 2024-01-03 08:49:39 +01:00
Benjamin Otte
3e4d0b69d4 gdkpng: Make the png loader safer against overflows
Load images that result in a texture >4GB in size.

And now let me keep playing with my 60k x 60k image, thanks.
I'm trying to OOM my GPU.
2024-01-03 04:11:35 +01:00
Luca Bacci
e4e0c27f58 Merge branch 'fix-wgl-leak' into 'main'
GdkWin32: Do not create multiple WGL contexts for the dummy window

Closes #6285

See merge request GNOME/gtk!6688
2023-12-27 15:43:54 +00:00
Luca Bacci
4e5456c8c3 GdkWin32: Do not create multiple WGL contexts for the dummy window
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/6285
2023-12-27 16:26:06 +01:00
Maximiliano Sandoval R.
e857f0a3af Add Since annotations to enums
Doing this in a way that is picked up by gobject-introspection
requires splitting off new enum members into separate doc
comments, which is a bit unfortunate.
2023-12-22 08:47:47 -05:00
Benjamin Otte
c21ca4811e vulkan: Require Vulkan 1.3
Some dmabuf formats were added in Vulkan 1.3.

Note that this does not require the Vulkan drivers to be version 1.3 -
it just means compilation against libvulkan 1.3
2023-12-21 17:21:54 +01:00
Benjamin Otte
96152303a6 dmabuf: Let the EGL code initialize GL
The EGL downloader initialization already calls prepare_gl(), so no need
to call it in init_dmabuf_formats(), too.
2023-12-21 17:21:52 +01:00
Benjamin Otte
d2a85abf79 Merge branch 'wip/otte/dmabuf-refactoring' into 'main'
dmabuf refactoring

See merge request GNOME/gtk!6678
2023-12-20 10:25:29 +00:00
Benjamin Otte
74620ffc46 dmabufdownloader: Add a close() function
We need to unrealize renderers before unreffing them. This vfunc takes
care of that.
2023-12-20 10:59:25 +01:00
Benjamin Otte
568eed9477 dmabuf: Turn the downloader into an interface
This way, we can move the actual downloader code into GSK - by just
implementing the interface in the GskGLRenderer.
2023-12-20 10:59:25 +01:00
Benjamin Otte
26561ab2e7 dmabuf: Refactor downloader vfuncs
This is in preparation for future commits. It also makes the API
clearer.
2023-12-20 01:51:46 +01:00
Benjamin Otte
26060b1be2 dmabuf: move DmabufTexture typedef
Preparation work.
2023-12-20 01:51:46 +01:00
Benjamin Otte
210c71b856 egl: Split out a function
This makes no sense by itself, but we want to create the EGLImage at
DmabufTexture construction so that we can actually reject dmabufs that
we can't create EGLImages for.

This will make it possible to bail when the stride limitation for AMD
GPUs hits.
2023-12-20 01:51:46 +01:00
Benjamin Otte
7206060450 dmabuf: Move thread marshalling into DmabufTexture
All downloaders are going to need this, it would make no sense if they
all need to duplicate that code.
2023-12-20 01:51:46 +01:00
Matthias Clasen
31cd2b19cd Merge branch 'macos-pre-10.13' into 'main'
gdk/macos: fix builds on macOS before 10.13

Closes #5738

See merge request GNOME/gtk!5813
2023-12-19 01:20:18 +00:00
Benjamin Otte
738b48c660 dmabufegl: Remove unsued argument from function 2023-12-18 23:34:47 +01:00
Benjamin Otte
66b992c3c0 dmabuf: Change the way downloaders work
Instead of having an add_formats() function, make the get_downloader()
function add the formats.

This allows putting the actual downloader in a different place from the
initialization code.
2023-12-16 21:36:21 +01:00
Benjamin Otte
b19f71dd24 dmabuf: Add Vulkan formats to the large table
This is done without testing, just doing my best to map all the DRM
formats to VkFormats.

Once people start using them, they'll figure it out when it's wrong.
(Somebody needs to write a testsuite.)
2023-12-16 19:16:50 +01:00
Benjamin Otte
cccec91b66 memoryformat: Put dmabuf fourccs into the big format table
I'm concentrating the data about memory formats, and this part was
missing.
2023-12-16 17:01:42 +01:00
Benjamin Otte
00566261b2 dmabuf: Explode the DmabufFormatInfo array
it's growing more and mroe, and it gets too wide and unreadable
otherwise.
2023-12-16 09:21:20 +01:00
Benjamin Otte
888b9ee352 dmabuf: Don't use a downloader for builtin downloads
When we use the builtin downloads via mmap(), it's a special case where
we don't need to initialize subsystems and query them for support. We
know what we can and can't do.

Also, we want to use these formats with the lowest priority but pick the
downloader first for supported formats, and queueing it in the
downloaders list doesn't reflect that. So don't do it.
2023-12-16 09:21:19 +01:00
Benjamin Otte
f0eceb4aa3 dmabuf: Remove out argument
The format is the same everywhere, so instead of letting every
implementation do the same thing, do it in a central place instead.
2023-12-16 09:20:36 +01:00
Benjamin Otte
ff082a7758 memoryformat: Add Vulkan format information
This is not used yet, but I want to add it, so that it exists.

That way, when we add new formats, people don't forget to add the Vulkan
formats.
2023-12-16 09:20:36 +01:00
Benjamin Otte
f357623170 memoryformat: Fix broken swizzle values
I can't copy/paste.
2023-12-16 09:20:29 +01:00
Matthias Clasen
c48a3152f0 memoryformat: Expand docs
This captures some irc exchanges about the intended use of
the new memory format apis.
2023-12-13 12:44:20 -05:00
Benjamin Otte
81adf6be22 dmabuf: Add gdk_dmabuf_fourcc_is_yuv()
In the future, we want to be using GdkColorState instead, but for now,
let's use this.

Also remove a duplicate entry in the list of formats.
2023-12-13 05:54:06 +01:00
Benjamin Otte
6ad9db0bf0 Merge branch 'texture-diff-against-distant-ancestors' into 'main'
texture: Enable texture diff against arbitrarily distant ancestors

See merge request GNOME/gtk!6644
2023-12-12 01:46:05 +00:00
Benjamin Otte
486157f6bf Merge branch 'wip/otte/for-main' into 'main'
testsuite: Add a test for opacity + color-matrix nodes

See merge request GNOME/gtk!6659
2023-12-12 01:05:00 +00:00
Benjamin Otte
5ca4ab3aaa dmabuf: Add gdk_dmabuf_import/export_sync_fd()
Vulkan needs this.

This code is following the code that compositors with Wayland support -
like wlroots - are doing.

The code was introduced to Linux in
https://lore.kernel.org/dri-devel/20220506180216.2095060-1-jason@jlekstrand.net/
2023-12-12 01:49:41 +01:00
Benjamin Otte
a37b3fb691 dmabuf: Add gdk_dmabuf_ioctl()
The function is a copy of libdrm's drmIoctl() and handles EINTR and
EAGAIN error.s

Use it for the sync ioctls in the dmabuf mmaping calls.
2023-12-12 01:49:41 +01:00
Benjamin Otte
4dfc07ef57 memoryformat: Fix variable types
Use the same types that GL uses.
2023-12-12 01:49:41 +01:00
Benjamin Otte
e3c85be53f memoryformat: Add gdk_memory_format_get_fallbacks()
Track fallback formats to use in the memoryformat directly instead of
using in the GL uploading code.

First of all, this allows sharing the code and ensuring all our
renderers use the same fallback mechanism.

But also, this allows tracking fallbacks per-format which is useful
because the fallback formats aren't really a tree. We want to make
FLOAT16 fall back to FLOAT32 when not available, but we also want
FLOAT32 fall back to FLOAT16.
By tracking the fallbacks per-format, we can achieve that.
2023-12-12 01:49:40 +01:00
Benjamin Otte
0f5fda2277 memoryformat: Introduce new (private) API
Add gdk_memory_format_get_premultiplied() and
gdk_memory_format_get_straight() which return the matching
premultiplied/straight format.

Use this to pick the premultiplied format when uploading GL textures.

And remove the duplication in the dmabuf code, where we can now use
these functions instead of tracking both the premultiplied and straight
alpha versions.
2023-12-12 01:49:40 +01:00
Benjamin Otte
0889037959 gltexture: Use the right format to download
When the format is set correctly, which it should be, we should just use
it.

So do that.
2023-12-12 01:49:40 +01:00
Benjamin Otte
ee56ad792c memoryformat: Fix 2 broken formats
They are straight alpha, and the GL renderer isn't using them yet, so
existing code is not affected.
2023-12-12 01:49:40 +01:00
Benjamin Otte
5688b7b4bb gl: Add a new alternative format
Add an "RGBA" format that just maps to the swizzled version of the
default format.

This way, BGR gets mapped to RGB + swizzling first before trying to map
it to the default format for the depth.

The benefit here is that this format has the same memory width, so
uploading/downloading code can treat it equivalent to the original
format and there's no conversion neccessary later.
2023-12-12 01:49:40 +01:00
Benjamin Otte
84de90756d memoryformat: Make the big array more readable
Prefix the struct members with their name, similar to how our Vulkan
code looks.
2023-12-11 22:11:28 +01:00
Benjamin Otte
3a1349e8ef gl: Make gdk_memory_format_gl_format() no longer check support
Now that we have gdk_gl_context_get_memory_flags() and code can use that
function, make the code do that.

Remove support checks from gdk_memory_format_gl_format().

This is an initial naive port that doesn't try to make use of the finer-grained
flags yet.
2023-12-11 07:33:26 +01:00
Benjamin Otte
5485d806c5 glcontext: Add gdk_gl_context_get_memory_flags()
Checks which features of a given memory format are supported by
the current GL implementation.

We check:
 * usable: Can be used as a texture with NEAREST filter
 * renderable: Can be used as a render target
 * filterable: Can be used with GL_LINEAR

In normal GL, all formats are all of these things, but GLES is a lot
more picky.

So far nobody uses this.
2023-12-11 07:33:26 +01:00
Benjamin Otte
8fd02f6fa2 subsurface: Do not punch holes for subsurfaces that are above
If a subsurface is not below, it is visible no matter what the opaque
region is.

Also, we don't need to care about transparency in the subsurface if we
ignore it anyway. So this is a win-win.
2023-12-11 07:32:06 +01:00
Benjamin Otte
9bc0ad9a13 gdk: Handle subsurface opaque region with transparency
We accept transparent subsurfaces for passthrough now, when they are
above the surface.
But we did not unset the opaque region to empty when the texture is
transprent.
2023-12-11 07:32:06 +01:00
Benjamin Otte
abf942efe5 dmabuf: Don't leak the display 2023-12-09 19:32:39 +01:00
g.willems
dfe7afdb04 gdk/win32: support default-settings debug flag 2023-12-09 17:59:24 +01:00
Ben Mather
1629b072fe texture: Enable texture diff against arbitrarily distant ancestors 2023-12-08 11:29:56 +00:00
Matthias Clasen
7cc5d5c7a5 Revert "Merge branch 'rgba-new-from-string' into 'main'"
This reverts commit 77f40d7508, reversing
changes made to b969f4649d.

It turns out we did not have agreement on this after all.
2023-12-02 10:55:35 +05:45
Arjan Molenaar
6948a74d72 Fix function signature warning
No arguments -> void
2023-11-28 21:24:10 +01:00
Matthias Clasen
77f40d7508 Merge branch 'rgba-new-from-string' into 'main'
Add convenience function gdk_rgba_new_from_string()

See merge request GNOME/gtk!6599
2023-11-28 17:56:21 +00:00
FeRD (Frank Dana)
f4f25e584c Fix docs function reference 2023-11-27 21:16:44 -05:00
FeRD (Frank Dana)
b049a3501a Additional review fixes 2023-11-27 19:44:24 -05:00
Emmanuele Bassi
0114fad8a5 Style/doc fixes from review 2023-11-28 00:42:19 +00:00
Matthias Clasen
6961c1fe4a Use O_CLOEXEC instead of FD_CLOEXEC
GLib is complaining vocally about this.
2023-11-27 17:50:18 -05:00
Matthias Clasen
b937c17985 wayland: Be more careful when loading cursors
Make sure we don't access the cursor_images array out of bounds.

Related: #6234
2023-11-27 13:58:38 -05:00
FeRD (Frank Dana)
114d0621aa Fix coding style issues 2023-11-26 16:19:06 -05:00
Matthias Clasen
d72fd951e1 Quiet a compiler warning 2023-11-26 08:47:51 -05:00
Matthias Clasen
c99f62aef1 Merge branch 'wip/dnd-fixes' into 'main'
DnD fixes

See merge request GNOME/gtk!6608
2023-11-25 17:59:39 +00:00
FeRD (Frank Dana)
39db73dff1 Add gdk_rgba_new_from_string()
Signed-off-by: FeRD (Frank Dana) <ferdnyc@gmail.com>
2023-11-24 22:19:39 -05:00
Benjamin Otte
d7bc4c719b dmabuf: Remove unused headers 2023-11-25 01:44:34 +01:00
Benjamin Otte
725857e15b dmabuf: Add a fallback list of fourccs
That way, we can work with older libdrm versions.

The list was generated via a bit of sed and grep from the current
dmabuf-fourcc.h, which is why I put it into its own file and included
all the formats, no matter how old they are.
2023-11-25 01:44:34 +01:00
Benjamin Otte
50ee872978 dmabuf: Add gdk_dmabuf_get_fourcc()
Returns the fourcc for a given GdkMemoryFormat.

Not sure if this is the best name, but I didn't know a better one.
2023-11-25 01:44:34 +01:00
Benjamin Otte
b6c82c6b54 dmabuf: Add all formats
Add the matching GdkMemoryFormat for all dmabuf formats.

This way, we don't fall back to RGBA8 for 10- and 16-bit formats that we
don't support natively when EGL or Vulkan use them.

Also includes corrections for a few mixups.
2023-11-25 01:44:34 +01:00
Benjamin Otte
1bf94b045c dmabuf: Refactor function
1. Don't require passing in a GdkDisplay

2. return TRUE/FALSE if a format was found, so calling code can
   decide how to handle failure itself
2023-11-25 01:44:34 +01:00
Matthias Clasen
f21175b3d0 frameclock: Inline a few things
There is no need to call type-checking getters in a loop.
2023-11-24 17:53:34 -05:00
Carlos Garnacho
988b9de210 gdk/wayland: Pass surface-relative coordinates in DnD events
Make this event behave like the other regular events, and emit
coordinates based on native surfaces. Fixes DnD over popovers
finding the correct coordinates.
2023-11-24 23:35:45 +01:00
Carlos Garnacho
0c19ef6c2c gdk/wayland: Improve recent serial lookup
This function takes an event, so the place(s) that do
not have one readily available can only pass NULL, so
the serial lookup will only work for the pointer.

Pass a device (plus optional sequence) to this function,
as these places do at least have the corresponding
GdkDevice at hand.

Fixes serial lookups for DnD, for other devices than
pointers (e.g. tablets, or touch).
2023-11-24 23:30:36 +01:00
Maximiliano Sandoval R.
3a8834a437
gdk-enums: Add GDK_NO_MODIFIER_MASK 2023-11-24 18:04:56 +01:00
Matthias Clasen
b7a1b1d7ee Fix some static analysis warnings 2023-11-24 10:35:57 -05:00
Matthias Clasen
57e382b59c Merge branch 'sumibi-yakitori/fix-mouse-cursor-on-macos' into 'main'
macos: Change to send motion events to NSApp

Closes #6134

See merge request GNOME/gtk!6451
2023-11-24 13:06:53 +00:00
Matthias Clasen
a90a6c4517 Address various static analysis complaints
These were picked out of the scan_build logs in ci.
2023-11-22 00:07:47 -05:00
Matthias Clasen
c99c06f0da wayland: Careful offloading with fractional scales
Sadly, subsurface positioning is undefined in this case. We'll
trust the compositor to not mess up if the device coordinates
after applying the scale are integral, but otherwise, we'll
decline.
2023-11-21 13:47:10 -05:00
Matthias Clasen
bda8f5393d wayland: Allow attaching (some) non-opaque textures
Allow translucent textures when we are raising the subsurface.
2023-11-21 13:24:04 -05:00
Matthias Clasen
160fa969d4 subsurface: Replace place_above/below
Instead, do it all in attach(), which becomes more and more like
ConfigureWindow. This is good, because it will let us take the
above-ness into account when making decisions about attaching.
2023-11-21 13:24:04 -05:00
Benjamin Otte
edf33a6617 Merge branch 'wip/otte/for-main' into 'main'
subsurface: Don't marka failure as success

See merge request GNOME/gtk!6594
2023-11-21 17:01:54 +00:00
Benjamin Otte
86587a9328 subsurface: Don't marka failure as success
There was one branch in the success case that turned it into a failure,
yet we were still reporting a success (and discarding the buffer).

Don't do that.
2023-11-21 17:31:40 +01:00
Matthias Clasen
463b6dd1fd Merge branch 'egl-device-info' into 'main'
EGL: Print out the device info

See merge request GNOME/gtk!6590
2023-11-21 05:04:35 +00:00
Matthias Clasen
88e1f77f90 EGL: Print out the device info
This may become more relevant info, with dmabuf formats being
tied to specific devices.
2023-11-20 23:40:00 -05:00
Matthias Clasen
eae0e15b9d wayland: Move subsurface creation code
This belongs with all the other subsurface handling.
2023-11-20 18:01:09 -05:00
Matthias Clasen
2dcec44714 Drop the nograbs debug value
This was only used in the x11 backend, and I haven't seen it
actively recommended for debugging anything in ages.
2023-11-20 08:02:03 -05:00
Matthias Clasen
f04c819439 Drop the gl-legacy debug value
The consensus is that we can do without this.
2023-11-20 08:02:02 -05:00
Matthias Clasen
699c6d6159 Use GLES by default
With the advent of dmabuf support, using GLES has become more
attractive, since we can use its external texture support to
support more dmabuf formats.

You can go back to the previous preference order by setting

    GDK_DEBUG=gl-prefer-gl
2023-11-19 08:07:03 -05:00
Matthias Clasen
025b846fce Add a debug value to prefer desktop GL
This will be used in the next commit, when we change the default
preference to be GLES.
2023-11-19 08:07:02 -05:00
Matthias Clasen
fcdbab3f69 gl: Tweak debug values for GL api selection
Replace GDK_DEBUG=gl-gles with GDK_DEBUG=gl-disable-gl, and add
a GDK_DEBUG=gl-disable-gles to match.
2023-11-19 08:07:02 -05:00
Luca Bacci
0b853f62ed Merge branch '6203_gdk_win32_precalculate_keymap' into 'main'
GdkWin32: precalculate keymap at display opening

Closes #6203

See merge request GNOME/gtk!6566
2023-11-18 13:24:21 +00:00
Matthias Clasen
d4a569057f Cosmetics: Typo fix 2023-11-16 20:54:15 -05:00
Matthias Clasen
c5727df568 dmabuf: Add support for separate alpha formats
Support dmabuf formats with alpha in a separate plane.

Related: #6208
2023-11-16 20:53:52 -05:00
Benjamin Otte
7406cea257 Merge branch 'wip/otte/for-main' into 'main'
wayland: Don't create a new wl_buffer if the texture didn't change

See merge request GNOME/gtk!6577
2023-11-16 23:54:57 +00:00
Benjamin Otte
010ff81b2f wayland: Don't create a new wl_buffer if the texture didn't change
Avoids flickering in Mutter - which is probably a mutter bug.

But it also reduces traffic, so it's a good thing anyway.
2023-11-17 00:22:27 +01:00
Matthias Clasen
6eb6b0cb50 Cosmetics: typo fix 2023-11-15 06:45:52 -05:00
Matthias Clasen
c81954120a Merge branch 'fix-giodesktopappinfo-check' into 'main'
Revert "Conditional check for gdesktopappinfo header"

See merge request GNOME/gtk!6568
2023-11-15 05:13:08 +00:00
Matthias Clasen
4bdc44f4af Revert "Conditional check for gdesktopappinfo header"
This reverts commit 13b94dab10.

As pointed out in #6557, this commit is broken and causes
gio/gdesktopappinfo.h to never be found.
2023-11-14 23:45:17 -05:00
Matthias Clasen
429056c214 Merge branch 'wip/otte/for-mclasen' into 'main'
gl: Don't punch hole if the subsurface is above

See merge request GNOME/gtk!6567
2023-11-15 00:26:45 +00:00
Benjamin Otte
acecf519bc offload: Reject non-integer rectangles
We shouldn't just fudge with coordinates if we want accurate rendering.
2023-11-14 21:55:10 +01:00
Benjamin Otte
b2fbdcda41 subsurface: Report better error messages when rejecting textures 2023-11-14 21:54:38 +01:00
Luca Bacci
2803189afd Merge branch 'gdkwin32_modernize_clipboard' into 'main'
GdkWin32: switch to new clipboard API

Closes #442

See merge request GNOME/gtk!6560
2023-11-14 20:09:55 +00:00
g.willems
ad08c1444a win32: precalculate keymap at display opening
The default keymap and keymap layouts are calculated on request.
If done once a surface is setup and listening at win32 events,
we may then enter in a recursive loop.
To avoid this, precalculate the keymap as soon as displays are open.

Fixes #6203
Closes #6203
2023-11-14 20:26:05 +01:00
Benjamin Otte
46d4c70cd7 offload: Only print one debug message
... when failing to create the wl_buffer.
2023-11-14 15:04:38 +01:00
Benjamin Otte
4920ac4a57 offload: Move a debug message
If we fail to attach a buffer, we don't want to print this.
2023-11-14 15:04:38 +01:00
Benjamin Otte
190e7da317 wayland: Don't g_warning() on expected error
Print a GDK_DEBUG() message instead.
2023-11-14 13:06:05 +01:00
Matthias Clasen
00d7d4b17b wayland: Implement empty_frame in draw contexts 2023-11-13 22:17:35 +01:00
Matthias Clasen
9eef566b54 gdk: Introduce empty frames in GdkDrawContext
We need a way to commit pending subsurface changes, even when no
drawing happened for the frame. empty_frame() is that way.
2023-11-13 22:17:35 +01:00
Matthias Clasen
ca054bfdc9 wayland: Request frame callbacks on subsurfaces
We need this for the case when the subsurface completely covers
up the main surface. Without it, we just stop updating.
2023-11-13 22:17:35 +01:00
Matthias Clasen
59dbfb0843 wayland: Implement subsurface api
This is not used anywhere yet.
2023-11-13 22:17:35 +01:00
Matthias Clasen
223e27e7dc gdk: Add private subsurface api
Add api to allow creating subsurfaces, attaching textures to them,
and changing the stacking order.

This is just the api, there is no implementation yet.
2023-11-13 22:17:35 +01:00
Matthias Clasen
efe1415429 gdk: Add a debug flag for subsurfaces
You can now use GDK_DEBUG=offload to get debug spew about
subsurfaces and graphics offload.
2023-11-13 22:17:35 +01:00
Matthias Clasen
489723916d wayland: Get format info for dmabufs
For now, all we do with it is dump the formats if you
set GDK_DEBUG=misc. In the future, this will be used
when attaching dmabufs to subsurfaces.
2023-11-13 22:17:35 +01:00
g.willems
a58424588f win32: switch to new clipboard API
This is a backport of !1143 to gtk4.

SetClipboardViewer() API is obsolete is prone to clipboard chain breaks
from other applications.
Use recommended AddClipboardFormatListener() instead.

Fixes #442
2023-11-13 21:29:48 +01:00
Matthias Clasen
b24ae31716 dmabuf: Improve consistency of debug messages
Make sure all our dmabuf debug messages are display-scoped so the
inspector doesn't trigger them, use the same formatting throughout,
and improve consistency of wording here and there.
2023-11-12 13:02:58 +01:00
Matthias Clasen
7cf805c8b3 dmabuf: Add a debug message for format fallback
This may be helpful in pinpointing why a dmabuf format behaves
unexpectedly.
2023-11-12 11:24:37 +01:00
Matthias Clasen
6ae9cbfe0f dmabuf: NV12 is opaque
Getting this wrong matters, since we won't offload textures in
non-opaque formats. Found by Robert Mader. At the same time,
unify the two places we have for mapping from fourcc to memory
format.
2023-11-11 23:56:01 +01:00
Benjamin Otte
a9e4993184 Merge branch 'wip/otte/enable-debug' into 'main'
Remove G_ENABLE_DEBUG around debug checks

See merge request GNOME/gtk!6546
2023-11-07 15:12:11 +00:00
Benjamin Otte
cd7e1c1387 dmabuf: Modify gdk_gl_context_import_dmabuf()
Move a bunch of code - namely the target selection - into the function.

I want to use the same code in the NGL renderer, so no need to duplicate
it.
2023-11-07 05:12:57 +01:00
Benjamin Otte
61207f81c3 dmabuf: Set same YUV colorspace as elsewhere
We use ITU.601 full range everywhere, so ensure it's used here, too.
2023-11-07 05:12:57 +01:00
Benjamin Otte
1a93967e1f gdk: Remove debug modes in gdk_debug_parse_var()
Always support all variables.
2023-11-05 11:16:23 +01:00
Benjamin Otte
310ab7b531 Remove G_ENABLE_DEBUG around debug checks
It started out as busywork, but it does many separate things. If I could
start over, I'd take them apart into multiple commits:

1. Remove G_ENABLE_DEBUG around GDK_DEBUG_*() calls
   This is not needed at all, the calls themselves take care of it.

2. Remove G_ENABLE_DEBUG around profiling code
   This now enables profiling support in release builds.

3. Stop poking _gdk_debug_flags and use GDK_DEBUG_CHECK()
   This was old code that was never updated.

4. Make !G_ENABLE_DEBUG turn off GDK_DEBUG_CHECK()
   The code used to
     #define GDK_DEBUG_CHECK(...) false
     #define GDK_DEBUG(...)
   which would compile away all the code inside those macros. This
   means a lot of variable definitions and debug utility functions
   would suddenly no longer be used and cause compiler errors.
2023-11-05 11:16:23 +01:00
Benjamin Otte
d55801c8ba debug: Turn gdk_debug_message() into a function
1. MSVC can't deal with the nonstandard ##__VA_ARGS__

2. It allows setting a breakpoint on it.
2023-11-05 10:21:54 +01:00
Matthias Clasen
1914adc344 dmabuf: Don't check for image storage
I was wrong about this extension, and it isn't even a GL extension
to begin with, so revert all this.
2023-10-29 14:45:20 -04:00
Matthias Clasen
6e236b9459 Revert "gl context: Check for more GL extensions"
This reverts commit b8b5835fc6.
2023-10-29 14:44:46 -04:00
Matthias Clasen
11715760f9 Revert "glcontext: Better debug spew"
This reverts commit 30e14f73fa.
2023-10-29 14:44:29 -04:00
Matthias Clasen
06dda4e12b Merge branch 'memory-format-swizzle-check' into 'main'
gl: Check all swizzle values

See merge request GNOME/gtk!6524
2023-10-26 02:38:35 +00:00
Matthias Clasen
4a749aee6e Fix swizzle values for some memory formats
For opaque formats with 3 channels, we should use the default
GL_ALPHA, but for opaque formats with an ignored 4th channel,
we must use GL_ONE.
2023-10-25 21:39:52 -04:00
Matthias Clasen
bb2b8bf2c3 dmabuf: Refine the handling of implicit modifiers
If all formats with a given fourcc are external, treat the
fourcc with implicit modifiers as external too, following a
sugestion by Benjamin Otte.
2023-10-24 22:33:45 -04:00
Matthias Clasen
eb048c91be dmabuf: Allow implicit modifiers
Remove all the roadblocks we've put up to keep implicit modifiers
out. Our importing code already handles them as a signal that says
'No modifiers, please!'. Now we just hope for the best and pass
things along.

This is necessary since some drivers won't produce any explicit
modifiers.
2023-10-24 22:33:45 -04:00
Matthias Clasen
8f90ddb906 dmabuf: Cache egl formats
Only call eglQueryDmaBufModifiersEXT once, and reuse the results.
2023-10-24 21:53:09 -04:00
Matthias Clasen
a90ffb117f docs: Some additions
Add a link to the kernel docs about dmabufs.
2023-10-24 10:50:46 -04:00
Matthias Clasen
29681717ed Fix annotations
It is always org.gtk.Property, even if we are in gdk.
2023-10-24 07:16:42 -04:00
Benjamin Otte
51a181af7a Merge branch 'wip/otte/for-main' into 'main'
dmabuf: Seek back to the start

See merge request GNOME/gtk!6526
2023-10-23 19:57:21 +00:00
Benjamin Otte
e2edf693f5 gdk: Make float32 report its true depth
I have no idea how this is the only value that is wrong.
2023-10-23 21:22:17 +02:00
Benjamin Otte
323300e92a dmabuf: Seek back to the start
https://docs.kernel.org/driver-api/dma-buf.html recommends doing that,
so we do that.
2023-10-23 17:57:57 +02:00
Benjamin Otte
e688be1cff gdk: Add some debug messages around dmabuf initialization 2023-10-23 17:57:57 +02:00
Matthias Clasen
625eb508e8 dmabuftexturebuilder: Fix doc formatting 2023-10-22 23:24:46 -04:00
Matthias Clasen
2718e1715d display: Add details to the docs 2023-10-22 23:24:27 -04:00
Matthias Clasen
6ddcad6b33 dmabuf: Update a comment 2023-10-22 23:14:07 -04:00
Matthias Clasen
30e14f73fa glcontext: Better debug spew
Print out all the extensions we checked.
2023-10-22 22:41:53 -04:00
Matthias Clasen
39e205aa78 dmabuf: Don't print unsupported formats
We were confusingly printing "supported format" for dmabuf formats
that we end up not adding to our list of supported formats. Don't
do that, it is confusing. At the same time, we shuold print out
the linear formats we support via mmap.
2023-10-22 22:29:44 -04:00
Matthias Clasen
79f98f3a13 Cosmetics
Typo fix.
2023-10-22 22:18:30 -04:00
Benjamin Otte
a579e3bc6d build: Fix up header includes
These weren't fixed in the merge request in
  https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/6489
to the change from
  https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/6514
2023-10-23 03:12:09 +02:00
Benjamin Otte
8f70f4b85e dmabuf: Add support for 3 plane YUV formats 2023-10-23 02:54:23 +02:00
Benjamin Otte
911198cddd dmabuf: Add NV16, NV61, NV24 and NV42
and sanitize them and NV21.
2023-10-23 02:54:23 +02:00
Matthias Clasen
a4d0a5bda5 dmabuf: We don't support external formats on GL
Filter out external-only formats unless we are on GLES.
2023-10-22 17:54:18 -04:00
Matthias Clasen
494154beb6 dmabuf: Add an EGL downloader
Add an implementation of GdkDmabufDownloader that uses
gsk_renderer_render_texture + GL texture download.

Since gsk isn't threadsafe, we do the download in the main thread,
taking care to not disturb the current GL context of whatever is
going on there at the time.

And since gsk renderers are expensive to create, we cache it
in the display.

Note that gsk does not yet have any special support for
dmabuf textures, so for now, they will always get downloaded
and then reuploaded as GL textures.
2023-10-22 16:42:17 -04:00
Matthias Clasen
8fb0ab2b43 gl context: Add private dmabuf API
Add API to import a dmabuf into a texture,
and to export a texture to a dmabuf.

All this is implemented using the relevant
EGL and GL extensions.
2023-10-22 16:39:24 -04:00
Matthias Clasen
b8b5835fc6 gl context: Check for more GL extensions
These will be used in future commits.
2023-10-22 16:39:24 -04:00
Matthias Clasen
463307655c display: Check for more EGL extensions
We are going to rely on this in future commits.
2023-10-22 16:39:24 -04:00
Benjamin Otte
e05764806a build: Change where we get drm_fourcc.h from
The canonical source for userspace is libdrm, not kernel headers.

Fixes compilation on Arch Linux.
2023-10-22 20:40:20 +02:00
Benjamin Otte
32ba1e389c build: Check for drm/drm_fourcc.h too
It's part of the kernel headers package so I did not check for libdrm.

As a side effect I checked the #define to HAVE_DMABUF.
2023-10-22 17:27:11 +02:00
Benjamin Otte
beb9e0c906 dmabuf: Add gdk_dmabuf_is_disjoint()
No users yet, but Vulkan will use this later. So have it available
already.
2023-10-22 17:03:15 +02:00
Benjamin Otte
98f02f6221 dmabuf: Reject the INVALID modifier
Trying to use it is a programming error, applications should have code
that uses real modifiers.

Also add a check to the formatsbuilder so our code doesn't include the
invalid modifier by accident.

We don't really know how to deal with it, so better force applications
to figure out what to do.
2023-10-22 17:03:15 +02:00
Benjamin Otte
13848969f4 dmabuf: Allow downloaders to fail initialization
When adding the formats of a downloader, allow them to return FALSE to
mean "This method is not supported", which is a useful way to opt out
when checking GL or Vulkan extensions and finding out that the desired
one isn't supported.
2023-10-22 17:03:13 +02:00
Matthias Clasen
9e3f537a15 dmabuf: Give downloaders a name
Add name to the downloader struct, and add it
to the debug spew for newly created dmabuf
textures.
2023-10-21 19:19:21 -04:00
Matthias Clasen
410240fe7b Merge branch 'matthiasc/for-main' into 'main'
Cosmetics

See merge request GNOME/gtk!6509
2023-10-21 20:34:36 +00:00
Matthias Clasen
73cf3a92f9 cosmetics 2023-10-21 16:10:09 -04:00
Matthias Clasen
dd15122ccb dmabuf: Add some debug spew 2023-10-21 14:44:28 -04:00
Benjamin Otte
cbfd8542c6 dmabuf: Require valid fds for all planes
This seems to be what everyone does, so we should do it, too.

Previously it was assumed that an fd of -1 would mean reusing the
previous fd with a different offset, but that seems to be uncommon.
2023-10-21 16:42:15 +02:00
Matthias Clasen
59ce7ab222 dmabuf: Improve the debug message
Printing the format can only help.
2023-10-20 20:03:27 -04:00
Matthias Clasen
0992837b08 dmabuf: Fix the mmap logic
We want to unmap the buffers we mapped in
the first loop, so pass the right pointers
here.
2023-10-20 20:03:11 -04:00
Matthias Clasen
aca02916ad dmabuf: Fix NV12 import
We were not seeking in the right fd,
so our sizes were wrong, and crashes
happened.
2023-10-20 19:53:33 -04:00
Matthias Clasen
8843c0d504 dmabuf: Fix format mapping for RGB formats
The channel order was reversed.
2023-10-20 19:22:00 -04:00
Matthias Clasen
a1c5c20e2c dmabuf: Add xrgb formats 2023-10-20 18:14:45 -04:00
Matthias Clasen
10250a0a6a Add XRGB memory formats
These are not uncommon in dmabufs,
and supporting them is easy.

Fixes: #6172
2023-10-20 17:58:06 -04:00
Matthias Clasen
bd974b08b3 Add GDK_MEMORY_A8B8G8R8_PREMULTIPLIED
We did have 4 ordering variations of ARGB straight,
but only 3 premultiplied. Add the missing one.

Update all the places where we switch over memory formats.
2023-10-20 16:42:40 -04:00
Benjamin Otte
008d9e5327 vulkan: Actually check for GDK_DEBUG=vulkan-disable
The dmabuf code would happily init Vulkan even if it was told we don't
want it.
2023-10-20 14:26:59 +02:00
Benjamin Otte
09723d79c6 dmabuf: Support YUYV and friends
Same as the NV12 support, but necessary for the poor people stuck on
Intel laptops.
2023-10-20 14:26:59 +02:00
Benjamin Otte
4586af5876 dmabuf: Add support for NV12 and NV21
This is as-good-as-necessary and doesn't do any fancy colorspace magic
or chroma whatevering.

That's a task for the future.
2023-10-20 14:26:59 +02:00
Benjamin Otte
193d9cd31a dmabuf: Improve download
1. Split out the download function from the mmap'ing of the plane(s)

2. Make the code mmap() all the planes

3. Determine size using lseek() as documented by libdrm, instead of
   trying to guess it from the format.

4. Fix some bugs, like switcheroos of width and height
2023-10-20 14:26:59 +02:00
Benjamin Otte
f29303dea7 dmabuf: Allocate the intermediate buffer properly.
We should use the stride from the buffer's format, not from the dmabuf.
2023-10-20 14:26:59 +02:00
Benjamin Otte
4e47d0d71e dmabuf: Ensure the number of planes is sane
Make it a programming error when setting planes to 0 and throw a GError
if somebody uses more than GDK_DMABUF_MAX_PLANES.
2023-10-20 14:26:59 +02:00
Benjamin Otte
dd8c6e9f51 dmabuf: Add gdk_dmabuf_sanitize()
Tries to sanitize the dmabuf to conform to the values expected
by Vulkan/EGL which should also be the values expected by
Wayland compositors

We put these sanitized values into the GdkDmabufTexture, by
sanitizing the input from GdkDmabufTextureBuilder, which are
controlled by the callers.

Things we do here:

1. Disallow any dmabuf format that we do not know.

1. Treat the INVALID modifier the same as LINEAR.

2. Ignore all other modifiers.

3. Try and fix various inconsistencies between V4L and Mesa,
   like NV12.

*** WARNING ***

This function is not absolutely perfect, you do not have a
perfect dmabuf afterwards.

In particular, it doesn't check sizes.
2023-10-20 13:58:22 +02:00
Matthias Clasen
b8ffceaebb glcontext: Add api to check for vertex arrays
Vertex arrays are available in GL and in GLES >= 3.

We don't check for the GLES extension that provided
vertex arrays in older GLES, since that requires
using different API.

This api avoids version checks all over the place.
2023-10-19 22:43:13 -04:00
Matthias Clasen
148b8e5cd8 Merge branch 'gles-bgra' into 'main'
memoryformat: Check for BGRA support in GL

Closes #6171

See merge request GNOME/gtk!6498
2023-10-19 21:34:44 +00:00
Matthias Clasen
583ad47b03 memoryformat: Check for BGRA support
Check for whether the GL context we are using
supports uploads with GL_BGRA before returning
that memory format.

Fixes: #6171
2023-10-19 16:44:18 -04:00
Matthias Clasen
b95d8ebdd3 memoryformat: Change some private API
Make gdk_memory_format_gl_format take the GdkGLContext,
instead of just a gles boolean. This will let us
check for extensions that may be needed for certain
formats.

Update all callers.
2023-10-19 16:44:18 -04:00
Benjamin Otte
677a601d11 Merge branch 'wip/otte/for-main' into 'main'
dmabuf: Init the dmabuf subsystem before creating texture

See merge request GNOME/gtk!6499
2023-10-19 19:30:23 +00:00
Benjamin Otte
194db51fba dmabuf: Make Builder::display non-nullable
We always have a display - the default display - so there's no need to
accept NULL.

Plus, we need a display when building the texture, so accepthing NULL
wouldn't even make sense.

Includes update to defaultvalue test.
2023-10-19 20:51:51 +02:00
Matthias Clasen
d55fa0dfef glcontext: Check for GL_EXT_texture_format_BGRA8888
Check for this GLES extension and add a private getter.
2023-10-19 13:55:18 -04:00
Benjamin Otte
612b5416af dmabuf: Init the dmabuf subsystem before creating texture
We did not do that, so when the dmabuf building looked at the list of
downloaders, it was empty and the result was an error. That's not good.
2023-10-19 19:12:46 +02:00
Matthias Clasen
014adb841e gdk: Add an annotation
We are returning interned strings here, and
g-i seems to have trouble interpreting the const,
so lets help it out by being more explicit with
our annotations.

Fixes: #6167
2023-10-19 10:06:53 -04:00
Matthias Clasen
4417509515 dmabuf: Add a display getter
Add private api to get the display of
a dmabuf texture. We will need it in
the following commit.
2023-10-16 22:29:20 -04:00
Matthias Clasen
9dc2e554e5 dmabuf: Tweak error messages 2023-10-16 22:29:10 -04:00
Benjamin Otte
570e80a9ff dmabuf: Split out GdkDmabuf and GdkDmabufDownloader
GdkDmabuf is a struct encapsulating all the values of a dmabuf, so
nothing to see here.

GdkDmabufDownloader is a vtable for a thing that can download dmabufs.
For now only one implementation exists, so this just looks like a ton
of work for no benefit.

The only neat thing is that gdkdmabuftexture.c got a whole lot tidier.
2023-10-16 18:56:52 -04:00
Matthias Clasen
2f842b087c dmabuf: Cosmetics 2023-10-15 12:00:23 -04:00
Matthias Clasen
699f6a7993 Add a dmabuf debug flag
Add a new debug flag for dmabuf-related information,
and use it in gdkdmabuftexture.c.

This will let us separate out dmabuf debug spew from
opengl debug spew.
2023-10-15 11:05:32 -04:00
Matthias Clasen
9f8d34ab01 dmabufformatsbuilder: Make it work
The qsort arguments were mixed up, leading to nonsense.
2023-10-14 23:04:00 -04:00
Benjamin Otte
57d8cc08a3 gdk: Add GDK_DEBUG=dmabuf-disable
I chose the name for consistency with gl-disable and vulkan-disable.
2023-10-14 22:30:17 +02:00
Benjamin Otte
1ca067a478 dmabuf: Add a GError to gdk_dmabuf_texture_builder_build() 2023-10-14 22:30:17 +02:00
Benjamin Otte
7a13e4f9b9 docs: Remove docs for private GdkDmabufFormat struct
This is a leftover from the design of the GdkDmabufFormats struct.
2023-10-14 22:30:17 +02:00
Benjamin Otte
d101e17608 dmabuf: Use the new FormatsBuilder to initialize formats 2023-10-14 22:30:17 +02:00
Benjamin Otte
203a4fc45e dmabufformats: Add GdkDmabufFormatsBuilder
This is a utility object that helps in constructing GdkDmabufFormats.
2023-10-14 22:29:10 +02:00
Benjamin Otte
a9823e05bb array: constify the additions array
We can only do that for by-value arrays, because compilers get confused
with const when there's too many dereferences going on.
2023-10-14 22:11:44 +02:00
Benjamin Otte
6f5833df28 dmabufformats: Mark a bunch of functions as pure 2023-10-14 22:11:44 +02:00
Benjamin Otte
e584d17aad Merge branch 'dmabuf-texture-api' into 'main'
Add API for dmabuf textures

See merge request GNOME/gtk!6463
2023-10-11 20:25:50 +00:00
Matthias Clasen
4936965fb6 display: Get supported dmabuf formats
These are the dmabuf formats that we can import
into a GL context as an EGLImage, and successfully
download.

We skip the GdkDisplay:dmabuf-formats property
in the default value tests, since the nominal
default value is NULL, but the actual value is
constructed on demand.
2023-10-11 15:43:01 -04:00
Matthias Clasen
c93efe85dd Add GdkDmabufTexture
Add an implementation of GdkDmabufTexture.

For now, this implementation is rather minimal,
since we need a roundtrip through GL to convert
most nottrivial formats.
2023-10-11 15:43:01 -04:00
Matthias Clasen
d23e13aced Add GdkDmabufTextureBuilder
Add a builder for a new GdkTexture subclass that
wraps dmabuf buffers on Linux. For now, this is
just an API. The implementation will follow in
subsequent commits.
2023-10-11 14:54:21 -04:00