Commit Graph

12196 Commits

Author SHA1 Message Date
Chun-wei Fan
95ad05181c gdksurface-win32.c: Drop a global variable
Use the gdk_win32_surface_parent_class that is given to us by
G_DEFINE_TYPE() instead of using a global variable to store up the
parent class of GdkWin32Surface.
2024-10-07 10:28:34 +08:00
Arjan Molenaar
0ea35efec4 macos: Fix double emission of mouse release event
The event is propagated anyway.

Fixes #7021.
2024-10-06 14:08:05 +02: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
9fe78d9f75 cairo: Add gdk_cairo_pattern_add_color_stop_color
This is a generalization of gdk_cairo_pattern_add_color_stop_rgba_ccs
to allow non-sRGB sources.
2024-10-04 14:50:23 -04:00
Chun-wei Fan
c373e2c76b Merge branch 'gdk-win32-rename' into 'main'
GDK/Win32: Rename instances of "window" as in the GTK+-3.x-era GdkWindow as appropriate

See merge request GNOME/gtk!7738
2024-10-03 05:44:07 +00:00
Benjamin Otte
c6a3efaf70 dmabuf: Unify initialization debug messages
... and print if a format is advertised.

We now use the same style of message and use the term "advertise" for
formats that will be available via GdkDisplay::dmabuf-formats and
"supports" for formats the backend pretends it can handle but don't
want to advertise them.
2024-10-02 13:39:48 +02:00
Benjamin Otte
9870234294 dmabuf: Change a debug message
Instead of only printing the advertised dmabuf formats, print all
supported ones. This is now useful information because we will try to
use them when downloading.

Fixes me looking like I don't know what I'm talking about on IRC when
claiming that llvmpipe can't do dmabufs, because it only supports linear
ones and we didn't print those.
2024-10-02 13:39:48 +02:00
Chun-wei Fan
979a37d3f7 GDK/Win32: Rename _gdk_win32_get_window_rect()
... to gdk_win32_get_surface_hwnd_rect(), so that things are a bit
clearer.
2024-10-02 12:52:44 +08:00
Chun-wei Fan
270e6165f4 GDK/Win32: Rename GtkShowWindow() to GtkShowSurfaceHWND()
Makes this function a bit clearer on what is being done.
2024-10-02 12:52:44 +08:00
Chun-wei Fan
df51d474fc GDK/Win32: Rename "window" for event handling code
We want to make the distinction between GdkSurface's and native Windows
HWNDs clearer.
2024-10-02 12:52:44 +08:00
Chun-wei Fan
1e0ab6f249 gdkprivate-win32.h: Rename "window" as needed
We want to make the distinction between GdkSurface's and native Windows
HWNDs clearer.
2024-10-02 12:52:44 +08:00
Chun-wei Fan
deb4de6332 gdkvulkancontext-win32.c: Rename "window" as needed
We want to make the distinction between GdkSurface's and native Windows
HWNDs clear, and we don't want to confuse between GdkSurface's and
Vulkan surfaces.
2024-10-02 12:52:44 +08:00
Chun-wei Fan
b4c7dd770c GDK/Win32: Rename "window" for DND/clipboard code
We want to make the distinction between GdkSurface's and native Windows
HWND clearer.
2024-10-02 12:52:44 +08:00
Chun-wei Fan
7488644176 gdkdisplay-win32.c: Rename "window" as appropriate
We want to make the distinction between GDK surfaces and the native
(underlying) Windows HWNDs clearer.
2024-10-02 12:52:44 +08:00
Chun-wei Fan
9ed7cecd42 GDK/Win32: Rename "window" in GdkDevice/GdkDeviceManager code
Make the distinction between GdkSurfaces and the underlying native
Windows HWND clearer in the code and in the comments.
2024-10-02 12:52:44 +08:00
Chun-wei Fan
df36ab3f93 GDK/Win32: Rename "window" items in Cairo context code
Make the distinction between GDK surfaces and native Windows HWNDs
clearer.
2024-10-02 12:52:44 +08:00
Chun-wei Fan
7e4fdea71b GDK/Win32: Rename "window" in gdksurface-win32.* code
In order to help us in our refactoring, make the distinction between Gdk
surfaces and native Win32 HWND clearer in terms of the variables that we
used, and in the comments in the code.

Also, group forward function prototype declarations in one place, and
drop some unneeded items in gdkprivate-win32.h to fold them into
gdksurface-win32.c, as they are only used there.
2024-10-02 12:52:44 +08:00
Matthias Clasen
c4efe7709b Drop GDK_VULKAN_DEVICE support
We don't need our own mechanism for device selection; mesa has a
Vulkan layer that works perfectly fine for this purpose; just set
MESA_VK_DEVICE_SELECT.
2024-10-01 21:00:16 -04:00
Benjamin Otte
43a6c8c5f5 gl: Treat internal textures as special case
Treat external as the normal case, and only try importing dmabufs
as non-external images if their format is on the internal formats
list.

