Commit Graph

11438 Commits

Author SHA1 Message Date
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
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
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
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