[vlc-devel] [RFC PATCH 4/8] vlc_opengl: vlc_gl_GetNativeDpy

Thomas Guillem thomas at gllm.fr
Fri Feb 10 11:35:58 CET 2017


This function will return the current X11 or WL Display.
---
 include/vlc_opengl.h              |  6 ++++++
 modules/video_output/glx.c        |  9 +++++++++
 modules/video_output/opengl/egl.c | 15 +++++++++++++++
 3 files changed, 30 insertions(+)

diff --git a/include/vlc_opengl.h b/include/vlc_opengl.h
index 6642f78554..4e79753b61 100644
--- a/include/vlc_opengl.h
+++ b/include/vlc_opengl.h
@@ -50,6 +50,7 @@ struct vlc_gl_t
     void (*resize)(vlc_gl_t *, unsigned, unsigned);
     void (*swap)(vlc_gl_t *);
     void*(*getProcAddress)(vlc_gl_t *, const char *);
+    int  (*getNativeDpy)(vlc_gl_t *, void **nativedpy);
 };
 
 enum {
@@ -86,6 +87,11 @@ static inline void *vlc_gl_GetProcAddress(vlc_gl_t *gl, const char *name)
     return (gl->getProcAddress != NULL) ? gl->getProcAddress(gl, name) : NULL;
 }
 
+static inline int vlc_gl_GetNativeDpy(vlc_gl_t *gl, void **nativedpy)
+{
+    return gl->getNativeDpy ? gl->getNativeDpy(gl, nativedpy) : -1;
+}
+
 VLC_API vlc_gl_t *vlc_gl_surface_Create(vlc_object_t *,
                                         const struct vout_window_cfg_t *,
                                         struct vout_window_t **) VLC_USED;
diff --git a/modules/video_output/glx.c b/modules/video_output/glx.c
index dc692e9a59..9d2b3deacd 100644
--- a/modules/video_output/glx.c
+++ b/modules/video_output/glx.c
@@ -75,6 +75,14 @@ static void *GetSymbol(vlc_gl_t *gl, const char *procname)
 #endif
 }
 
+static int GetNativeDpy(vlc_gl_t *gl, void **nativedpy)
+{
+    vlc_gl_sys_t *sys = gl->sys;
+
+    *nativedpy = sys->display;
+    return 0;
+}
+
 static bool CheckGLX (vlc_object_t *vd, Display *dpy)
 {
     int major, minor;
@@ -208,6 +216,7 @@ static int Open (vlc_object_t *obj)
     gl->resize = NULL;
     gl->swap = SwapBuffers;
     gl->getProcAddress = GetSymbol;
+    gl->getNativeDpy = GetNativeDpy;
 
 #ifdef GLX_ARB_get_proc_address
     bool is_swap_interval_set = false;
diff --git a/modules/video_output/opengl/egl.c b/modules/video_output/opengl/egl.c
index 7a2bad0833..cc9c76d389 100644
--- a/modules/video_output/opengl/egl.c
+++ b/modules/video_output/opengl/egl.c
@@ -103,6 +103,20 @@ static void *GetSymbol(vlc_gl_t *gl, const char *procname)
     return (void *)eglGetProcAddress (procname);
 }
 
+static int GetNativeDpy(vlc_gl_t *gl, void **nativedpy)
+{
+    vlc_gl_sys_t *sys = gl->sys;
+
+#if defined (USE_PLATFORM_X11)
+    *nativedpy = sys->x11;
+#elif defined (USE_PLATFORM_WAYLAND)
+    *nativedpy = gl->surface->display.wl;
+#else
+    *nativedpy = NULL;
+#endif
+    return *nativedpy != NULL ? 0 : -1;
+}
+
 static bool CheckToken(const char *haystack, const char *needle)
 {
     size_t len = strlen(needle);
@@ -371,6 +385,7 @@ static int Open (vlc_object_t *obj, const struct gl_api *api)
     gl->resize = Resize;
     gl->swap = SwapBuffers;
     gl->getProcAddress = GetSymbol;
+    gl->getNativeDpy = GetNativeDpy;
     return VLC_SUCCESS;
 
 error:
-- 
2.11.0



More information about the vlc-devel mailing list