summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJasper St. Pierre <jstpierre@mecheye.net>2016-03-21 13:43:50 -0700
committerJasper St. Pierre <jstpierre@mecheye.net>2016-03-21 13:44:44 -0700
commit190357c56135400fc5ff8eab476c0ce174e2626a (patch)
tree3d3d8a95157b21a8ae5d96af4c05c017696476cb /src
parent92c8a51ba68b29c7209acf03ae3e33099d973e5f (diff)
downloadmutter-190357c56135400fc5ff8eab476c0ce174e2626a.tar.gz
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.
Diffstat (limited to 'src')
-rw-r--r--src/compositor/meta-shaped-texture-private.h1
-rw-r--r--src/compositor/meta-shaped-texture.c7
-rw-r--r--src/compositor/meta-surface-actor-x11.c33
-rw-r--r--src/compositor/meta-surface-actor.c7
-rw-r--r--src/compositor/meta-surface-actor.h1
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 21c633512..1a841de85 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 b74474405..5b2630b87 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 b50b8f2c7..dfc4848d2 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 2e50a0e3f..6f3a929ce 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 489fa2090..8c6dda253 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);