Blame SOURCES/0001-egl-Use-eglGetPlatformDisplay-not-eglGetDisplay.patch

db7a92
From 988e021960eb372be50038fdf0b2874f063c02b6 Mon Sep 17 00:00:00 2001
db7a92
From: Adam Jackson <ajax@redhat.com>
db7a92
Date: Tue, 11 Oct 2016 16:16:38 -0400
db7a92
Subject: [PATCH] egl: Use eglGetPlatformDisplay not eglGetDisplay
db7a92
db7a92
The latter requires the implementation to guess which kind of display it
db7a92
is. Different implementations do different thing, in particular glvnd
db7a92
does something different from Mesa, and it's better to be explicit about
db7a92
what we need.
db7a92
db7a92
Signed-off-by: Adam Jackson <ajax@redhat.com>
db7a92
---
db7a92
 cogl/cogl-egl.h                       |  1 -
db7a92
 cogl/winsys/cogl-winsys-egl-kms.c     |  3 ++-
db7a92
 cogl/winsys/cogl-winsys-egl-private.h | 33 +++++++++++++++++++++++++++++++++
db7a92
 cogl/winsys/cogl-winsys-egl-wayland.c |  3 ++-
db7a92
 cogl/winsys/cogl-winsys-egl-x11.c     |  2 +-
db7a92
 5 files changed, 38 insertions(+), 4 deletions(-)
db7a92
db7a92
diff --git a/cogl/cogl-egl.h b/cogl/cogl-egl.h
db7a92
index cea7b10..5dac55f 100644
db7a92
--- a/cogl/cogl-egl.h
db7a92
+++ b/cogl/cogl-egl.h
db7a92
@@ -98,7 +98,6 @@ cogl_egl_context_get_egl_display (CoglContext *context);
db7a92
 EGLContext
db7a92
 cogl_egl_context_get_egl_context (CoglContext *context);
db7a92
 
db7a92
-
db7a92
 COGL_END_DECLS
db7a92
 
db7a92
 /* The gobject introspection scanner seems to parse public headers in
db7a92
diff --git a/cogl/winsys/cogl-winsys-egl-kms.c b/cogl/winsys/cogl-winsys-egl-kms.c
db7a92
index 4da1f14..ae9f6fc 100644
db7a92
--- a/cogl/winsys/cogl-winsys-egl-kms.c
db7a92
+++ b/cogl/winsys/cogl-winsys-egl-kms.c
db7a92
@@ -342,7 +342,8 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
db7a92
       goto fail;
db7a92
     }
db7a92
 
db7a92
-  egl_renderer->edpy = eglGetDisplay ((EGLNativeDisplayType)kms_renderer->gbm);
db7a92
+  egl_renderer->edpy = cogl_winsys_egl_get_display(EGL_PLATFORM_GBM_KHR,
db7a92
+                                                   kms_renderer->gbm);
db7a92
   if (egl_renderer->edpy == EGL_NO_DISPLAY)
db7a92
     {
db7a92
       _cogl_set_error (error, COGL_WINSYS_ERROR,
db7a92
diff --git a/cogl/winsys/cogl-winsys-egl-private.h b/cogl/winsys/cogl-winsys-egl-private.h
db7a92
index 5d21b4f..27ac25c 100644
db7a92
--- a/cogl/winsys/cogl-winsys-egl-private.h
db7a92
+++ b/cogl/winsys/cogl-winsys-egl-private.h
db7a92
@@ -200,4 +200,37 @@ CoglBool
db7a92
 _cogl_winsys_egl_renderer_connect_common (CoglRenderer *renderer,
db7a92
                                           CoglError **error);
db7a92
 
db7a92
+static inline EGLDisplay
db7a92
+cogl_winsys_egl_get_display (EGLint type, void *native)
db7a92
+{
db7a92
+  EGLDisplay dpy = NULL;
db7a92
+  const char *client_exts = eglQueryString (NULL, EGL_EXTENSIONS);
db7a92
+
db7a92
+  if (g_strstr_len (client_exts, -1, "EGL_KHR_platform_base"))
db7a92
+    {
db7a92
+      PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display =
db7a92
+	(void *) eglGetProcAddress ("eglGetPlatformDisplay");
db7a92
+
db7a92
+      if (get_platform_display)
db7a92
+	dpy = get_platform_display (type, native, NULL);
db7a92
+
db7a92
+      if (dpy)
db7a92
+	return dpy;
db7a92
+    }
db7a92
+
db7a92
+  if (g_strstr_len (client_exts, -1, "EGL_EXT_platform_base"))
db7a92
+    {
db7a92
+      PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display =
db7a92
+	(void *) eglGetProcAddress ("eglGetPlatformDisplayEXT");
db7a92
+
db7a92
+      if (get_platform_display)
db7a92
+	dpy = get_platform_display (type, native, NULL);
db7a92
+
db7a92
+      if (dpy)
db7a92
+	return dpy;
db7a92
+    }
db7a92
+
db7a92
+  return eglGetDisplay ((EGLNativeDisplayType) native);
db7a92
+}
db7a92
+
db7a92
 #endif /* __COGL_WINSYS_EGL_PRIVATE_H */
db7a92
diff --git a/cogl/winsys/cogl-winsys-egl-wayland.c b/cogl/winsys/cogl-winsys-egl-wayland.c
db7a92
index 2e22052..463041b 100644
db7a92
--- a/cogl/winsys/cogl-winsys-egl-wayland.c
db7a92
+++ b/cogl/winsys/cogl-winsys-egl-wayland.c
db7a92
@@ -289,7 +289,8 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
db7a92
     }
db7a92
 
db7a92
   egl_renderer->edpy =
db7a92
-    eglGetDisplay ((EGLNativeDisplayType) wayland_renderer->wayland_display);
db7a92
+    cogl_winsys_egl_get_display (EGL_PLATFORM_WAYLAND_KHR,
db7a92
+                                 wayland_renderer->wayland_display);
db7a92
 
db7a92
   if (!_cogl_winsys_egl_renderer_connect_common (renderer, error))
db7a92
     goto error;
db7a92
diff --git a/cogl/winsys/cogl-winsys-egl-x11.c b/cogl/winsys/cogl-winsys-egl-x11.c
db7a92
index 724a4d0..a7e9c2f 100644
db7a92
--- a/cogl/winsys/cogl-winsys-egl-x11.c
db7a92
+++ b/cogl/winsys/cogl-winsys-egl-x11.c
db7a92
@@ -278,7 +278,7 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
db7a92
     goto error;
db7a92
 
db7a92
   egl_renderer->edpy =
db7a92
-    eglGetDisplay ((EGLNativeDisplayType) xlib_renderer->xdpy);
db7a92
+    cogl_winsys_egl_get_display (EGL_PLATFORM_X11_KHR, xlib_renderer->xdpy);
db7a92
 
db7a92
   if (!_cogl_winsys_egl_renderer_connect_common (renderer, error))
db7a92
     goto error;
db7a92
-- 
db7a92
2.9.3
db7a92