Commit Graph

10224 Commits

Author SHA1 Message Date
Benjamin Otte
d128ffcc14 egl: Move EGLSurface handling to GdkSurface
Calling gdk_surface_set_egl_native_window() enables this.
2021-10-06 03:44:35 +02:00
Benjamin Otte
aba37c40d3 display: Get carried away by extension checker
I wanted to make it easy to check for multiple extensions and then got
carried away by trying to generate beautiful error messages.
2021-10-06 03:43:47 +02:00
Benjamin Otte
c8204a902c surface: Add a private struct
Adding a random member to it resulted in a lot of header surgery as a
side effect.
2021-10-06 03:43:47 +02:00
Benjamin Otte
032eb15079 glcontext: The content cannot be the current context
The current context owns a reference to the context, so it cannot be
disposed.
2021-10-06 03:43:47 +02:00
Benjamin Otte
70607f56d9 x11: Port to shared EGL code 2021-10-06 03:43:47 +02:00
Benjamin Otte
bfb158d773 egl: Move initialization code and port Wayland
Moves the EGL initialization code to gdk/ so it can be shared between
backends.

Also port the Wayland backend to this code, so I know that it works.
2021-10-06 03:43:47 +02:00
Benjamin Otte
ae8de7168a build: Add a HAVE_EGL define to config.h 2021-10-06 03:43:47 +02:00
Benjamin Otte
04da2ff7c8 surface: Use g_clear_thing() 2021-10-05 04:48:15 +02:00
Benjamin Otte
38461ee204 gdk: Make GDK_DEBUG GL backend selection global
We have a global GdkGLBackendType now, just set it.

This way, using the variable forces the backend type, and we don't need
special code handling the env vars in the backends.

It also means setting the env var will now "work" on GDK backends that
don't even support that GL backend and simualte another GDK backend
having registered that GL backend already. So you can run
  GDK_DEBUG=gl-wgl gtk4-demo
on test what Wayland will do when WGL is in use.
2021-10-05 04:48:15 +02:00
Benjamin Otte
6ec6bcafbf win32: Remove unused variables 2021-10-05 04:48:15 +02:00
Benjamin Otte
d939f379f4 win32: Comment out unused function 2021-10-04 04:26:49 +02:00
Matthias Clasen
b8622adac5 contentdeserializer: Plug a small memleak
Found by asan in ci. We intern the mimetypes
when they are registered, so there is no need
to leak this string.
2021-10-03 14:52:09 -04:00
Timm Bäder
1efccfcced gdk loaders: Add noreturn attribtues where appropriate 2021-10-02 09:08:14 +02:00
Matthias Clasen
08fd62e328 x11: Better debug for egl
Print the extensions one per line, and sort them
alphabetically, so it is actually possible to find
something in the list.

Also print a short description of the chosen config.
2021-10-01 22:23:08 -04:00
Matthias Clasen
a9f401a9a0 wayland: better debug for egl
Print the extensions one per line, and sort them
alphabetically, so it is actually possible to find
something in the list.

Also print a short description of the chosen config.
2021-10-01 20:55:05 -04:00
Matthias Clasen
2a3a1aaf1e Merge branch 'fix-wgl-cairo-fallback' into 'master'
Apply MR !3964 to master (fix WGL->Cairo fallback-related items)

Closes #4257

See merge request GNOME/gtk!3987
2021-10-01 00:29:40 +00:00
Chun-wei Fan
9bff56db9f GDK-Win32: Fix build
Include the appropriate headers as some function prototypes were moved lately.