Also add internal linear formats to the internal formats list.

This fixes an issue where AR24:0 dmabufs were imported as external
textures, causing some of the compare tests to fail.
2024-09-30 21:16:41 -04:00
Matthias Clasen
c397460c11 Drop gdk_dmabuf_downloader_supports
It is not used anymore.
2024-09-30 18:37:20 -04:00
Matthias Clasen
ff0045b8c9 dmabuftexture: Stop having a fixed downloader
Change things from picking a download method at creation time to
trying all methods at download time until one succeeds.
2024-09-30 18:37:20 -04:00
Matthias Clasen
c0cb10262d Make gdk_dmabuf_download_mmap return status
Make this function return whether it was successful, and only emit
a debug message if we succeeded. In particular, make it return FALSE
if the dmabuf format is not linear.
2024-09-30 18:37:20 -04:00
Matthias Clasen
279a5f7825 Make gdk_dmabuf_downloader_download failable
This will enable us to try multiple downloaders in a row.
2024-09-30 18:37:20 -04:00
Matthias Clasen
0673d74986 Merge branch 'for-main' into 'main'
Cosmetics

See merge request GNOME/gtk!7768
2024-09-30 13:53:51 +00:00
Ilya Fedin
ff78e1888b wayland: Look for default cursor theme in XDG directories
Currently it's looked up only in /usr/share what is a problem for non-FHS distros like NixOS
2024-09-30 15:50:11 +04:00
Matthias Clasen
bb46edcc21 dmabuf: Initizalize some memory
I've seen valgrind complain about external_only being uninitialized
after the call, when using llvmpipe. Better be safe than sorry, and
initialize these arrays.
2024-09-30 06:55:57 -04:00
Matthias Clasen
24173e3f93 Cosmetics
No point in having an early return since EGL_NO_IMAGE is what we
want to return anyway.
2024-09-30 06:50:20 -04:00
Matthias Clasen
95cea06462 Revamp GDK_VULKAN_DEVICE slightly
Support a "help" value, as we do for other env vars.
2024-09-29 09:54:24 -04:00
Matthias Clasen
3d3cafefc8 Merge branch 'clear-settings-portal' into 'main'
wayland: Clear settings_portal when going to fallback with no portal settings

See merge request GNOME/gtk!7756
2024-09-29 13:25:15 +00:00
Matthias Clasen
cbadb1ed8e Merge branch 'pointer-viewporter-again' into 'main'
wayland: Bring back the pointer viewporter

See merge request GNOME/gtk!7760
2024-09-28 16:13:06 +00:00
Matthias Clasen
3768c751c5 wayland: Improve our cursor size selection
When picking a cursor image size for a given size, look for sizes
that do better when scaled by the viewporter:
- exact size
- twice the size
- closest larger size
- closest size
2024-09-28 10:26:42 -04:00
Matthias Clasen
e42014573a wayland: Bring back the pointer viewporter
This was a thinko in 403da9a2d5. We have the cursor
image in device pixels, but we still need to apply the viewporter
to inform the compositor about the desired pointer size in
application pixels.
2024-09-28 10:01:04 -04:00
Ilya Fedin
a9f1ff471b wayland: Use the same default cursor size as gsettings schema
Fixes: #7043
2024-09-28 16:50:05 +04:00
Ilya Fedin
e26a1bbda9 wayland: Clear settings_portal when going to fallback with no portal settings
All other code paths with goto fallback clear it, this makes the behavior consistent with them
2024-09-28 16:41:13 +04:00
Matthias Clasen
403da9a2d5 wayland: Redo cursor loading
Stop using a viewporter to scale cursors. Instead, just pass
the surface scale to the cursor loading code, and take the
buffer dimensions and hotspot that it returns, unchanged.

This avoids problems with cursor themes like Breeze, where
buffer dimensions are different from the nominal cursor size.

Make the cursor loading code take a floating point scale,
and return the closest sized cursor that it can find.
2024-09-27 12:37:25 -04:00
Matthias Clasen
58ce0a39dc dmabuf: Use the ngl downloader
It works, now and is faster than the old GL downloader.

Playing the Barbie trailer @ 4k with hardware decoding but the Cairo
renderer on a 4k screen:

downloader  windowed  fullscreen
GL          12fps     19fps
NGL         16fps     29fps
Vulkan      16fps     29fps
no dmabufs  12fps     19fps
2024-09-26 22:06:18 +02:00
Benjamin Otte
5fdaa4a232 gl: Move function
We want to share the texture download function with the renderers, so
they can download textures without needing to wrap them in a
GdkGLTexture.

Move it into gdkglcontext.c for that purpose.
2024-09-26 22:06:17 +02:00
Benjamin Otte
8b166dff74 gltexture: Split out a function
No functional changes
2024-09-26 22:06:17 +02:00
Matthias Clasen
b11e45762b Merge branch 'cursor-update-now' into 'main'
wayland: Make cursor changes effective immediately

