Friendly janitor cleaning up unnecessary header dependencies
[platform/core/uifw/dali-core.git] / dali / internal / update / manager / update-manager.cpp
index a3f8b6e..2846281 100644 (file)
 #include <dali/internal/event/common/notification-manager.h>
 #include <dali/internal/event/common/property-notification-impl.h>
 #include <dali/internal/event/common/property-notifier.h>
-#include <dali/internal/event/animation/animation-finished-notifier.h>
-#include <dali/internal/event/render-tasks/render-task-list-impl.h>
 
 #include <dali/internal/update/animation/scene-graph-animator.h>
 #include <dali/internal/update/animation/scene-graph-animation.h>
 #include <dali/internal/update/common/discard-queue.h>
-#include <dali/internal/update/common/double-buffered.h>
 #include <dali/internal/update/manager/prepare-render-algorithms.h>
 #include <dali/internal/update/manager/process-render-tasks.h>
 #include <dali/internal/update/resources/resource-manager.h>
@@ -151,7 +148,7 @@ struct UpdateManager::Impl
 {
   Impl( NotificationManager& notificationManager,
         GlSyncAbstraction& glSyncAbstraction,
-        AnimationFinishedNotifier& animationFinishedNotifier,
+        CompleteNotificationInterface& animationFinishedNotifier,
         PropertyNotifier& propertyNotifier,
         ResourceManager& resourceManager,
         DiscardQueue& discardQueue,
@@ -180,7 +177,6 @@ struct UpdateManager::Impl
     systemLevelTaskList ( completeStatusManager ),
     root( NULL ),
     systemLevelRoot( NULL ),
-    defaultShader( NULL ),
     messageQueue( renderController, sceneGraphBuffers ),
     dynamicsChanged( false ),
     keepRenderingSeconds( 0.0f ),
@@ -190,10 +186,9 @@ struct UpdateManager::Impl
     previousUpdateScene( false ),
     frameCounter( 0 ),
     renderSortingHelper(),
-    renderTaskList( NULL ),
     renderTaskWaiting( false )
   {
-    sceneController = new SceneControllerImpl( renderMessageDispatcher, renderQueue, discardQueue, textureCache, completeStatusManager, defaultShader );
+    sceneController = new SceneControllerImpl( renderMessageDispatcher, renderQueue, discardQueue, textureCache, completeStatusManager );
   }
 
   ~Impl()
@@ -240,7 +235,7 @@ struct UpdateManager::Impl
   SceneGraphBuffers                   sceneGraphBuffers;             ///< Used to keep track of which buffers are being written or read
   RenderMessageDispatcher             renderMessageDispatcher;       ///< Used for passing messages to the render-thread
   NotificationManager&                notificationManager;           ///< Queues notification messages for the event-thread.
-  AnimationFinishedNotifier&          animationFinishedNotifier;     ///< Provides notification to applications when animations are finished.
+  CompleteNotificationInterface&      animationFinishedNotifier;     ///< Provides notification to applications when animations are finished.
   PropertyNotifier&                   propertyNotifier;              ///< Provides notification to applications when properties are modified.
   ResourceManager&                    resourceManager;               ///< resource manager
   DiscardQueue&                       discardQueue;                  ///< Nodes are added here when disconnected from the scene-graph.
@@ -271,7 +266,6 @@ struct UpdateManager::Impl
   AnimationContainer                  animations;                    ///< A container of owned animations
   PropertyNotificationContainer       propertyNotifications;         ///< A container of owner property notifications.
 
-  Shader*                             defaultShader;                 ///< The default shader; owned by ShaderContainer
   ShaderContainer                     shaders;                       ///< A container of owned shaders
   AnimatableMeshContainer             animatableMeshes;              ///< A container of owned animatable meshes
   MaterialContainer                   materials;                     ///< A container of owned materials
@@ -293,14 +287,13 @@ struct UpdateManager::Impl
   int                                 frameCounter;                  ///< Frame counter used in debugging to choose which frame to debug and which to ignore.
   RendererSortingHelper               renderSortingHelper;           ///< helper used to sort transparent renderers
 
-  Internal::RenderTaskList*           renderTaskList;                ///< Stores a pointer to the internal implementation to the render task list.
   GestureContainer                    gestures;                      ///< A container of owned gesture detectors
   bool                                renderTaskWaiting;             ///< A REFRESH_ONCE render task is waiting to be rendered
 };
 
 UpdateManager::UpdateManager( NotificationManager& notificationManager,
                               GlSyncAbstraction& glSyncAbstraction,
-                              AnimationFinishedNotifier& animationFinishedNotifier,
+                              CompleteNotificationInterface& animationFinishedNotifier,
                               PropertyNotifier& propertyNotifier,
                               ResourceManager& resourceManager,
                               DiscardQueue& discardQueue,
@@ -332,11 +325,6 @@ UpdateManager::~UpdateManager()
   delete mImpl;
 }
 
-void UpdateManager::SetRenderTaskList( Internal::RenderTaskList* renderTaskList )
-{
-  mImpl->renderTaskList = renderTaskList;
-}
-
 EventToUpdate& UpdateManager::GetEventToUpdate()
 {
   return mImpl->messageQueue;
@@ -369,7 +357,7 @@ void UpdateManager::AddNode( Node* node )
   mImpl->activeDisconnectedNodes.insert( node ); // Takes ownership of node
 }
 
-void UpdateManager::ConnectNode( Node* parent, Node* node )
+void UpdateManager::ConnectNode( Node* parent, Node* node, int index )
 {
   DALI_ASSERT_ALWAYS( NULL != parent );
   DALI_ASSERT_ALWAYS( NULL != node );
@@ -386,7 +374,7 @@ void UpdateManager::ConnectNode( Node* parent, Node* node )
 
   node->SetActive( true );
 
-  parent->ConnectChild( node );
+  parent->ConnectChild( node, index );
 }
 
 void UpdateManager::DisconnectNode( Node* node )
@@ -541,26 +529,27 @@ void UpdateManager::PropertyNotificationSetNotify( PropertyNotification* propert
   propertyNotification->SetNotifyMode( notifyMode );
 }
 
-Shader* UpdateManager::GetDefaultShader()
-{
-  return mImpl->defaultShader;
-}
-
 void UpdateManager::AddShader( Shader* shader )
 {
   DALI_ASSERT_DEBUG( NULL != shader );
 
-  // Note: The first shader added becomes the default shader
-  if( NULL == mImpl->defaultShader )
+  if( mImpl->shaders.Count() == 0 )
   {
-    mImpl->defaultShader = shader;
+    // the first added shader becomes our default shader
+    // Construct message in the render queue memory; note that delete should not be called on the return value
+    typedef MessageValue1< RenderManager, Shader* > DerivedType;
+
+    // Reserve some memory inside the render queue
+    unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+
+    // Construct message in the render queue memory; note that delete should not be called on the return value
+    new (slot) DerivedType( &mImpl->renderManager, &RenderManager::SetDefaultShader, shader );
   }
 
   mImpl->shaders.PushBack( shader );
 
-  // Allows the shader to dispatch texture requests to the cache and "save shader"
-  // requests to the resource manager from the render thread.
-  shader->Initialize( mImpl->renderManager, mImpl->renderQueue, mImpl->sceneController->GetTextureCache() );
+  // Allows the shader to dispatch texture requests to the cache
+  shader->Initialize( mImpl->renderQueue, mImpl->sceneController->GetTextureCache() );
 }
 
 void UpdateManager::RemoveShader(Shader* shader)
@@ -593,19 +582,18 @@ void UpdateManager::SetShaderProgram( Shader* shader, GeometryType geometryType,
   DALI_ASSERT_ALWAYS( NULL != shader && "shader is uninitialized" );
 
   Integration::ShaderDataPtr shaderData( mImpl->resourceManager.GetShaderData(resourceId) );
-  shaderData->SetHashValue( shaderHash );
-
   if( shaderData )
   {
-    // This is done in the render thread, to allow GL program compilation
-    // Will trigger a NotifySaveRequest back to updateManager to forward onto ResourceClient
-    typedef MessageValue6< Shader, GeometryType, Internal::ShaderSubTypes, Integration::ResourceId, Integration::ShaderDataPtr, Context*, bool> DerivedType;
+    shaderData->SetHashValue( shaderHash );
+    shaderData->SetResourceId( resourceId );
+
+    typedef MessageValue6< Shader, GeometryType, Internal::ShaderSubTypes, Integration::ResourceId, Integration::ShaderDataPtr, ProgramCache*, bool> DerivedType;
 
     // Reserve some memory inside the render queue
     unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
 
     // Construct message in the render queue memory; note that delete should not be called on the return value
-    new (slot) DerivedType( shader, &Shader::SetProgram, geometryType, subType, resourceId, shaderData, &(mImpl->renderManager.GetContext()), modifiesGeometry );
+    new (slot) DerivedType( shader, &Shader::SetProgram, geometryType, subType, resourceId, shaderData, mImpl->renderManager.GetProgramCache(), modifiesGeometry );
   }
 }
 
@@ -841,7 +829,7 @@ void UpdateManager::Animate( float elapsedSeconds )
   if ( mImpl->animationFinishedDuringUpdate )
   {
     // The application should be notified by NotificationManager, in another thread
-    mImpl->notificationManager.QueueMessage( AnimationFinishedMessage( mImpl->animationFinishedNotifier ) );
+    mImpl->notificationManager.QueueCompleteNotification( &mImpl->animationFinishedNotifier );
   }
 
   PERF_MONITOR_END(PerformanceMonitor::ANIMATE_NODES);
@@ -1118,7 +1106,7 @@ unsigned int UpdateManager::Update( float elapsedSeconds,
     }
   }
 
-  // check the countdown and notify
+  // check the countdown and notify (note, at the moment this is only done for normal tasks, not for systemlevel tasks)
   bool doRenderOnceNotify = false;
   mImpl->renderTaskWaiting = false;
   const RenderTaskList::RenderTaskContainer& tasks = mImpl->taskList.GetTasks();
@@ -1144,7 +1132,7 @@ unsigned int UpdateManager::Update( float elapsedSeconds,
   if( doRenderOnceNotify )
   {
     DALI_LOG_INFO(gRenderTaskLogFilter, Debug::General, "Notify a render task has finished\n");
-    mImpl->notificationManager.QueueMessage( NotifyFinishedMessage( *mImpl->renderTaskList ) );
+    mImpl->notificationManager.QueueCompleteNotification( mImpl->taskList.GetCompleteNotificationInterface() );
   }
 
   PERF_MONITOR_END(PerformanceMonitor::PROCESS_RENDER_TASKS);