Refactored Animator classes to reduce code binary size by 60%
[platform/core/uifw/dali-core.git] / dali / internal / update / manager / update-manager.cpp
index 308b6a5..dbc7125 100644 (file)
@@ -105,22 +105,6 @@ namespace SceneGraph
 namespace
 {
 /**
- * Helper to reset animate-able objects to base values
- * @param container to iterate over
- * @param updateBufferIndex to use
- */
-template< class T >
-inline void ResetToBaseValues( OwnerContainer<T*>& container, BufferIndex updateBufferIndex )
-{
-  // Reset animatable properties to base values
-  // use reference to avoid extra copies of the iterator
-  for( auto&& iter : container )
-  {
-    iter->ResetToBaseValues( updateBufferIndex );
-  }
-}
-
-/**
  * Helper to Erase an object from OwnerContainer using discard queue
  * @param container to remove from
  * @param object to remove
@@ -245,12 +229,13 @@ struct UpdateManager::Impl
 
   /**
    * Lazy init for FrameCallbackProcessor.
+   * @param[in]  updateManager  A reference to the update-manager
    */
-  FrameCallbackProcessor& GetFrameCallbackProcessor()
+  FrameCallbackProcessor& GetFrameCallbackProcessor( UpdateManager& updateManager )
   {
     if( ! frameCallbackProcessor )
     {
-      frameCallbackProcessor = new FrameCallbackProcessor( transformManager );
+      frameCallbackProcessor = new FrameCallbackProcessor( updateManager, transformManager );
     }
     return *frameCallbackProcessor;
   }
@@ -284,7 +269,7 @@ struct UpdateManager::Impl
   OwnerContainer< PropertyOwner* >     customObjects;                 ///< A container of owned objects (with custom properties)
 
   OwnerContainer< PropertyResetterBase* > propertyResetters;          ///< A container of property resetters
-  AnimationContainer                   animations;                    ///< A container of owned animations
+  OwnerContainer< Animation* >         animations;                    ///< A container of owned animations
   PropertyNotificationContainer        propertyNotifications;         ///< A container of owner property notifications.
   OwnerContainer< Renderer* >          renderers;                     ///< A container of owned renderers
   OwnerContainer< TextureSet* >        textureSets;                   ///< A container of owned texture sets
@@ -432,10 +417,10 @@ void UpdateManager::AddCamera( OwnerPointer< Camera >& camera )
   mImpl->cameras.PushBack( camera.Release() ); // takes ownership
 }
 
-void UpdateManager::RemoveCamera( const Camera* camera )
+void UpdateManager::RemoveCamera( Camera* camera )
 {
   // Find the camera and destroy it
-  EraseUsingDiscardQueue( mImpl->cameras, const_cast<Camera*>( camera ), mImpl->discardQueue, mSceneGraphBuffers.GetUpdateBufferIndex() );
+  EraseUsingDiscardQueue( mImpl->cameras, camera, mImpl->discardQueue, mSceneGraphBuffers.GetUpdateBufferIndex() );
 }
 
 void UpdateManager::AddObject( OwnerPointer<PropertyOwner>& object )
@@ -659,11 +644,10 @@ bool UpdateManager::ProcessGestures( BufferIndex bufferIndex, uint32_t lastVSync
 
 void UpdateManager::Animate( BufferIndex bufferIndex, float elapsedSeconds )
 {
-  AnimationContainer &animations = mImpl->animations;
-  AnimationIter iter = animations.Begin();
+  auto&& iter = mImpl->animations.Begin();
   bool animationLooped = false;
 
-  while ( iter != animations.End() )
+  while ( iter != mImpl->animations.End() )
   {
     Animation* animation = *iter;
     bool finished = false;
@@ -682,7 +666,7 @@ void UpdateManager::Animate( BufferIndex bufferIndex, float elapsedSeconds )
     // Remove animations that had been destroyed but were still waiting for an update
     if (animation->GetState() == Animation::Destroyed)
     {
-      iter = animations.Erase(iter);
+      iter = mImpl->animations.Erase(iter);
     }
     else
     {
@@ -849,6 +833,12 @@ uint32_t UpdateManager::Update( float elapsedSeconds,
       }
     }
 
+    // Call the frame-callback-processor if set
+    if( mImpl->frameCallbackProcessor )
+    {
+      mImpl->frameCallbackProcessor->Update( bufferIndex, elapsedSeconds );
+    }
+
     //Update node hierarchy, apply constraints and perform sorting / culling.
     //This will populate each Layer with a list of renderers which are ready.
     UpdateNodes( bufferIndex );
@@ -860,12 +850,6 @@ uint32_t UpdateManager::Update( float elapsedSeconds,
     //Update renderers and apply constraints
     UpdateRenderers( bufferIndex );
 
-    // Call the frame-callback-processor if set
-    if( mImpl->frameCallbackProcessor )
-    {
-      mImpl->frameCallbackProcessor->Update( bufferIndex, elapsedSeconds );
-    }
-
     //Update the transformations of all the nodes
     mImpl->transformManager.Update();
 
@@ -1076,12 +1060,12 @@ bool UpdateManager::IsDefaultSurfaceRectChanged()
 
 void UpdateManager::AddFrameCallback( OwnerPointer< FrameCallback >& frameCallback, const Node* rootNode )
 {
-  mImpl->GetFrameCallbackProcessor().AddFrameCallback( frameCallback, rootNode );
+  mImpl->GetFrameCallbackProcessor( *this ).AddFrameCallback( frameCallback, rootNode );
 }
 
 void UpdateManager::RemoveFrameCallback( FrameCallbackInterface* frameCallback )
 {
-  mImpl->GetFrameCallbackProcessor().RemoveFrameCallback( frameCallback );
+  mImpl->GetFrameCallbackProcessor( *this ).RemoveFrameCallback( frameCallback );
 }
 
 void UpdateManager::AddSampler( OwnerPointer< Render::Sampler >& sampler )