Use modern construct 'using' instead of typedef.
[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) 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/devel-api/common/owner-container.h>
23 #include <dali/internal/common/message.h>
24 #include <dali/internal/event/common/event-thread-services.h>
25 #include <dali/internal/update/render-tasks/scene-graph-render-task.h>
26
27 namespace Dali
28 {
29
30 namespace Internal
31 {
32
33 class CompleteNotificationInterface;
34
35 namespace SceneGraph
36 {
37 class RenderMessageDispatcher;
38 class RenderTask;
39
40 /**
41  * An ordered list of render-tasks.
42  */
43 class RenderTaskList
44 {
45 public:
46   using RenderTaskContainer = OwnerContainer<RenderTask*>;
47
48   /**
49    * Construct a new RenderTaskList.
50    * @return A new RenderTaskList
51    */
52   static RenderTaskList* New();
53
54   /**
55    * Destructor
56    */
57   ~RenderTaskList();
58
59   /**
60    * Overriden delete operator
61    * Deletes the RenderTaskList from its global memory pool
62    */
63   void operator delete( void* ptr );
64
65   /**
66    * Set the renderMessageDispatcher to send message.
67    * @param[in] renderMessageDispatcher The renderMessageDispatcher to send messages.
68    */
69   void SetRenderMessageDispatcher( RenderMessageDispatcher* renderMessageDispatcher );
70
71   /**
72    * Add a new RenderTask to the list.
73    * @param[in] newTask The RenderTaskList takes ownership of this task.
74    */
75   void AddTask( OwnerPointer< RenderTask >& newTask );
76
77   /**
78    * Remove a RenderTask from the list.
79    * @param[in] task The RenderTaskList will destroy this task.
80    */
81   void RemoveTask( RenderTask* task );
82
83   /**
84    * Retrieve the count of RenderTasks.
85    * @return The count.
86    */
87   uint32_t GetTaskCount();
88
89   /**
90    * Retrieve the container of RenderTasks.
91    * @return The container.
92    */
93   RenderTaskContainer& GetTasks();
94
95   /**
96    * Retrieve the container of RenderTasks.
97    * @return The container.
98    */
99   const RenderTaskContainer& GetTasks() const;
100
101   /**
102    * Set the notification method to package in the NotifyFinishedMessage
103    * @param object to store in notification managers queue
104    */
105   void SetCompleteNotificationInterface( CompleteNotificationInterface* object );
106
107   /**
108    * Get the Notification interface for when 1+ render tasks have finished
109    */
110   CompleteNotificationInterface* GetCompleteNotificationInterface();
111
112 protected:
113
114   /**
115    * Protected constructor. See New()
116    */
117   RenderTaskList();
118
119 private:
120
121   // Undefined
122   RenderTaskList(const RenderTaskList&);
123
124   // Undefined
125   RenderTaskList& operator=(const RenderTaskList&);
126
127 private:
128
129   CompleteNotificationInterface* mNotificationObject; ///< object to pass in to the complete notification
130   RenderMessageDispatcher* mRenderMessageDispatcher; ///< for sending messages to render thread
131   RenderTaskContainer mRenderTasks; ///< A container of owned RenderTasks
132
133 };
134
135 // Messages for RenderTaskList
136
137 inline void AddTaskMessage( EventThreadServices& eventThreadServices, const RenderTaskList& list, OwnerPointer< RenderTask >& task )
138 {
139   // Message has ownership of the RenderTask while in transit from event -> update
140   using LocalType = MessageValue1<RenderTaskList, OwnerPointer<RenderTask> >;
141
142   // Reserve some memory inside the message queue
143   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
144
145   // Construct message in the message queue memory; note that delete should not be called on the return value
146   new (slot) LocalType( &list, &RenderTaskList::AddTask, task );
147 }
148
149 inline void RemoveTaskMessage( EventThreadServices& eventThreadServices, const RenderTaskList& list, const RenderTask& constTask )
150 {
151   // Scene graph thread can destroy this object.
152   RenderTask& task = const_cast< RenderTask& >( constTask );
153
154   using LocalType = MessageValue1<RenderTaskList, RenderTask*>;
155
156   // Reserve some memory inside the message queue
157   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
158
159   // Construct message in the message queue memory; note that delete should not be called on the return value
160   new (slot) LocalType( &list, &RenderTaskList::RemoveTask, &task );
161 }
162
163 } // namespace SceneGraph
164
165 } // namespace Internal
166
167 } // namespace Dali
168
169 #endif // DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_LIST_H