Merge "Updated test harness code to enable styling through links." into tizen
[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   /**
100    * This method refreshes all render tasks that have a frame buffer
101    * and a refresh rate of RefreshOnce.
102    */
103   void RecoverFromContextLoss();
104
105 protected:
106
107   /**
108    * Construct a new RenderTaskList.
109    * @param[in] eventToUpdate Used for creating render-tasks in the scene graph.
110    * @param[in] defaults Provides the default source & camera actors.
111    * @param[in] systemLevel True if this is the system-level list.
112    */
113   RenderTaskList( EventToUpdate& eventToUpdate, RenderTaskDefaults& defaults, bool systemLevel );
114
115   /**
116    * A reference counted object may only be deleted by calling Unreference()
117    */
118   virtual ~RenderTaskList();
119
120   /**
121    * 2nd-phase construction
122    */
123   void Initialize( SceneGraph::UpdateManager& updateManager );
124
125 private: // from CompleteNotificationInterface
126
127   /**
128    * @copydoc CompleteNotificationInterface::NotifyCompleted()
129    */
130   virtual void NotifyCompleted();
131
132 private:
133
134   EventToUpdate& mEventToUpdate;
135   RenderTaskDefaults& mDefaults;
136
137   bool mIsSystemLevel; ///< True if the layers are added via the SystemLevel API
138
139   SceneGraph::RenderTaskList* mSceneObject; ///< Raw-pointer to the scene-graph object; not owned.
140
141   RenderTaskContainer mTasks; ///< Reference counted render-tasks
142 };
143
144 } // namespace Internal
145
146 // Helpers for public-api forwarding methods
147
148 inline Internal::RenderTaskList& GetImplementation(Dali::RenderTaskList& taskList)
149 {
150   DALI_ASSERT_ALWAYS(taskList && "RenderTaskList handle is empty");
151
152   BaseObject& handle = taskList.GetBaseObject();
153
154   return static_cast<Internal::RenderTaskList&>(handle);
155 }
156
157 inline const Internal::RenderTaskList& GetImplementation(const Dali::RenderTaskList& taskList)
158 {
159   DALI_ASSERT_ALWAYS(taskList && "RenderTaskList handle is empty");
160
161   const BaseObject& handle = taskList.GetBaseObject();
162
163   return static_cast<const Internal::RenderTaskList&>(handle);
164 }
165
166 } // namespace Dali
167
168 #endif //__DALI_INTERNAL_RENDER_TASK_LIST_H__