gl/wayland: add preferred window size, and set it according to video size
authormemeka <mihailescu2m@gmail.com>
Tue, 24 Oct 2017 07:09:50 +0000 (17:39 +1030)
committerMatthew Waters <matthew@centricular.com>
Tue, 28 Aug 2018 04:30:19 +0000 (14:30 +1000)
The glimagesink wayland backend lacks the implementation of
gst_gl_window_wayland_egl_set_preferred_size. Because of this, glimagesink windows on
wayland are created with a fixed window size of 320x240.

[Matthew Waters]: gst-indent sources

https://bugzilla.gnome.org/show_bug.cgi?id=789384

gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.c
gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.h

index 3852818..beac6f7 100644 (file)
@@ -57,6 +57,8 @@ static gboolean gst_gl_window_wayland_egl_open (GstGLWindow * window,
 static guintptr gst_gl_window_wayland_egl_get_display (GstGLWindow * window);
 static gboolean gst_gl_window_wayland_egl_set_render_rectangle (GstGLWindow *
     window, gint x, gint y, gint width, gint height);
+static void gst_gl_window_wayland_egl_set_preferred_size (GstGLWindow * window,
+    gint width, gint height);
 
 #if 0
 static void
@@ -306,12 +308,16 @@ create_surfaces (GstGLWindowWaylandEGL * window_egl)
 
   if (window_egl->window.window_width > 0)
     width = window_egl->window.window_width;
+  else if (window_egl->window.preferred_width > 0)
+    width = window_egl->window.preferred_width;
   else
     width = 320;
   window_egl->window.window_width = width;
 
   if (window_egl->window.window_height > 0)
     height = window_egl->window.window_height;
+  else if (window_egl->window.preferred_height > 0)
+    height = window_egl->window.preferred_height;
   else
     height = 240;
   window_egl->window.window_height = height;
@@ -344,6 +350,8 @@ gst_gl_window_wayland_egl_class_init (GstGLWindowWaylandEGLClass * klass)
       GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_get_display);
   window_class->set_render_rectangle =
       GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_set_render_rectangle);
+  window_class->set_preferred_size =
+      GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_set_preferred_size);
 }
 
 static void
@@ -584,6 +592,20 @@ gst_gl_window_wayland_egl_set_render_rectangle (GstGLWindow * window,
   return TRUE;
 }
 
+static void
+gst_gl_window_wayland_egl_set_preferred_size (GstGLWindow * window, gint width,
+    gint height)
+{
+  GstGLWindowWaylandEGL *window_egl = GST_GL_WINDOW_WAYLAND_EGL (window);
+
+  window_egl->window.preferred_width = width;
+  window_egl->window.preferred_height = height;
+  if (window_egl->window.window_height != height
+      || window_egl->window.window_width != width) {
+    window_resize (window_egl, width, height);
+  }
+}
+
 static guintptr
 gst_gl_window_wayland_egl_get_display (GstGLWindow * window)
 {
index 07c7ad1..09858e8 100644 (file)
@@ -72,6 +72,7 @@ struct window {
   struct wl_callback        *callback;
   int fullscreen, configured;
   int window_width, window_height;
+  int preferred_width, preferred_height;
   int window_x, window_y;
 };