[gtk/css-animation-change] css: Avoid unneeded transition work
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/css-animation-change] css: Avoid unneeded transition work
- Date: Sun, 18 Aug 2019 15:57:42 +0000 (UTC)
commit a1cacc590d2418e39481073f16c3709cad4309fa
Author: Benjamin Otte <otte benjamin googlemail com>
Date: Sun Aug 18 15:57:09 2019 +0000
css: Avoid unneeded transition work
Add an early exit in the transition creation code when no transitions are given. In that case, both
transition-duration and transition-delay are equal to their default value of 0, which means no transitions
should run at all.
gtk/gtkcssanimatedstyle.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkcssanimatedstyle.c b/gtk/gtkcssanimatedstyle.c
index c09ddb01ce..f1abcbe87e 100644
--- a/gtk/gtkcssanimatedstyle.c
+++ b/gtk/gtkcssanimatedstyle.c
@@ -272,11 +272,17 @@ gtk_css_animated_style_create_css_transitions (GSList *animations,
GtkCssValue *durations, *delays, *timing_functions;
guint i;
- transition_infos_set (transitions, gtk_css_style_get_value (base_style,
GTK_CSS_PROPERTY_TRANSITION_PROPERTY));
-
durations = gtk_css_style_get_value (base_style, GTK_CSS_PROPERTY_TRANSITION_DURATION);
delays = gtk_css_style_get_value (base_style, GTK_CSS_PROPERTY_TRANSITION_DELAY);
timing_functions = gtk_css_style_get_value (base_style, GTK_CSS_PROPERTY_TRANSITION_TIMING_FUNCTION);
+ /* early exit if transition-duration and transition-delay aren't set (default) */
+ if (_gtk_css_array_value_get_n_values (durations) == 1 &&
+ _gtk_css_array_value_get_n_values (delays) == 1 &&
+ _gtk_css_number_value_get (_gtk_css_array_value_get_nth (durations, 0), 100)
+ + _gtk_css_number_value_get (_gtk_css_array_value_get_nth (delays, transitions[i].index), 100) == 0)
+ return animations;
+
+ transition_infos_set (transitions, gtk_css_style_get_value (base_style,
GTK_CSS_PROPERTY_TRANSITION_PROPERTY));
for (i = 0; i < GTK_CSS_PROPERTY_N_PROPERTIES; i++)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]