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