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