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.
This commit is contained in:
Emmanuele Bassi 2021-05-11 12:26:55 +01:00
parent abc2d7e4a9
commit 2588f9cee6
2 changed files with 38 additions and 9 deletions

View File

@ -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;

View File

@ -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__ */