[mutter] clutter: Remove ClutterAnimation



commit 322b51cded630fb36f1759ebb608fe4985bd228b
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Thu Apr 9 17:54:45 2020 +0200

    clutter: Remove ClutterAnimation
    
    This removes ClutterAnimation and related tests. ClutterAnimation has
    been deprecated for a long time, and replacements exist and are used by
    e.g. GNOME Shell since a while back.
    
    This also disables a few relatively unrelated interactive tests, as they
    rely on ClutterAnimation to implement some animations they use to
    illustrate what they actually test.
    
    As interactive tests currently are more or less untestable due to any
    interaction with them crashing, as well as they in practice means
    rewriting the tests using non-deprecated animation APIs, they are not
    ported right now. To actually port the interactive tests, it needs to be
    possible to fist interact with them.
    
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1192

 clutter/clutter/clutter-animatable.c               |   14 +-
 clutter/clutter/clutter-animatable.h               |    3 -
 clutter/clutter/clutter-deprecated.h               |    1 -
 clutter/clutter/clutter-enums.h                    |    2 +-
 clutter/clutter/clutter-interval.c                 |    3 -
 clutter/clutter/clutter-script-parser.c            |   81 -
 clutter/clutter/clutter-script-private.h           |    2 -
 clutter/clutter/clutter-timeline.c                 |    3 +-
 clutter/clutter/clutter-types.h                    |    2 -
 clutter/clutter/deprecated/clutter-animation.c     | 1598 --------------------
 clutter/clutter/deprecated/clutter-animation.h     |  152 --
 clutter/clutter/meson.build                        |    2 -
 src/tests/clutter/conform/script-parser.c          |   23 -
 .../conform/scripts/test-script-animation.json     |   14 -
 src/tests/clutter/interactive/meson.build          |    5 -
 src/tests/clutter/interactive/test-easing.c        |   38 +-
 16 files changed, 19 insertions(+), 1924 deletions(-)
---
diff --git a/clutter/clutter/clutter-animatable.c b/clutter/clutter/clutter-animatable.c
index e8c951110..e14012c5d 100644
--- a/clutter/clutter/clutter-animatable.c
+++ b/clutter/clutter/clutter-animatable.c
@@ -27,35 +27,23 @@
  * @short_description: Interface for animatable classes
  *
  * #ClutterAnimatable is an interface that allows a #GObject class
- * to control how a #ClutterAnimation will animate a property.
+ * to control how an actor will animate a property.
  *
  * Each #ClutterAnimatable should implement the
  * #ClutterAnimatableInterface.interpolate_property() virtual function of the
  * interface to compute the animation state between two values of an interval
  * depending on a progress factor, expressed as a floating point value.
  *
- * If a #ClutterAnimatable is animated by a #ClutterAnimation
- * instance, the #ClutterAnimation will call
- * clutter_animatable_interpolate_property() passing the name of the
- * currently animated property; the values interval; and the progress factor.
- * The #ClutterAnimatable implementation should return the computed value for
- * the animated
- * property.
- *
  * #ClutterAnimatable is available since Clutter 1.0
  */
 
 #include "clutter-build-config.h"
 
-#define CLUTTER_DISABLE_DEPRECATION_WARNINGS
-
 #include "clutter-animatable.h"
 #include "clutter-interval.h"
 #include "clutter-debug.h"
 #include "clutter-private.h"
 
-#include "deprecated/clutter-animation.h"
-
 G_DEFINE_INTERFACE (ClutterAnimatable, clutter_animatable, G_TYPE_OBJECT);
 
 static void
