57b218788e5d8dfe54b35e6f7bbf8a5ef9c777a8
[platform/core/uifw/dali-core.git] / dali / internal / update / render-tasks / scene-graph-render-task-list.h
1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_LIST_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_LIST_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 // INTERNAL INCLUDES
21 #include <dali/internal/common/event-to-update.h>
22 #include <dali/internal/common/message.h>
23 #include <dali/internal/common/owner-container.h>
24
25 namespace Dali
26 {
27
28 namespace Internal
29 {
30 class CompleteStatusManager;
31
32 namespace SceneGraph
33 {
34
35 class RenderTask;
36
37 /**
38  * An ordered list of render-tasks.
39  */
40 class RenderTaskList
41 {
42 public:
43
44   typedef OwnerContainer< RenderTask* > RenderTaskContainer;
45
46   /**
47    * Constructor
48    */
49   RenderTaskList( CompleteStatusManager& completeStatusManager );
50
51   /**
52    * Destructor
53    */
54   ~RenderTaskList();
55
56   /**
57    * Add a new RenderTask to the list.
58    * @param[in] newTask The RenderTaskList takes ownership of this task.
59    */
60   void AddTask( RenderTask* newTask );
61
62   /**
63    * Remove a RenderTask from the list.
64    * @param[in] task The RenderTaskList will destroy this task.
65    */
66   void RemoveTask( RenderTask* task );
67
68   /**
69    * Retrieve the container of RenderTasks.
70    * @return The container.
71    */
72   RenderTaskContainer& GetTasks();
73
74   /**
75    * Retrieve the container of RenderTasks.
76    * @return The container.
77    */
78   const RenderTaskContainer& GetTasks() const;
79
80 private:
81
82   // Undefined
83   RenderTaskList(const RenderTaskList&);
84
85   // Undefined
86   RenderTaskList& operator=(const RenderTaskList&);
87
88 private:
89   RenderTaskContainer mRenderTasks; ///< A container of owned RenderTasks
90   CompleteStatusManager& mCompleteStatusManager; ///< The complete status tracker (render tasks need this)
91 };
92
93 // Messages for RenderTaskList
94
95 inline void AddTaskMessage( EventToUpdate& eventToUpdate, RenderTaskList& list, RenderTask& task )
96 {
97   typedef MessageValue1< RenderTaskList, RenderTask* > LocalType;
98
99   // Reserve some memory inside the message queue
100   unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
101
102   // Construct message in the message queue memory; note that delete should not be called on the return value
103   new (slot) LocalType( &list, &RenderTaskList::AddTask, &task );
104 }
105
106 inline void RemoveTaskMessage( EventToUpdate& eventToUpdate, RenderTaskList& list, const RenderTask& constTask )
107 {
108   // Scene graph thread can destroy this object.
109   RenderTask& task = const_cast< RenderTask& >( constTask );
110
111   typedef MessageValue1< RenderTaskList, RenderTask* > LocalType;
112
113   // Reserve some memory inside the message queue
114   unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
115
116   // Construct message in the message queue memory; note that delete should not be called on the return value
117   new (slot) LocalType( &list, &RenderTaskList::RemoveTask, &task );
118 }
119
120 } // namespace SceneGraph
121
122 } // namespace Internal
123
124 } // namespace Dali
125
126 #endif // __DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_LIST_H__