Closes #6909

See merge request GNOME/gtk!7745
2024-09-26 18:07:28 +00:00
Matthias Clasen
d22d2f77a6 wayland: Make cursor changes effective immediately
When the cursor theme changes, update the cursors of our surfaces.

Fixes: #6909
2024-09-26 12:53:38 -04:00
Benjamin Otte
7458461d06 gl: Remove unpack-subimage checks
GLES 3.0 supports it unconditionally.
2024-09-26 18:41:13 +02:00
Benjamin Otte
283615936b gl: Remove check for half-float vertex data
All supported versions require it after we dropped support for GLES 2.
2024-09-26 18:41:13 +02:00
Benjamin Otte
2274bca95b gl: Require support for GLsync
It's supported by GL >= 3.2 and GLES >= 3.0 and we require both now.
2024-09-26 18:41:13 +02:00
Benjamin Otte
f8b4deeac0 gdk: Drop support for GL < 3.3
The new renderers need features from GL 3.3 and GLSync is very required
these days, too.

Note that this is about GL proper, not GLES.
2024-09-26 18:41:13 +02:00
Benjamin Otte
afa503c2e0 gl: Remove GLES 2 specific parts of format checks 2024-09-26 18:41:13 +02:00
Benjamin Otte
b83ad60a1f gdk: Drop support for GLES 2
We now require GLES 3.
2024-09-26 18:41:13 +02:00
Matthias Clasen
8c04801f6a Stop using g_memdup
Its deprecated in favor of g_memdup2
2024-09-25 10:56:36 +02:00
Benjamin Otte
310a4a3bf6 gdk: Fix parameter names
Believe in your self!
2024-09-25 02:50:22 +02:00
Benjamin Otte
87a1a17868 memoryformat: Rename parameter
It's meant to match the prototype.
2024-09-25 02:50:22 +02:00
Benjamin Otte
70f386bd68 keynames: Use C types
Then we don't need to include glib.h
2024-09-25 02:50:22 +02:00
Benjamin Otte
0af89088ba gdk: Include missing header 2024-09-25 02:50:22 +02:00
Benjamin Otte
7342317c31 gdk: Fix parameter names 2024-09-25 02:50:22 +02:00
Benjamin Otte
8d8bd4efba broadway: Fix argument name 2024-09-25 02:50:22 +02:00
Benjamin Otte
0ae3c8968e gdk: Add missing header 2024-09-25 02:50:22 +02:00
Benjamin Otte
5e3f13acd1 filetransferportal: Include missing header 2024-09-25 02:50:22 +02:00
Benjamin Otte
32cdf35583 broadway: Fix argument name 2024-09-25 02:50:22 +02:00
Benjamin Otte
5a7fc4054b memoryformat: Fix argument names in prototype 2024-09-25 02:50:22 +02:00
Benjamin Otte
bab8f2f976 Revert "dmabuf: Use the ngl downloader"
This reverts commit 97e0f872a2.
2024-09-24 11:29:59 +02:00
Matthias Clasen
4801c3275e Merge branch 'wip/otte/win32-remove-sync' into 'main'
win32: Remove gdk_display_sync()

See merge request GNOME/gtk!7727
2024-09-24 07:03:53 +00:00
Matthias Clasen
39354b3b99 Merge branch 'wip/otte/x11-remove-sync' into 'main'
x11: Remove gdk_display_sync() call

See merge request GNOME/gtk!7728
2024-09-24 07:03:20 +00:00
Matthias Clasen
97e0f872a2 dmabuf: Use the ngl downloader
It works, now.
2024-09-23 21:14:53 +02:00
Matthias Clasen
b623b2acef wayland: Be more careful with mimetypes
Sometimes, jokers send us 'mimetypes' like DELETE or
org.webkitgtk.WebKit.custom-pasteboard-data, and gdk_intern_mime_type
will return NULL for such things. Handle that by just closing the fd.

Better than running into an assertion further down.
2024-09-22 09:25:44 +02:00
Benjamin Otte
236b6d1cd6 x11: Remove gdk_display_sync() call
This is unnecessary.
Worse, it is reentrant and can cause all sorts of avoc when processing
events halfway through initializing the Vulkan context.

It was introduced in commit e11a6a0e68 but back then GTK was barely
branched for GTK4 and Vulkan drivers were very new, and it looks like an
unnecessary workaround.

Testing did not seem to indicate any issues with just removing it, so
here it goes.

Related: #7022
2024-09-21 18:59:49 +02:00
Benjamin Otte
6e714722c4 win32: Remove gdk_display_sync()
This is unnecessary.
Worse, it is reentrant and causes all sorts of avoc when processing
events halfway through initializing the context.

It only exists because in commit c4244ea1 the win32 Vulkan code was
copy/pasted from another backend.

Related: #7022
2024-09-21 18:19:26 +02:00
Benjamin Otte
60b1496091 wayland: Don't call gdk_display_sync()
It is not necessary.
Worse, it is reentrant and causes all sorts of avoc when processing
events halfway through initializing the context.

