use modern construct 'override' in the derive class.
[platform/core/uifw/dali-core.git] / dali / internal / event / render-tasks / render-task-impl.h
index ffd0402..235a795 100644 (file)
@@ -1,27 +1,31 @@
-#ifndef __DALI_INTERNAL_RENDER_TASK_H__
-#define __DALI_INTERNAL_RENDER_TASK_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_H
+#define DALI_INTERNAL_RENDER_TASK_H
+
+/*
+ * Copyright (c) 2020 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/object/base-object.h>
+#include <dali/public-api/object/weak-handle.h>
 #include <dali/public-api/render-tasks/render-task.h>
-#include <dali/public-api/images/frame-buffer-image.h>
-#include <dali/internal/event/common/proxy-object.h>
+#include <dali/internal/event/common/object-impl.h>
+#include <dali/internal/event/rendering/frame-buffer-impl.h>
+#include <dali/internal/event/render-tasks/render-task-list-impl.h>
+#include <dali/internal/event/events/actor-observer.h>
 
 namespace Dali
 {
@@ -31,24 +35,33 @@ namespace Internal
 
 class Actor;
 class CameraActor;
-class EventToUpdate;
+class EventThreadServices;
+class RenderTaskList;
 
 namespace SceneGraph
 {
+class RenderTaskList;
 class RenderTask;
+class Camera;
 }
 
-class RenderTask : public ProxyObject
+using RenderTaskPtr = IntrusivePtr<RenderTask>;
+
+class RenderTask : public Object
 {
 public:
 
-  typedef Dali::RenderTask::ScreenToFrameBufferFunction ScreenToFrameBufferFunction;
+  using ScreenToFrameBufferFunction = Dali::RenderTask::ScreenToFrameBufferFunction;
 
   /**
    * Creates a new RenderTask.
-   * @param[in] isSystemLevel Whether the render-task is on the system level task list.
+   *
+   * @param[in] sourceActor The source actor.
+   * @param[in] cameraActor The camera actor.
+   * @param[in] renderTaskList The render task list.
+   * @return The created render task
    */
-  static RenderTask* New( bool isSystemLevel );
+  static RenderTaskPtr New( Actor* sourceActor, CameraActor* cameraActor, RenderTaskList& renderTaskList );
 
   /**
    * @copydoc Dali::RenderTask::SetSourceActor()
@@ -91,14 +104,14 @@ public:
   CameraActor* GetCameraActor() const;
 
   /**
-   * @copydoc Dali::RenderTask::SetTargetFrameBuffer()
-   */
-  void SetTargetFrameBuffer( Dali::FrameBufferImage frameBuffer );
+    * @copydoc Dali::RenderTask::SetFrameBuffer()
+    */
+   void SetFrameBuffer( FrameBufferPtr frameBuffer );
 
-  /**
-   * @copydoc Dali::RenderTask::GetTargetFrameBuffer
-   */
-  Dali::FrameBufferImage GetTargetFrameBuffer() const;
+   /**
+    * @copydoc Dali::RenderTask::GetFrameBuffer
+    */
+   FrameBuffer* GetFrameBuffer() const;
 
   /**
    * @copydoc Dali::RenderTask::SetScreenToFrameBufferFunction
@@ -113,12 +126,12 @@ public:
   /**
    * copydoc Dali::RenderTask::SetScreenToFrameBufferMappingActor
    */
-  void SetScreenToFrameBufferMappingActor( Actor* mappingActor );
+  void SetScreenToFrameBufferMappingActor( Dali::Actor& mappingActor );
 
   /**
    * copydoc Dali::RenderTask::GetScreenToFrameBufferMAppingActor
    */
