[clutter/remove-alpha: 3/3] Snapshot/WIP



commit 1e38e164a14cfeb112f51ebc93d87a247f6b1569
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Fri Oct 7 17:45:00 2011 +0100

    Snapshot/WIP

 clutter/clutter-alpha.c     |   13 ------
 clutter/clutter-animation.c |   96 +++++++++++++++++++++++++++++++------------
 clutter/clutter-animation.h |    3 +
 clutter/clutter-timeline.c  |    2 +-
 clutter/clutter-timeline.h  |    2 +-
 5 files changed, 74 insertions(+), 42 deletions(-)
---
diff --git a/clutter/clutter-alpha.c b/clutter/clutter-alpha.c
index 2624c21..367d865 100644
--- a/clutter/clutter-alpha.c
+++ b/clutter/clutter-alpha.c
@@ -787,19 +787,6 @@ typedef struct _AlphaData {
 
 static GPtrArray *clutter_alphas = NULL;
 
-static gdouble
-clutter_alpha_easing (ClutterAlpha *alpha,
-                      gpointer      data)
-{
-  ClutterTimeline *timeline = alpha->priv->timeline;
-  gdouble (* easing_func) (gdouble, gdouble) = data;
-
-  g_assert (easing_func != NULL);
-
-  return easing_func (clutter_timeline_get_elapsed_time (timeline),
-                      clutter_timeline_get_duration (timeline));
-}
-
 /**
  * clutter_alpha_set_mode:
  * @alpha: a #ClutterAlpha
diff --git a/clutter/clutter-animation.c b/clutter/clutter-animation.c
index 8124373..f8db784 100644
--- a/clutter/clutter-animation.c
+++ b/clutter/clutter-animation.c
@@ -193,6 +193,7 @@ struct _ClutterAnimationPrivate
   GHashTable *properties;
 
   ClutterAlpha *alpha;
+  ClutterTimeline *timeline;
 
   guint timeline_started_id;
   guint timeline_completed_id;
@@ -310,7 +311,7 @@ clutter_animation_dispose (GObject *gobject)
   if (priv->alpha != NULL)
     timeline = clutter_alpha_get_timeline (priv->alpha);
   else
-    timeline = NULL;
+    timeline = priv->timeline;
 
   if (timeline != NULL && priv->timeline_started_id != 0)
     g_signal_handler_disconnect (timeline, priv->timeline_started_id);
@@ -546,13 +547,16 @@ clutter_animation_class_init (ClutterAnimationClass *klass)
    * The #ClutterAlpha used by the animation.
    *
    * Since: 1.0
+   *
+   * Deprecated: 1.10: Use the #ClutterAnimation:timeline property and
+   *   the #ClutterTimeline:progress-mode property instead.
    */
   obj_props[PROP_ALPHA] =
     g_param_spec_object ("alpha",
                          P_("Alpha"),
                          P_("The alpha used by the animation"),
                          CLUTTER_TYPE_ALPHA,
-                         CLUTTER_PARAM_READWRITE);
+                         CLUTTER_PARAM_READWRITE | G_PARAM_DEPRECATED);
 
   g_object_class_install_properties (gobject_class,
                                      PROP_LAST,
@@ -1089,7 +1093,10 @@ on_timeline_frame (ClutterTimeline  *timeline,
 
   priv = animation->priv;
 
-  alpha_value = clutter_alpha_get_alpha (priv->alpha);
+  if (priv->alpha != NULL)
+    alpha_value = clutter_alpha_get_alpha (priv->alpha);
+  else
+    alpha_value = clutter_timeline_get_progress (priv->timeline);
 
   if (CLUTTER_IS_ANIMATABLE (priv->object))
     {
@@ -1169,12 +1176,16 @@ clutter_animation_get_timeline_internal (ClutterAnimation *animation)
 {
   ClutterAnimationPrivate *priv = animation->priv;
   ClutterTimeline *timeline;
-  ClutterAlpha *alpha;
 
-  alpha = clutter_animation_get_alpha_internal (animation);
-  timeline = clutter_alpha_get_timeline (alpha);
-  if (timeline != NULL)
-    return timeline;
+  if (priv->timeline != NULL)
+    return priv->timeline;
+
+  if (priv->alpha != NULL)
+    {
+      timeline = clutter_alpha_get_timeline (priv->alpha);
+      if (timeline != NULL)
+        return timeline;
+    }
 
   timeline = g_object_new (CLUTTER_TYPE_TIMELINE, NULL);
 
@@ -1193,14 +1204,19 @@ clutter_animation_get_timeline_internal (ClutterAnimation *animation)
                       G_CALLBACK (on_timeline_frame),
                       animation);
 
-  clutter_alpha_set_timeline (alpha, timeline);
+  if (priv->alpha != NULL)
+    {
+      clutter_alpha_set_timeline (priv->alpha, timeline);
 
-  /* the alpha owns the timeline now */
-  g_object_unref (timeline);
+      /* the alpha owns the timeline now */
+      g_object_unref (timeline);
+    }
+
+  priv->timeline = timeline;
 
   g_object_notify_by_pspec (G_OBJECT (animation), obj_props[PROP_TIMELINE]);
 
-  return timeline;
+  return priv->timeline;
 }
 
 /**
@@ -1301,16 +1317,29 @@ void
 clutter_animation_set_mode (ClutterAnimation *animation,
                             gulong            mode)
 {
-  ClutterAlpha *alpha;
-
   g_return_if_fail (CLUTTER_IS_ANIMATION (animation));
 
   g_object_freeze_notify (G_OBJECT (animation));
 
-  alpha = clutter_animation_get_alpha_internal (animation);
-  g_assert (CLUTTER_IS_ALPHA (alpha));
+  if (animation->priv->alpha != NULL || mode > CLUTTER_ANIMATION_LAST)
+    {
+      ClutterAlpha *alpha;
+
+      if (animation->priv->alpha == NULL)
+        alpha = clutter_animation_get_alpha_internal (animation);
+      else
+        alpha = animation->priv->alpha;
+
+      clutter_alpha_set_mode (alpha, mode);
+    }
+  else
+    {
+      ClutterTimeline *timeline;
+
+      timeline = clutter_animation_get_timeline_internal (animation);
 
-  clutter_alpha_set_mode (alpha, mode);
+      clutter_timeline_set_progress_mode (timeline, mode);
+    }
 
   g_object_notify_by_pspec (G_OBJECT (animation), obj_props[PROP_MODE]);
 
@@ -1331,13 +1360,16 @@ clutter_animation_set_mode (ClutterAnimation *animation,
 gulong
 clutter_animation_get_mode (ClutterAnimation *animation)
 {
-  ClutterAlpha *alpha;
+  ClutterTimeline *timeline;
 
   g_return_val_if_fail (CLUTTER_IS_ANIMATION (animation), CLUTTER_LINEAR);
 
-  alpha = clutter_animation_get_alpha_internal (animation);
+  if (animation->priv->alpha != NULL)
+    return clutter_alpha_get_mode (animation->priv->alpha);
 
-  return clutter_alpha_get_mode (alpha);
+  timeline = clutter_animation_get_timeline_internal (animation);
+
+  return clutter_timeline_get_progress_mode (timeline);
 }
 
 /**
@@ -1363,8 +1395,6 @@ clutter_animation_set_duration (ClutterAnimation *animation,
   g_object_freeze_notify (G_OBJECT (animation));
 
   timeline = clutter_animation_get_timeline_internal (animation);
-  g_assert (CLUTTER_IS_TIMELINE (timeline));
-
   clutter_timeline_set_duration (timeline, msecs);
   clutter_timeline_rewind (timeline);
 
@@ -1453,11 +1483,13 @@ clutter_animation_get_duration (ClutterAnimation *animation)
 /**
  * clutter_animation_set_timeline:
  * @animation: a #ClutterAnimation
- * @timeline: a #ClutterTimeline, or %NULL to unset the
+ * @timeline: (allow-none): a #ClutterTimeline, or %NULL to unset the
  *   current #ClutterTimeline
  *
  * Sets the #ClutterTimeline used by @animation.
  *
+ * This function will take a reference on the passed @timeline.
+ *
  * Since: 1.0
  */
 void
@@ -1466,7 +1498,6 @@ clutter_animation_set_timeline (ClutterAnimation *animation,
 {
   ClutterAnimationPrivate *priv;
   ClutterTimeline *cur_timeline;
-  ClutterAlpha *alpha;
 
   g_return_if_fail (CLUTTER_IS_ANIMATION (animation));
   g_return_if_fail (timeline == NULL || CLUTTER_IS_TIMELINE (timeline));
@@ -1496,14 +1527,19 @@ clutter_animation_set_timeline (ClutterAnimation *animation,
   priv->timeline_completed_id = 0;
   priv->timeline_frame_id = 0;
 
-  alpha = clutter_animation_get_alpha_internal (animation);
-  clutter_alpha_set_timeline (alpha, timeline);
+  if (priv->alpha != NULL)
+    clutter_alpha_set_timeline (priv->alpha, timeline);
+  else
+    priv->timeline = timeline;
+
   g_object_notify_by_pspec (G_OBJECT (animation), obj_props[PROP_TIMELINE]);
   g_object_notify_by_pspec (G_OBJECT (animation), obj_props[PROP_DURATION]);
   g_object_notify_by_pspec (G_OBJECT (animation), obj_props[PROP_LOOP]);
 
-  if (timeline)
+  if (timeline != NULL)
     {
+      g_object_ref (timeline);
+
       priv->timeline_started_id =
         g_signal_connect (timeline, "started",
                           G_CALLBACK (on_timeline_started),
@@ -1550,6 +1586,9 @@ clutter_animation_get_timeline (ClutterAnimation *animation)
  * of the #ClutterAlpha instance.
  *
  * Since: 1.0
+ *
+ * Deprecated: 1.10: Use clutter_animation_get_timeline() and
+ *   clutter_timeline_set_progress_mode() instead.
  */
 void
 clutter_animation_set_alpha (ClutterAnimation *animation,
@@ -1650,6 +1689,9 @@ out:
  * Return value: (transfer none): the alpha object used by the animation
  *
  * Since: 1.0
+ *
+ * Deprecated: 1.10: Use clutter_animation_get_timeline() and
+ *   clutter_timeline_get_progress_mode() instead.
  */
 ClutterAlpha *
 clutter_animation_get_alpha (ClutterAnimation *animation)
diff --git a/clutter/clutter-animation.h b/clutter/clutter-animation.h
index f572e4d..6eac7bc 100644
--- a/clutter/clutter-animation.h
+++ b/clutter/clutter-animation.h
@@ -114,9 +114,12 @@ gboolean             clutter_animation_get_loop        (ClutterAnimation     *an
 void                 clutter_animation_set_timeline    (ClutterAnimation     *animation,
                                                         ClutterTimeline      *timeline);
 ClutterTimeline *    clutter_animation_get_timeline    (ClutterAnimation     *animation);
+
+#if !defined(CLUTTER_DISABLE_DEPRECATED) || defined(CLUTTER_COMPILATION)
 void                 clutter_animation_set_alpha       (ClutterAnimation     *animation,
                                                         ClutterAlpha         *alpha);
 ClutterAlpha *       clutter_animation_get_alpha       (ClutterAnimation     *animation);
+#endif
 
 ClutterAnimation *   clutter_animation_bind            (ClutterAnimation     *animation,
                                                         const gchar          *property_name,
diff --git a/clutter/clutter-timeline.c b/clutter/clutter-timeline.c
index 96fc68c..cadc08e 100644
--- a/clutter/clutter-timeline.c
+++ b/clutter/clutter-timeline.c
@@ -1804,7 +1804,7 @@ clutter_timeline_get_progress_mode (ClutterTimeline *timeline)
  * clutter_timeline_set_progress_func:
  * @timeline: a #ClutterTimeline
  * @func: (allow-none): a #ClutterTimelineProgressFunc or %NULL
- * @data: (closure) (scope notified): data to be passed to @func
+ * @user_data: (closure) (scope notified): data to be passed to @func
  * @notify: function to be called when the progress function is removed
  *   or when the @timeline is finalized
  *
diff --git a/clutter/clutter-timeline.h b/clutter/clutter-timeline.h
index 28b9bc0..ce7c67a 100644
--- a/clutter/clutter-timeline.h
+++ b/clutter/clutter-timeline.h
@@ -100,7 +100,7 @@ typedef enum {
  * Since: 1.8
  */
 typedef gdouble (* ClutterTimelineProgressFunc) (gdouble  elapsed,
-                                                 gdouble  total,
+                                                 gdouble  duration,
                                                  gpointer user_data);
 
 typedef struct _ClutterTimeline        ClutterTimeline;



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