It only exists because in commit 3887548 the Wayland Vulkan code
was copy/pasted from X11.

Fixes #7022
Fixes #7025
2024-09-21 18:18:29 +02:00
Benjamin Otte
db95e37e15 vulkan: Demote g_critical() to g_warning()
For VK_DEBUG_REPORT_WARNING_BIT_EXT we should always have used
g_warning().

For VK_DEBUG_REPORT_ERROR_BIT_EXT g_critical() is technically the right
choice, but Mesa has been using this flag for normal warnings, so until
that gets fixed, we don't want to throw criticals.

Related: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31292
Fixes: !7020
2024-09-20 23:02:15 +02:00
Matthias Clasen
7acc1c0125 Make dmabuf initialization lazier
Only initialize the Vulkan or EGL parts where possible.

When dmabufs or dmabuf formats are actually used, we still
initialize fully by creating both a Vulkan and EGL downloader.

This shortens the time to first commit from 149ms to 108ms.
2024-09-17 09:46:01 +02:00
Matthias Clasen
6059eaf355 gdk: Reorganize dmabuf initialization
Change the xxx_get_downloader() functions to init_dmabuf_xxx(),
and make them initialize both xxx_dmabuf_formats and xxx_downloader.
2024-09-17 09:46:01 +02:00
Matthias Clasen
24dc9dc653 Drop the dmabuf_downloaders array
Just use two individual fields, so we can track if we've already
created each one. This also matches the individual fields we have
for the dmabuf formats.

And change preference order of downloaders

Previously, our order was mmap > vulkan > egl.

But depending on the hw (discrete vs integrated gpu), mmap
can be catastrophically slower (on the order of 20ms vs 1.5s).

So, change the order to egl > vulkan > mmap.

Note that this currently has less effect than we'd like to,
since we don't let the downloaders claim linear formats.
2024-09-16 09:55:31 +02:00
Benjamin Otte
f2e75529cb Merge branch 'wip/otte/for-main' into 'main'
vulkan: Actually return the preferred memory format

See merge request GNOME/gtk!7713
2024-09-15 08:19:53 +00:00
Benjamin Otte
376dbe9def memoryformat: Move fast path into the threaded path
We don't want to get slower in the fast path.
2024-09-15 02:31:02 +02:00
Benjamin Otte
bba7979670 memoryformat: Add a fastpath for RGBA8 <=> BGRA8
Cairo is using BGRA8 but we want to use RGBA8 because it's the canonical
GL format.

So getting this fast sounds useful.
2024-09-15 02:31:02 +02:00
Benjamin Otte
01aafc6e65 memoryformat: Don't always convert to rec2100-linear and back
It turns out we lost the check to see if color states are equal when we
multithreaded things in !7657

Whoops.
2024-09-15 02:31:01 +02:00
Arjan Molenaar
250322deb0 Merge branch 'amolenaar/dnd-icon-on-top' into 'main'
macos: Keep DnD windows always on top

Closes #6809 and #6818

See merge request GNOME/gtk!7706
2024-09-12 09:25:05 +00:00
Matthias Clasen
bdee95c32c Merge branch 'wip/otte/for-main' into 'main'
gpu: Don't crash when there's no ops

Closes #6992

See merge request GNOME/gtk!7710
2024-09-12 00:27:29 +00:00
Arjan Molenaar
e92bd4d9ce macOS: drag surfaces should ignore all events
This fixes the Dnd demo.
2024-09-11 14:59:03 +02:00
Arjan Molenaar
a84fe6bde6 macos: Put DnD windows on status level
This will make sure the dragged window will stay visible.
2024-09-11 08:19:39 +02:00
Benjamin Otte
1ff9d1545d Revert "vulkan: Set VK_SWAPCHAIN_CREATE_DEFERRED_MEMORY_ALLOCATION_BIT_EXT"
This reverts commit ffae0010c4.

The commit doesn't work with the nvidia driver and it's not necessary to
use it, so drop it for now.

Fixes #6992
2024-09-11 08:17:43 +02:00
Emmanuel Gil Peyrot
6dd55e381d vulkan: Fix error string
This one got added in 66ba1f76ba but didn’t end
the sentence with a dot, and didn’t have its enum name between parentheses so
that people can debug more easily which error code got generated.
2024-09-10 22:46:29 +00:00
Emmanuel Gil Peyrot
abd8d40bf9 vulkan: Add another two error codes
Those two come from the VK_KHR_pipeline_binary extension and have been added in
Vulkan 1.3.294.
2024-09-10 22:45:41 +00:00
Simon McVittie
0fa2ae48d4 gdkgltexture: Avoid use-after-free when switching GdkGLContext
`thread_current_context` might be holding the last reference to
`previous`, in which case `gdk_gl_context_make_current` on the new
context will free `previous`, leaving it a dangling pointer.
Avoid this by making sure to hold a reference.

