Commit 59acb389 authored by Daniel van Vugt's avatar Daniel van Vugt Committed by Florian Müllner

clutter: Avoid redundant margin changes

When profiling gnome-shell it was found that one of the main triggers
of `clutter_actor_queue_relayout` during animations was
`clutter_actor_set_margin_internal` continuously setting the same
zero margins. That's obviously pointless but also expensive since it
incurs full stage relayouts and reallocation. So just avoid redundant
margin changes.

Helps to further improve:
GNOME/mutter#233,
GNOME/gnome-shell#349
parent fa495286
......@@ -18434,6 +18434,10 @@ clutter_actor_set_margin_top (ClutterActor *self,
g_return_if_fail (margin >= 0.f);
info = _clutter_actor_get_layout_info_or_defaults (self);
if (info->margin.top == margin)
return;
_clutter_actor_create_transition (self, obj_props[PROP_MARGIN_TOP],
info->margin.top,
margin);
......@@ -18478,6 +18482,10 @@ clutter_actor_set_margin_bottom (ClutterActor *self,
g_return_if_fail (margin >= 0.f);
info = _clutter_actor_get_layout_info_or_defaults (self);
if (info->margin.bottom == margin)
return;
_clutter_actor_create_transition (self, obj_props[PROP_MARGIN_BOTTOM],
info->margin.bottom,
margin);
......@@ -18522,6 +18530,10 @@ clutter_actor_set_margin_left (ClutterActor *self,
g_return_if_fail (margin >= 0.f);
info = _clutter_actor_get_layout_info_or_defaults (self);
if (info->margin.left == margin)
return;
_clutter_actor_create_transition (self, obj_props[PROP_MARGIN_LEFT],
info->margin.left,
margin);
......@@ -18566,6 +18578,10 @@ clutter_actor_set_margin_right (ClutterActor *self,
g_return_if_fail (margin >= 0.f);
info = _clutter_actor_get_layout_info_or_defaults (self);
if (info->margin.right == margin)
return;
_clutter_actor_create_transition (self, obj_props[PROP_MARGIN_RIGHT],
info->margin.right,
margin);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment