Notice style transitions that don't change how StThemeNode paints

Add st_theme_node_paint_equal() and use that to do two things:

 1) Avoid animating transitions where nothing changes.
 2) Copy cached painting state from the old theme node to the new
    theme node.

https://bugzilla.gnome.org/show_bug.cgi?id=627083
This commit is contained in:
Owen W. Taylor
2010-08-26 14:10:46 -04:00
parent b9f9dd948a
commit 5e7c25e136
9 changed files with 210 additions and 3 deletions

View File

@ -1222,6 +1222,7 @@ st_widget_recompute_style (StWidget *widget,
{
StThemeNode *new_theme_node = st_widget_get_theme_node (widget);
int transition_duration;
gboolean paint_equal;
if (!old_theme_node ||
!st_theme_node_geometry_equal (old_theme_node, new_theme_node))
@ -1229,6 +1230,11 @@ st_widget_recompute_style (StWidget *widget,
transition_duration = st_theme_node_get_transition_duration (new_theme_node);
paint_equal = old_theme_node && st_theme_node_paint_equal (old_theme_node, new_theme_node);
if (paint_equal)
st_theme_node_copy_cached_paint_state (new_theme_node, old_theme_node);
if (transition_duration > 0)
{
if (widget->priv->transition_animation != NULL)
@ -1236,8 +1242,14 @@ st_widget_recompute_style (StWidget *widget,
st_theme_node_transition_update (widget->priv->transition_animation,
new_theme_node);
}
else if (old_theme_node)
else if (old_theme_node && !paint_equal)
{
/* Since our transitions are only of the painting done by StThemeNode, we
* only want to start a transition when what is painted changes; if
* other visual aspects like the foreground color of a label change,
* we can't animate that anyways.
*/
widget->priv->transition_animation =
st_theme_node_transition_new (old_theme_node,
new_theme_node,