Also, re-order the include order of the gdk/*private.h headers alphabetically
in the files that were updated.
2021-09-30 16:21:38 +08:00
Christian Hergert
e77eaa0ace macos: handle NULL surface when creating GL context
Fixes #4279
2021-09-28 17:36:23 -07:00
Benjamin Otte
30a741e6af Merge branch 'wip/lantw/GDK-Win32-Use-lowercase-windows.h' into 'master'
GDK/Win32: Use lowercase windows.h

See merge request GNOME/gtk!4000
2021-09-27 23:23:36 +00:00
Ting-Wei Lan
5175b1676b GDK/Win32: Use lowercase windows.h
Fix build on case-sensitive file systems, so it can be cross-compiled
from Linux with MinGW.
2021-09-26 21:52:12 +08:00
Ting-Wei Lan
f96c4eb5bb broadway: Use the correct way to call find_library
While broadway currently doesn't build on Windows, it is still better to
avoid using the old and unsupported way to call find_library.
2021-09-26 18:51:13 +08:00
Benjamin Otte
a29474567a gdk: Remove gdkinternals.h 2021-09-24 22:50:29 +02:00
Benjamin Otte
279f9aa6d3 wayland: Don't include gdkinternals.h 2021-09-24 22:50:29 +02:00
Benjamin Otte
d4f9d38368 win32: Fix gcc warnings 2021-09-24 22:50:29 +02:00
Benjamin Otte
47e0539968 x11: Don't include gdkinternals.h 2021-09-24 22:50:29 +02:00
Benjamin Otte
4e836493cc macos: Don't include gdkinternals.h 2021-09-24 22:50:29 +02:00
Benjamin Otte
226ecaf9a2 win32: Don't include gdkinternals.h 2021-09-24 22:50:29 +02:00
Benjamin Otte
bcd9a0141a broadway: Don't include gdkinternals.h 2021-09-24 22:11:57 +02:00
Benjamin Otte
811b5d995b gdk: Don't include gdkinternals.h in gdk-private.h 2021-09-24 22:11:57 +02:00
Benjamin Otte
c7992884ae gdk: Remove gdk.h include form gdkframeclockidle.c 2021-09-24 22:11:57 +02:00
Benjamin Otte
39f2bb28de gdk: Remove gdk.h include from header 2021-09-24 22:11:57 +02:00
Benjamin Otte
78d7cb712e gdk: Remove gdk.h include from gdk-private.h 2021-09-24 22:11:57 +02:00
Benjamin Otte
d61c71c378 macos: Actually set the vfuncs 2021-09-24 22:11:57 +02:00
Benjamin Otte
23acc993cc gdk: Make sure only one GL backend is used
Creative people managed to create an X11 display and a Wayland display
at once, thereby getting EGL and GLX involved in a fight to the death
over the ownership of the glFoo() symbolspace.

A way to force such a fight with available tools here is (on Wayland)
running something like:
GTK_INSPECTOR_DISPLAY=:1 GTK_DEBUG=interactive gtk4-demo

Related: xdg-desktop-portal-gnome#5
2021-09-24 01:59:37 +02:00
Matthias Clasen
0b9f6985b1 texture: Document constructors as threadsafe
We aren't providing async loading apis here,
but we want to allow applications to create
textures in a thread, to avoid blocking the
main thread.
2021-09-21 23:10:53 -04:00
Chun-wei Fan
ece02317b9 gdkdisplay-win32.c: Don't retry WGL initialization
On Windows, GLES is not that widely available unless one installs wrapper
libraries such as libANGLE, so GLES/EGL support on Windows is used more like
a fallback mode if Desktop OpenGL (WGL) support is inadequate on the system.

Hence, unless one forces WGL or EGL, we will first try to initialize WGL, and
then try to initialize GLES if enabled and if WGL initialization failed, and
then just return whatever the last result we can obtain from these
initialization attempts, since unlike X11 EGL contexts, we do not have
separate modes for WGL except for legacy and non-legacy contexts.
2021-09-22 11:09:02 +08:00
Chun-wei Fan
218a3e3d01 gdkglcontext-win32-wgl.c: Fix Cairo fallback check
We were setting the WGL pixel format in GdkWin32Display too early, so the code
does not bail out correctly when we retry establishing the WGL context.

Fix this by pushing back setting the WGL pixel format only after it passes the
shader availability check.

Should fix issue #4257.
2021-09-22 11:08:53 +08:00
Benjamin Otte
d19f4ad53a Merge branch 'wip/otte/for-master' into 'master'
cssprovider: Be clearer about warnings vs errors

See merge request GNOME/gtk!3980
2021-09-20 05:38:27 +00:00
Benjamin Otte
d17552670c wayland: Add format hex value to debug print
It's how it's listed in the spec, this makes it easier to search.
2021-09-20 07:04:20 +02:00
Matthias Clasen
56e6a51ac0 Merge branch 'delayed-loading' into 'master'
gtk-demo: Cosmetics

See merge request GNOME/gtk!3975
2021-09-18 23:02:00 +00:00
Matthias Clasen
c9135546b6 loaders: Add profiler marks
These are potentially expensive calls, we
should make sure they show up in profiles.
2021-09-18 17:35:00 -04:00
Timm Bäder
c24b7877a0 gdktiff: Use guint32 instead of int32
The latter seems to be deprecated.
2021-09-18 09:00:16 +02:00
Benjamin Otte
1b85b5597b texture: Implement GIcon and GLoadableIcon
This is mainly for feature parity with GdkPixbuf. And it doesn't hurt
anyone (I hope).
2021-09-17 04:31:46 +02:00
Benjamin Otte
fae32846c7 texture: Refactor gdk_texture_new_from_bytes()
1. Split into a real loader and a fake one

2. Only try the fake one if the real one doesn't support the file.
2021-09-17 04:31:46 +02:00
Benjamin Otte
b271a94f92 texture: Rework error enum
1. Change INSUFFICIENT_MEMORY to TOO_LARGE
   GTK crashes on insufficient memory, we don't emit GErrors.

2. Split UNSUPPORTED into UNSUPPORTED_CONTENT and UNSUPPORTED_FORMAT
   So we know if you need to find an RPM with a loader or curse and
   the weird file.

3. Translate error messages, they are meant for end users.
2021-09-17 03:25:35 +02:00
Matthias Clasen
b226478e8b Support 16bit formats in the png loader
When loading, convert all >8-bit data to
GDK_MEMORY_R16G16B16A16_PREMULTIPLIED.

When saving, save all 8-bit formats as 8-bit RGBA,
and save all >8-bt formats as 16-bit RGBA.
2021-09-17 02:02:51 +02:00
Matthias Clasen
14280b5f5b contentdeserializer: Use our on jpeg loader 2021-09-17 02:02:51 +02:00
Matthias Clasen
e720f9d35d Add code to save jpegs 2021-09-17 02:02:51 +02:00
Benjamin Otte
679c93e843 texture: Add private can_load() function
... and use it to load textures in gtk_picture_set_from_file().
2021-09-17 00:25:22 +02:00
Benjamin Otte
2d3de8608c texture: Split out type detection
This way, the code using it becomes clearer and we can use it in
multiple places without accidentally doing it wrong (hint: see next
commit).
2021-09-17 00:25:22 +02:00