summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorrbuj <[email protected]>2019-04-18 13:57:33 +0200
committerRobert Antoni Buj Gelonch <[email protected]>2019-04-19 21:26:31 +0200
commit4b1d0a8d4c2f0662e805fc9cf38a9d6a5e898748 (patch)
treee159ac3708677bebfe4d18663c4aab46ef9457eb /tools
parentda0e17fbb19958d838a9ea6093a05384aa6fc207 (diff)
downloadmate-session-manager-4b1d0a8d4c2f0662e805fc9cf38a9d6a5e898748.tar.bz2
mate-session-manager-4b1d0a8d4c2f0662e805fc9cf38a9d6a5e898748.tar.xz
mate-session-check-accelerated-gles-helper: fixes
cppcheck: Condition 'renderer!=NULL' is always false ifdef GDK_WINDOWING_X11 char *renderer = ... ... endif out: Apply Fedora patch: egl_dpy = get_display (display); From: Adam Jackson Date: Tue, 4 Oct 2016 13:15:39 -0400 Subject: [PATCH] check-accelerated-gles: Use eglGetPlatformDisplay{,EXT} eglGetDisplay forces the implementation to guess, and in general it can't guess correctly. Be explicit. https://src.fedoraproject.org/rpms/gnome-session/blob/master/f/0001-check-accelerated-gles-Use-eglGetPlatformDisplay-EXT.patch deprecations (gdk_error_trap_push & gdk_error_trap_pop_ignored): gdk_x11_display_error_trap_push (gdk_dpy); ... gdk_x11_display_error_trap_pop_ignored (gdk_dpy);
Diffstat (limited to 'tools')
-rw-r--r--tools/mate-session-check-accelerated-gles-helper.c49
1 files changed, 40 insertions, 9 deletions
diff --git a/tools/mate-session-check-accelerated-gles-helper.c b/tools/mate-session-check-accelerated-gles-helper.c
index ff6a62e..4dac1d5 100644
--- a/tools/mate-session-check-accelerated-gles-helper.c
+++ b/tools/mate-session-check-accelerated-gles-helper.c
@@ -38,11 +38,43 @@
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <EGL/egl.h>
+#include <EGL/eglext.h>
#endif
#include "mate-session-check-accelerated-common.h"
#ifdef GDK_WINDOWING_X11
+static EGLDisplay
+get_display (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 (EGL_PLATFORM_X11_KHR, 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 (EGL_PLATFORM_X11_KHR, native, NULL);
+
+ if (dpy)
+ return dpy;
+ }
+
+ return eglGetDisplay ((EGLNativeDisplayType) native);
+}
+
static char *
get_gles_renderer (void)
{
@@ -61,6 +93,7 @@ get_gles_renderer (void)
};
gboolean egl_inited = FALSE;
+ GdkDisplay *gdk_dpy;
Display *display;
Window win = None;
EGLContext egl_ctx = NULL;
@@ -68,10 +101,10 @@ get_gles_renderer (void)
EGLSurface egl_surf = NULL;
char *renderer = NULL;
- gdk_error_trap_push ();
-
- display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
- egl_dpy = eglGetDisplay (display);
+ gdk_dpy = gdk_display_get_default ();
+ gdk_x11_display_error_trap_push (gdk_dpy);
+ display = GDK_DISPLAY_XDISPLAY (gdk_dpy);
+ egl_dpy = get_display (display);
if (!egl_dpy) {
g_warning ("eglGetDisplay() failed");
goto out;
@@ -150,7 +183,7 @@ get_gles_renderer (void)
if (win != None)
XDestroyWindow (display, win);
- gdk_error_trap_pop_ignored ();
+ gdk_x11_display_error_trap_pop_ignored (gdk_dpy);
return renderer;
}
#endif
@@ -166,7 +199,6 @@ int
main (int argc,
char **argv)
{
- char *renderer = NULL;
GOptionContext *context;
int ret = HELPER_NO_ACCEL;
GError *error = NULL;
@@ -184,9 +216,7 @@ main (int argc,
}
#ifdef GDK_WINDOWING_X11
- renderer = get_gles_renderer ();
-#endif
-
+ char *renderer = get_gles_renderer ();
if (renderer != NULL) {
if (print_renderer)
g_print ("%s", renderer);
@@ -195,6 +225,7 @@ main (int argc,
else
ret = HELPER_ACCEL;
}
+#endif
out:
return ret;