diff --git a/clutter/clutter/clutter-animatable.h b/clutter/clutter/clutter-animatable.h
index 92006d0ca..d03e0589d 100644
--- a/clutter/clutter/clutter-animatable.h
+++ b/clutter/clutter/clutter-animatable.h
@@ -51,9 +51,6 @@ G_DECLARE_INTERFACE (ClutterAnimatable, clutter_animatable,
  * @interpolate_value: virtual function for interpolating the progress
  *   of a property
  *
- * Base interface for #GObject<!-- -->s that can be animated by a
- * a #ClutterAnimation.
- *
  * Since: 1.0
  */
 struct _ClutterAnimatableInterface
diff --git a/clutter/clutter/clutter-deprecated.h b/clutter/clutter/clutter-deprecated.h
index 4b6147324..c2bb1cff2 100644
--- a/clutter/clutter/clutter-deprecated.h
+++ b/clutter/clutter/clutter-deprecated.h
@@ -4,7 +4,6 @@
 #define __CLUTTER_DEPRECATED_H_INSIDE__
 
 #include "deprecated/clutter-actor.h"
-#include "deprecated/clutter-animation.h"
 #include "deprecated/clutter-box.h"
 #include "deprecated/clutter-container.h"
 #include "deprecated/clutter-group.h"
diff --git a/clutter/clutter/clutter-enums.h b/clutter/clutter/clutter-enums.h
index f7e8bc4c2..2d4f41c42 100644
--- a/clutter/clutter/clutter-enums.h
+++ b/clutter/clutter/clutter-enums.h
@@ -190,7 +190,7 @@ typedef enum /*< prefix=CLUTTER_REQUEST >*/
  * @CLUTTER_ANIMATION_LAST: last animation mode, used as a guard for
  *   registered global alpha functions
  *
- * The animation modes used by #ClutterAnimation. This
+ * The animation modes used by #ClutterAnimatable. This
  * enumeration can be expanded in later versions of Clutter.
  *
  * <figure id="easing-modes">
diff --git a/clutter/clutter/clutter-interval.c b/clutter/clutter/clutter-interval.c
index 6f14287b4..97d2026aa 100644
--- a/clutter/clutter/clutter-interval.c
+++ b/clutter/clutter/clutter-interval.c
@@ -37,9 +37,6 @@
  * any object taking a reference on a #ClutterInterval instance should
  * also take ownership of the interval by using g_object_ref_sink().
  *
- * #ClutterInterval is used by #ClutterAnimation to define the
- * interval of values that an implicit animation should tween over.
- *
  * #ClutterInterval can be subclassed to override the validation
  * and value computation.
  *
diff --git a/clutter/clutter/clutter-script-parser.c b/clutter/clutter/clutter-script-parser.c
index c64289309..bf3d51878 100644
--- a/clutter/clutter/clutter-script-parser.c
+++ b/clutter/clutter/clutter-script-parser.c
@@ -798,87 +798,6 @@ parse_signals (ClutterScript *script,
   return retval;
 }
 
-/* define the names of the animation modes to match the ones
- * that developers might be more accustomed to
- */
-static const struct
-{
-  const gchar *name;
-  ClutterAnimationMode mode;
-} animation_modes[] = {
-  { "linear", CLUTTER_LINEAR },
-  { "easeInQuad", CLUTTER_EASE_IN_QUAD },
-  { "easeOutQuad", CLUTTER_EASE_OUT_QUAD },
-  { "easeInOutQuad", CLUTTER_EASE_IN_OUT_QUAD },
-  { "easeInCubic", CLUTTER_EASE_IN_CUBIC },
-  { "easeOutCubic", CLUTTER_EASE_OUT_CUBIC },
-  { "easeInOutCubic", CLUTTER_EASE_IN_OUT_CUBIC },
-  { "easeInQuart", CLUTTER_EASE_IN_QUART },
-  { "easeOutQuart", CLUTTER_EASE_OUT_QUART },
-  { "easeInOutQuart", CLUTTER_EASE_IN_OUT_QUART },
-  { "easeInQuint", CLUTTER_EASE_IN_QUINT },
-  { "easeOutQuint", CLUTTER_EASE_OUT_QUINT },
-  { "easeInOutQuint", CLUTTER_EASE_IN_OUT_QUINT },
-  { "easeInSine", CLUTTER_EASE_IN_SINE },
-  { "easeOutSine", CLUTTER_EASE_OUT_SINE },
-  { "easeInOutSine", CLUTTER_EASE_IN_OUT_SINE },
-  { "easeInExpo", CLUTTER_EASE_IN_EXPO },
-  { "easeOutExpo", CLUTTER_EASE_OUT_EXPO },
-  { "easeInOutExpo", CLUTTER_EASE_IN_OUT_EXPO },
-  { "easeInCirc", CLUTTER_EASE_IN_CIRC },
-  { "easeOutCirc", CLUTTER_EASE_OUT_CIRC },
-  { "easeInOutCirc", CLUTTER_EASE_IN_OUT_CIRC },
-  { "easeInElastic", CLUTTER_EASE_IN_ELASTIC },
-  { "easeOutElastic", CLUTTER_EASE_OUT_ELASTIC },
-  { "easeInOutElastic", CLUTTER_EASE_IN_OUT_ELASTIC },
-  { "easeInBack", CLUTTER_EASE_IN_BACK },
-  { "easeOutBack", CLUTTER_EASE_OUT_BACK },
-  { "easeInOutBack", CLUTTER_EASE_IN_OUT_BACK },
-  { "easeInBounce", CLUTTER_EASE_IN_BOUNCE },
-  { "easeOutBounce", CLUTTER_EASE_OUT_BOUNCE },
-  { "easeInOutBounce", CLUTTER_EASE_IN_OUT_BOUNCE },
-};
-
-static const gint n_animation_modes = G_N_ELEMENTS (animation_modes);
-
-gulong
-_clutter_script_resolve_animation_mode (JsonNode *node)
-{
-  gint i, res = CLUTTER_CUSTOM_MODE;
-
-  if (JSON_NODE_TYPE (node) != JSON_NODE_VALUE)
-    return CLUTTER_CUSTOM_MODE;
-
-  if (json_node_get_value_type (node) == G_TYPE_INT64)
-    return json_node_get_int (node);
-
-  if (json_node_get_value_type (node) == G_TYPE_STRING)
-    {
-      const gchar *name = json_node_get_string (node);
-
-      /* XXX - we might be able to optimize by changing the ordering
-       * of the animation_modes array, e.g.
-       *  - special casing linear
-       *  - tokenizing ('ease', 'In', 'Sine') and matching on token
-       *  - binary searching?
-       */
-      for (i = 0; i < n_animation_modes; i++)
-        {
-          if (strcmp (animation_modes[i].name, name) == 0)
-            return animation_modes[i].mode;
-        }
-
-      if (_clutter_script_enum_from_string (CLUTTER_TYPE_ANIMATION_MODE,
-                                            name,
-                                            &res))
-        return res;
-
-      g_warning ("Unable to find the animation mode '%s'", name);
-    }
-
-  return CLUTTER_CUSTOM_MODE;
-}
-
 static void
 clutter_script_parser_object_end (JsonParser *json_parser,
                                   JsonObject *object)
diff --git a/clutter/clutter/clutter-script-private.h b/clutter/clutter/clutter-script-private.h
index b17c04581..52c240e2a 100644
--- a/clutter/clutter/clutter-script-private.h
+++ b/clutter/clutter/clutter-script-private.h
@@ -110,8 +110,6 @@ gboolean _clutter_script_parse_node        (ClutterScript *script,
 GType    _clutter_script_get_type_from_symbol (const gchar *symbol);
 GType    _clutter_script_get_type_from_class  (const gchar *name);
 
-gulong   _clutter_script_resolve_animation_mode (JsonNode *node);
-
 gboolean _clutter_script_enum_from_string  (GType          gtype,
                                             const gchar   *string,
                                             gint          *enum_value);
diff --git a/clutter/clutter/clutter-timeline.c b/clutter/clutter/clutter-timeline.c
index b6f7ac666..cd0e795eb 100644
--- a/clutter/clutter/clutter-timeline.c
+++ b/clutter/clutter/clutter-timeline.c
@@ -24,7 +24,6 @@
 /**
  * SECTION:clutter-timeline
  * @short_description: A class for time-based events
- * @see_also: #ClutterAnimation, #ClutterAnimator, #ClutterState
  *
  * #ClutterTimeline is a base class for managing time-based event that cause
  * Clutter to redraw a stage, such as animations.
@@ -71,7 +70,7 @@
  * when reaching completion by using the #ClutterTimeline:auto-reverse property.
  *
  * Timelines are used in the Clutter animation framework by classes like
- * #ClutterAnimation, #ClutterAnimator, and #ClutterState.
+ * #ClutterTransition.
  *
  * ## Defining Timelines in ClutterScript
  *
diff --git a/clutter/clutter/clutter-types.h b/clutter/clutter/clutter-types.h
index 35cf5580b..1b65573a3 100644
--- a/clutter/clutter/clutter-types.h
+++ b/clutter/clutter/clutter-types.h
@@ -79,8 +79,6 @@ typedef struct _ClutterKnot                     ClutterKnot;
 typedef struct _ClutterMargin                   ClutterMargin;
 typedef struct _ClutterPerspective              ClutterPerspective;
 
-typedef struct _ClutterAnimation                ClutterAnimation;
-
 typedef struct _ClutterInputDeviceTool          ClutterInputDeviceTool;
 typedef struct _ClutterInputDevice              ClutterInputDevice;
 typedef struct _ClutterVirtualInputDevice       ClutterVirtualInputDevice;
diff --git a/clutter/clutter/meson.build b/clutter/clutter/meson.build
index 22c5e4ee4..f21d0e77c 100644
--- a/clutter/clutter/meson.build
+++ b/clutter/clutter/meson.build
@@ -219,7 +219,6 @@ clutter_nonintrospected_sources = [
 
 clutter_deprecated_headers = [
   'deprecated/clutter-actor.h',
-  'deprecated/clutter-animation.h',
   'deprecated/clutter-box.h',
   'deprecated/clutter-container.h',
   'deprecated/clutter-group.h',
@@ -229,7 +228,6 @@ clutter_deprecated_headers = [
 ]
 
 clutter_deprecated_sources = [
-  'deprecated/clutter-animation.c',
   'deprecated/clutter-box.c',
   'deprecated/clutter-group.c',
   'deprecated/clutter-rectangle.c',
diff --git a/src/tests/clutter/conform/script-parser.c b/src/tests/clutter/conform/script-parser.c
index b51db38d6..7a7e6a8b6 100644
--- a/src/tests/clutter/conform/script-parser.c
+++ b/src/tests/clutter/conform/script-parser.c
@@ -251,28 +251,6 @@ script_named_object (void)
   g_free (test_file);
 }
 
-static void
-script_animation (void)
-{
-  ClutterScript *script = clutter_script_new ();
-  GObject *animation = NULL;
-  GError *error = NULL;
-  gchar *test_file;
-
-  test_file = g_test_build_filename (G_TEST_DIST, "scripts", "test-script-animation.json", NULL);
-  clutter_script_load_from_file (script, test_file, &error);
-  if (g_test_verbose () && error)
-    g_print ("Error: %s", error->message);
-
-  g_assert_no_error (error);
-
-  animation = clutter_script_get_object (script, "test");
-  g_assert (CLUTTER_IS_ANIMATION (animation));
-
-  g_object_unref (script);
-  g_free (test_file);
-}
-
 static void
 script_layout_property (void)
 {
@@ -383,7 +361,6 @@ CLUTTER_TEST_SUITE (
   CLUTTER_TEST_UNIT ("/script/single-object", script_single)
   CLUTTER_TEST_UNIT ("/script/container-child", script_child)
   CLUTTER_TEST_UNIT ("/script/named-object", script_named_object)
-  CLUTTER_TEST_UNIT ("/script/animation", script_animation)
   CLUTTER_TEST_UNIT ("/script/object-property", script_object_property)
   CLUTTER_TEST_UNIT ("/script/layout-property", script_layout_property)
   CLUTTER_TEST_UNIT ("/script/actor-margin", script_margin)
diff --git a/src/tests/clutter/interactive/meson.build b/src/tests/clutter/interactive/meson.build
index 59aead635..0e7180f13 100644
--- a/src/tests/clutter/interactive/meson.build
+++ b/src/tests/clutter/interactive/meson.build
@@ -17,7 +17,6 @@ clutter_tests_interactive_link_args = [
 clutter_tests_interactive_test_sources = [
   'test-events.c',
   'test-actors.c',
-  'test-shader-effects.c',
   'test-script.c',
   'test-grab.c',
   'test-cogl-shader-glsl.c',
@@ -25,9 +24,7 @@ clutter_tests_interactive_test_sources = [
   'test-cogl-tex-convert.c',
   'test-cogl-offscreen.c',
   'test-cogl-tex-polygon.c',
-  'test-cogl-multitexture.c',
   'test-paint-wrapper.c',
-  'test-layout.c',
   'test-animation.c',
   'test-easing.c',
   'test-binding-pool.c',
@@ -38,11 +35,9 @@ clutter_tests_interactive_test_sources = [
   'test-stage-sizing.c',
   'test-swipe-action.c',
   'test-cogl-point-sprites.c',
-  'test-path-constraint.c',
   'test-devices.c',
   'test-content.c',
   'test-keyframe-transition.c',
-  'test-bind-constraint.c',
   'test-touch-events.c',
   'test-rotate-zoom.c',
   'test-image.c',
diff --git a/src/tests/clutter/interactive/test-easing.c b/src/tests/clutter/interactive/test-easing.c
index c0d175a21..1ec88e814 100644
--- a/src/tests/clutter/interactive/test-easing.c
+++ b/src/tests/clutter/interactive/test-easing.c
@@ -53,8 +53,6 @@ static gboolean recenter = FALSE;
 static ClutterActor *main_stage = NULL;
 static ClutterActor *easing_mode_label = NULL;
 
-static ClutterAnimation *last_animation = NULL;
-
 int
 test_easing_main (int argc, char *argv[]);
 
@@ -66,21 +64,23 @@ test_easing_describe (void);
  * repositions (through an animation) the bouncer at the center of the stage
  */
 static void
-recenter_bouncer (ClutterAnimation *animation,
-                  ClutterActor     *rectangle)
+recenter_bouncer (ClutterActor *rectangle)
 {
   gfloat base_x, base_y;
   gint cur_mode;
 
+
+  cur_mode = easing_modes[current_mode].mode;
   base_x = clutter_actor_get_width (main_stage) / 2;
   base_y = clutter_actor_get_height (main_stage) / 2;
 
-  cur_mode = easing_modes[current_mode].mode;
+  clutter_actor_set_easing_duration (rectangle, 250);
+  clutter_actor_set_easing_mode (rectangle, cur_mode);
+  clutter_actor_set_position (rectangle, base_x, base_y);
 
-  clutter_actor_animate (rectangle, cur_mode, 250,
-                         "x", base_x,
-                         "y", base_y,
-                         NULL);
+  g_signal_connect_after (rectangle, "transition-completed",
+                          G_CALLBACK (clutter_actor_restore_easing_state),
+                          NULL);
 }
 
 static gboolean
@@ -108,28 +108,22 @@ on_button_press (ClutterActor       *actor,
     }
   else if (event->button == CLUTTER_BUTTON_PRIMARY)
     {
-      ClutterAnimation *animation;
       ClutterAnimationMode cur_mode;
 
       cur_mode = easing_modes[current_mode].mode;
 
-      /* tween the actor using the current easing mode */
-      animation =
-        clutter_actor_animate (rectangle, cur_mode, duration * 1000,
-                               "x", event->x,
-                               "y", event->y,
-                               NULL);
+      clutter_actor_save_easing_state (rectangle);
+      clutter_actor_set_easing_duration (rectangle, duration * 1000);
+      clutter_actor_set_easing_mode (rectangle, cur_mode);
+      clutter_actor_set_position (rectangle, event->x, event->y);
 
       /* if we were asked to, recenter the bouncer at the end of the
        * animation. we keep track of the animation to avoid connecting
        * the signal handler to the same Animation twice.
        */
-      if (recenter && last_animation != animation)
-        g_signal_connect_after (animation, "completed",
-                                G_CALLBACK (recenter_bouncer),
-                                rectangle);
-
-      last_animation = animation;
+      g_signal_connect_after (rectangle, "transition-completed",
+                              G_CALLBACK (recenter_bouncer),
+                              rectangle);
     }
 
   return TRUE;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]