waylandsink: Only call wl_surface_damage() when buffer content changed
authorRobert Mader <robert.mader@collabora.com>
Thu, 30 Dec 2021 17:14:24 +0000 (18:14 +0100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 13 Jan 2022 19:39:59 +0000 (19:39 +0000)
From the spec:
> This request is used to describe the regions where the pending
> buffer is different from the current surface contents

We currently also call `wl_surface_damage()` on surfaces without
new or still compositor-hold buffers, e.g. when resizing the window.
In that case we call it on `area_surface_wrapper`, even though it
gets resized via `wp_viewport_set_destination()`, in which case
the compositor is in charge of repainting the area on screen.

Doing so is currently not forbidden by the spec, however it might
be in the future, see
https://gitlab.freedesktop.org/wayland/wayland/-/issues/267

Thus lets stay close to the spec and only call `wl_surface_damage()`
when we just attached a buffer.

Right now this prevents runtime assertions in Mutter.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1446>

subprojects/gst-plugins-bad/ext/wayland/wlwindow.c

index 49a0447..34b7b17 100644 (file)
@@ -409,10 +409,8 @@ gst_wl_window_resize_video_surface (GstWlWindow * window, gboolean commit)
 
   wl_subsurface_set_position (window->video_subsurface, res.x, res.y);
 
-  if (commit) {
-    wl_surface_damage (window->video_surface_wrapper, 0, 0, res.w, res.h);
+  if (commit)
     wl_surface_commit (window->video_surface_wrapper);
-  }
 
   /* this is saved for use in wl_surface_damage */
   window->video_rectangle = res;
@@ -468,8 +466,6 @@ gst_wl_window_render (GstWlWindow * window, GstWlBuffer * buffer,
   if (G_UNLIKELY (info)) {
     /* commit also the parent (area_surface) in order to change
      * the position of the video_subsurface */
-    wl_surface_damage (window->area_surface_wrapper, 0, 0,
-        window->render_rectangle.w, window->render_rectangle.h);
     wl_surface_commit (window->area_surface_wrapper);
     wl_subsurface_set_desync (window->video_subsurface);
   }
@@ -517,6 +513,7 @@ gst_wl_window_update_borders (GstWlWindow * window)
       window->display, &info);
   gwlbuf = gst_buffer_add_wl_buffer (buf, wlbuf, window->display);
   gst_wl_buffer_attach (gwlbuf, window->area_surface_wrapper);
+  wl_surface_damage (window->area_surface_wrapper, 0, 0, width, height);
 
   /* at this point, the GstWlBuffer keeps the buffer
    * alive and will free it on wl_buffer::release */
@@ -553,7 +550,6 @@ gst_wl_window_set_render_rectangle (GstWlWindow * window, gint x, gint y,
     gst_wl_window_resize_video_surface (window, TRUE);
   }
 
-  wl_surface_damage (window->area_surface_wrapper, 0, 0, w, h);
   wl_surface_commit (window->area_surface_wrapper);
 
   if (window->video_width != 0)