1 #ifndef DALI_INTERNAL_RENDER_TASK_LIST_H
2 #define DALI_INTERNAL_RENDER_TASK_LIST_H
5 * Copyright (c) 2021 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/public-api/common/vector-wrapper.h>
23 #include <dali/public-api/object/base-object.h>
24 #include <dali/public-api/render-tasks/render-task-list.h>
26 #include <dali/internal/event/common/complete-notification-interface.h>
27 #include <dali/internal/event/events/actor-observer.h>
28 #include <dali/internal/event/render-tasks/render-task-impl.h>
34 class EventThreadServices;
35 class RenderTaskDefaults;
39 using RenderTaskPtr = IntrusivePtr<RenderTask>;
41 using RenderTaskListPtr = IntrusivePtr<RenderTaskList>;
47 } // namespace SceneGraph
50 * A proxy for the scene-graph RenderTaskList.
51 * A separate LayerList is maintained for actors added via the SystemLevel::Add().
53 class RenderTaskList : public BaseObject, public CompleteNotificationInterface
56 using RenderTaskContainer = std::vector<RenderTaskPtr>;
60 RenderTask* renderTaskPtr; ///< Pointer for comparison with current rendertask.
61 ActorObserver actor; ///< For comparison with current actor.
63 bool operator==(const Exclusive& other) const
65 return renderTaskPtr == other.renderTaskPtr;
69 using ExclusivesContainer = std::vector<Exclusive>;
70 using ExclusiveIter = ExclusivesContainer::iterator;
73 * Create a RenderTaskList.
74 * @return A newly allocated RenderTaskList; the caller takes ownership.
76 static RenderTaskListPtr New();
79 * @copydoc Dali::RenderTaskList::CreateTask()
81 RenderTaskPtr CreateTask();
84 * @brief Creates a new RenderTask.
86 * This will be appended to the list of render-tasks.
88 * @param[in] sourceActor The actor and its children to be rendered for this render task.
89 * @param[in] cameraActor The actor from which the scene is viewed for this render task.
90 * @return A valid handle to a new RenderTask
92 RenderTaskPtr CreateTask(Actor* sourceActor, CameraActor* cameraActor);
95 * @brief Creates a new RenderTask for overlay.
96 * This will be appended to the end of render-task list.
97 * @param[in] sourceActor The actor and its children to be rendered for this render task.
98 * @param[in] cameraActor The actor from which the scene is viewed for this render task.
99 * @return A valid handle to a new overlay RenderTask
100 * @note The Overlay RenderTask will be rendered after all the other render tasks are rendered.
102 RenderTaskPtr CreateOverlayTask(Actor* sourceActor, CameraActor* cameraActor);
105 * @copydoc Dali::RenderTaskList::RemoveTask()
107 void RemoveTask(Internal::RenderTask& task);
110 * @copydoc Dali::RenderTaskList::GetTaskCount()
112 uint32_t GetTaskCount() const;
115 * @copydoc Dali::RenderTaskList::GetTask()
117 RenderTaskPtr GetTask(uint32_t index) const;
120 * @copydoc Dali::RenderTaskList::GetOverlayTask()
122 RenderTaskPtr GetOverlayTask() const;
125 * Retrieve the container of render-tasks.
126 * @return The container.
128 RenderTaskContainer& GetTasks()
134 * @brief Mark a rendertask as having exclusive access to its source actor.
136 * @param[in] task Pointer to the rendertask.
137 * @param[in] exclusive If a rendertask is to have exclusive acesss to its source actor.
139 void SetExclusive(RenderTask* task, bool exclusive);
142 * @brief Return the list of rendertasks that exclusively own their source actor.
144 * @return [description]
146 const ExclusivesContainer& GetExclusivesList() const
152 * Provide notification signals for a "Finished" render task.
153 * This method should be called in the event-thread
154 * Queue NotifyFinishedMessage() from update-thread
155 * @param object pointer to this class instance
157 static void NotifyFinished(void* object);
160 * This method refreshes all render tasks that have a frame buffer
161 * and a refresh rate of RefreshOnce.
163 void RecoverFromContextLoss();
166 * Retrieve the SceneGraph::RenderTaskList object.
167 * @return The RenderTaskList.
169 const SceneGraph::RenderTaskList& GetSceneObject() const;
173 * Construct a new RenderTaskList.
178 * A reference counted object may only be deleted by calling Unreference()
180 ~RenderTaskList() override;
183 * 2nd-phase construction
187 private: // from CompleteNotificationInterface
189 * @copydoc CompleteNotificationInterface::NotifyCompleted()
191 void NotifyCompleted() override;
194 EventThreadServices& mEventThreadServices;
195 RenderTaskDefaults& mDefaults;
197 SceneGraph::RenderTaskList* mSceneObject; ///< Raw-pointer to the scene-graph object; not owned.
199 RenderTaskContainer mTasks; ///< Reference counted render-tasks
200 ExclusivesContainer mExclusives; ///< List of rendertasks with exclusively owned source actors.
201 RenderTaskPtr mOverlayRenderTask{nullptr};
204 } // namespace Internal
206 // Helpers for public-api forwarding methods
208 inline Internal::RenderTaskList& GetImplementation(Dali::RenderTaskList& taskList)
210 DALI_ASSERT_ALWAYS(taskList && "RenderTaskList handle is empty");
212 BaseObject& handle = taskList.GetBaseObject();
214 return static_cast<Internal::RenderTaskList&>(handle);
217 inline const Internal::RenderTaskList& GetImplementation(const Dali::RenderTaskList& taskList)
219 DALI_ASSERT_ALWAYS(taskList && "RenderTaskList handle is empty");
221 const BaseObject& handle = taskList.GetBaseObject();
223 return static_cast<const Internal::RenderTaskList&>(handle);
228 #endif // DALI_INTERNAL_RENDER_TASK_LIST_H