gtk: implement basic wayland GL support
authorMatthew Waters <matthew@centricular.com>
Mon, 15 Jun 2015 04:33:08 +0000 (14:33 +1000)
committerMatthew Waters <matthew@centricular.com>
Mon, 15 Jun 2015 04:41:05 +0000 (14:41 +1000)
ext/gtk/gtkgstglwidget.c

index dfe2c2f..b0c7079 100644 (file)
 #include <gst/gl/x11/gstglcontext_glx.h>
 #endif
 
+#if GST_GL_HAVE_WINDOW_WAYLAND && defined (GDK_WINDOWING_WAYLAND)
+#include <gdk/gdkwayland.h>
+#include <gst/gl/wayland/gstgldisplay_wayland.h>
+#endif
+
 /**
  * SECTION:gtkgstglwidget
  * @short_description: a #GtkGLArea that renders GStreamer video #GstBuffers
@@ -503,6 +508,14 @@ gtk_gst_gl_widget_init (GtkGstGLWidget * widget)
         gst_gl_display_x11_new_with_display (gdk_x11_display_get_xdisplay
         (display));
 #endif
+#if GST_GL_HAVE_WINDOW_WAYLAND && defined (GDK_WINDOWING_WAYLAND)
+  if (GDK_IS_WAYLAND_DISPLAY (display)) {
+    struct wl_display *wayland_display =
+        gdk_wayland_display_get_wl_display (display);
+    widget->priv->display = (GstGLDisplay *)
+        gst_gl_display_wayland_new_with_display (wayland_display);
+  }
+#endif
 
   if (!widget->priv->display)
     widget->priv->display = gst_gl_display_new ();
@@ -575,6 +588,17 @@ _get_gl_context (GtkGstGLWidget * gst_widget)
           platform, gl_api);
   }
 #endif
+#if GST_GL_HAVE_WINDOW_WAYLAND && defined (GDK_WINDOWING_WAYLAND)
+  if (GST_IS_GL_DISPLAY_WAYLAND (gst_widget->priv->display)) {
+    platform = GST_GL_PLATFORM_EGL;
+    gl_api = gst_gl_context_get_current_gl_api (NULL, NULL);
+    gl_handle = gst_gl_context_get_current_gl_context (platform);
+    if (gl_handle)
+      gst_widget->priv->other_context =
+          gst_gl_context_new_wrapped (gst_widget->priv->display, gl_handle,
+          platform, gl_api);
+  }
+#endif
 
   if (gst_widget->priv->other_context) {
     GError *error = NULL;