-  Actor* GetScreenToFrameBufferMappingActor() const;
+  Dali::Actor GetScreenToFrameBufferMappingActor() const;
 
   /**
    * @copydoc Dali::RenderTask::SetViewportPosition
@@ -161,6 +174,18 @@ public:
   const Vector4& GetClearColor() const;
 
   /**
+   * Indicate whether GL sync is required for native render target.
+   * @param[in] requiresSync whether GL sync is required.
+   */
+  void SetSyncRequired( bool requiresSync );
+
+  /**
+   * Query whether the sync object is required for native render target.
+   * @return True if the sync object is required, false otherwise.
+   */
+ bool IsSyncRequired() const;
+
+  /**
    * @copydoc Dali::RenderTask::SetClearEnabled()
    */
   void SetClearEnabled( bool enabled );
@@ -171,14 +196,24 @@ public:
   bool GetClearEnabled() const;
 
   /**
+   * @copydoc Dali::RenderTask::SetCullMode()
+   */
+  void SetCullMode( bool mode );
+
+  /**
+   * @copydoc Dali::RenderTask::GetCullMode()
+   */
+  bool GetCullMode() const;
+
+  /**
    * @copydoc Dali::RenderTask::SetRefreshRate()
    */
-  void SetRefreshRate( unsigned int refreshRate );
+  void SetRefreshRate( uint32_t refreshRate );
 
   /**
    * @copydoc Dali::RenderTask::GetRefreshRate()
    */
-  unsigned int GetRefreshRate() const;
+  uint32_t GetRefreshRate() const;
 
   /**
    * Check if the render-task is hittable. If render task is offscreen, the screen coordinates may be translated.
@@ -195,102 +230,60 @@ public:
   bool TranslateCoordinates( Vector2& screenCoords ) const;
 
   /**
-   * Query whether the RenderTask is on the system level render-task list.
-   * @return true, if on the system level task list, false otherwise.
-   */
-  bool IsSystemLevel() const;
-
-public: // Used by RenderTaskList, which owns the SceneGraph::RenderTasks
-
-  /**
-   * Create the scene-graph RenderTask object.
-   * @pre CreateSceneObject has not already been called.
-   * @return A newly allocated scene-graph object; the caller takes ownership.
-   */
-  SceneGraph::RenderTask* CreateSceneObject();
-
-  /**
-   * Retrieve the scene-graph RenderTask object.
-   * @return The scene-graph object, or NULL if this has been discarded.
-   */
-  SceneGraph::RenderTask* GetRenderTaskSceneObject();
-
-  /**
-   * Discard the scene-graph RenderTask object.
-   */
-  void DiscardSceneObject();
-
-public: // Implementation of ProxyObject
-
-  /**
-   * @copydoc Dali::Internal::ProxyObject::IsSceneObjectRemovable()
+   * @copydoc Dali::RenderTask::WorldToViewport()
    */
-  virtual bool IsSceneObjectRemovable() const;
+  bool WorldToViewport(const Vector3 &position, float& viewportX, float& viewportY) const;
 
   /**
-   * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyCount()
+   * @copydoc Dali::RenderTask::ViewportToLocal()
    */
-  virtual unsigned int GetDefaultPropertyCount() const;
+  bool ViewportToLocal(Actor* actor, float viewportX, float viewportY, float &localX, float &localY) const;
 
-  /**
-   * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName()
-   */
-  virtual const std::string& GetDefaultPropertyName(Property::Index index) const;
-
-  /**
-   * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex()
-   */
-  virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
-
-  /**
-   * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyWritable()
-   */
-  virtual bool IsDefaultPropertyWritable(Property::Index index) const;
+public: // Used by RenderTaskList, which owns the SceneGraph::RenderTasks
 
   /**
-   * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAnimatable()
+   * Retrieve the scene-graph RenderTask object.
+   * @return The scene-graph object
    */
-  virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
+  const SceneGraph::RenderTask& GetRenderTaskSceneObject() const;
 
   /**
-   * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyType()
+   * Retrieve the render task list RenderTask object belongs to.
+   * @return The render task list
    */
-  virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
+  RenderTaskList& GetRenderTaskList() const;
 
