[mutter] surface-actor: Do not copy empty clip/unobscured regions
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] surface-actor: Do not copy empty clip/unobscured regions
- Date: Sat, 29 Feb 2020 19:52:42 +0000 (UTC)
commit c979cd95aa5c5865173e5b75e0090e0779184bea
Author: Robert Mader <robert mader posteo de>
Date: Tue Feb 25 19:59:22 2020 +0100
surface-actor: Do not copy empty clip/unobscured regions
Clip and unobscured regions stricly shrink during culling. If they
are already empty, simply reference the empty region to reduce allocations.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1082
src/compositor/meta-surface-actor.c | 40 ++++++++++++++++++++++++-------------
1 file changed, 26 insertions(+), 14 deletions(-)
---
diff --git a/src/compositor/meta-surface-actor.c b/src/compositor/meta-surface-actor.c
index 02b7af2fc..ff66f3c0a 100644
--- a/src/compositor/meta-surface-actor.c
+++ b/src/compositor/meta-surface-actor.c
@@ -103,21 +103,28 @@ set_unobscured_region (MetaSurfaceActor *surface_actor,
g_clear_pointer (&priv->unobscured_region, cairo_region_destroy);
if (unobscured_region)
{
- cairo_rectangle_int_t bounds = { 0, };
- float width, height;
-
- clutter_content_get_preferred_size (CLUTTER_CONTENT (priv->texture),
- &width,
- &height);
- bounds = (cairo_rectangle_int_t) {
- .width = width,
- .height = height,
- };
+ if (cairo_region_is_empty (unobscured_region))
+ {
+ priv->unobscured_region = cairo_region_reference (unobscured_region);
+ }
+ else
+ {
+ cairo_rectangle_int_t bounds = { 0, };
+ float width, height;
+
+ clutter_content_get_preferred_size (CLUTTER_CONTENT (priv->texture),
+ &width,
+ &height);
+ bounds = (cairo_rectangle_int_t) {
+ .width = width,
+ .height = height,
+ };
- priv->unobscured_region =
- get_scaled_region (surface_actor, unobscured_region);
+ priv->unobscured_region =
+ get_scaled_region (surface_actor, unobscured_region);
- cairo_region_intersect_rectangle (priv->unobscured_region, &bounds);
+ cairo_region_intersect_rectangle (priv->unobscured_region, &bounds);
+ }
}
}
@@ -130,7 +137,12 @@ set_clip_region (MetaSurfaceActor *surface_actor,
g_clear_pointer (&priv->clip_region, cairo_region_destroy);
if (clip_region)
- priv->clip_region = get_scaled_region (surface_actor, clip_region);
+ {
+ if (cairo_region_is_empty (clip_region))
+ priv->clip_region = cairo_region_reference (clip_region);
+ else
+ priv->clip_region = get_scaled_region (surface_actor, clip_region);
+ }
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]