From 6189e343f3071edd37e3b748c8f3376867810860 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 11 May 2021 12:24:34 +0100 Subject: [PATCH 1/3] build: Do not use C arguments with C++ Otherwise the C++ compiler will start to complain. The C++ keyword test does not need additional warnings. --- testsuite/gtk/meson.build | 1 - 1 file changed, 1 deletion(-) diff --git a/testsuite/gtk/meson.build b/testsuite/gtk/meson.build index f2d6491287..a33fd29c1e 100644 --- a/testsuite/gtk/meson.build +++ b/testsuite/gtk/meson.build @@ -223,7 +223,6 @@ endforeach if add_languages('cpp', required: false, native: false) test_exe = executable('autotestkeywords', sources: 'autotestkeywords.cc', - cpp_args: test_cargs, dependencies: libgtk_dep, install: get_option('install-tests'), install_dir: testexecdir, From abc2d7e4a905817556b5eb86970255b92e1ad218 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 11 May 2021 12:25:38 +0100 Subject: [PATCH 2/3] x11: Add EGLDisplay getter Getting an EGLDisplay object is messy; might as well expose the function we use internally to save some time. --- gdk/x11/gdkglcontext-egl.c | 19 ++++++++++++++++++- gdk/x11/gdkx11glcontext.h | 3 +++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/gdk/x11/gdkglcontext-egl.c b/gdk/x11/gdkglcontext-egl.c index 1836f19057..91f3e8297c 100644 --- a/gdk/x11/gdkglcontext-egl.c +++ b/gdk/x11/gdkglcontext-egl.c @@ -84,12 +84,29 @@ drawable_info_free (gpointer data) g_free (info); } -static EGLDisplay +/** + * gdk_x11_display_get_egl_display: + * @display: (type GdkX11Display): an X11 display + * + * Retrieves the EGL display connection object for the given GDK display. + * + * This function returns `NULL` if GDK is using GLX. + * + * Returns: (nullable): the EGL display object + * + * Since: 4.4 + */ +gpointer gdk_x11_display_get_egl_display (GdkDisplay *display) { EGLDisplay edpy = NULL; Display *dpy; + g_return_val_if_fail (GDK_IS_X11_DISPLAY (display), NULL); + + if (GDK_X11_DISPLAY (display)->have_glx) + return NULL; + edpy = g_object_get_data (G_OBJECT (display), "-gdk-x11-egl-display"); if (edpy != NULL) return edpy; diff --git a/gdk/x11/gdkx11glcontext.h b/gdk/x11/gdkx11glcontext.h index 34cbd70d75..173f6acac7 100644 --- a/gdk/x11/gdkx11glcontext.h +++ b/gdk/x11/gdkx11glcontext.h @@ -48,6 +48,9 @@ gboolean gdk_x11_display_get_egl_version (GdkDisplay *display, int *major, int *minor); +GDK_AVAILABLE_IN_4_4 +gpointer gdk_x11_display_get_egl_display (GdkDisplay *display); + G_END_DECLS #endif /* __GDK_X11_GL_CONTEXT_H__ */ From 2588f9cee65012430a21a20b44bb567dae8ca96f Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 11 May 2021 12:26:55 +0100 Subject: [PATCH 3/3] wayland: Add EGLDisplay getter Getting an EGLDisplay object is messy; might as well expose the function we use internally to save some time, just like we did for the X11 backend. --- gdk/wayland/gdkglcontext-wayland.c | 44 ++++++++++++++++++++++++------ gdk/wayland/gdkwaylanddisplay.h | 3 ++ 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/gdk/wayland/gdkglcontext-wayland.c b/gdk/wayland/gdkglcontext-wayland.c index 9e2572f5be..b0edf86956 100644 --- a/gdk/wayland/gdkglcontext-wayland.c +++ b/gdk/wayland/gdkglcontext-wayland.c @@ -333,8 +333,31 @@ gdk_wayland_gl_context_init (GdkWaylandGLContext *self) { } +/** + * gdk_wayland_display_get_egl_display: + * @display: (type GdkWaylandDisplay): a Wayland display + * + * Retrieves the EGL display connection object for the given GDK display. + * + * Returns: (nullable): the EGL display + */ +gpointer +gdk_wayland_display_get_egl_display (GdkDisplay *display) +{ + GdkWaylandDisplay *display_wayland; + + g_return_val_if_fail (GDK_IS_WAYLAND_DISPLAY (display), NULL); + + if (!gdk_wayland_display_init_gl (display)) + return NULL; + + display_wayland = GDK_WAYLAND_DISPLAY (display); + + return display_wayland->egl_display; +} + static EGLDisplay -gdk_wayland_get_display (GdkWaylandDisplay *display_wayland) +get_egl_display (GdkWaylandDisplay *display_wayland) { EGLDisplay dpy = NULL; @@ -343,12 +366,12 @@ gdk_wayland_get_display (GdkWaylandDisplay *display_wayland) PFNEGLGETPLATFORMDISPLAYPROC getPlatformDisplay = (void *) eglGetProcAddress ("eglGetPlatformDisplay"); - if (getPlatformDisplay) + if (getPlatformDisplay != NULL) dpy = getPlatformDisplay (EGL_PLATFORM_WAYLAND_EXT, display_wayland->wl_display, NULL); - if (dpy) - return dpy; + if (dpy != NULL) + goto out; } if (epoxy_has_egl_extension (NULL, "EGL_EXT_platform_base")) @@ -356,15 +379,18 @@ gdk_wayland_get_display (GdkWaylandDisplay *display_wayland) PFNEGLGETPLATFORMDISPLAYEXTPROC getPlatformDisplay = (void *) eglGetProcAddress ("eglGetPlatformDisplayEXT"); - if (getPlatformDisplay) + if (getPlatformDisplay != NULL) dpy = getPlatformDisplay (EGL_PLATFORM_WAYLAND_EXT, display_wayland->wl_display, NULL); - if (dpy) - return dpy; + if (dpy != NULL) + goto out; } - return eglGetDisplay ((EGLNativeDisplayType) display_wayland->wl_display); + dpy = eglGetDisplay ((EGLNativeDisplayType) display_wayland->wl_display); + +out: + return dpy; } gboolean @@ -377,7 +403,7 @@ gdk_wayland_display_init_gl (GdkDisplay *display) if (display_wayland->have_egl) return TRUE; - dpy = gdk_wayland_get_display (display_wayland); + dpy = get_egl_display (display_wayland); if (dpy == NULL) return FALSE; diff --git a/gdk/wayland/gdkwaylanddisplay.h b/gdk/wayland/gdkwaylanddisplay.h index 239bf26ce5..7aac2db509 100644 --- a/gdk/wayland/gdkwaylanddisplay.h +++ b/gdk/wayland/gdkwaylanddisplay.h @@ -63,6 +63,9 @@ GDK_AVAILABLE_IN_ALL gboolean gdk_wayland_display_query_registry (GdkDisplay *display, const char *global); +GDK_AVAILABLE_IN_4_4 +gpointer gdk_wayland_display_get_egl_display (GdkDisplay *display); + G_END_DECLS #endif /* __GDK_WAYLAND_DISPLAY_H__ */