From f6b270d8eb0583940b59af35ea8552876234d335 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Thu, 22 Sep 2016 18:55:23 -0400 Subject: [PATCH] waylandsink: Update our window size on configure event This is specific to when the waylandsink is not being embedded. In this patch we pass the render lock to the window so it can safely call gst_wl_window_set_render_rectangle() with the new size. https://bugzilla.gnome.org/show_bug.cgi?id=722343 --- ext/wayland/gstwaylandsink.c | 7 ++++--- ext/wayland/wlwindow.c | 22 +++++++++++++++++----- ext/wayland/wlwindow.h | 7 +++++-- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/ext/wayland/gstwaylandsink.c b/ext/wayland/gstwaylandsink.c index 1349c6bf14..bc32e1c7d6 100644 --- a/ext/wayland/gstwaylandsink.c +++ b/ext/wayland/gstwaylandsink.c @@ -600,8 +600,8 @@ gst_wayland_sink_show_frame (GstVideoSink * vsink, GstBuffer * buffer) if (!sink->window) { /* if we were not provided a window, create one ourselves */ - sink->window = - gst_wl_window_new_toplevel (sink->display, &sink->video_info); + sink->window = gst_wl_window_new_toplevel (sink->display, + &sink->video_info, &sink->render_lock); } } @@ -806,7 +806,8 @@ gst_wayland_sink_set_window_handle (GstVideoOverlay * overlay, guintptr handle) "an externally-supplied display handle. Consider providing a " "display handle from your application with GstContext")); } else { - sink->window = gst_wl_window_new_in_surface (sink->display, surface); + sink->window = gst_wl_window_new_in_surface (sink->display, surface, + &sink->render_lock); } } else { GST_ERROR_OBJECT (sink, "Failed to find display handle, " diff --git a/ext/wayland/wlwindow.c b/ext/wayland/wlwindow.c index febf552472..b60f351165 100644 --- a/ext/wayland/wlwindow.c +++ b/ext/wayland/wlwindow.c @@ -46,11 +46,21 @@ static void handle_configure (void *data, struct wl_shell_surface *shell_surface, uint32_t edges, int32_t width, int32_t height) { + GstWlWindow *window = data; + + GST_DEBUG ("Windows configure: edges %x, width = %i, height %i", edges, + width, height); + + if (width == 0 || height == 0) + return; + + gst_wl_window_set_render_rectangle (window, 0, 0, width, height); } static void handle_popup_done (void *data, struct wl_shell_surface *shell_surface) { + GST_DEBUG ("Window popup done."); } static const struct wl_shell_surface_listener shell_surface_listener = { @@ -99,13 +109,14 @@ gst_wl_window_finalize (GObject * gobject) } static GstWlWindow * -gst_wl_window_new_internal (GstWlDisplay * display) +gst_wl_window_new_internal (GstWlDisplay * display, GMutex * render_lock) { GstWlWindow *window; struct wl_region *region; window = g_object_new (GST_TYPE_WL_WINDOW, NULL); window->display = g_object_ref (display); + window->render_lock = render_lock; window->area_surface = wl_compositor_create_surface (display->compositor); window->video_surface = wl_compositor_create_surface (display->compositor); @@ -140,12 +151,13 @@ gst_wl_window_new_internal (GstWlDisplay * display) } GstWlWindow * -gst_wl_window_new_toplevel (GstWlDisplay * display, const GstVideoInfo * info) +gst_wl_window_new_toplevel (GstWlDisplay * display, const GstVideoInfo * info, + GMutex * render_lock) { GstWlWindow *window; gint width; - window = gst_wl_window_new_internal (display); + window = gst_wl_window_new_internal (display, render_lock); /* go toplevel */ window->shell_surface = wl_shell_get_shell_surface (display->shell, @@ -172,10 +184,10 @@ gst_wl_window_new_toplevel (GstWlDisplay * display, const GstVideoInfo * info) GstWlWindow * gst_wl_window_new_in_surface (GstWlDisplay * display, - struct wl_surface * parent) + struct wl_surface * parent, GMutex * render_lock) { GstWlWindow *window; - window = gst_wl_window_new_internal (display); + window = gst_wl_window_new_internal (display, render_lock); /* embed in parent */ window->area_subsurface = diff --git a/ext/wayland/wlwindow.h b/ext/wayland/wlwindow.h index 9b2d6483f9..e247b4e231 100644 --- a/ext/wayland/wlwindow.h +++ b/ext/wayland/wlwindow.h @@ -41,6 +41,8 @@ struct _GstWlWindow { GObject parent_instance; + GMutex *render_lock; + GstWlDisplay *display; struct wl_surface *area_surface; struct wl_subsurface *area_subsurface; @@ -62,6 +64,7 @@ struct _GstWlWindow /* this will be set when viewporter is available and black background has * already been set on the area_subsurface */ gboolean no_border_update; + }; struct _GstWlWindowClass @@ -72,9 +75,9 @@ struct _GstWlWindowClass GType gst_wl_window_get_type (void); GstWlWindow *gst_wl_window_new_toplevel (GstWlDisplay * display, - const GstVideoInfo * info); + const GstVideoInfo * info, GMutex * render_lock); GstWlWindow *gst_wl_window_new_in_surface (GstWlDisplay * display, - struct wl_surface * parent); + struct wl_surface * parent, GMutex * render_lock); GstWlDisplay *gst_wl_window_get_display (GstWlWindow * window); struct wl_surface *gst_wl_window_get_wl_surface (GstWlWindow * window);