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.
This commit is contained in:
Benjamin Otte 2021-10-02 05:21:29 +02:00
parent 75370a2fee
commit 38461ee204
3 changed files with 9 additions and 12 deletions

View File

@ -31,6 +31,7 @@
#include "gdkconstructor.h"
#include "gdkdebug.h"
#include "gdkdisplay.h"
#include "gdkglcontextprivate.h"
#include "gdkintl.h"
#include "gdk-private.h"
@ -294,6 +295,14 @@ gdk_pre_parse (void)
gdk_debug_keys,
G_N_ELEMENTS (gdk_debug_keys));
/* These are global */
if (GDK_DEBUG_CHECK (GL_EGL))
gdk_gl_backend_use (GDK_GL_EGL);
else if (GDK_DEBUG_CHECK (GL_GLX))
gdk_gl_backend_use (GDK_GL_GLX);
else if (GDK_DEBUG_CHECK (GL_WGL))
gdk_gl_backend_use (GDK_GL_WGL);
#ifndef G_HAS_CONSTRUCTORS
stash_desktop_startup_notification_id ();
#endif

View File

@ -1152,13 +1152,6 @@ gdk_win32_display_init_gl_backend (GdkDisplay *display,
{
gboolean result = FALSE;
#ifdef GDK_WIN32_ENABLE_EGL
if (GDK_DISPLAY_DEBUG_CHECK (display, GL_EGL))
return gdk_win32_display_init_egl (display, error);
#endif
if (GDK_DISPLAY_DEBUG_CHECK (display, GL_WGL))
return gdk_win32_display_init_wgl (display, error);
/* No env vars set, do the regular GL initialization, first WGL and then EGL,
* as WGL is the more tried-and-tested configuration.
*/

View File

@ -2893,11 +2893,6 @@ gdk_x11_display_init_gl_backend (GdkX11Display *self,
{
GdkDisplay *display G_GNUC_UNUSED = GDK_DISPLAY (self);
if (GDK_DISPLAY_DEBUG_CHECK (display, GL_EGL))
return gdk_x11_display_init_egl (self, TRUE, out_visual, out_depth, error);
if (GDK_DISPLAY_DEBUG_CHECK (display, GL_GLX))
return gdk_x11_display_init_glx (self, out_visual, out_depth, error);
/* No env vars set, do the regular GL initialization.
*
* We try EGL first, but are very picky about what we accept.