[gtk/matthiasc/for-master] inspector: Use new get_egl_display apis
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master] inspector: Use new get_egl_display apis
- Date: Thu, 13 May 2021 02:05:11 +0000 (UTC)
commit 9fa7978f1be5a8577a8ba71aa9748fa9f6215b62
Author: Matthias Clasen <mclasen redhat com>
Date: Wed May 12 15:57:33 2021 -0400
inspector: Use new get_egl_display apis
This makes the code a bit more concise.
gtk/inspector/general.c | 149 ++++++++++++++----------------------------------
1 file changed, 42 insertions(+), 107 deletions(-)
---
diff --git a/gtk/inspector/general.c b/gtk/inspector/general.c
index e8c1b08eda..b6aab1a90f 100644
--- a/gtk/inspector/general.c
+++ b/gtk/inspector/general.c
@@ -38,10 +38,12 @@
#ifdef GDK_WINDOWING_X11
#include "x11/gdkx.h"
#include <epoxy/glx.h>
+#include <epoxy/egl.h>
#endif
#ifdef GDK_WINDOWING_WIN32
#include "win32/gdkwin32.h"
+#include <epoxy/egl.h>
#endif
#ifdef GDK_WINDOWING_MACOS
@@ -247,7 +249,7 @@ append_glx_extension_row (GtkInspectorGeneral *gen,
}
#endif
-#if defined(GDK_WINDOWING_WAYLAND) || defined (GDK_WINDOWING_X11)
+#if defined(GDK_WINDOWING_WAYLAND) || defined (GDK_WINDOWING_X11) || defined (GDK_WINDOWING_WIN32)
static void
append_egl_extension_row (GtkInspectorGeneral *gen,
EGLDisplay dpy,
@@ -259,55 +261,25 @@ append_egl_extension_row (GtkInspectorGeneral *gen,
static EGLDisplay
get_egl_display (GdkDisplay *display)
{
- void *native;
- GLenum platform;
- EGLDisplay dpy = NULL;
-
#ifdef GDK_WINDOWING_WAYLAND
if (GDK_IS_WAYLAND_DISPLAY (display))
- {
- native = gdk_wayland_display_get_wl_display (display);
- platform = EGL_PLATFORM_WAYLAND_EXT;
- }
+ return gdk_wayland_display_get_egl_display (display);
else
#endif
#ifdef GDK_WINDOWING_X11
if (GDK_IS_X11_DISPLAY (display))
- {
- native = gdk_x11_display_get_xdisplay (display);
- platform = EGL_PLATFORM_X11_EXT;
- }
+ return gdk_x11_display_get_egl_display (display);
+ else
+#endif
+#ifdef GDK_WINDOWING_WIN32
+ if (GDK_IS_WIN32_DISPLAY (display))
+ return gdk_win32_display_get_egl_display (display);
else
#endif
return NULL;
-
- if (epoxy_has_egl_extension (NULL, "EGL_KHR_platform_base"))
- {
- PFNEGLGETPLATFORMDISPLAYPROC getPlatformDisplay =
- (void *) eglGetProcAddress ("eglGetPlatformDisplay");
-
- if (getPlatformDisplay)
- dpy = getPlatformDisplay (platform, native, NULL);
- if (dpy)
- return dpy;
- }
-
- if (epoxy_has_egl_extension (NULL, "EGL_EXT_platform_base"))
- {
- PFNEGLGETPLATFORMDISPLAYEXTPROC getPlatformDisplay =
- (void *) eglGetProcAddress ("eglGetPlatformDisplayEXT");
-
- if (getPlatformDisplay)
- dpy = getPlatformDisplay (platform, native, NULL);
- if (dpy)
- return dpy;
- }
-
- return eglGetDisplay ((EGLNativeDisplayType)native);
}
#endif
-
static void
init_gl (GtkInspectorGeneral *gen)
{
@@ -318,85 +290,48 @@ init_gl (GtkInspectorGeneral *gen)
return;
}
-#ifdef GDK_WINDOWING_X11
- if (GDK_IS_X11_DISPLAY (gen->display))
+#if defined(GDK_WINDOWING_X11) || defined(GDK_WINDOWING_WAYLAND) || defined(GDK_WINDOWING_WIN32)
+ EGLDisplay egl_display = get_egl_display (gen->display);
+ if (egl_display)
{
- if (gdk_display_get_debug_flags (gen->display) & GDK_DEBUG_GL_GLX)
- {
- Display *dpy = GDK_DISPLAY_XDISPLAY (gen->display);
- int error_base, event_base;
- char *version;
-
- if (!glXQueryExtension (dpy, &error_base, &event_base))
- return;
-
- version = g_strconcat ("GLX ", glXGetClientString (dpy, GLX_VERSION), NULL);
- gtk_label_set_text (GTK_LABEL (gen->gl_version), version);
- g_free (version);
- gtk_label_set_text (GTK_LABEL (gen->gl_vendor), glXGetClientString (dpy, GLX_VENDOR));
-
- append_glx_extension_row (gen, dpy, "GLX_ARB_create_context_profile");
- append_glx_extension_row (gen, dpy, "GLX_SGI_swap_control");
- append_glx_extension_row (gen, dpy, "GLX_EXT_texture_from_pixmap");
- append_glx_extension_row (gen, dpy, "GLX_SGI_video_sync");
- append_glx_extension_row (gen, dpy, "GLX_EXT_buffer_age");
- append_glx_extension_row (gen, dpy, "GLX_OML_sync_control");
- append_glx_extension_row (gen, dpy, "GLX_ARB_multisample");
- append_glx_extension_row (gen, dpy, "GLX_EXT_visual_rating");
- }
- else
- {
- EGLDisplay dpy;
- EGLint major, minor;
- char *version;
-
- dpy = get_egl_display (gen->display);
-
- if (!eglInitialize (dpy, &major, &minor))
- {
- gtk_label_set_text (GTK_LABEL (gen->gl_version), C_("GL version", "None"));
- gtk_label_set_text (GTK_LABEL (gen->gl_vendor), C_("GL vendor", "None"));
- return;
- }
-
- version = g_strconcat ("EGL ", eglQueryString (dpy, EGL_VERSION), NULL);
- gtk_label_set_text (GTK_LABEL (gen->gl_version), version);
- g_free (version);
- gtk_label_set_text (GTK_LABEL (gen->gl_vendor), eglQueryString (dpy, EGL_VENDOR));
-
- append_egl_extension_row (gen, dpy, "EGL_KHR_create_context");
- append_egl_extension_row (gen, dpy, "EGL_EXT_buffer_age");
- append_egl_extension_row (gen, dpy, "EGL_EXT_swap_buffers_with_damage");
- append_egl_extension_row (gen, dpy, "EGL_KHR_surfaceless_context");
- }
+ char *version;
+
+ version = g_strconcat ("EGL ", eglQueryString (egl_display, EGL_VERSION), NULL);
+ gtk_label_set_text (GTK_LABEL (gen->gl_version), version);
+ g_free (version);
+
+ gtk_label_set_text (GTK_LABEL (gen->gl_vendor), eglQueryString (egl_display, EGL_VENDOR));
+
+ append_egl_extension_row (gen, egl_display, "EGL_KHR_create_context");
+ append_egl_extension_row (gen, egl_display, "EGL_EXT_buffer_age");
+ append_egl_extension_row (gen, egl_display, "EGL_EXT_swap_buffers_with_damage");
+ append_egl_extension_row (gen, egl_display, "EGL_KHR_surfaceless_context");
}
else
#endif
-#ifdef GDK_WINDOWING_WAYLAND
- if (GDK_IS_WAYLAND_DISPLAY (gen->display))
+#ifdef GDK_WINDOWING_X11
+ if (GDK_IS_X11_DISPLAY (gen->display))
{
- EGLDisplay dpy;
- EGLint major, minor;
+ Display *dpy = GDK_DISPLAY_XDISPLAY (gen->display);
+ int error_base, event_base;
char *version;
- dpy = get_egl_display (gen->display);
+ if (!glXQueryExtension (dpy, &error_base, &event_base))
+ return;
- if (!eglInitialize (dpy, &major, &minor))
- {
- gtk_label_set_text (GTK_LABEL (gen->gl_version), C_("GL version", "None"));
- gtk_label_set_text (GTK_LABEL (gen->gl_vendor), C_("GL vendor", "None"));
- return;
- }
-
- version = g_strconcat ("EGL ", eglQueryString (dpy, EGL_VERSION), NULL);
+ version = g_strconcat ("GLX ", glXGetClientString (dpy, GLX_VERSION), NULL);
gtk_label_set_text (GTK_LABEL (gen->gl_version), version);
g_free (version);
- gtk_label_set_text (GTK_LABEL (gen->gl_vendor), eglQueryString (dpy, EGL_VENDOR));
-
- append_egl_extension_row (gen, dpy, "EGL_KHR_create_context");
- append_egl_extension_row (gen, dpy, "EGL_EXT_buffer_age");
- append_egl_extension_row (gen, dpy, "EGL_EXT_swap_buffers_with_damage");
- append_egl_extension_row (gen, dpy, "EGL_KHR_surfaceless_context");
+ gtk_label_set_text (GTK_LABEL (gen->gl_vendor), glXGetClientString (dpy, GLX_VENDOR));
+
+ append_glx_extension_row (gen, dpy, "GLX_ARB_create_context_profile");
+ append_glx_extension_row (gen, dpy, "GLX_SGI_swap_control");
+ append_glx_extension_row (gen, dpy, "GLX_EXT_texture_from_pixmap");
+ append_glx_extension_row (gen, dpy, "GLX_SGI_video_sync");
+ append_glx_extension_row (gen, dpy, "GLX_EXT_buffer_age");
+ append_glx_extension_row (gen, dpy, "GLX_OML_sync_control");
+ append_glx_extension_row (gen, dpy, "GLX_ARB_multisample");
+ append_glx_extension_row (gen, dpy, "GLX_EXT_visual_rating");
}
else
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]