-  /**
-   * @copydoc Dali::Internal::ProxyObject::SetDefaultProperty()
-   */
-  virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
+public: // Implementation of Object
 
   /**
-   * @copydoc Dali::Internal::ProxyObject::SetCustomProperty()
+   * @copydoc Dali::Internal::Object::SetDefaultProperty()
    */
-  virtual void SetCustomProperty( Property::Index index, const CustomProperty& entry, const Property::Value& value );
+  void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue) override;
 
   /**
-   * @copydoc Dali::Internal::ProxyObject::GetDefaultProperty()
+   * @copydoc Dali::Internal::Object::GetDefaultProperty()
    */
-  virtual Property::Value GetDefaultProperty( Property::Index index ) const;
+  Property::Value GetDefaultProperty( Property::Index index ) const override;
 
   /**
-   * @copydoc Dali::Internal::ProxyObject::InstallSceneObjectProperty()
+   * @copydoc Dali::Internal::Object::GetDefaultPropertyCurrentValue()
    */
-  virtual void InstallSceneObjectProperty( SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index );
+  Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const override;
 
   /**
-   * @copydoc Dali::Internal::ProxyObject::GetSceneObject()
+   * @copydoc Dali::Internal::Object::OnNotifyDefaultPropertyAnimation()
    */
-  virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
+  void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType ) override;
 
   /**
-   * @copydoc Dali::Internal::ProxyObject::GetSceneObjectAnimatableProperty()
+   * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
    */
-  virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
+  const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const override;
 
   /**
-   * @copydoc Dali::Internal::ProxyObject::GetSceneObjectInputProperty()
+   * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
    */
-  virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
+  const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const override;
 
 public: //signals
 
@@ -311,7 +304,7 @@ public: //signals
   /**
    * @copydoc Dali::RenderTask::FinishedSignal()
    */
-  Dali::RenderTask::RenderTaskSignalV2& FinishedSignal();
+  Dali::RenderTask::RenderTaskSignalType& FinishedSignal();
 
   /**
    * Connects a callback function with the object's signals.
@@ -327,117 +320,53 @@ public: //signals
 protected:
 
   /**
-   * Construct a new RenderTask.
-   * @param[in] eventToUpdate Used to send messages to the update-thread.
-   * @param[in] isSystemLevel Whether the RenderTask is on the system level task list.
+   * Constructor.
+   *
+   * @param[in] sceneObject The scene graph object
+   * @param[in] renderTaskList The render task list
    */
-  RenderTask( EventToUpdate& eventToUpdate, bool isSystemLevel );
+  RenderTask( const SceneGraph::RenderTask* sceneObject, RenderTaskList& renderTaskList );
 
   /**
    * A reference counted object may only be deleted by calling Unreference()
    */
-  virtual ~RenderTask();
-
-  /**
-   * Helper class for connecting Nodes to the scene-graph RenderTask
-   */
-  class Connector : public ProxyObject::Observer
-  {
-  public:
-
-    enum Type
-    {
-      SOURCE_CONNECTOR,
-      CAMERA_CONNECTOR,
-      MAPPING_CONNECTOR
-    };
+  ~RenderTask() override;
 
-    /**
-     * Create the helper class
-     */
-    Connector( Type type, RenderTask& renderTask );
+private: // not copyable
 
-    /**
-     * Non-virtual destructor; not suitable as a base object.
-     */
-    ~Connector();
-
-    /**
-     * Set the actor to be observed.
-     * @param[in] actor The actor to be observed.
-     */
-    void SetActor( Actor* actor );
-
-    /**
-     * Update the scene-graph RenderTask with a new source/camera Node.
-     */
-    void UpdateRenderTask();
-
-  public: // From ProxyObject::Observer
-
-    /**
-     * @copydoc Dali::Internal::ProxyObject::Observer::SceneObjectAdded
-     */
-    virtual void SceneObjectAdded( ProxyObject& proxy );
-
-    /**
-     * @copydoc Dali::Internal::ProxyObject::Observer::SceneObjectAdded
-     */
-    virtual void SceneObjectRemoved( ProxyObject& proxy );
-
-    /**
-     * @copydoc Dali::Internal::ProxyObject::Observer::ProxyDestroyed
-     */
-    virtual void ProxyDestroyed( ProxyObject& proxy );
-
-  private:
-
-    // Undefined
-    Connector(const Connector&);
-
-    // Undefined
-    Connector& operator=(const Connector& rhs);
-
-  public:
-
-    const Type mType;
-
-    RenderTask& mRenderTask;
-
-    Actor* mActor; ///< Raw-pointer to the actor; not owned.
-  };
+  RenderTask() = delete;
+  RenderTask( const RenderTask& ) = delete;
+  RenderTask& operator=( const RenderTask& ) = delete;
 
 private:
 
