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