Fixed bug in animation when specifying BakeFinal as destroy action. 81/27881/3
authorFerran Sole <ferran.sole@samsung.com>
Mon, 22 Sep 2014 11:13:32 +0000 (12:13 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 23 Sep 2014 14:50:02 +0000 (07:50 -0700)
[Problem] BakeFinal was ignored when specified for destroy action, it
          would just bake current value instead of final animation value.

[Solution] Bake final value when animation is destroyed if destroy action is BakeFinal.

Change-Id: I5acac43e0137359c7a26bca6362fb6a50b136248

dali/internal/update/animation/scene-graph-animation.cpp
dali/internal/update/animation/scene-graph-animation.h

index f6a290a..95dd664 100644 (file)
@@ -106,6 +106,23 @@ void Animation::Pause()
   }
 }
 
+void Animation::Bake(BufferIndex bufferIndex, EndAction action)
+{
+  if( action == Dali::Animation::BakeFinal )
+  {
+    if( mSpeedFactor > 0.0f )
+    {
+      mElapsedSeconds = mDurationSeconds + Math::MACHINE_EPSILON_1; // Force animation to reach it's end
+    }
+    else
+    {
+      mElapsedSeconds = 0.0f - Math::MACHINE_EPSILON_1; //Force animation to reach it's beginning
+    }
+  }
+
+  UpdateAnimators(bufferIndex, true/*bake the final result*/);
+}
+
 bool Animation::Stop(BufferIndex bufferIndex)
 {
   bool animationFinished(false);
@@ -116,19 +133,7 @@ bool Animation::Stop(BufferIndex bufferIndex)
 
     if( mEndAction != Dali::Animation::Discard )
     {
-      if( mEndAction == Dali::Animation::BakeFinal )
-      {
-        if( mSpeedFactor > 0.0f )
-        {
-          mElapsedSeconds = mDurationSeconds + Math::MACHINE_EPSILON_1; // Force animation to reach it's end
-        }
-        else
-        {
-          mElapsedSeconds = 0.0f - Math::MACHINE_EPSILON_1; //Force animation to reach it's beginning
-        }
-
-      }
-      UpdateAnimators(bufferIndex, true/*bake the final result*/);
+      Bake( bufferIndex, mEndAction );
     }
 
     // The animation has now been played to completion
@@ -147,7 +152,7 @@ void Animation::OnDestroy(BufferIndex bufferIndex)
   {
     if (mDestroyAction != Dali::Animation::Discard)
     {
-      UpdateAnimators(bufferIndex, true/*bake the final result*/);
+      Bake( bufferIndex, mDestroyAction );
     }
   }
 
index afce4f9..c99c182 100644 (file)
@@ -263,6 +263,14 @@ private:
    */
   void UpdateAnimators(BufferIndex bufferIndex, bool bake);
 
+  /**
+   * Helper function to bake the result of the animation when it is stopped or
+   * destroyed.
+   * @param[in] bufferIndex The buffer to update.
+   * @param[in] action The end action specified.
+   */
+  void Bake(BufferIndex bufferIndex, EndAction action );
+
   // Undefined
   Animation(const Animation&);