From 4b1d0a8d4c2f0662e805fc9cf38a9d6a5e898748 Mon Sep 17 00:00:00 2001 From: rbuj Date: Thu, 18 Apr 2019 13:57:33 +0200 Subject: 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); --- tools/mate-session-check-accelerated-gles-helper.c | 49 ++++++++++++++++++---- 1 file 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 #include #include +#include #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; -- cgit v1.2.1