summaryrefslogtreecommitdiff
path: root/gtk/gtkcssanimatedstyle.c
diff options
context:
space:
mode:
authorTimm Bäder <mail@baedert.org>2020-05-06 19:17:11 +0200
committerTimm Bäder <mail@baedert.org>2020-05-10 08:44:20 +0200
commit1b10020b6e0853f92f75c7b9bae9d08acff2b5f6 (patch)
treed573507210ea73ae7cef74efc3388444723329fc /gtk/gtkcssanimatedstyle.c
parent57444f77f755423653b0da6e36a74695aa7e1c90 (diff)
downloadgtk+-1b10020b6e0853f92f75c7b9bae9d08acff2b5f6.tar.gz
css: Make GtkStyleAnimation and subclasses non-objects
Making them GObjects is unnecessary. This enables further optimizations down the road. The only place we use them in is gtkcssanimatedstyle.c after all.
Diffstat (limited to 'gtk/gtkcssanimatedstyle.c')
-rw-r--r--gtk/gtkcssanimatedstyle.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/gtk/gtkcssanimatedstyle.c b/gtk/gtkcssanimatedstyle.c
index c04f040b0b..bef4a9028c 100644
--- a/gtk/gtkcssanimatedstyle.c
+++ b/gtk/gtkcssanimatedstyle.c
@@ -81,7 +81,7 @@ gtk_css_animated_style_dispose (GObject *object)
guint i;
for (i = 0; i < style->n_animations; i ++)
- g_object_unref (style->animations[i]);
+ gtk_style_animation_unref (style->animations[i]);
style->n_animations = 0;
g_free (style->animations);
@@ -646,7 +646,7 @@ gtk_css_animated_style_find_transition (GtkCssAnimatedStyle *style,
{
GtkStyleAnimation *animation = style->animations[i];
- if (!GTK_IS_CSS_TRANSITION (animation))
+ if (!_gtk_css_transition_is_transition (animation))
continue;
if (_gtk_css_transition_get_property ((GtkCssTransition *)animation) == property_id)
@@ -745,7 +745,7 @@ gtk_css_animated_style_find_animation (GtkStyleAnimation **animations,
{
GtkStyleAnimation *animation = animations[i];
- if (!GTK_IS_CSS_ANIMATION (animation))
+ if (!_gtk_css_animation_is_animation (animation))
continue;
if (g_str_equal (_gtk_css_animation_get_name ((GtkCssAnimation *)animation), name))
@@ -765,9 +765,19 @@ gtk_css_animated_style_create_css_animations (GPtrArray *animations,
{
GtkCssValue *durations, *delays, *timing_functions, *animation_names;
GtkCssValue *iteration_counts, *directions, *play_states, *fill_modes;
+ gboolean source_is_animated;
guint i;
animation_names = base_style->animation->animation_name;
+
+ if (_gtk_css_array_value_get_n_values (animation_names) == 1)
+ {
+ const char *name = _gtk_css_ident_value_get (_gtk_css_array_value_get_nth (animation_names, 0));
+
+ if (g_ascii_strcasecmp (name, "none") == 0)
+ return animations;
+ }
+
durations = base_style->animation->animation_duration;
delays = base_style->animation->animation_delay;
timing_functions = base_style->animation->animation_timing_function;
@@ -775,6 +785,7 @@ gtk_css_animated_style_create_css_animations (GPtrArray *animations,
directions = base_style->animation->animation_direction;
play_states = base_style->animation->animation_play_state;
fill_modes = base_style->animation->animation_fill_mode;
+ source_is_animated = GTK_IS_CSS_ANIMATED_STYLE (source);
for (i = 0; i < _gtk_css_array_value_get_n_values (animation_names); i++)
{
@@ -792,14 +803,14 @@ gtk_css_animated_style_create_css_animations (GPtrArray *animations,
if (animation)
continue;
- if (GTK_IS_CSS_ANIMATED_STYLE (source))
+ if (source_is_animated)
animation = gtk_css_animated_style_find_animation ((GtkStyleAnimation **)GTK_CSS_ANIMATED_STYLE (source)->animations,
GTK_CSS_ANIMATED_STYLE (source)->n_animations,
name);
if (animation)
{
- animation = _gtk_css_animation_advance_with_play_state (GTK_CSS_ANIMATION (animation),
+ animation = _gtk_css_animation_advance_with_play_state ((GtkCssAnimation *)animation,
timestamp,
_gtk_css_play_state_value_get (_gtk_css_array_value_get_nth (play_states, i)));
}
@@ -825,7 +836,7 @@ gtk_css_animated_style_create_css_animations (GPtrArray *animations,
}
if (!animations)
- animations = g_ptr_array_new ();
+ animations = g_ptr_array_sized_new (16);
g_ptr_array_add (animations, animation);
}
@@ -928,7 +939,7 @@ gtk_css_animated_style_new_advance (GtkCssAnimatedStyle *source,
continue;
if (!animations)
- animations = g_ptr_array_new ();
+ animations = g_ptr_array_sized_new (16);
animation = _gtk_style_animation_advance (animation, timestamp);
g_ptr_array_add (animations, animation);