[gtk/ebassi/egl-display-get] wayland: Add EGLDisplay getter
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/ebassi/egl-display-get] wayland: Add EGLDisplay getter
- Date: Tue, 11 May 2021 11:46:17 +0000 (UTC)
commit 2588f9cee65012430a21a20b44bb567dae8ca96f
Author: Emmanuele Bassi <ebassi gnome org>
Date: Tue May 11 12:26:55 2021 +0100
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__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]