[Tizen] Revert "Skip rendering if no animation is currently active"
[platform/core/uifw/dali-core.git] / dali / internal / update / animation / scene-graph-animation.cpp
index e9dd7b3..3a95d54 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -82,9 +82,7 @@ Animation::Animation( float durationSeconds, float speedFactor, const Vector2& p
 {
 }
 
-Animation::~Animation()
-{
-}
+Animation::~Animation() = default;
 
 void Animation::operator delete( void* ptr )
 {
@@ -122,9 +120,9 @@ void Animation::SetDisconnectAction(Dali::Animation::EndAction action)
   {
     mDisconnectAction = action;
 
-    for ( AnimatorIter iter = mAnimators.Begin(), endIter = mAnimators.End(); iter != endIter; ++iter )
+    for ( auto&& item : mAnimators )
     {
-      (*iter)->SetDisconnectAction( action );
+      item->SetDisconnectAction( action );
     }
   }
 }
@@ -176,6 +174,8 @@ void Animation::PlayFrom( float progress )
     mState = Playing;
 
     SetAnimatorsActive( true );
+
+    mCurrentLoop = 0;
   }
 }
 
@@ -207,7 +207,7 @@ void Animation::Pause()
 
 void Animation::Bake(BufferIndex bufferIndex, EndAction action)
 {
-  if( action == Dali::Animation::BakeFinal )
+  if( action == Dali::Animation::BAKE_FINAL )
   {
     if( mSpeedFactor > 0.0f )
     {
@@ -224,9 +224,9 @@ void Animation::Bake(BufferIndex bufferIndex, EndAction action)
 
 void Animation::SetAnimatorsActive( bool active )
 {
-  for ( AnimatorIter iter = mAnimators.Begin(), endIter = mAnimators.End(); iter != endIter; ++iter )
+  for ( auto&& item : mAnimators )
   {
-    (*iter)->SetActive( active );
+    item->SetActive( active );
   }
 }
 
@@ -238,7 +238,7 @@ bool Animation::Stop(BufferIndex bufferIndex)
   {
     animationFinished = true; // The actor-thread should be notified of this
 
-    if( mEndAction != Dali::Animation::Discard )
+    if( mEndAction != Dali::Animation::DISCARD )
     {
       Bake( bufferIndex, mEndAction );
 
@@ -264,7 +264,7 @@ void Animation::OnDestroy(BufferIndex bufferIndex)
 {
   if (mState == Playing || mState == Paused)
   {
-    if (mEndAction != Dali::Animation::Discard)
+    if (mEndAction != Dali::Animation::DISCARD)
     {
       Bake( bufferIndex, mEndAction );
 
@@ -283,13 +283,12 @@ void Animation::SetLoopingMode( bool loopingMode )
 {
   mAutoReverseEnabled = loopingMode;
 
-  for ( AnimatorIter iter = mAnimators.Begin(), endIter = mAnimators.End(); iter != endIter; ++iter )
+  for ( auto&& item : mAnimators )
   {
     // Send some variables together to figure out the Animation status
-    (*iter)->SetSpeedFactor( mSpeedFactor );
-    (*iter)->SetLoopCount( mLoopCount );
-
-    (*iter)->SetLoopingMode( loopingMode );
+    item->SetSpeedFactor( mSpeedFactor );
+    item->SetLoopCount( mLoopCount );
+    item->SetLoopingMode( loopingMode );
   }
 }
 
@@ -301,7 +300,7 @@ void Animation::AddAnimator( OwnerPointer<AnimatorBase>& animator )
   mAnimators.PushBack( animator.Release() );
 }
 
-void Animation::Update(BufferIndex bufferIndex, float elapsedSeconds, bool& looped, bool& finished, bool& progressReached )
+void Animation::Update( BufferIndex bufferIndex, float elapsedSeconds, bool& looped, bool& finished, bool& progressReached )
 {
   looped = false;
   finished = false;
@@ -377,7 +376,7 @@ void Animation::Update(BufferIndex bufferIndex, float elapsedSeconds, bool& loop
 
           // Make elapsed second as edge of range forcely.
           mElapsedSeconds = edgeRangeSeconds + signSpeedFactor * Math::MACHINE_EPSILON_10;
-          UpdateAnimators(bufferIndex, finished && (mEndAction != Dali::Animation::Discard), finished );
+          UpdateAnimators(bufferIndex, finished && (mEndAction != Dali::Animation::DISCARD), finished );
 
           // After update animation, mElapsedSeconds must be begin of value
           mElapsedSeconds = playRangeStartSeconds + playRangeEndSeconds - edgeRangeSeconds;
@@ -430,7 +429,7 @@ void Animation::UpdateAnimators( BufferIndex bufferIndex, bool bake, bool animat
 
   //Loop through all animators
   bool applied(true);
-  for ( AnimatorIter iter = mAnimators.Begin(); iter != mAnimators.End(); )
+  for ( auto&& iter = mAnimators.Begin(); iter != mAnimators.End(); )
   {
     AnimatorBase *animator = *iter;