Add Overlay Layer in scene
[platform/core/uifw/dali-core.git] / dali / internal / event / render-tasks / render-task-list-impl.h
index 55e37e8..c01b981 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_INTERNAL_RENDER_TASK_LIST_H__
-#define __DALI_INTERNAL_RENDER_TASK_LIST_H__
+#ifndef DALI_INTERNAL_RENDER_TASK_LIST_H
+#define DALI_INTERNAL_RENDER_TASK_LIST_H
 
 /*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 #include <dali/public-api/common/vector-wrapper.h>
 #include <dali/public-api/object/base-object.h>
 #include <dali/public-api/render-tasks/render-task-list.h>
+
 #include <dali/internal/event/common/complete-notification-interface.h>
+#include <dali/internal/event/events/actor-observer.h>
 #include <dali/internal/event/render-tasks/render-task-impl.h>
 
 namespace Dali
 {
-
 namespace Internal
 {
-
 class EventThreadServices;
 class RenderTaskDefaults;
 class Actor;
 class CameraActor;
 
+using RenderTaskPtr = IntrusivePtr<RenderTask>;
 class RenderTaskList;
 using RenderTaskListPtr = IntrusivePtr<RenderTaskList>;
 
@@ -43,7 +44,7 @@ namespace SceneGraph
 {
 class RenderTaskList;
 class UpdateManager;
-}
+} // namespace SceneGraph
 
 /**
  * A proxy for the scene-graph RenderTaskList.
@@ -52,15 +53,22 @@ class UpdateManager;
 class RenderTaskList : public BaseObject, public CompleteNotificationInterface
 {
 public:
-
-  using RenderTaskContainer = std::vector< RenderTaskPtr >;
+  using RenderTaskContainer = std::vector<RenderTaskPtr>;
 
   struct Exclusive
   {
-    RenderTask* renderTaskPtr;        ///< Pointer for comparison with current rendertask.
-    Actor* actorPtr;                  ///< Pointer for comparison with current actor.
+    RenderTask*   renderTaskPtr; ///< Pointer for comparison with current rendertask.
+    ActorObserver actor;         ///< For comparison with current actor.
+
+    bool operator==(const Exclusive& other) const
+    {
+      return renderTaskPtr == other.renderTaskPtr;
+    }
   };
 
+  using ExclusivesContainer = std::vector<Exclusive>;
+  using ExclusiveIter       = ExclusivesContainer::iterator;
+
   /**
    * Create a RenderTaskList.
    * @return A newly allocated RenderTaskList; the caller takes ownership.
@@ -81,12 +89,22 @@ public:
    * @param[in] cameraActor The actor from which the scene is viewed for this render task.
    * @return A valid handle to a new RenderTask
    */
-  RenderTaskPtr CreateTask( Actor* sourceActor, CameraActor* cameraActor);
+  RenderTaskPtr CreateTask(Actor* sourceActor, CameraActor* cameraActor);
+
+  /**
+   * @brief Creates a new RenderTask for overlay.
+   * This will be appended to the end of render-task list.
+   * @param[in] sourceActor The actor and its children to be rendered for this render task.
+   * @param[in] cameraActor The actor from which the scene is viewed for this render task.
+   * @return A valid handle to a new overlay RenderTask
+   * @note The Overlay RenderTask will be rendered after all the other render tasks are rendered.
+   */
+  RenderTaskPtr CreateOverlayTask(Actor* sourceActor, CameraActor* cameraActor);
 
   /**
    * @copydoc Dali::RenderTaskList::RemoveTask()
    */
-  void RemoveTask( Internal::RenderTask& task );
+  void RemoveTask(Internal::RenderTask& task);
 
   /**
    * @copydoc Dali::RenderTaskList::GetTaskCount()
@@ -96,7 +114,12 @@ public:
   /**
    * @copydoc Dali::RenderTaskList::GetTask()
    */
-  RenderTaskPtr GetTask( uint32_t index ) const;
+  RenderTaskPtr GetTask(uint32_t index) const;
+
+  /**
+   * @copydoc Dali::RenderTaskList::GetOverlayTask()
+   */
+  RenderTaskPtr GetOverlayTask() const;
 
   /**
    * Retrieve the container of render-tasks.
@@ -113,14 +136,14 @@ public:
    * @param[in] task Pointer to the rendertask.
    * @param[in] exclusive If a rendertask is to have exclusive acesss to its source actor.
    */
-  void SetExclusive( RenderTask* task, bool exclusive );
+  void SetExclusive(RenderTask* task, bool exclusive);
 
   /**
    * @brief Return the list of rendertasks that exclusively own their source actor.
    *
    * @return [description]
    */
-  const Vector< Exclusive >& GetExclusivesList() const
+  const ExclusivesContainer& GetExclusivesList() const
   {
     return mExclusives;
   }
@@ -131,7 +154,7 @@ public:
    * Queue NotifyFinishedMessage() from update-thread
    * @param object pointer to this class instance
    */
-  static void NotifyFinished( void* object );
+  static void NotifyFinished(void* object);
 
   /**
    * This method refreshes all render tasks that have a frame buffer
@@ -139,8 +162,13 @@ public:
    */
   void RecoverFromContextLoss();
 
-protected:
+  /**
+   * Retrieve the SceneGraph::RenderTaskList object.
+   * @return The RenderTaskList.
+   */
+  const SceneGraph::RenderTaskList& GetSceneObject() const;
 
+protected:
   /**
    * Construct a new RenderTaskList.
    */
@@ -149,7 +177,7 @@ protected:
   /**
    * A reference counted object may only be deleted by calling Unreference()
    */
-  virtual ~RenderTaskList();
+  ~RenderTaskList() override;
 
   /**
    * 2nd-phase construction
@@ -157,21 +185,20 @@ protected:
   void Initialize();
 
 private: // from CompleteNotificationInterface
-
   /**
    * @copydoc CompleteNotificationInterface::NotifyCompleted()
    */
-  virtual void NotifyCompleted();
+  void NotifyCompleted() override;
 
 private:
-
   EventThreadServices& mEventThreadServices;
-  RenderTaskDefaults& mDefaults;
+  RenderTaskDefaults&  mDefaults;
 
   SceneGraph::RenderTaskList* mSceneObject; ///< Raw-pointer to the scene-graph object; not owned.
 
-  RenderTaskContainer mTasks;           ///< Reference counted render-tasks
-  Vector< Exclusive > mExclusives;      ///< List of rendertasks with exclusively owned source actors.
+  RenderTaskContainer mTasks;      ///< Reference counted render-tasks
+  ExclusivesContainer mExclusives; ///< List of rendertasks with exclusively owned source actors.
+  RenderTaskPtr       mOverlayRenderTask{nullptr};
 };
 
 } // namespace Internal
@@ -198,4 +225,4 @@ inline const Internal::RenderTaskList& GetImplementation(const Dali::RenderTaskL
 
 } // namespace Dali
 
-#endif //__DALI_INTERNAL_RENDER_TASK_LIST_H__
+#endif // DALI_INTERNAL_RENDER_TASK_LIST_H