Prefer eglGetPlatformDisplay to eglGetDisplay

This commit is contained in:
Adam Jackson 2016-10-11 16:30:52 -04:00
parent 5194d28d74
commit 34773a597d
2 changed files with 127 additions and 1 deletions

View File

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

View File

@ -6,13 +6,18 @@
Name: cogl
Version: 1.22.2
Release: 1%{?dist}
Release: 2%{?dist}
Summary: A library for using 3D graphics hardware to draw pretty pictures
License: LGPLv2+
URL: http://www.clutter-project.org/
Source0: http://download.gnome.org/sources/cogl/1.22/cogl-%{version}.tar.xz
# Vaguely related to https://bugzilla.gnome.org/show_bug.cgi?id=772419
# but on the 1.22 branch, and the static inline in the header is gross
# ajax promises he'll clean this up.
Patch0: 0001-egl-Use-eglGetPlatformDisplay-not-eglGetDisplay.patch
BuildRequires: cairo-devel
BuildRequires: chrpath
BuildRequires: gdk-pixbuf2-devel
@ -84,6 +89,7 @@ This package contains the installable tests for %{cogl}.
%prep
%setup -q
%patch0 -p1
%build
CFLAGS="$RPM_OPT_FLAGS -fPIC"
@ -149,6 +155,9 @@ chrpath --delete $RPM_BUILD_ROOT%{_libdir}/libcogl-pango.so
%endif
%changelog
* Tue Oct 11 2016 Adam Jackson <ajax@redhat.com> - 1.22.2-2
- Prefer eglGetPlatformDisplay to eglGetDisplay
* Fri Aug 26 2016 Kalev Lember <klember@redhat.com> - 1.22.2-1
- Update to 1.22.2
- Don't set group tags