6d351c2073379c76622d76789376d68df724eb05
[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 EventThreadServices;
35 class RenderTaskDefaults;
36 class Actor;
37 class CameraActor;
38
39 class RenderTaskList;
40 typedef IntrusivePtr<RenderTaskList> RenderTaskListPtr;
41
42 namespace SceneGraph
43 {
44 class RenderTaskList;
45 class UpdateManager;
46 }
47
48 /**
49  * A proxy for the scene-graph RenderTaskList.
50  * A separate LayerList is maintained for actors added via the SystemLevel::Add().
51  */
52 class RenderTaskList : public BaseObject, public CompleteNotificationInterface
53 {
54 public:
55
56   typedef std::vector< Dali::RenderTask > RenderTaskContainer;
57
58   struct Exclusive
59   {
60     RenderTask* renderTaskPtr;        ///< Pointer for comparison with current rendertask.
61     Actor* actorPtr;                  ///< Pointer for comparison with current actor.
62   };
63
64   /**
65    * Create a RenderTaskList.
66    * @return A newly allocated RenderTaskList; the caller takes ownership.
67    */
68   static RenderTaskListPtr New();
69
70   /**
71    * @copydoc Dali::RenderTaskList::CreateTask()
72    */
73   Dali::RenderTask CreateTask();
74
75   /**
76    * @brief Creates a new RenderTask.
77    *
78    * This will be appended to the list of render-tasks.
79    *
80    * @param[in] sourceActor The actor and its children to be rendered for this render task.
81    * @param[in] cameraActor The actor from which the scene is viewed for this render task.
82    * @return A valid handle to a new RenderTask
83    */
84   Dali::RenderTask CreateTask( Actor* sourceActor, CameraActor* cameraActor);
85
86   /**
87    * @copydoc Dali::RenderTaskList::RemoveTask()
88    */
89   void RemoveTask( Dali::RenderTask task );
90
91   /**
92    * @copydoc Dali::RenderTaskList::GetTaskCount()
93    */
94   uint32_t GetTaskCount() const;
95
96   /**
97    * @copydoc Dali::RenderTaskList::GetTask()
98    */
99   Dali::RenderTask GetTask( uint32_t index ) const;
100
101   /**
102    * Retrieve the container of render-tasks.
103    * @return The container.
104    */
105   RenderTaskContainer& GetTasks()
106   {
107     return mTasks;
108   }
109
110   /**
111    * @brief Mark a rendertask as having exclusive access to its source actor.
112    *
113    * @param[in] task Pointer to the rendertask.
114    * @param[in] exclusive If a rendertask is to have exclusive acesss to its source actor.
115    */
116   void SetExclusive( RenderTask* task, bool exclusive );
117
118   /**
119    * @brief Return the list of rendertasks that exclusively own their source actor.
120    *
121    * @return [description]
122    */
123   const Vector< Exclusive >& GetExclusivesList() const
124   {
125     return mExclusives;
126   }
127
128   /**
129    * Provide notification signals for a "Finished" render task.
130    * This method should be called in the event-thread
131    * Queue NotifyFinishedMessage() from update-thread
132    * @param object pointer to this class instance
133    */
134   static void NotifyFinished( void* object );
135
136   /**
137    * This method refreshes all render tasks that have a frame buffer
138    * and a refresh rate of RefreshOnce.
139    */
140   void RecoverFromContextLoss();
141
142 protected:
143
144   /**
145    * Construct a new RenderTaskList.
146    */
147   RenderTaskList();
148
149   /**
150    * A reference counted object may only be deleted by calling Unreference()
151    */
152   virtual ~RenderTaskList();
153
154   /**
155    * 2nd-phase construction
156    */
157   void Initialize();
158
159   /**
160    * Helper to create a scene-graph render task list
161    */
162   void CreateSceneObject();
163
164   /**
165    * Helper to destroy a scene-graph render task list
166    */
167   void DestroySceneObject();
168
169 private: // from CompleteNotificationInterface
170
171   /**
172    * @copydoc CompleteNotificationInterface::NotifyCompleted()
173    */
174   virtual void NotifyCompleted();
175
176 private:
177
178   EventThreadServices& mEventThreadServices;
179   RenderTaskDefaults& mDefaults;
180
181   SceneGraph::RenderTaskList* mSceneObject; ///< Raw-pointer to the scene-graph object; not owned.
182
183   RenderTaskContainer mTasks;           ///< Reference counted render-tasks
184   Vector< Exclusive > mExclusives;      ///< List of rendertasks with exclusively owned source actors.
185 };
186
187 } // namespace Internal
188
189 // Helpers for public-api forwarding methods
190
191 inline Internal::RenderTaskList& GetImplementation(Dali::RenderTaskList& taskList)
192 {
193   DALI_ASSERT_ALWAYS(taskList && "RenderTaskList handle is empty");
194
195   BaseObject& handle = taskList.GetBaseObject();
196
197   return static_cast<Internal::RenderTaskList&>(handle);
198 }
199
200 inline const Internal::RenderTaskList& GetImplementation(const Dali::RenderTaskList& taskList)
201 {
202   DALI_ASSERT_ALWAYS(taskList && "RenderTaskList handle is empty");
203
204   const BaseObject& handle = taskList.GetBaseObject();
205
206   return static_cast<const Internal::RenderTaskList&>(handle);
207 }
208
209 } // namespace Dali
210
211 #endif //__DALI_INTERNAL_RENDER_TASK_LIST_H__