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