License conversion from Flora to Apache 2.0
[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/common/message.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
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    */
96   void NotifyFinished();
97
98 protected:
99
100   /**
101    * Construct a new RenderTaskList.
102    * @param[in] eventToUpdate Used for creating render-tasks in the scene graph.
103    * @param[in] defaults Provides the default source & camera actors.
104    * @param[in] systemLevel True if this is the system-level list.
105    */
106   RenderTaskList( EventToUpdate& eventToUpdate, RenderTaskDefaults& defaults, bool systemLevel );
107
108   /**
109    * A reference counted object may only be deleted by calling Unreference()
110    */
111   virtual ~RenderTaskList();
112
113   /**
114    * 2nd-phase construction
115    */
116   void Initialize( SceneGraph::UpdateManager& updateManager );
117
118 private:
119
120   EventToUpdate& mEventToUpdate;
121   RenderTaskDefaults& mDefaults;
122
123   bool mIsSystemLevel; ///< True if the layers are added via the SystemLevel API
124
125   SceneGraph::RenderTaskList* mSceneObject; ///< Raw-pointer to the scene-graph object; not owned.
126
127   RenderTaskContainer mTasks; ///< Reference counted render-tasks
128 };
129
130 /**
131  * Notification message for when 1+ render tasks have finished
132  * @param[in] renderTaskList This will provide the notification signals.
133  */
134 inline MessageBase* NotifyFinishedMessage( RenderTaskList& renderTaskList )
135 {
136   return new Message< RenderTaskList >( &renderTaskList, &RenderTaskList::NotifyFinished );
137 }
138
139 } // namespace Internal
140
141 // Helpers for public-api forwarding methods
142
143 inline Internal::RenderTaskList& GetImplementation(Dali::RenderTaskList& taskList)
144 {
145   DALI_ASSERT_ALWAYS(taskList && "RenderTaskList handle is empty");
146
147   BaseObject& handle = taskList.GetBaseObject();
148
149   return static_cast<Internal::RenderTaskList&>(handle);
150 }
151
152 inline const Internal::RenderTaskList& GetImplementation(const Dali::RenderTaskList& taskList)
153 {
154   DALI_ASSERT_ALWAYS(taskList && "RenderTaskList handle is empty");
155
156   const BaseObject& handle = taskList.GetBaseObject();
157
158   return static_cast<const Internal::RenderTaskList&>(handle);
159 }
160
161 } // namespace Dali
162
163 #endif //__DALI_INTERNAL_RENDER_TASK_LIST_H__