-  EventToUpdate& mEventToUpdate;
+  ActorObserver mSourceActor; ///< Source actor
+  ActorObserver mCameraActor; ///< Camera actor
+  WeakHandle<Dali::Actor> mInputMappingActor; /// used to mapping screen to frame buffer coordinate, not kept alive by rendertask
+  RenderTaskList& mRenderTaskList; ///< The render task list
 
-  SceneGraph::RenderTask* mSceneObject; ///< Raw-pointer to the scene-graph object; not owned.
+  Vector4 mClearColor;       ///< Optional clear color
 
-  Connector mSourceConnector; ///< Responsible for connecting/disconnecting source Nodes
-  Connector mCameraConnector; ///< Responsible for connecting/disconnecting camera Nodes
-  Connector mMappingConnector; /// Responsible for connecting/disconnection actor node, which used to mapping screen to frame buffer coordinate
+  Vector2 mViewportPosition; ///< The cached viewport position
+  Vector2 mViewportSize;     ///< The cached viewport size
 
-  Vector4 mClearColor;       ///< Optional clear color
+  uint32_t mRefreshRate; ///< Determines how often the task is processed.
 
-  unsigned int mRefreshRate; ///< Determines how often the task is processed.
+  uint32_t mRefreshOnceCounter;
 
-  unsigned int mRefreshOnceCounter;
+  FrameBufferPtr  mFrameBuffer;
 
-  Dali::FrameBufferImage mFrameBufferImage;  ///< Optional off-screen render target.
 
   Dali::RenderTask::ScreenToFrameBufferFunction mScreenToFrameBufferFunction; ///< Used to convert screen to frame-buffer coordinates
 
   bool mExclusive     : 1; ///< True if the render-task has exclusive access to the source Nodes.
   bool mInputEnabled  : 1; ///< True if the render-task should be considered for input handling.
   bool mClearEnabled  : 1; ///< True if the render-task should be clear the color buffer.
-  bool mIsSystemLevel : 1; ///< True if the render-task is on the system level task list.
-
-  // Default properties
-  typedef std::map<std::string, Property::Index> DefaultPropertyLookup;
-  static DefaultPropertyLookup* sDefaultPropertyLookup;
+  bool mCullMode      : 1; ///< True if the render-task's actors should be culled
+  bool mRequiresSync  : 1; ///< True if the GL sync is required to track the render of.
 
   //Signals
-  Dali::RenderTask::RenderTaskSignalV2  mSignalFinishedV2; ///< Signal emmited when the render task has been processed.
+  Dali::RenderTask::RenderTaskSignalType  mSignalFinished; ///< Signal emmited when the render task has been processed.
 };
 
 } // namespace Internal
@@ -464,4 +393,4 @@ inline const Internal::RenderTask& GetImplementation(const Dali::RenderTask& tas
 
 } // namespace Dali
 
-#endif //__DALI_INTERNAL_RENDER_TASK_H__
+#endif // DALI_INTERNAL_RENDER_TASK_H