css: Avoid more recomputation during animation

Don't trigger recomputation if the values didn't change. We only
do this for custom values, since those are animated with a flip
at 50%, so it is likely that we see no-change updates.
This commit is contained in:
Matthias Clasen 2024-05-20 11:41:19 -04:00
parent 2aeb80f490
commit 6bae80c331
3 changed files with 13 additions and 7 deletions

View File

@ -645,15 +645,20 @@ gtk_css_animated_style_get_intrinsic_value (GtkCssAnimatedStyle *style,
return gtk_css_style_get_value (style->style, id);
}
void
gboolean
gtk_css_animated_style_set_animated_custom_value (GtkCssAnimatedStyle *animated,
int id,
GtkCssVariableValue *value)
{
GtkCssStyle *style = (GtkCssStyle *)animated;
GtkCssVariableValue *old_value;
gtk_internal_return_if_fail (GTK_IS_CSS_ANIMATED_STYLE (style));
gtk_internal_return_if_fail (value != NULL);
gtk_internal_return_val_if_fail (GTK_IS_CSS_ANIMATED_STYLE (style), FALSE);
gtk_internal_return_val_if_fail (value != NULL, FALSE);
old_value = gtk_css_style_get_custom_property (style, id);
if (gtk_css_value_equal0 ((GtkCssValue *) old_value, (GtkCssValue *) value))
return FALSE;
if (style->variables == NULL)
{
@ -669,6 +674,8 @@ gtk_css_animated_style_set_animated_custom_value (GtkCssAnimatedStyle *animated,
}
gtk_css_variable_set_add (style->variables, id, value);
return TRUE;
}
void

View File

@ -70,7 +70,7 @@ void gtk_css_animated_style_set_animated_value(GtkCssAnimated
GtkCssValue * gtk_css_animated_style_get_intrinsic_value (GtkCssAnimatedStyle *style,
guint id);
void gtk_css_animated_style_set_animated_custom_value (GtkCssAnimatedStyle *animated,
gboolean gtk_css_animated_style_set_animated_custom_value (GtkCssAnimatedStyle *animated,
int id,
GtkCssVariableValue *value);

View File

@ -126,11 +126,10 @@ gtk_css_animation_apply_values (GtkStyleAnimation *style_animation,
if (!value)
continue;
gtk_css_animated_style_set_animated_custom_value (style, variable_id, value);
if (gtk_css_animated_style_set_animated_custom_value (style, variable_id, value))
change |= GTK_CSS_ANIMATION_CHANGE_VARIABLES;
gtk_css_variable_value_unref (value);
change |= GTK_CSS_ANIMATION_CHANGE_VARIABLES;
}
for (i = 0; i < _gtk_css_keyframes_get_n_properties (resolved_keyframes); i++)