diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-05-11 12:42:50 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-05-11 12:42:50 +0000 |
commit | 78852b181a719932c0ef6306024d22e628bf29fa (patch) | |
tree | bff41a059615248d351c9dea9057e8073ae47419 | |
parent | 8bfa182ed937ae929f724239cae89324a271b7ba (diff) | |
parent | 2588f9cee65012430a21a20b44bb567dae8ca96f (diff) | |
download | gtk+-78852b181a719932c0ef6306024d22e628bf29fa.tar.gz |
Merge branch 'ebassi/egl-display-get' into 'master'
Add backend-specific getter for the EGLDisplay
See merge request GNOME/gtk!3542
-rw-r--r-- | gdk/wayland/gdkglcontext-wayland.c | 44 | ||||
-rw-r--r-- | gdk/wayland/gdkwaylanddisplay.h | 3 | ||||
-rw-r--r-- | gdk/x11/gdkglcontext-egl.c | 19 | ||||
-rw-r--r-- | gdk/x11/gdkx11glcontext.h | 3 | ||||
-rw-r--r-- | testsuite/gtk/meson.build | 1 |
5 files changed, 59 insertions, 11 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__ */ 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__ */ 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, |