[gtk/wip/otte/gl-hdr: 4/14] gdk: Make GDK_DEBUG GL backend selection global




commit 979d8a387dbe74e697b9d1f8e9dc0ee2e5cc33c8
Author: Benjamin Otte <otte redhat com>
Date:   Sat Oct 2 05:21:29 2021 +0200

    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.

 gdk/gdk.c                    | 9 +++++++++
 gdk/win32/gdkdisplay-win32.c | 7 -------
 gdk/x11/gdkdisplay-x11.c     | 5 -----
 3 files changed, 9 insertions(+), 12 deletions(-)
---
diff --git a/gdk/gdk.c b/gdk/gdk.c
index cd8c0bdcc8..8f0cbbb3bb 100644
--- a/gdk/gdk.c
+++ b/gdk/gdk.c
@@ -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
diff --git a/gdk/win32/gdkdisplay-win32.c b/gdk/win32/gdkdisplay-win32.c
index 323ef8a7d8..5495f0f6af 100644
--- a/gdk/win32/gdkdisplay-win32.c
+++ b/gdk/win32/gdkdisplay-win32.c
@@ -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.
    */
diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
index 6e5fd276f7..2e4273db8f 100644
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@ -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.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]