From 79f4a5fcf3aa6a609d95c04d23dabeffeeaf75ee Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Wed, 27 May 2015 15:43:06 +1000 Subject: [PATCH] gl/utils: implement wayland display GstContext requried for sharing GL contexts or subsurface support --- gst-libs/gst/gl/gstglutils.c | 65 ++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/gst-libs/gst/gl/gstglutils.c b/gst-libs/gst/gl/gstglutils.c index 20c5da611e..5c751de0b4 100644 --- a/gst-libs/gst/gl/gstglutils.c +++ b/gst-libs/gst/gl/gstglutils.c @@ -31,6 +31,9 @@ #if GST_GL_HAVE_WINDOW_X11 #include #endif +#if GST_GL_HAVE_WINDOW_WAYLAND +#include +#endif #ifndef GL_FRAMEBUFFER_UNDEFINED #define GL_FRAMEBUFFER_UNDEFINED 0x8219 @@ -618,6 +621,30 @@ gst_gl_display_context_query (GstElement * element, GstGLDisplay ** display_ptr) goto out; #endif +#if GST_GL_HAVE_WINDOW_WAYLAND + gst_query_unref (query); + query = + _gst_context_query (element, display_ptr, + "GstWaylandDisplayHandleContextType"); + gst_query_parse_context (query, &ctxt); + if (ctxt + && gst_context_has_context_type (ctxt, + "GstWaylandDisplayHandleContextType")) { + const GstStructure *s; + struct wl_display *display; + + s = gst_context_get_structure (ctxt); + if (gst_structure_get (s, "display", G_TYPE_POINTER, &display, NULL) + && display) { + *display_ptr = + (GstGLDisplay *) gst_gl_display_wayland_new_with_display (display); + } + } + + if (*display_ptr) + goto out; +#endif + out: gst_query_unref (query); } @@ -741,6 +768,17 @@ gst_gl_handle_set_context (GstElement * element, GstContext * context, display_replacement = (GstGLDisplay *) gst_gl_display_x11_new_with_display (display); } +#endif +#if GST_GL_HAVE_WINDOW_WAYLAND + else if (g_strcmp0 (context_type, "GstWaylandDisplayHandleContextType") == 0) { + const GstStructure *s; + struct wl_display *display; + + s = gst_context_get_structure (context); + if (gst_structure_get (s, "display", G_TYPE_POINTER, &display, NULL)) + display_replacement = + (GstGLDisplay *) gst_gl_display_wayland_new_with_display (display); + } #endif else if (g_strcmp0 (context_type, "gst.gl.app_context") == 0) { const GstStructure *s = gst_context_get_structure (context); @@ -838,6 +876,33 @@ gst_gl_handle_context_query (GstElement * element, GstQuery * query, res = x11_display != NULL; } +#endif +#if GST_GL_HAVE_WINDOW_WAYLAND + else if (g_strcmp0 (context_type, "GstWaylandDisplayHandleContextType") == 0) { + GstStructure *s; + struct wl_display *wayland_display = NULL; + + gst_query_parse_context (query, &old_context); + + if (old_context) + context = gst_context_copy (old_context); + else + context = gst_context_new ("GstWaylandDisplayHandleContextType", TRUE); + + if (*display + && ((*display)->type & GST_GL_DISPLAY_TYPE_WAYLAND) == + GST_GL_DISPLAY_TYPE_WAYLAND) + wayland_display = + (struct wl_display *) gst_gl_display_get_handle (*display); + + s = gst_context_writable_structure (context); + gst_structure_set (s, "display", G_TYPE_POINTER, wayland_display, NULL); + + gst_query_set_context (query, context); + gst_context_unref (context); + + res = wayland_display != NULL; + } #endif else if (g_strcmp0 (context_type, "gst.gl.app_context") == 0) { GstStructure *s;