mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-20 04:56:24 +00:00
gl/utils: implement wayland display GstContext
requried for sharing GL contexts or subsurface support
This commit is contained in:
parent
00cff1f9e4
commit
79f4a5fcf3
1 changed files with 65 additions and 0 deletions
|
@ -31,6 +31,9 @@
|
||||||
#if GST_GL_HAVE_WINDOW_X11
|
#if GST_GL_HAVE_WINDOW_X11
|
||||||
#include <gst/gl/x11/gstgldisplay_x11.h>
|
#include <gst/gl/x11/gstgldisplay_x11.h>
|
||||||
#endif
|
#endif
|
||||||
|
#if GST_GL_HAVE_WINDOW_WAYLAND
|
||||||
|
#include <gst/gl/wayland/gstgldisplay_wayland.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef GL_FRAMEBUFFER_UNDEFINED
|
#ifndef GL_FRAMEBUFFER_UNDEFINED
|
||||||
#define GL_FRAMEBUFFER_UNDEFINED 0x8219
|
#define GL_FRAMEBUFFER_UNDEFINED 0x8219
|
||||||
|
@ -618,6 +621,30 @@ gst_gl_display_context_query (GstElement * element, GstGLDisplay ** display_ptr)
|
||||||
goto out;
|
goto out;
|
||||||
#endif
|
#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:
|
out:
|
||||||
gst_query_unref (query);
|
gst_query_unref (query);
|
||||||
}
|
}
|
||||||
|
@ -741,6 +768,17 @@ gst_gl_handle_set_context (GstElement * element, GstContext * context,
|
||||||
display_replacement =
|
display_replacement =
|
||||||
(GstGLDisplay *) gst_gl_display_x11_new_with_display (display);
|
(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
|
#endif
|
||||||
else if (g_strcmp0 (context_type, "gst.gl.app_context") == 0) {
|
else if (g_strcmp0 (context_type, "gst.gl.app_context") == 0) {
|
||||||
const GstStructure *s = gst_context_get_structure (context);
|
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;
|
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
|
#endif
|
||||||
else if (g_strcmp0 (context_type, "gst.gl.app_context") == 0) {
|
else if (g_strcmp0 (context_type, "gst.gl.app_context") == 0) {
|
||||||
GstStructure *s;
|
GstStructure *s;
|
||||||
|
|
Loading…
Reference in a new issue