Support multiple window rendering
[platform/core/uifw/dali-core.git] / dali / internal / event / animation / animation-impl.cpp
index c61b1e3..876ec29 100644 (file)
@@ -140,29 +140,19 @@ void ValidateParameters( Property::Type propertyType, Property::Type destination
 
 AnimationPtr Animation::New(float durationSeconds)
 {
-  Stage* stage = Stage::GetCurrent();
-
-  if( stage )
+  if( durationSeconds < 0.0f )
   {
-    AnimationPlaylist& playlist = stage->GetAnimationPlaylist();
-
-    if( durationSeconds < 0.0f )
-    {
-      DALI_LOG_WARNING("duration should be greater than 0.0f.\n");
-      durationSeconds = 0.0f;
-    }
+    DALI_LOG_WARNING("duration should be greater than 0.0f.\n");
+    durationSeconds = 0.0f;
+  }
 
-    AnimationPtr animation = new Animation( *stage, playlist, durationSeconds, DEFAULT_END_ACTION, DEFAULT_DISCONNECT_ACTION, DEFAULT_ALPHA_FUNCTION );
+  ThreadLocalStorage& tls = ThreadLocalStorage::Get();
+  AnimationPtr animation = new Animation( tls.GetEventThreadServices(), tls.GetAnimationPlaylist(), durationSeconds, DEFAULT_END_ACTION, DEFAULT_DISCONNECT_ACTION, DEFAULT_ALPHA_FUNCTION );
 
-    // Second-phase construction
-    animation->Initialize();
+  // Second-phase construction
+  animation->Initialize();
 
-    return animation;
-  }
-  else
-  {
-    return NULL;
-  }
+  return animation;
 }
 
 Animation::Animation( EventThreadServices& eventThreadServices, AnimationPlaylist& playlist, float durationSeconds, EndAction endAction, EndAction disconnectAction, AlphaFunction defaultAlpha )
@@ -877,17 +867,13 @@ void Animation::EmitSignalProgressReached()
 
 bool Animation::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
 {
-  bool connected( true );
+  bool connected( false );
   Animation* animation = static_cast< Animation* >(object); // TypeRegistry guarantees that this is the correct type.
 
   if( 0 == signalName.compare( SIGNAL_FINISHED ) )
   {
     animation->FinishedSignal().Connect( tracker, functor );
-  }
-  else
-  {
-    // signalName does not match any signal
-    connected = false;
+    connected = true;
   }
 
   return connected;
@@ -1011,12 +997,13 @@ void Animation::SetCurrentProgress(float progress)
 
 float Animation::GetCurrentProgress()
 {
-  if( mAnimation )
+  float progress = 0.f;
+  if( mAnimation ) // always exists in practice
   {
-    return mAnimation->GetCurrentProgress();
+    progress = mAnimation->GetCurrentProgress();
   }
 
-  return 0.0f;
+  return progress;
 }
 
 void Animation::ExtendDuration( const TimePeriod& timePeriod )