If a RenderTask's exclusive actor is destoryed, then ensure the RenderTaskList of...
[platform/core/uifw/dali-core.git] / dali / internal / event / render-tasks / render-task-list-impl.h
index a515893..068a42f 100644 (file)
@@ -1,28 +1,30 @@
-#ifndef __DALI_INTERNAL_RENDER_TASK_LIST_H__
-#define __DALI_INTERNAL_RENDER_TASK_LIST_H__
-
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+#ifndef DALI_INTERNAL_RENDER_TASK_LIST_H
+#define DALI_INTERNAL_RENDER_TASK_LIST_H
+
+/*
+ * Copyright (c) 2019 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
 
 // INTERNAL INCLUDES
 #include <dali/public-api/common/vector-wrapper.h>
 #include <dali/public-api/object/base-object.h>
-#include <dali/public-api/render-tasks/render-task.h>
 #include <dali/public-api/render-tasks/render-task-list.h>
-#include <dali/internal/common/message.h>
+#include <dali/internal/event/common/complete-notification-interface.h>
+#include <dali/internal/event/render-tasks/render-task-impl.h>
+#include <dali/internal/event/events/actor-observer.h>
 
 namespace Dali
 {
@@ -30,8 +32,14 @@ namespace Dali
 namespace Internal
 {
 
-class EventToUpdate;
+class EventThreadServices;
 class RenderTaskDefaults;
+class Actor;
+class CameraActor;
+
+using RenderTaskPtr = IntrusivePtr<RenderTask>;
+class RenderTaskList;
+using RenderTaskListPtr = IntrusivePtr<RenderTaskList>;
 
 namespace SceneGraph
 {
@@ -43,40 +51,56 @@ class UpdateManager;
  * A proxy for the scene-graph RenderTaskList.
  * A separate LayerList is maintained for actors added via the SystemLevel::Add().
  */
-class RenderTaskList : public BaseObject
+class RenderTaskList : public BaseObject, public CompleteNotificationInterface
 {
 public:
 
-  typedef std::vector< Dali::RenderTask > RenderTaskContainer;
+  using RenderTaskContainer = std::vector< RenderTaskPtr >;
+
+  struct Exclusive
+  {
+    RenderTask* renderTaskPtr;        ///< Pointer for comparison with current rendertask.
+    ActorObserver actor;              ///< For comparison with current actor.
+  };
+
+  using ExclusivesContainer = std::vector< Exclusive >;
 
   /**
    * Create a RenderTaskList.
-   * @param[in] updateManager Used for creating render-tasks in the scene graph.
-   * @param[in] defaults Provides the default source & camera actors.
-   * @param[in] systemLevel True if this is the LayerList for actors added via the SystemLevel::Add().
    * @return A newly allocated RenderTaskList; the caller takes ownership.
    */
-  static RenderTaskList* New( SceneGraph::UpdateManager& updateManager, RenderTaskDefaults& defaults, bool systemLevel );
+  static RenderTaskListPtr New();
 
   /**
    * @copydoc Dali::RenderTaskList::CreateTask()
    */
-  Dali::RenderTask CreateTask();
+  RenderTaskPtr CreateTask();
+
+  /**
+   * @brief Creates a new RenderTask.
+   *
+   * This will be appended to the list of render-tasks.
+   *
+   * @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 RenderTask
+   */
+  RenderTaskPtr CreateTask( Actor* sourceActor, CameraActor* cameraActor);
 
   /**
    * @copydoc Dali::RenderTaskList::RemoveTask()
    */
-  void RemoveTask( Dali::RenderTask task );
+  void RemoveTask( Internal::RenderTask& task );
 
   /**
    * @copydoc Dali::RenderTaskList::GetTaskCount()
    */
-  unsigned int GetTaskCount() const;
+  uint32_t GetTaskCount() const;
 
   /**
    * @copydoc Dali::RenderTaskList::GetTask()
    */
-  Dali::RenderTask GetTask( unsigned int index ) const;
+  RenderTaskPtr GetTask( uint32_t index ) const;
 
   /**
    * Retrieve the container of render-tasks.
@@ -88,21 +112,49 @@ public:
   }
 
   /**
+   * @brief Mark a rendertask as having exclusive access to its source actor.
+   *
+   * @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 );
+
+  /**
+   * @brief Return the list of rendertasks that exclusively own their source actor.
+   *
+   * @return [description]
+   */
+  const ExclusivesContainer& GetExclusivesList() const
+  {
+    return mExclusives;
+  }
+
+  /**
    * Provide notification signals for a "Finished" render task.
    * This method should be called in the event-thread
    * Queue NotifyFinishedMessage() from update-thread
+   * @param object pointer to this class instance
    */
-  void NotifyFinished();
+  static void NotifyFinished( void* object );
+
+  /**
+   * This method refreshes all render tasks that have a frame buffer
+   * and a refresh rate of RefreshOnce.
+   */
+  void RecoverFromContextLoss();
+
+  /**
+   * Retrieve the SceneGraph::RenderTaskList object.
+   * @return The RenderTaskList.
+   */
+  const SceneGraph::RenderTaskList& GetSceneObject() const;
 
 protected:
 
   /**
    * Construct a new RenderTaskList.
-   * @param[in] eventToUpdate Used for creating render-tasks in the scene graph.
-   * @param[in] defaults Provides the default source & camera actors.
-   * @param[in] systemLevel True if this is the system-level list.
    */
-  RenderTaskList( EventToUpdate& eventToUpdate, RenderTaskDefaults& defaults, bool systemLevel );
+  RenderTaskList();
 
   /**
    * A reference counted object may only be deleted by calling Unreference()
@@ -112,29 +164,26 @@ protected:
   /**
    * 2nd-phase construction
    */
-  void Initialize( SceneGraph::UpdateManager& updateManager );
+  void Initialize();
+
+private: // from CompleteNotificationInterface
+
+  /**
+   * @copydoc CompleteNotificationInterface::NotifyCompleted()
+   */
+  virtual void NotifyCompleted();
 
 private:
 
-  EventToUpdate& mEventToUpdate;
+  EventThreadServices& mEventThreadServices;
   RenderTaskDefaults& mDefaults;
 
-  bool mIsSystemLevel; ///< True if the layers are added via the SystemLevel API
-
   SceneGraph::RenderTaskList* mSceneObject; ///< Raw-pointer to the scene-graph object; not owned.
 
-  RenderTaskContainer mTasks; ///< Reference counted render-tasks
+  RenderTaskContainer mTasks;           ///< Reference counted render-tasks
+  ExclusivesContainer mExclusives;      ///< List of rendertasks with exclusively owned source actors.
 };
 
-/**
- * Notification message for when 1+ render tasks have finished
- * @param[in] renderTaskList This will provide the notification signals.
- */
-inline MessageBase* NotifyFinishedMessage( RenderTaskList& renderTaskList )
-{
-  return new Message< RenderTaskList >( &renderTaskList, &RenderTaskList::NotifyFinished );
-}
-
 } // namespace Internal
 
 // Helpers for public-api forwarding methods
@@ -159,4 +208,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