Fixes: 41cd0c6f "gl: Fix initial EGL context creation on X11"
Resolves: https://gitlab.gnome.org/GNOME/gtk/-/issues/6995
Signed-off-by: Simon McVittie <smcv@debian.org>
2024-09-10 00:11:18 +01:00
Benjamin Otte
9ba41ed6e8 Merge branch 'wip/otte/blur-and-blit' into 'main'
Fix blur for opaque textures

Closes #6980

See merge request GNOME/gtk!7697
2024-09-09 04:46:43 +00:00
Matthias Clasen
75fa51ef6d Cosmetics
Fix a typo
2024-09-08 19:35:53 -04:00
Benjamin Otte
5e4f692e63 tiff: Store RGBx images as 4 channels
Set the alpha channel to "undefined" in this case.

Gimp doesn't seem to like this when opening the image and insists to
doing something with it, that's a bit of a bummer.

But it allows GTK to load RGBx textures.
2024-09-09 01:25:03 +02:00
Benjamin Otte
ffae0010c4 vulkan: Set VK_SWAPCHAIN_CREATE_DEFERRED_MEMORY_ALLOCATION_BIT_EXT
It seems Mesa doesn't support that yet, but having it doesn't hurt.

And it allows drivers to allocate less memory for the swapchains,
because we don't need all the 4 images we request in minImageCount.
But drivers tend to take that minimum image count as gospel, so we need
to use a higher number to not cause lag in corner cases.
2024-09-08 16:22:49 +02:00
Benjamin Otte
6c72a223f5 vulkan: Enable VK_EXT_swapchain_maintenance1 if available
This just adds the plumbing, usage will happen later.

For testing, GDK_VULKAN_DISABLE=swapchain-maintenance will turn it off.
2024-09-08 16:22:49 +02:00
Benjamin Otte
5a027594c3 vulkan: Add gdk_vulkan_context_has_feature()
A siimplification that will come in handy in the future.
2024-09-08 16:22:49 +02:00
Arjan Molenaar
ae0cf9ff54 Merge branch 'amolenaar/focus-im-popups' into 'main'
macos: Fix popup window and keyboard input

Closes #6950 and #5049

See merge request GNOME/gtk!7653
2024-09-08 12:54:24 +00:00
Maximiliano Sandoval
ba32140671
docs: Remove all org.gtk.Method annotations
Removed via regex and grep.
2024-09-07 09:51:32 +02:00
Maximiliano Sandoval
91d36dd410
docs: Remove all org.gtk.Property annotations
Removed via regex and grep.

The following were intentionally not removed:

- GtkImage:file: (attributes org.gtk.Property.set=gtk_image_set_from_file)
- GtkImage:resource: (attributes org.gtk.Property.set=gtk_image_set_from_resource)

As they have no getter and (setter PROP) without a (getter PROP) crash
gobject-introspection. This is fixed by
ad3118eb51.
2024-09-07 09:51:32 +02:00
Maximiliano Sandoval
4fd1e32752
docs: Use correct property gir annotations
The annotations should only be set when the name of the setter or getter
for a property "GtkClassName:prop-name" is not gtk_class_name_g(s)et_property_name.
2024-09-07 09:51:26 +02:00
Matthias Clasen
03b19d8861 docs: Recommend glycin for image loading
Best to send people elsewhere to avoid misunderstandings of our api.
2024-09-06 16:52:47 -04:00
Matthias Clasen
d3db28b3f4 memory format: Add profiler marks
Add profiler marks to our long-running threaded operations.
To avoid spamming profiles too much, only report runs that take
at least 0.5 ms.
2024-09-06 16:14:24 -04:00
Benjamin Otte
896ea5b753 memoryformat: Add linear/nearest choice for mipmaping
linear will average all the pixels for the lod, nearest will just pick
one (using the same method as OpenGL/Vulkan, picking bottom right
center).

