[mutter] surface-actor-x11: Unredirect ARGB32 windows with full opaque regions



commit 190357c56135400fc5ff8eab476c0ce174e2626a
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Mon Mar 21 13:43:50 2016 -0700

    surface-actor-x11: Unredirect ARGB32 windows with full opaque regions
    
    We can detect that these windows are already fully opaque, so allow them
    to unredirect. Allows unredirecting Totem during video playback, giving
    a significant speed boost.

 src/compositor/meta-shaped-texture-private.h |    1 +
 src/compositor/meta-shaped-texture.c         |    7 +++++
 src/compositor/meta-surface-actor-x11.c      |   33 +++++++++++++++++++++++--
 src/compositor/meta-surface-actor.c          |    7 +++++
 src/compositor/meta-surface-actor.h          |    1 +
 5 files changed, 46 insertions(+), 3 deletions(-)
---
diff --git a/src/compositor/meta-shaped-texture-private.h b/src/compositor/meta-shaped-texture-private.h
index 21c6335..1a841de 100644
--- a/src/compositor/meta-shaped-texture-private.h
+++ b/src/compositor/meta-shaped-texture-private.h
@@ -36,5 +36,6 @@ void meta_shaped_texture_set_fallback_size (MetaShapedTexture *stex,
                                             guint              fallback_width,
                                             guint              fallback_height);
 gboolean meta_shaped_texture_is_obscured (MetaShapedTexture *self);
+cairo_region_t * meta_shaped_texture_get_opaque_region (MetaShapedTexture *stex);
 
 #endif
diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c
index b744744..5b2630b 100644
--- a/src/compositor/meta-shaped-texture.c
+++ b/src/compositor/meta-shaped-texture.c
@@ -790,6 +790,13 @@ meta_shaped_texture_set_opaque_region (MetaShapedTexture *stex,
     priv->opaque_region = NULL;
 }
 
+cairo_region_t *
+meta_shaped_texture_get_opaque_region (MetaShapedTexture *stex)
+{
+  MetaShapedTexturePrivate *priv = stex->priv;
+  return priv->opaque_region;
+}
+
 /**
  * meta_shaped_texture_get_image:
  * @stex: A #MetaShapedTexture
diff --git a/src/compositor/meta-surface-actor-x11.c b/src/compositor/meta-surface-actor-x11.c
index b50b8f2..dfc4848 100644
--- a/src/compositor/meta-surface-actor-x11.c
+++ b/src/compositor/meta-surface-actor-x11.c
@@ -239,6 +239,33 @@ meta_surface_actor_x11_is_visible (MetaSurfaceActor *actor)
 }
 
 static gboolean
+meta_surface_actor_x11_is_opaque (MetaSurfaceActor *actor)
+{
+  MetaSurfaceActorX11 *self = META_SURFACE_ACTOR_X11 (actor);
+  MetaSurfaceActorX11Private *priv = meta_surface_actor_x11_get_instance_private (self);
+
+  /* If we're not ARGB32, then we're opaque. */
+  if (!meta_surface_actor_is_argb32 (actor))
+    return TRUE;
+
+  cairo_region_t *opaque_region = meta_surface_actor_get_opaque_region (actor);
+
+  /* If we have no opaque region, then no pixels are opaque. */
+  if (!opaque_region)
+    return FALSE;
+
+  MetaWindow *window = priv->window;
+  cairo_rectangle_int_t client_area;
+  meta_window_get_client_area_rect (window, &client_area);
+
+  /* Otherwise, check if our opaque region covers our entire surface. */
+  if (cairo_region_contains_rectangle (opaque_region, &client_area) == CAIRO_REGION_OVERLAP_IN)
+    return TRUE;
+
+  return FALSE;
+}
+
+static gboolean
 meta_surface_actor_x11_should_unredirect (MetaSurfaceActor *actor)
 {
   MetaSurfaceActorX11 *self = META_SURFACE_ACTOR_X11 (actor);
@@ -255,15 +282,15 @@ meta_surface_actor_x11_should_unredirect (MetaSurfaceActor *actor)
   if (window->shape_region != NULL)
     return FALSE;
 
-  if (meta_surface_actor_is_argb32 (actor) && !meta_window_requested_bypass_compositor (window))
-    return FALSE;
-
   if (!meta_window_is_monitor_sized (window))
     return FALSE;
 
   if (meta_window_requested_bypass_compositor (window))
     return TRUE;
 
+  if (!meta_surface_actor_x11_is_opaque (actor))
+    return FALSE;
+
   if (meta_window_is_override_redirect (window))
     return TRUE;
 
diff --git a/src/compositor/meta-surface-actor.c b/src/compositor/meta-surface-actor.c
index 2e50a0e..6f3a929 100644
--- a/src/compositor/meta-surface-actor.c
+++ b/src/compositor/meta-surface-actor.c
@@ -235,6 +235,13 @@ meta_surface_actor_set_opaque_region (MetaSurfaceActor *self,
   meta_shaped_texture_set_opaque_region (priv->texture, region);
 }
 
+cairo_region_t *
+meta_surface_actor_get_opaque_region (MetaSurfaceActor *actor)
+{
+  MetaSurfaceActorPrivate *priv = actor->priv;
+  return meta_shaped_texture_get_opaque_region (priv->texture);
+}
+
 static gboolean
 is_frozen (MetaSurfaceActor *self)
 {
diff --git a/src/compositor/meta-surface-actor.h b/src/compositor/meta-surface-actor.h
index 489fa20..8c6dda2 100644
--- a/src/compositor/meta-surface-actor.h
+++ b/src/compositor/meta-surface-actor.h
@@ -60,6 +60,7 @@ void meta_surface_actor_set_input_region (MetaSurfaceActor *self,
                                           cairo_region_t   *region);
 void meta_surface_actor_set_opaque_region (MetaSurfaceActor *self,
                                            cairo_region_t   *region);
+cairo_region_t * meta_surface_actor_get_opaque_region (MetaSurfaceActor *self);
 
 void meta_surface_actor_process_damage (MetaSurfaceActor *actor,
                                         int x, int y, int width, int height);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]