1 #ifndef DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_LIST_H
2 #define DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_LIST_H
5 * Copyright (c) 2019 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>
33 class CompleteNotificationInterface;
37 class RenderMessageDispatcher;
41 * An ordered list of render-tasks.
46 using RenderTaskContainer = OwnerContainer<RenderTask*>;
49 * Construct a new RenderTaskList.
50 * @return A new RenderTaskList
52 static RenderTaskList* New();
60 * Overriden delete operator
61 * Deletes the RenderTaskList from its global memory pool
63 void operator delete( void* ptr );
66 * Set the renderMessageDispatcher to send message.
67 * @param[in] renderMessageDispatcher The renderMessageDispatcher to send messages.
69 void SetRenderMessageDispatcher( RenderMessageDispatcher* renderMessageDispatcher );
72 * Add a new RenderTask to the list.
73 * @param[in] newTask The RenderTaskList takes ownership of this task.
75 void AddTask( OwnerPointer< RenderTask >& newTask );
78 * Remove a RenderTask from the list.
79 * @param[in] task The RenderTaskList will destroy this task.
81 void RemoveTask( RenderTask* task );
84 * Retrieve the count of RenderTasks.
87 uint32_t GetTaskCount();
90 * Retrieve the container of RenderTasks.
91 * @return The container.
93 RenderTaskContainer& GetTasks();
96 * Retrieve the container of RenderTasks.
97 * @return The container.
99 const RenderTaskContainer& GetTasks() const;
102 * Set the notification method to package in the NotifyFinishedMessage
103 * @param object to store in notification managers queue
105 void SetCompleteNotificationInterface( CompleteNotificationInterface* object );
108 * Get the Notification interface for when 1+ render tasks have finished
110 CompleteNotificationInterface* GetCompleteNotificationInterface();
115 * Protected constructor. See New()
122 RenderTaskList(const RenderTaskList&);
125 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
135 // Messages for RenderTaskList
137 inline void AddTaskMessage( EventThreadServices& eventThreadServices, const RenderTaskList& list, OwnerPointer< RenderTask >& task )
139 // Message has ownership of the RenderTask while in transit from event -> update
140 using LocalType = MessageValue1<RenderTaskList, OwnerPointer<RenderTask> >;
142 // Reserve some memory inside the message queue
143 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
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 );
149 inline void RemoveTaskMessage( EventThreadServices& eventThreadServices, const RenderTaskList& list, const RenderTask& constTask )
151 // Scene graph thread can destroy this object.
152 RenderTask& task = const_cast< RenderTask& >( constTask );
154 using LocalType = MessageValue1<RenderTaskList, RenderTask*>;
156 // Reserve some memory inside the message queue
157 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
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 );
163 } // namespace SceneGraph
165 } // namespace Internal
169 #endif // DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_LIST_H