wayland: set opaque region for YUV surface.
authorKristian Høgsberg <krh@bitplanet.net>
Fri, 14 Sep 2012 14:30:35 +0000 (10:30 -0400)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Mon, 17 Sep 2012 08:06:13 +0000 (10:06 +0200)
This allows the compositor to optimize redraws and cull away changes
obscured by the video surface.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
gst-libs/gst/vaapi/gstvaapiwindow_wayland.c

index ac2882e..2607c64 100644 (file)
@@ -49,6 +49,7 @@ struct _GstVaapiWindowWaylandPrivate {
     struct wl_shell_surface    *shell_surface;
     struct wl_surface          *surface;
     struct wl_buffer           *buffer;
+    struct wl_region           *opaque_region;
     guint                       redraw_pending  : 1;
 };
 
@@ -161,7 +162,18 @@ gst_vaapi_window_wayland_resize(
     guint            height
 )
 {
+    GstVaapiWindowWaylandPrivate * const priv =
+        GST_VAAPI_WINDOW_WAYLAND(window)->priv;
+    GstVaapiDisplayWaylandPrivate * const priv_display =
+        GST_VAAPI_OBJECT_DISPLAY_WAYLAND(window)->priv;
+
     GST_DEBUG("resize window, new size %ux%u", width, height);
+
+    if (priv->opaque_region)
+       wl_region_destroy(priv->opaque_region);
+    priv->opaque_region = wl_compositor_create_region(priv_display->compositor);
+    wl_region_add(priv->opaque_region, 0, 0, width, height);
+
     return TRUE;
 }
 
@@ -248,6 +260,12 @@ gst_vaapi_window_wayland_render(
     wl_surface_attach(priv->surface, buffer, 0, 0);
     wl_surface_damage(priv->surface, 0, 0, width, height);
 
+    if (priv->opaque_region) {
+        wl_surface_set_opaque_region(priv->surface, priv->opaque_region);
+        wl_region_destroy(priv->opaque_region);
+        priv->opaque_region = NULL;
+    }
+
     wl_display_iterate(wl_display, WL_DISPLAY_WRITABLE);
     priv->redraw_pending = TRUE;
     priv->buffer = buffer;