GtkStyleAnimation * _gtk_css_animation_copy (GtkCssAnimation *animation, gint64 at_time_us, GtkCssPlayState play_state) { g_return_val_if_fail (GTK_IS_CSS_ANIMATION (animation), NULL); if (animation->play_state == play_state) return g_object_ref (animation); return _gtk_css_animation_new (animation->name, animation->keyframes, at_time_us, - gtk_css_animation_get_elapsed (animation, at_time_us), animation->duration, animation->ease, animation->direction, play_state, animation->fill_mode, animation->iteration_count); }
static void gtk_css_computed_values_create_css_animations (GtkCssComputedValues *values, GtkCssComputedValues *parent_values, gint64 timestamp, GtkStyleProviderPrivate *provider, GtkCssComputedValues *source) { GtkCssValue *durations, *delays, *timing_functions, *animations; GtkCssValue *iteration_counts, *directions, *play_states, *fill_modes; guint i; animations = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_ANIMATION_NAME); durations = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_ANIMATION_DURATION); delays = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_ANIMATION_DELAY); timing_functions = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_ANIMATION_TIMING_FUNCTION); iteration_counts = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_ANIMATION_ITERATION_COUNT); directions = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_ANIMATION_DIRECTION); play_states = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_ANIMATION_PLAY_STATE); fill_modes = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_ANIMATION_FILL_MODE); for (i = 0; i < _gtk_css_array_value_get_n_values (animations); i++) { GtkStyleAnimation *animation; GtkCssKeyframes *keyframes; const char *name; name = _gtk_css_ident_value_get (_gtk_css_array_value_get_nth (animations, i)); if (g_ascii_strcasecmp (name, "none") == 0) continue; animation = gtk_css_computed_values_find_animation (values, name); if (animation) continue; if (source) animation = gtk_css_computed_values_find_animation (source, name); if (animation) { animation = _gtk_css_animation_copy (GTK_CSS_ANIMATION (animation), timestamp, _gtk_css_play_state_value_get (_gtk_css_array_value_get_nth (play_states, i))); } else { keyframes = _gtk_style_provider_private_get_keyframes (provider, name); if (keyframes == NULL) continue; keyframes = _gtk_css_keyframes_compute (keyframes, provider, values, parent_values); animation = _gtk_css_animation_new (name, keyframes, timestamp, _gtk_css_number_value_get (_gtk_css_array_value_get_nth (delays, i), 100) * G_USEC_PER_SEC, _gtk_css_number_value_get (_gtk_css_array_value_get_nth (durations, i), 100) * G_USEC_PER_SEC, _gtk_css_array_value_get_nth (timing_functions, i), _gtk_css_direction_value_get (_gtk_css_array_value_get_nth (directions, i)), _gtk_css_play_state_value_get (_gtk_css_array_value_get_nth (play_states, i)), _gtk_css_fill_mode_value_get (_gtk_css_array_value_get_nth (fill_modes, i)), _gtk_css_number_value_get (_gtk_css_array_value_get_nth (iteration_counts, i), 100)); _gtk_css_keyframes_unref (keyframes); } values->animations = g_slist_prepend (values->animations, animation); } }