This doesn't really make linear/nearest filtering work as it should
(because it's still a form of mipmaps), but it has 2 advantages:

1. it gets closer to the desired effect

2. it is a lot faster

Because only 1 pixel is chosen from the original image, instead of
averaging all pixels, a lot less memory needs to be accessed, and
because memory access is the bottleneck for large images, the speedup is
almost linear with the number of pixels not accessed.
And that means that even for lot level 3, aka 1/8th scale, only 1/64 of
the pixels need to be accessed, and everything is 50x faster.

Switching gtk4-demo --run=image_scaling to linear/nearest makes all the
lag go away for me, even with a 64k x 64k image.
2024-09-06 15:47:35 -04:00
Benjamin Otte
5498b077fd memoryformat: Parallelize gdk_memory_mipmap() 2024-09-06 15:47:34 -04:00
Benjamin Otte
534a9b6ba0 memoryformat: Add fast path for mipmap
We have fast conversion functions, use those directly instead of calling
into gdk_memory_convert().

This is useful because as mentioned before, the main optimization here
is RGB8 => RGBA8 and we have a fastpath for that.
2024-09-06 15:47:34 -04:00
Benjamin Otte
cea961f4f4 memoryformat: Take src_format and dest_format
Why do we need this? Because RGB images are provided in RGB format but
GPUs can't handle RGB, only RGBA, so we need to convert.

And we need to do that without allocating too much memory, because
allocating memory is slow. Which means in aprticular we need to do the
conversion after mipmapping, not before (like we were doing).
2024-09-06 15:47:34 -04:00
Benjamin Otte
848c6815d3 gpu: Allow uploading of mipmap levels when tiling
This allows uploading less memory but requires computing lod levels on
the CPU which is slow because it reads through all of the memory and so
far entirely not optimized.

However, it uses significantly less VRAM.

This is done by adding a gdk_memory_mipmap() function that does this
task.
The texture upload op now accepts a lod level and if that is >0 it uses
gdk_memory_mipmap() on the source texture.
2024-09-06 15:47:34 -04:00
Benjamin Otte
46559039f3 memoryformat: Parallelize gdk_memory_convert_color_state() 2024-09-06 15:47:34 -04:00
Benjamin Otte
eb7a42bc13 memoryformat: Parallelize generic path of gdk_memory_convert() 2024-09-06 15:47:34 -04:00
Benjamin Otte
ffe56fe6b3 memoryformat: Parallelize
Refactor code so that it uses g_parallel_task_run().
2024-09-06 15:47:34 -04:00
Benjamin Otte
d4ba57fcc3 gdk: Add gdk_parallel_task_run()
This is just the API. Users will come later.

I considered putting it into gdkmemoryformat.c because it's likely gonna
be the only user and this one function is so little code, but it didn't
fit at all.
So now it's a new file.
2024-09-06 15:47:34 -04:00
Benjamin Otte
a95c9ebc51 memoryformat: Split out a function
Allow querying the fast conversion functions outside of
gdk_memory_convert().
2024-09-06 15:47:34 -04:00
Benjamin Otte
9195c39756 build: Alphabetic order is hard 2024-09-06 15:47:34 -04:00
Luca Bacci
7559a87e8a WGL: Detect MESA D3D12 driver and request GDI compatibility
This way we get a non-opaque framebuffer / render target

Fixes #6975

References:
  [1] https://gitlab.gnome.org/GNOME/gtk/-/issues/6975
  [2] https://gitlab.freedesktop.org/mesa/mesa/-/issues/11828
2024-09-04 20:02:44 +02:00
Luca Bacci
3a9f26113f WGL: Fix attribs_remove_last() 2024-09-04 17:07:01 +02:00
Luca Bacci
6a240c36ac WGL: Swap core / compat in debug output 2024-09-04 17:04:58 +02:00
Luca Bacci
aaf4261969 WGL: Include renderer string in debug output 2024-09-04 17:03:54 +02:00
Arjan Molenaar
aca11d6879 macos: Only allow keyboard focus on toplevel windows
This avoids the focus to move to a popup or popover window.
The red/yellow/green buttons remain colored.
2024-09-04 17:03:14 +02:00
Luca Bacci
5dceb7f7d2 WGL: Make context current to get debug info
Otherwise we get NULL from glGetString()
2024-09-04 17:02:20 +02:00
Benjamin Otte
0277e26152 Merge branch 'wip/otte/for-main' into 'main'
gpu: Use right GL context when exporting texture

See merge request GNOME/gtk!7679
2024-09-01 23:08:49 +00:00
Benjamin Otte
b0e4be7fda rendernode: Colors should not influence depth decisions
Depth of a rendernode should be determined by the textures used and the
compositing colorstate requirements.
Colors influence the colorstate choice, so they indirectly influence the
depth, but they should not influence the depth directly.

Otherwise a single color in a border being rec2100-pq would make us
switch to 16bit float.

Also remove gdk_color_get_depth(), because it was only used here and
because again: Colors should not influence depth decisions.
2024-09-02 00:22:37 +02:00
Arjan Molenaar
8054099d0e Merge branch 'amolenaar/macos-maximize-and-transparency' into 'main'
macos: Fix maximizing windows

See merge request GNOME/gtk!7650
2024-09-01 19:22:38 +00:00
Maxim Zakharov
9a8e5b07ae gdk: Add missed compute_size and request_layout vfunc to GdkBroadwaySurface 2024-09-01 13:48:22 +00:00
Matthias Clasen
5b6b42b5a9 x11: Fix initialization mess
When prepare_gl fails in the right way (or the wrong way?), we
end up creating the leader window twice, and as a side effect,
creating two instances of the "Virtual core pointer" device, which
is bad news for grabs.

Fixes: #6840
2024-08-31 11:28:52 -04:00
Matthias Clasen
ae8a06cdca x11: Cosmetics
Don't return FALSE from a function returning a pointer.
2024-08-31 11:28:52 -04:00
Matthias Clasen
ae8e9ef650 Merge branch 'vulkan-dnd-offset' into 'main'
vulkan: Use wl_surface_offset

Closes #6972

See merge request GNOME/gtk!7673
2024-08-31 11:47:53 +00:00
Matthias Clasen
bbfd8e0e89 vulkan: Use wl_surface_offset
Call wl_surface_offset in end_frame to apply the offset for drag
surfaces. This matches what the GL draw context already does, and
it fixes drag surfaces jumping at the beginning of the drag.

Fixes: #6972
2024-08-31 07:15:08 -04:00
Matthias Clasen
3273637179 Update keyname tables 2024-08-30 16:03:40 -04:00
Matthias Clasen
1eaa0e9b74 gdkkeysyms.h: Regenerate for libX11 1.8.10 2024-08-30 15:52:58 -04:00
Matthias Clasen
28d1bce2d4 Update a script slightly
Make gdkkeysyms-update.pl use #pragma once, as our headers
do nowadays.
2024-08-30 15:52:14 -04:00
Arjan Molenaar
d23833285e macos: Set transparent background for toplevel window
Toplevel window background is almost transparent.
For fully transparent windows the (macOS) shadow calculatation
becomes really slow.
2024-08-30 12:06:18 +02:00
Chun-wei Fan
0376e4668c GDK/Win32: Fix gdk_display_get_name()
We switched to using the Unicode (UTF-16) versions of the Windows API by
default, so we also obtain the display name in UTF-16 form as well.

This updates the implementation in the Windows backend so that we
properly acquire the names that we need in UTF-16, and then convert the
results to UTF-8, which is what we use in GTK/GLib.
2024-08-30 08:47:01 +08:00
Benjamin Otte
41cd0c6f13 gl: Fix initial EGL context creation on X11
After commit 447bc18c48 EGL on X11 broke.

But the handling of the GL context also was quite awkward because it was
unclear who was responsible for ensuring it got reset.

Change that by making gdk_gl_context_clear_current_if_surface() return
the context (with a reference because it might be the last reference) it
had unset, so that after changing EGL properties the code that caused
the clearing can re-make it current.

This moves the responsibility to the actual code that is dealing with
updating properties and frees the outer layers of code from that task.

And that means the X11 EGL code doesn't need to care and the code in the
Wayland backend that did care can be removed.

Related: !7662
Fixes: #6964 on X11
2024-08-29 01:31:47 +02:00
Benjamin Otte
db02abe54e Merge branch 'wip/otte/to-make-current-or-not-make-current' into 'main'
wayland: Rework how we handle EGLWindows

Closes #6964

See merge request GNOME/gtk!7662
2024-08-28 18:14:03 +00:00
Benjamin Otte
447bc18c48 wayland: Rework how we handle EGLWindows
This essentially reverts the changes from
c230546a2c but implies new semantics.

Namely, surface-attached contexts can now be bound to EGL_NO_SURFACE if
the windowing system isn't ready yet.

It is the task of the windowing system to make sure the context is
properly rebound when the contents become available.
We ensure this by checking in begin_frame() if we created the EGL window
and if we did, we make_current(). This works because creating the EGL
window creates the EGL surface and that does a clear_current(), so this
is always going to have the desired effect of re-making the current
context.

It is very convoluted though.

Fixes: #6964
Related: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11784
2024-08-28 19:09:45 +02:00
Luca Bacci
63b68d2f5e Merge branch 'gdk-win32-incremental-rendering-fixes' into 'main'
GdkWin32: Incremental rendering fixes

See merge request GNOME/gtk!7655
2024-08-28 09:30:29 +00:00
Matthias Clasen
a10670c991 wayland: Fix an ordering problem
When setting an event queue on a proxy, we should not destroy
the queue before the proxy.

May fix: #6965
2024-08-27 16:35:46 -04:00
Luca Bacci
f4bd883003 GdkWin32: Try to call _gdk_surface_update_size() only when the size actually changed
Otherwise we adapt Vulkan and OpenGL swap chains a lot and we effectively
disable incremental rendering.

Note that the fix is not complete.
2024-08-26 17:05:19 +02:00
Luca Bacci
0fcdadc531 GdkWin32GLContextWGL: Use the previous frames paint regions kept by GdkGLContext
We do this because:

 a) The parent class (GdkGLContext) already stores the paint regions of
    previous frames, no need to do the same.
 b) The painted region passed to end_frame () includes the backbuffer's
    damage region, so it's not really what we want.

