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.
47 typedef OwnerContainer< RenderTask* > RenderTaskContainer;
50 * Construct a new RenderTaskList.
51 * @return A new RenderTaskList
53 static RenderTaskList* New();
61 * Overriden delete operator
62 * Deletes the RenderTaskList from its global memory pool
64 void operator delete( void* ptr );
67 * Set the renderMessageDispatcher to send message.
68 * @param[in] renderMessageDispatcher The renderMessageDispatcher to send messages.
70 void SetRenderMessageDispatcher( RenderMessageDispatcher* renderMessageDispatcher );
73 * Add a new RenderTask to the list.
74 * @param[in] newTask The RenderTaskList takes ownership of this task.
76 void AddTask( OwnerPointer< RenderTask >& newTask );
79 * Remove a RenderTask from the list.
80 * @param[in] task The RenderTaskList will destroy this task.
82 void RemoveTask( RenderTask* task );
85 * Retrieve the count of RenderTasks.
88 uint32_t GetTaskCount();
91 * Retrieve the container of RenderTasks.
92 * @return The container.
94 RenderTaskContainer& GetTasks();
97 * Retrieve the container of RenderTasks.
98 * @return The container.
100 const RenderTaskContainer& GetTasks() const;
103 * Set the notification method to package in the NotifyFinishedMessage
104 * @param object to store in notification managers queue
106 void SetCompleteNotificationInterface( CompleteNotificationInterface* object );
109 * Get the Notification interface for when 1+ render tasks have finished
111 CompleteNotificationInterface* GetCompleteNotificationInterface();
116 * Protected constructor. See New()
123 RenderTaskList(const RenderTaskList&);
126 RenderTaskList& operator=(const RenderTaskList&);
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
136 // Messages for RenderTaskList
138 inline void AddTaskMessage( EventThreadServices& eventThreadServices, const RenderTaskList& list, OwnerPointer< RenderTask >& task )
140 // Message has ownership of the RenderTask while in transit from event -> update
141 typedef MessageValue1< RenderTaskList, OwnerPointer< RenderTask > > LocalType;
143 // Reserve some memory inside the message queue
144 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
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 );
150 inline void RemoveTaskMessage( EventThreadServices& eventThreadServices, const RenderTaskList& list, const RenderTask& constTask )
152 // Scene graph thread can destroy this object.
153 RenderTask& task = const_cast< RenderTask& >( constTask );
155 typedef MessageValue1< RenderTaskList, RenderTask* > LocalType;
157 // Reserve some memory inside the message queue
158 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
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 );
164 } // namespace SceneGraph
166 } // namespace Internal
170 #endif // DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_LIST_H