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