This also fixes a leak of cairo_region_t that I introduced by mistake
in !7418
2024-08-26 17:05:13 +02:00
Arjan Molenaar
ffeca06bd6 macos: Revert "macos: fix window transparency"
This reverts commit 84847e46fa.

It breaks maximizing windows.
2024-08-25 12:00:51 +02:00
Matthias Clasen
90c65e3611 Merge branch 'wip/otte/ci-fixes' into 'main'
CI improvements

See merge request GNOME/gtk!7639
2024-08-24 20:25:30 +00:00
Matthias Clasen
c3329123a3 Merge branch 'matthiasc/for-main' into 'main'
Add a since tag to GDK_TOPLEVEL_STATE_SUSPENDED

See merge request GNOME/gtk!7645
2024-08-24 17:33:23 +00:00
Benjamin Otte
68ef86ac4f wayland: Don't ask dbus about settings we don't care about
When running with default settings, we don't care what dbus thinks about
non-default settings.
2024-08-24 18:36:23 +02:00
Matthias Clasen
89118ee7ba Add a since tag to GDK_TOPLEVEL_STATE_SUSPENDED
We've changed the way we document additions in enums.
2024-08-24 08:38:19 -04:00
Arjan Molenaar
4b5d503cf0 Merge branch 'macos-control-click' into 'main'
macos: Add Ctrl+left-click mapping for context menus

