Blame SOURCES/0001-check-accelerated-gles-Use-eglGetPlatformDisplay-EXT.patch

3b5eee
From 687ec347d2fa0bca227e3a583a3a47f9bbc10bb0 Mon Sep 17 00:00:00 2001
3b5eee
From: Adam Jackson <ajax@redhat.com>
3b5eee
Date: Tue, 4 Oct 2016 13:15:39 -0400
3b5eee
Subject: [PATCH] check-accelerated-gles: Use eglGetPlatformDisplay{,EXT}
3b5eee
3b5eee
eglGetDisplay forces the implementation to guess, and in general it
3b5eee
can't guess correctly. Be explicit.
3b5eee
3b5eee
Signed-off-by: Adam Jackson <ajax@redhat.com>
3b5eee
---
3b5eee
 .../gnome-session-check-accelerated-gles-helper.c  | 36 +++++++++++++++++++++-
3b5eee
 1 file changed, 35 insertions(+), 1 deletion(-)
3b5eee
3b5eee
diff --git a/tools/gnome-session-check-accelerated-gles-helper.c b/tools/gnome-session-check-accelerated-gles-helper.c
3b5eee
index 2a38d9e..472d1ad 100644
3b5eee
--- a/tools/gnome-session-check-accelerated-gles-helper.c
3b5eee
+++ b/tools/gnome-session-check-accelerated-gles-helper.c
3b5eee
@@ -34,11 +34,43 @@
3b5eee
 #include <GLES2/gl2.h>
3b5eee
 #include <GLES2/gl2ext.h>
3b5eee
 #include <EGL/egl.h>
3b5eee
+#include <EGL/eglext.h>
3b5eee
 #endif
3b5eee
 
3b5eee
 #include "gnome-session-check-accelerated-common.h"
3b5eee
 
3b5eee
 #ifdef GDK_WINDOWING_X11
3b5eee
+static EGLDisplay
3b5eee
+get_display (void *native)
3b5eee
+{
3b5eee
+    EGLDisplay dpy = NULL;
3b5eee
+    const char *client_exts = eglQueryString (NULL, EGL_EXTENSIONS);
3b5eee
+
3b5eee
+    if (g_strstr_len (client_exts, -1, "EGL_KHR_platform_base")) {
3b5eee
+	PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display =
3b5eee
+	    (void *) eglGetProcAddress ("eglGetPlatformDisplay");
3b5eee
+
3b5eee
+	if (get_platform_display)
3b5eee
+	    dpy = get_platform_display (EGL_PLATFORM_X11_KHR, native, NULL);
3b5eee
+
3b5eee
+	if (dpy)
3b5eee
+	    return dpy;
3b5eee
+    }
3b5eee
+
3b5eee
+    if (g_strstr_len (client_exts, -1, "EGL_EXT_platform_base")) {
3b5eee
+	PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display =
3b5eee
+	    (void *) eglGetProcAddress ("eglGetPlatformDisplayEXT");
3b5eee
+
3b5eee
+	if (get_platform_display)
3b5eee
+	    dpy = get_platform_display (EGL_PLATFORM_X11_KHR, native, NULL);
3b5eee
+
3b5eee
+	if (dpy)
3b5eee
+	    return dpy;
3b5eee
+    }
3b5eee
+
3b5eee
+    return eglGetDisplay ((EGLNativeDisplayType) native);
3b5eee
+}
3b5eee
+
3b5eee
 static char *
3b5eee
 get_gles_renderer (void)
3b5eee
 {
3b5eee
@@ -67,7 +99,9 @@ get_gles_renderer (void)
3b5eee
         gdk_error_trap_push ();
3b5eee
 
3b5eee
         display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
3b5eee
-        egl_dpy = eglGetDisplay (display);
3b5eee
+
3b5eee
+        egl_dpy = get_display (display);
3b5eee
+
3b5eee
         if (!egl_dpy) {
3b5eee
                 g_warning ("eglGetDisplay() failed");
3b5eee
                 goto out;
3b5eee
-- 
3b5eee
2.9.3
3b5eee