[gtk/wip.win32.fixes: 52/52] Win32: Add EGLDisplay getter




commit ff79b0fe005c09846ddd572778552144b178487b
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Wed May 12 19:29:05 2021 +0800

    Win32: Add EGLDisplay getter
    
    Like what was done for Wayland and X11, add an API to retrieve the EGLDisplay
    if one is being used in place of WGL.

 gdk/win32/gdkglcontext-win32.c | 27 ++++++++++++++++++++++++++-
 gdk/win32/gdkwin32display.h    |  3 +++
 2 files changed, 29 insertions(+), 1 deletion(-)
---
diff --git a/gdk/win32/gdkglcontext-win32.c b/gdk/win32/gdkglcontext-win32.c
index 54781ad484..02aa35eb4b 100644
--- a/gdk/win32/gdkglcontext-win32.c
+++ b/gdk/win32/gdkglcontext-win32.c
@@ -424,7 +424,6 @@ static EGLDisplay
 _gdk_win32_get_egl_display (GdkWin32Display *display)
 {
   EGLDisplay disp;
-  gboolean success = FALSE;
 
   if (epoxy_has_egl_extension (NULL, "EGL_EXT_platform_base"))
     {
@@ -555,6 +554,32 @@ _gdk_win32_display_init_gl (GdkDisplay *display)
   return TRUE;
 }
 
+/**
+ * gdk_win32_display_get_egl_display:
+ * @display: (type GdkWin32Display): a Win32 display
+ *
+ * Retrieves the EGL display connection object for the given GDK display.
+ *
+ * Returns: (nullable): the EGL display
+ */
+gpointer
+gdk_win32_display_get_egl_display (GdkDisplay *display)
+{
+  GdkWin32Display *display_win32;
+
+  g_return_val_if_fail (GDK_IS_WIN32_DISPLAY (display), EGL_NO_DISPLAY);
+
+  if (!_gdk_win32_display_init_gl (display))
+    return EGL_NO_DISPLAY;
+
+  display_win32 = GDK_WIN32_DISPLAY (display);
+
+  if (display_win32->have_wgl)
+    return EGL_NO_DISPLAY;
+
+  return display_win32->egl_disp;
+}
+
 /* Setup the legacy context after creating it */
 static gboolean
 _ensure_legacy_gl_context (HDC           hdc,
diff --git a/gdk/win32/gdkwin32display.h b/gdk/win32/gdkwin32display.h
index a91fe3e49d..e9e621eba5 100644
--- a/gdk/win32/gdkwin32display.h
+++ b/gdk/win32/gdkwin32display.h
@@ -104,6 +104,9 @@ void       gdk_win32_display_remove_filter       (GdkWin32Display
 GDK_AVAILABLE_IN_ALL
 GdkMonitor * gdk_win32_display_get_primary_monitor (GdkDisplay *display);
 
+GDK_AVAILABLE_IN_4_4
+gpointer gdk_win32_display_get_egl_display         (GdkDisplay  *display);
+
 
 G_END_DECLS
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]