1 #ifndef DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_LIST_H
2 #define DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_LIST_H
5 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
31 class CompleteNotificationInterface;
35 class RenderMessageDispatcher;
39 * An ordered list of render-tasks.
44 using RenderTaskContainer = OwnerContainer<RenderTask*>;
47 * Construct a new RenderTaskList.
48 * @return A new RenderTaskList
50 static RenderTaskList* New();
58 * Overriden delete operator
59 * Deletes the RenderTaskList from its global memory pool
61 void operator delete(void* ptr);
64 * Set the renderMessageDispatcher to send message.
65 * @param[in] renderMessageDispatcher The renderMessageDispatcher to send messages.
67 void SetRenderMessageDispatcher(RenderMessageDispatcher* renderMessageDispatcher);
70 * Add a new RenderTask to the list.
71 * @param[in] newTask The RenderTaskList takes ownership of this task.
73 void AddTask(OwnerPointer<RenderTask>& newTask);
76 * Remove a RenderTask from the list.
77 * @param[in] task The RenderTaskList will destroy this task.
79 void RemoveTask(RenderTask* task);
82 * Retrieve the count of RenderTasks.
85 uint32_t GetTaskCount();
88 * Retrieve the container of RenderTasks.
89 * @return The container.
91 RenderTaskContainer& GetTasks();
94 * Retrieve the container of RenderTasks.
95 * @return The container.
97 const RenderTaskContainer& GetTasks() const;
100 * Set the notification method to package in the NotifyFinishedMessage
101 * @param object to store in notification managers queue
103 void SetCompleteNotificationInterface(CompleteNotificationInterface* object);
106 * Get the Notification interface for when 1+ render tasks have finished
108 CompleteNotificationInterface* GetCompleteNotificationInterface();
111 * Get the capacity of the memory pools
113 static uint32_t GetMemoryPoolCapacity();
117 * Protected constructor. See New()
123 RenderTaskList(const RenderTaskList&);
126 RenderTaskList& operator=(const RenderTaskList&);
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
134 // Messages for RenderTaskList
136 inline void AddTaskMessage(EventThreadServices& eventThreadServices, const RenderTaskList& list, OwnerPointer<RenderTask>& task)
138 // Message has ownership of the RenderTask while in transit from event -> update
139 using LocalType = MessageValue1<RenderTaskList, OwnerPointer<RenderTask> >;
141 // Reserve some memory inside the message queue
142 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
144 // Construct message in the message queue memory; note that delete should not be called on the return value
145 new(slot) LocalType(&list, &RenderTaskList::AddTask, task);
148 inline void RemoveTaskMessage(EventThreadServices& eventThreadServices, const RenderTaskList& list, const RenderTask& constTask)
150 // Scene graph thread can destroy this object.
151 RenderTask& task = const_cast<RenderTask&>(constTask);
153 using LocalType = MessageValue1<RenderTaskList, RenderTask*>;
155 // Reserve some memory inside the message queue
156 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
158 // Construct message in the message queue memory; note that delete should not be called on the return value
159 new(slot) LocalType(&list, &RenderTaskList::RemoveTask, &task);
162 } // namespace SceneGraph
164 } // namespace Internal
168 #endif // DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_LIST_H