Stop heap allocating messages from UpdateManager for Animation and RenderTask complet...
[platform/core/uifw/dali-core.git] / dali / internal / event / render-tasks / render-task-list-impl.h
1 #ifndef __DALI_INTERNAL_RENDER_TASK_LIST_H__
2 #define __DALI_INTERNAL_RENDER_TASK_LIST_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/common/vector-wrapper.h>
23 #include <dali/public-api/object/base-object.h>
24 #include <dali/public-api/render-tasks/render-task.h>
25 #include <dali/public-api/render-tasks/render-task-list.h>
26 #include <dali/internal/event/common/complete-notification-interface.h>
27
28 namespace Dali
29 {
30
31 namespace Internal
32 {
33
34 class EventToUpdate;
35 class RenderTaskDefaults;
36
37 namespace SceneGraph
38 {
39 class RenderTaskList;
40 class UpdateManager;
41 }
42
43 /**
44  * A proxy for the scene-graph RenderTaskList.
45  * A separate LayerList is maintained for actors added via the SystemLevel::Add().
46  */
47 class RenderTaskList : public BaseObject, public CompleteNotificationInterface
48 {
49 public:
50
51   typedef std::vector< Dali::RenderTask > RenderTaskContainer;
52
53   /**
54    * Create a RenderTaskList.
55    * @param[in] updateManager Used for creating render-tasks in the scene graph.
56    * @param[in] defaults Provides the default source & camera actors.
57    * @param[in] systemLevel True if this is the LayerList for actors added via the SystemLevel::Add().
58    * @return A newly allocated RenderTaskList; the caller takes ownership.
59    */
60   static RenderTaskList* New( SceneGraph::UpdateManager& updateManager, RenderTaskDefaults& defaults, bool systemLevel );
61
62   /**
63    * @copydoc Dali::RenderTaskList::CreateTask()
64    */
65   Dali::RenderTask CreateTask();
66
67   /**
68    * @copydoc Dali::RenderTaskList::RemoveTask()
69    */
70   void RemoveTask( Dali::RenderTask task );
71
72   /**
73    * @copydoc Dali::RenderTaskList::GetTaskCount()
74    */
75   unsigned int GetTaskCount() const;
76
77   /**
78    * @copydoc Dali::RenderTaskList::GetTask()
79    */
80   Dali::RenderTask GetTask( unsigned int index ) const;
81
82   /**
83    * Retrieve the container of render-tasks.
84    * @return The container.
85    */
86   RenderTaskContainer& GetTasks()
87   {
88     return mTasks;
89   }
90
91   /**
92    * Provide notification signals for a "Finished" render task.
93    * This method should be called in the event-thread
94    * Queue NotifyFinishedMessage() from update-thread
95    * @param object pointer to this class instance
96    */
97   static void NotifyFinished( void* object );
98
99 protected:
100
101   /**
102    * Construct a new RenderTaskList.
103    * @param[in] eventToUpdate Used for creating render-tasks in the scene graph.
104    * @param[in] defaults Provides the default source & camera actors.
105    * @param[in] systemLevel True if this is the system-level list.
106    */
107   RenderTaskList( EventToUpdate& eventToUpdate, RenderTaskDefaults& defaults, bool systemLevel );
108
109   /**
110    * A reference counted object may only be deleted by calling Unreference()
111    */
112   virtual ~RenderTaskList();
113
114   /**
115    * 2nd-phase construction
116    */
117   void Initialize( SceneGraph::UpdateManager& updateManager );
118
119 private: // from CompleteNotificationInterface
120
121   /**
122    * @copydoc CompleteNotificationInterface::NotifyCompleted()
123    */
124   virtual void NotifyCompleted();
125
126 private:
127
128   EventToUpdate& mEventToUpdate;
129   RenderTaskDefaults& mDefaults;
130
131   bool mIsSystemLevel; ///< True if the layers are added via the SystemLevel API
132
133   SceneGraph::RenderTaskList* mSceneObject; ///< Raw-pointer to the scene-graph object; not owned.
134
135   RenderTaskContainer mTasks; ///< Reference counted render-tasks
136 };
137
138 } // namespace Internal
139
140 // Helpers for public-api forwarding methods
141
142 inline Internal::RenderTaskList& GetImplementation(Dali::RenderTaskList& taskList)
143 {
144   DALI_ASSERT_ALWAYS(taskList && "RenderTaskList handle is empty");
145
146   BaseObject& handle = taskList.GetBaseObject();
147
148   return static_cast<Internal::RenderTaskList&>(handle);
149 }
150
151 inline const Internal::RenderTaskList& GetImplementation(const Dali::RenderTaskList& taskList)
152 {
153   DALI_ASSERT_ALWAYS(taskList && "RenderTaskList handle is empty");
154
155   const BaseObject& handle = taskList.GetBaseObject();
156
157   return static_cast<const Internal::RenderTaskList&>(handle);
158 }
159
160 } // namespace Dali
161
162 #endif //__DALI_INTERNAL_RENDER_TASK_LIST_H__