diff options
author | Timm Bäder <mail@baedert.org> | 2020-05-06 11:37:51 +0200 |
---|---|---|
committer | Timm Bäder <mail@baedert.org> | 2020-05-10 08:44:20 +0200 |
commit | e12c9de5dfd5b9ed0098650c516f4fed1653f423 (patch) | |
tree | 96e6fcd22ee88ed455fdcbc1d021af3fc21bda56 | |
parent | f38bbb9bc28420df20b7bc217f86a86cd7e5e9fe (diff) | |
download | gtk+-e12c9de5dfd5b9ed0098650c516f4fed1653f423.tar.gz |
csstransiton: Save finished state
Once a transtion is finished it can't change to unfinished again, so we
don't have to consult the progress tracker all the time.
-rw-r--r-- | gtk/gtkcsstransition.c | 10 | ||||
-rw-r--r-- | gtk/gtkcsstransitionprivate.h | 1 |
2 files changed, 8 insertions, 3 deletions
diff --git a/gtk/gtkcsstransition.c b/gtk/gtkcsstransition.c index 23478b618b..62731a513d 100644 --- a/gtk/gtkcsstransition.c +++ b/gtk/gtkcsstransition.c @@ -42,6 +42,7 @@ gtk_css_transition_advance (GtkStyleAnimation *style_animation, gtk_progress_tracker_init_copy (&source->tracker, &transition->tracker); gtk_progress_tracker_advance_frame (&transition->tracker, timestamp); + transition->finished = gtk_progress_tracker_get_state (&transition->tracker) == GTK_PROGRESS_STATE_AFTER; return GTK_STYLE_ANIMATION (transition); } @@ -55,8 +56,10 @@ gtk_css_transition_apply_values (GtkStyleAnimation *style_animation, double progress; GtkProgressState state; - end = gtk_css_animated_style_get_intrinsic_value (style, transition->property); + if (transition->finished) + return; + end = gtk_css_animated_style_get_intrinsic_value (style, transition->property); state = gtk_progress_tracker_get_state (&transition->tracker); if (state == GTK_PROGRESS_STATE_BEFORE) @@ -85,7 +88,7 @@ gtk_css_transition_is_finished (GtkStyleAnimation *animation) { GtkCssTransition *transition = GTK_CSS_TRANSITION (animation); - return gtk_progress_tracker_get_state (&transition->tracker) == GTK_PROGRESS_STATE_AFTER; + return transition->finished; } static gboolean @@ -93,7 +96,7 @@ gtk_css_transition_is_static (GtkStyleAnimation *animation) { GtkCssTransition *transition = GTK_CSS_TRANSITION (animation); - return gtk_progress_tracker_get_state (&transition->tracker) == GTK_PROGRESS_STATE_AFTER; + return transition->finished; } static void @@ -146,6 +149,7 @@ _gtk_css_transition_new (guint property, transition->ease = _gtk_css_value_ref (ease); gtk_progress_tracker_start (&transition->tracker, duration_us, delay_us, 1.0); gtk_progress_tracker_advance_frame (&transition->tracker, timestamp); + transition->finished = gtk_progress_tracker_get_state (&transition->tracker) == GTK_PROGRESS_STATE_AFTER; return GTK_STYLE_ANIMATION (transition); } diff --git a/gtk/gtkcsstransitionprivate.h b/gtk/gtkcsstransitionprivate.h index 822a8246d9..6f722023a1 100644 --- a/gtk/gtkcsstransitionprivate.h +++ b/gtk/gtkcsstransitionprivate.h @@ -43,6 +43,7 @@ struct _GtkCssTransition GtkCssValue *start; GtkCssValue *ease; GtkProgressTracker tracker; + guint finished; }; struct _GtkCssTransitionClass |