[mutter/wip/chergert/identity-matrix] clutter/actor: avoid transform node for identity matrix
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/chergert/identity-matrix] clutter/actor: avoid transform node for identity matrix
- Date: Thu, 20 Feb 2020 05:25:35 +0000 (UTC)
commit cfc348d69c4045ecb8168cf69d391e69e1417745
Author: Christian Hergert <chergert redhat com>
Date: Wed Feb 19 21:22:13 2020 -0800
clutter/actor: avoid transform node for identity matrix
If the transform matrix is an identity, then positioning wont change and
we can avoid creating the transform node altogether. This is based on
a similar find in GTK today while reducing temporary allocations.
This cuts the number of transforms created in clutter_actor_paint() by
about half under light testing of GNOME Shell from 6.8% to 2.4% of
allocations.
Before:
ALLOCATED TOTAL FUNCTION
[ 20.4 MiB] [ 21.20%] clutter_actor_paint
[ 11.0 MiB] [ 11.45%] clutter_paint_node_paint
[ 6.6 MiB] [ 6.84%] clutter_transform_node_new
[ 2.5 MiB] [ 2.61%] clutter_actor_node_new
After:
ALLOCATED TOTAL FUNCTION
[ 33.4 MiB] [ 24.12%] clutter_actor_paint
[ 26.2 MiB] [ 18.91%] clutter_paint_node_paint
[ 3.4 MiB] [ 2.43%] clutter_actor_node_new
[ 3.3 MiB] [ 2.41%] clutter_transform_node_new
Allocation amounts will have differed due to different amounts of running
time, but the % of allocations has now dropped below
clutter_actor_node_new() which should be expected.
https://gitlab.gnome.org/GNOME/mutter/issues/1056
clutter/clutter/clutter-actor.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c
index 610741abc..163d30d43 100644
--- a/clutter/clutter/clutter-actor.c
+++ b/clutter/clutter/clutter-actor.c
@@ -3997,11 +3997,14 @@ clutter_actor_paint (ClutterActor *self,
clutter_actor_get_transform (self, &transform);
- transform_node = clutter_transform_node_new (&transform);
- clutter_paint_node_add_child (transform_node, root_node);
- clutter_paint_node_unref (root_node);
+ if (!cogl_matrix_is_identity (&transform))
+ {
+ transform_node = clutter_transform_node_new (&transform);
+ clutter_paint_node_add_child (transform_node, root_node);
+ clutter_paint_node_unref (root_node);
- root_node = g_steal_pointer (&transform_node);
+ root_node = g_steal_pointer (&transform_node);
+ }
#ifdef CLUTTER_ENABLE_DEBUG
/* Catch when out-of-band transforms have been made by actors not as part
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]