gl/utils: implement wayland display GstContext

requried for sharing GL contexts or subsurface support
This commit is contained in:
Matthew Waters 2015-05-27 15:43:06 +10:00
parent be9739cd2f
commit b39ccd3745

View file

@ -31,6 +31,9 @@
#if GST_GL_HAVE_WINDOW_X11
#include <gst/gl/x11/gstgldisplay_x11.h>
#endif
#if GST_GL_HAVE_WINDOW_WAYLAND
#include <gst/gl/wayland/gstgldisplay_wayland.h>
#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;