Closes #6724

See merge request GNOME/gtk!7523
2024-08-24 11:42:35 +00:00
Benjamin Otte
d8926de40e vulkan: Don't print errors on vkCreateInstance() failure
We handle the error case right below with a proper GError, there's no
need to use the fallback error reporting.

Fixes #6947
2024-08-23 20:04:46 +02:00
Chun-wei Fan
cc1c3799b6 Merge branch 'wgl-report-damage' into 'main'
GdkWin32GLContextWGL: Add support for incremental rendering

See merge request GNOME/gtk!7418
2024-08-21 02:37:41 +00:00
Matthias Clasen
740965016f Merge branch 'matthiasc/for-main' into 'main'
Add a GDK_DISABLE env var

See merge request GNOME/gtk!7632
2024-08-20 01:58:54 +00:00
Matthias Clasen
39e6301f42 win32: Adapt to default flag changes
I hope this change does the right thing.
2024-08-19 21:37:49 -04:00
Matthias Clasen
26a2966a7b gdk: Beef up gdk_parse_debug_var
Add a docstring for the variable itself, and print it as part
of the help message. Update all callers to provide a docstring.
2024-08-19 20:40:32 -04:00
Matthias Clasen
29cfcbdc97 wayland: Respect GDK_DISABLE=color-mgmt
If the color-mgmt feature is disabled, don't use the
xx-color-management-v4 protocol.
2024-08-19 20:40:32 -04:00
Matthias Clasen
de62ea96ab Add GDK_DISABLE=color-mgmt
This flag is meant to turn off color management features of GDK.
If this is set, all surfaces will report sRGB as their preferred
color state.
2024-08-19 20:40:32 -04:00
Matthias Clasen
2d230f79a6 Change the offload-disable flag
Move this from GSK_DEBUG=offload-disable to GDK_DISABLE=offload.
2024-08-19 20:40:32 -04:00
Matthias Clasen
cde094a0df Add a GDK_DISABLE env var
This is taking over the feature-disabling keys from GDK_DEBUG.
2024-08-19 20:40:32 -04:00
Benjamin Otte
2fb3dc8c90 Merge branch 'wip/otte/for-main' into 'main'
wayland: Create EGL window in make_current() if necessary

Closes #6930

See merge request GNOME/gtk!7633
2024-08-19 23:34:35 +00:00
Benjamin Otte
f650f96b69 egl: Don't bind to NULL surface unless surfaceless
We need to ensure that an EGL surface exists before we call
eglMakeCurrent() with it. Otherwise we might end up binding to
EGL_NO_SURFACE and then never revising that decision.
Which leads to not rendering to the backbuffer, but into the void.

Fixes X11 rendering being black

Fixes #6930
2024-08-20 01:05:20 +02:00
Benjamin Otte
c230546a2c wayland: Create EGL window in make_current() if necessary
We make_current() before begin_frame() so doing it only in begin_frame()
is too late.
2024-08-20 01:05:20 +02:00
Chun-wei Fan
e14670d457 gdksurface-win32.c: Call _gdk_surface_update_size() more
The current resizing implementation in the GDK-Win32 backend is not
telling GDK early enough for Vulkan that a resize in the surface (i.e.
HWND) is done, so that GDK can re-create swapchain in time, which is
apparent on nVidia drivers (and AMD drivers that utilize the mailbox
presentation mode on Windows) when the HWND is being enlarged
interactively.

To work around this, bar a refactor in the Windows resizing/presentation
code, is to call _gdk_surface_update_size() when we really did resize
the HWND when we handle queued resizes via SetWindowsPos().

The existing call in gdksurface-win32.c in
_gdk_win32_surface_compute_size() remains required, otherwise the
surface won't display initially.

Thanks to Benjamin Otte for pointing this possibility out.
2024-08-19 11:25:50 +08:00
Matthias Clasen
16e764b402 wayland: Use interface names defined by protocol
We don't need to hardcode all the interface names as string literals,
since they come as part of the wl_interface structs in the protocol
bindings we use.
2024-08-18 18:23:18 -04:00