[mutter/wip/surface-content: 38/40] shaped-texture: Move unobscured_region processing here
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/surface-content: 38/40] shaped-texture: Move unobscured_region processing here
- Date: Tue, 4 Feb 2014 19:36:13 +0000 (UTC)
commit 09420871e4c9d41f77bb6253dcf89c60c91bc222
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Fri Dec 6 11:57:40 2013 -0500
shaped-texture: Move unobscured_region processing here
https://bugzilla.gnome.org/show_bug.cgi?id=720631
src/compositor/meta-shaped-texture-private.h | 3 +
src/compositor/meta-shaped-texture.c | 125 +++++++++++++++++++++-----
src/compositor/meta-surface-actor.c | 31 ++++---
src/compositor/meta-surface-actor.h | 11 ++-
src/compositor/meta-window-actor-private.h | 3 -
src/compositor/meta-window-actor.c | 65 ++------------
src/compositor/meta-window-group.c | 14 ---
src/meta/meta-shaped-texture.h | 3 +-
src/wayland/meta-wayland-surface.c | 6 +-
9 files changed, 139 insertions(+), 122 deletions(-)
---
diff --git a/src/compositor/meta-shaped-texture-private.h b/src/compositor/meta-shaped-texture-private.h
index 18d61a7..48ae0df 100644
--- a/src/compositor/meta-shaped-texture-private.h
+++ b/src/compositor/meta-shaped-texture-private.h
@@ -32,5 +32,8 @@
ClutterActor *meta_shaped_texture_new (void);
void meta_shaped_texture_set_texture (MetaShapedTexture *stex,
CoglTexture *texture);
+gboolean meta_shaped_texture_get_unobscured_bounds (MetaShapedTexture *stex,
+ cairo_rectangle_int_t *unobscured_bounds);
+gboolean meta_shaped_texture_is_obscured (MetaShapedTexture *self);
#endif
diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c
index 2939584..aaa5fe1 100644
--- a/src/compositor/meta-shaped-texture.c
+++ b/src/compositor/meta-shaped-texture.c
@@ -73,10 +73,15 @@ struct _MetaShapedTexturePrivate
CoglTexture *texture;
CoglTexture *mask_texture;
- cairo_region_t *clip_region;
cairo_region_t *input_shape_region;
+
+ /* The region containing only fully opaque pixels */
cairo_region_t *opaque_region;
+ /* MetaCullable regions, see that documentation for more details */
+ cairo_region_t *clip_region;
+ cairo_region_t *unobscured_region;
+
guint tex_width, tex_height;
guint create_mipmaps : 1;
@@ -114,14 +119,33 @@ meta_shaped_texture_init (MetaShapedTexture *self)
}
static void
+set_unobscured_region (MetaShapedTexture *self,
+ cairo_region_t *unobscured_region)
+{
+ MetaShapedTexturePrivate *priv = self->priv;
+
+ if (priv->unobscured_region)
+ cairo_region_destroy (priv->unobscured_region);
+
+ if (unobscured_region)
+ priv->unobscured_region = cairo_region_copy (unobscured_region);
+ else
+ priv->unobscured_region = NULL;
+}
+
+static void
set_clip_region (MetaShapedTexture *self,
- cairo_region_t *clip_region)
+ cairo_region_t *clip_region)
{
MetaShapedTexturePrivate *priv = self->priv;
- g_clear_pointer (&priv->clip_region, (GDestroyNotify) cairo_region_destroy);
+ if (priv->clip_region)
+ cairo_region_destroy (priv->clip_region);
+
if (clip_region)
priv->clip_region = cairo_region_copy (clip_region);
+ else
+ priv->clip_region = NULL;
}
static void
@@ -138,6 +162,7 @@ meta_shaped_texture_dispose (GObject *object)
g_clear_pointer (&priv->opaque_region, cairo_region_destroy);
meta_shaped_texture_set_mask_texture (self, NULL);
+ set_unobscured_region (self, NULL);
set_clip_region (self, NULL);
G_OBJECT_CLASS (meta_shaped_texture_parent_class)->dispose (object);
@@ -546,10 +571,37 @@ meta_shaped_texture_get_preferred_height (ClutterActor *self,
}
static gboolean
-meta_shaped_texture_get_paint_volume (ClutterActor *self,
+meta_shaped_texture_get_paint_volume (ClutterActor *actor,
ClutterPaintVolume *volume)
{
- return clutter_paint_volume_set_from_allocation (volume, self);
+ MetaShapedTexture *self = META_SHAPED_TEXTURE (actor);
+ cairo_rectangle_int_t unobscured_bounds;
+
+ if (!clutter_paint_volume_set_from_allocation (volume, actor))
+ return FALSE;
+
+ if (meta_shaped_texture_get_unobscured_bounds (self, &unobscured_bounds))
+ {
+ ClutterVertex origin;
+ cairo_rectangle_int_t bounds;
+
+ /* I hate ClutterPaintVolume so much... */
+ clutter_paint_volume_get_origin (volume, &origin);
+ bounds.x = origin.x;
+ bounds.y = origin.y;
+ bounds.width = clutter_paint_volume_get_width (volume);
+ bounds.height = clutter_paint_volume_get_height (volume);
+
+ gdk_rectangle_intersect (&bounds, &unobscured_bounds, &bounds);
+
+ origin.x = bounds.x;
+ origin.y = bounds.y;
+ clutter_paint_volume_set_origin (volume, &origin);
+ clutter_paint_volume_set_width (volume, bounds.width);
+ clutter_paint_volume_set_height (volume, bounds.height);
+ }
+
+ return TRUE;
}
void
@@ -640,6 +692,40 @@ get_clip (MetaShapedTexture *stex,
return TRUE;
}
+static cairo_region_t *
+effective_unobscured_region (MetaShapedTexture *self)
+{
+ MetaShapedTexturePrivate *priv = self->priv;
+
+ return clutter_actor_has_mapped_clones (CLUTTER_ACTOR (self)) ? NULL : priv->unobscured_region;
+}
+
+gboolean
+meta_shaped_texture_get_unobscured_bounds (MetaShapedTexture *self,
+ cairo_rectangle_int_t *unobscured_bounds)
+{
+ cairo_region_t *unobscured_region = effective_unobscured_region (self);
+
+ if (unobscured_region)
+ {
+ cairo_region_get_extents (unobscured_region, unobscured_bounds);
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
+gboolean
+meta_shaped_texture_is_obscured (MetaShapedTexture *self)
+{
+ MetaShapedTexturePrivate *priv = self->priv;
+
+ if (priv->unobscured_region)
+ return cairo_region_is_empty (priv->unobscured_region);
+ else
+ return FALSE;
+}
+
/**
* meta_shaped_texture_update_area:
* @stex: #MetaShapedTexture
@@ -647,14 +733,9 @@ get_clip (MetaShapedTexture *stex,
* @y: the y coordinate of the damaged area
* @width: the width of the damaged area
* @height: the height of the damaged area
- * @unobscured_region: The unobscured region of the window or %NULL if
- * there is no valid one (like when the actor is transformed or
- * has a mapped clone)
*
* Repairs the damaged area indicated by @x, @y, @width and @height
- * and queues a redraw for the intersection @unobscured_region and
- * the damage area. If @unobscured_region is %NULL a redraw will always
- * get queued.
+ * and potentially queues a redraw.
*
* Return value: Whether a redraw have been queued or not
*/
@@ -663,8 +744,7 @@ meta_shaped_texture_update_area (MetaShapedTexture *stex,
int x,
int y,
int width,
- int height,
- cairo_region_t *unobscured_region)
+ int height)
{
MetaShapedTexturePrivate *priv;
cairo_rectangle_int_t clip;
@@ -679,14 +759,14 @@ meta_shaped_texture_update_area (MetaShapedTexture *stex,
has_clip = get_clip (stex, x, y, width, height, &clip);
- if (unobscured_region)
+ if (priv->unobscured_region)
{
cairo_region_t *intersection;
- if (cairo_region_is_empty (unobscured_region))
+ if (cairo_region_is_empty (priv->unobscured_region))
return FALSE;
- intersection = cairo_region_copy (unobscured_region);
+ intersection = cairo_region_copy (priv->unobscured_region);
if (has_clip)
cairo_region_intersect_rectangle (intersection, &clip);
@@ -696,19 +776,19 @@ meta_shaped_texture_update_area (MetaShapedTexture *stex,
cairo_region_get_extents (intersection, &damage_rect);
clutter_actor_queue_redraw_with_clip (CLUTTER_ACTOR (stex), &damage_rect);
cairo_region_destroy (intersection);
-
return TRUE;
}
cairo_region_destroy (intersection);
-
return FALSE;
}
-
- if (has_clip)
- clutter_actor_queue_redraw_with_clip (CLUTTER_ACTOR (stex), &clip);
else
- clutter_actor_queue_redraw (CLUTTER_ACTOR (stex));
+ {
+ if (has_clip)
+ clutter_actor_queue_redraw_with_clip (CLUTTER_ACTOR (stex), &clip);
+ else
+ clutter_actor_queue_redraw (CLUTTER_ACTOR (stex));
+ }
return TRUE;
}
@@ -911,6 +991,7 @@ meta_shaped_texture_cull_out (MetaCullable *cullable,
MetaShapedTexture *self = META_SHAPED_TEXTURE (cullable);
MetaShapedTexturePrivate *priv = self->priv;
+ set_unobscured_region (self, unobscured_region);
set_clip_region (self, clip_region);
if (clutter_actor_get_paint_opacity (CLUTTER_ACTOR (self)) == 0xff)
diff --git a/src/compositor/meta-surface-actor.c b/src/compositor/meta-surface-actor.c
index 37b87b0..541094c 100644
--- a/src/compositor/meta-surface-actor.c
+++ b/src/compositor/meta-surface-actor.c
@@ -31,6 +31,14 @@ static void cullable_iface_init (MetaCullableInterface *iface);
G_DEFINE_TYPE_WITH_CODE (MetaSurfaceActor, meta_surface_actor, CLUTTER_TYPE_ACTOR,
G_IMPLEMENT_INTERFACE (META_TYPE_CULLABLE, cullable_iface_init));
+gboolean
+meta_surface_actor_get_unobscured_bounds (MetaSurfaceActor *self,
+ cairo_rectangle_int_t *unobscured_bounds)
+{
+ MetaSurfaceActorPrivate *priv = self->priv;
+ return meta_shaped_texture_get_unobscured_bounds (priv->texture, unobscured_bounds);
+}
+
static void
meta_surface_actor_class_init (MetaSurfaceActorClass *klass)
{
@@ -109,18 +117,13 @@ update_area (MetaSurfaceActor *self,
}
gboolean
-meta_surface_actor_damage_all (MetaSurfaceActor *self,
- cairo_region_t *unobscured_region)
+meta_surface_actor_damage_all (MetaSurfaceActor *self)
{
MetaSurfaceActorPrivate *priv = self->priv;
CoglTexture *texture = meta_shaped_texture_get_texture (priv->texture);
update_area (self, 0, 0, cogl_texture_get_width (texture), cogl_texture_get_height (texture));
- return meta_shaped_texture_update_area (priv->texture,
- 0, 0,
- cogl_texture_get_width (texture),
- cogl_texture_get_height (texture),
- unobscured_region);
+ return meta_shaped_texture_update_area (priv->texture, 0, 0, cogl_texture_get_width (texture),
cogl_texture_get_height (texture));
}
gboolean
@@ -128,15 +131,19 @@ meta_surface_actor_damage_area (MetaSurfaceActor *self,
int x,
int y,
int width,
- int height,
- cairo_region_t *unobscured_region)
+ int height)
{
MetaSurfaceActorPrivate *priv = self->priv;
update_area (self, x, y, width, height);
- return meta_shaped_texture_update_area (priv->texture,
- x, y, width, height,
- unobscured_region);
+ return meta_shaped_texture_update_area (priv->texture, x, y, width, height);
+}
+
+gboolean
+meta_surface_actor_is_obscured (MetaSurfaceActor *self)
+{
+ MetaSurfaceActorPrivate *priv = self->priv;
+ return meta_shaped_texture_is_obscured (priv->texture);
}
void
diff --git a/src/compositor/meta-surface-actor.h b/src/compositor/meta-surface-actor.h
index 484877b..fa7f0c3 100644
--- a/src/compositor/meta-surface-actor.h
+++ b/src/compositor/meta-surface-actor.h
@@ -43,15 +43,16 @@ cairo_surface_t *meta_surface_actor_get_image (MetaSurfaceActor *self,
MetaShapedTexture *meta_surface_actor_get_texture (MetaSurfaceActor *self);
-gboolean meta_surface_actor_damage_all (MetaSurfaceActor *self,
- cairo_region_t *unobscured_region);
-
+gboolean meta_surface_actor_damage_all (MetaSurfaceActor *self);
gboolean meta_surface_actor_damage_area (MetaSurfaceActor *self,
int x,
int y,
int width,
- int height,
- cairo_region_t *unobscured_region);
+ int height);
+
+gboolean meta_surface_actor_is_obscured (MetaSurfaceActor *self);
+gboolean meta_surface_actor_get_unobscured_bounds (MetaSurfaceActor *self,
+ cairo_rectangle_int_t *unobscured_bounds);
void meta_surface_actor_set_texture (MetaSurfaceActor *self,
CoglTexture *texture);
diff --git a/src/compositor/meta-window-actor-private.h b/src/compositor/meta-window-actor-private.h
index 0207a88..9c6a847 100644
--- a/src/compositor/meta-window-actor-private.h
+++ b/src/compositor/meta-window-actor-private.h
@@ -59,9 +59,6 @@ void meta_window_actor_set_updates_frozen (MetaWindowActor *self,
void meta_window_actor_queue_frame_drawn (MetaWindowActor *self,
gboolean no_delay_frame);
-void meta_window_actor_set_unobscured_region (MetaWindowActor *self,
- cairo_region_t *unobscured_region);
-
void meta_window_actor_effect_completed (MetaWindowActor *actor,
gulong event);
diff --git a/src/compositor/meta-window-actor.c b/src/compositor/meta-window-actor.c
index 7f5444d..30f78ec 100644
--- a/src/compositor/meta-window-actor.c
+++ b/src/compositor/meta-window-actor.c
@@ -72,9 +72,6 @@ struct _MetaWindowActorPrivate
/* The region we should clip to when painting the shadow */
cairo_region_t *shadow_clip;
- /* The region that is visible, used to optimize out redraws */
- cairo_region_t *unobscured_region;
-
guint send_frame_messages_timer;
gint64 frame_drawn_time;
@@ -424,7 +421,6 @@ meta_window_actor_dispose (GObject *object)
priv->send_frame_messages_timer = 0;
}
- g_clear_pointer (&priv->unobscured_region, cairo_region_destroy);
g_clear_pointer (&priv->shape_region, cairo_region_destroy);
g_clear_pointer (&priv->shadow_clip, cairo_region_destroy);
@@ -695,7 +691,7 @@ meta_window_actor_get_paint_volume (ClutterActor *actor,
{
MetaWindowActor *self = META_WINDOW_ACTOR (actor);
MetaWindowActorPrivate *priv = self->priv;
- cairo_rectangle_int_t bounds;
+ cairo_rectangle_int_t unobscured_bounds, bounds;
gboolean appears_focused = meta_window_appears_focused (priv->window);
ClutterVertex origin;
@@ -720,12 +716,8 @@ meta_window_actor_get_paint_volume (ClutterActor *actor,
gdk_rectangle_union (&bounds, &shadow_bounds, &bounds);
}
- if (priv->unobscured_region && !clutter_actor_has_mapped_clones (actor))
- {
- cairo_rectangle_int_t unobscured_bounds;
- cairo_region_get_extents (priv->unobscured_region, &unobscured_bounds);
- gdk_rectangle_intersect (&bounds, &unobscured_bounds, &bounds);
- }
+ if (meta_surface_actor_get_unobscured_bounds (priv->surface, &unobscured_bounds))
+ gdk_rectangle_intersect (&bounds, &unobscured_bounds, &bounds);
origin.x = bounds.x;
origin.y = bounds.y;
@@ -924,7 +916,6 @@ static void
meta_window_actor_damage_all (MetaWindowActor *self)
{
MetaWindowActorPrivate *priv = self->priv;
- cairo_region_t *unobscured_region;
gboolean redraw_queued;
if (!priv->needs_damage_all)
@@ -933,11 +924,7 @@ meta_window_actor_damage_all (MetaWindowActor *self)
if (priv->needs_pixmap)
return;
- unobscured_region =
- clutter_actor_has_mapped_clones (CLUTTER_ACTOR (priv->surface))
- ? NULL : priv->unobscured_region;
-
- redraw_queued = meta_surface_actor_damage_all (priv->surface, unobscured_region);
+ redraw_queued = meta_surface_actor_damage_all (priv->surface);
priv->repaint_scheduled = priv->repaint_scheduled || redraw_queued;
priv->needs_damage_all = FALSE;
@@ -996,17 +983,7 @@ meta_window_actor_queue_frame_drawn (MetaWindowActor *self,
if (!priv->repaint_scheduled)
{
- gboolean is_obscured = FALSE;
-
- /* Find out whether the window is completly obscured */
- if (priv->unobscured_region)
- {
- cairo_region_t *unobscured_window_region;
- unobscured_window_region = cairo_region_copy (priv->shape_region);
- cairo_region_intersect (unobscured_window_region, priv->unobscured_region);
- is_obscured = cairo_region_is_empty (unobscured_window_region);
- cairo_region_destroy (unobscured_window_region);
- }
+ gboolean is_obscured = meta_surface_actor_is_obscured (priv->surface);
/* A frame was marked by the client without actually doing any
* damage or any unobscured, or while we had the window frozen
@@ -1657,30 +1634,6 @@ see_region (cairo_region_t *region,
#endif
/**
- * meta_window_actor_set_unobscured_region:
- * @self: a #MetaWindowActor
- * @unobscured_region: the region of the screen that isn't completely
- * obscured.
- *
- * Provides a hint as to what areas of the window need to queue
- * redraws when damaged. Regions not in @unobscured_region are completely obscured.
- */
-void
-meta_window_actor_set_unobscured_region (MetaWindowActor *self,
- cairo_region_t *unobscured_region)
-{
- MetaWindowActorPrivate *priv = self->priv;
-
- if (priv->unobscured_region)
- cairo_region_destroy (priv->unobscured_region);
-
- if (unobscured_region)
- priv->unobscured_region = cairo_region_copy (unobscured_region);
- else
- priv->unobscured_region = NULL;
-}
-
-/**
* meta_window_actor_set_clip_region_beneath:
* @self: a #MetaWindowActor
* @clip_region: the region of the screen that isn't completely
@@ -1724,7 +1677,6 @@ meta_window_actor_cull_out (MetaCullable *cullable,
if (priv->unredirected)
return;
- meta_window_actor_set_unobscured_region (self, unobscured_region);
meta_cullable_cull_out_children (cullable, unobscured_region, clip_region);
meta_window_actor_set_clip_region_beneath (self, clip_region);
}
@@ -1895,7 +1847,6 @@ meta_window_actor_process_x11_damage (MetaWindowActor *self,
MetaWindowActorPrivate *priv = self->priv;
MetaCompScreen *info = meta_screen_get_compositor_data (priv->screen);
gboolean redraw_queued;
- cairo_region_t *unobscured_region;
priv->received_x11_damage = TRUE;
@@ -1943,15 +1894,11 @@ meta_window_actor_process_x11_damage (MetaWindowActor *self,
if (priv->needs_pixmap)
return;
- unobscured_region =
- clutter_actor_has_mapped_clones (CLUTTER_ACTOR (priv->surface))
- ? NULL : priv->unobscured_region;
redraw_queued = meta_surface_actor_damage_area (priv->surface,
event->area.x,
event->area.y,
event->area.width,
- event->area.height,
- unobscured_region);
+ event->area.height);
priv->repaint_scheduled = priv->repaint_scheduled || redraw_queued;
diff --git a/src/compositor/meta-window-group.c b/src/compositor/meta-window-group.c
index a36d596..5420605 100644
--- a/src/compositor/meta-window-group.c
+++ b/src/compositor/meta-window-group.c
@@ -115,8 +115,6 @@ meta_window_group_paint (ClutterActor *actor)
{
cairo_region_t *clip_region;
cairo_region_t *unobscured_region;
- ClutterActorIter iter;
- ClutterActor *child;
cairo_rectangle_int_t visible_rect, clip_rect;
int paint_x_offset, paint_y_offset;
int paint_x_origin, paint_y_origin;
@@ -125,18 +123,6 @@ meta_window_group_paint (ClutterActor *actor)
MetaWindowGroup *window_group = META_WINDOW_GROUP (actor);
ClutterActor *stage = clutter_actor_get_stage (actor);
- /* Start off by treating all windows as completely unobscured, so damage anywhere
- * in a window queues redraws, but confine it more below. */
- clutter_actor_iter_init (&iter, actor);
- while (clutter_actor_iter_next (&iter, &child))
- {
- if (META_IS_WINDOW_ACTOR (child))
- {
- MetaWindowActor *window_actor = META_WINDOW_ACTOR (child);
- meta_window_actor_set_unobscured_region (window_actor, NULL);
- }
- }
-
/* Normally we expect an actor to be drawn at it's position on the screen.
* However, if we're inside the paint of a ClutterClone, that won't be the
* case and we need to compensate. We look at the position of the window
diff --git a/src/meta/meta-shaped-texture.h b/src/meta/meta-shaped-texture.h
index 9eea4b8..b0870bf 100644
--- a/src/meta/meta-shaped-texture.h
+++ b/src/meta/meta-shaped-texture.h
@@ -69,8 +69,7 @@ gboolean meta_shaped_texture_update_area (MetaShapedTexture *stex,
int x,
int y,
int width,
- int height,
- cairo_region_t *unobscured_region);
+ int height);
CoglTexture * meta_shaped_texture_get_texture (MetaShapedTexture *stex);
diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
index 909d624..c24645e 100644
--- a/src/wayland/meta-wayland-surface.c
+++ b/src/wayland/meta-wayland-surface.c
@@ -115,11 +115,7 @@ surface_process_damage (MetaWaylandSurface *surface,
cairo_rectangle_int_t rect;
cairo_region_get_rectangle (region, i, &rect);
meta_surface_actor_damage_area (surface->surface_actor,
- rect.x,
- rect.y,
- rect.width,
- rect.height,
- NULL);
+ rect.x, rect.y, rect.width, rect.height);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]