-#ifndef __DALI_INTERNAL_RENDER_TASK_H__
-#define __DALI_INTERNAL_RENDER_TASK_H__
+#ifndef DALI_INTERNAL_RENDER_TASK_H
+#define DALI_INTERNAL_RENDER_TASK_H
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
// 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/events/actor-observer.h>
+#include <dali/internal/event/rendering/frame-buffer-impl.h>
namespace Dali
{
-
namespace Internal
{
-
class Actor;
class CameraActor;
-class EventToUpdate;
+class EventThreadServices;
+class RenderTaskList;
namespace SceneGraph
{
+class RenderTaskList;
class RenderTask;
-}
+class Camera;
+} // namespace SceneGraph
+
+using RenderTaskPtr = IntrusivePtr<RenderTask>;
-class RenderTask : public ProxyObject
+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.
+ * @param[in] isOverlayTask True if this render task is overlay task. default is false.
+ * @return The created render task
*/
- static RenderTask* New( bool isSystemLevel );
+ static RenderTaskPtr New(Actor* sourceActor, CameraActor* cameraActor, RenderTaskList& renderTaskList, bool isOverlayTask = false);
/**
* @copydoc Dali::RenderTask::SetSourceActor()
*/
- void SetSourceActor( Actor* actor );
+ void SetSourceActor(Actor* actor);
/**
* @copydoc Dali::RenderTask::GetSourceActor()
/**
* @copydoc Dali::RenderTask::SetExclusive()
*/
- void SetExclusive( bool exclusive );
+ void SetExclusive(bool exclusive);
/**
* @copydoc Dali::RenderTask::IsExclusive()
/**
* @copydoc Dali::RenderTask::SetInputEnabled()
*/
- void SetInputEnabled( bool enabled );
+ void SetInputEnabled(bool enabled);
/**
* @copydoc Dali::RenderTask::GetInputEnabled()
/**
* @copydoc Dali::RenderTask::SetCameraActor()
*/
- void SetCameraActor( CameraActor* cameraActor );
+ void SetCameraActor(CameraActor* cameraActor);
/**
* @copydoc Dali::RenderTask::GetCameraActor()
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
*/
- void SetScreenToFrameBufferFunction( ScreenToFrameBufferFunction conversionFunction );
+ void SetScreenToFrameBufferFunction(ScreenToFrameBufferFunction conversionFunction);
/**
* @copydoc Dali::RenderTask::GetScreenToFrameBufferFunction
ScreenToFrameBufferFunction GetScreenToFrameBufferFunction() const;
/**
- * copydoc Dali::RenderTask::SetScreenToFrameBufferMappingActor
+ * @copydoc Dali::RenderTask::SetScreenToFrameBufferMappingActor
*/
- void SetScreenToFrameBufferMappingActor( Actor* mappingActor );
+ void SetScreenToFrameBufferMappingActor(Dali::Actor& mappingActor);
/**
- * copydoc Dali::RenderTask::GetScreenToFrameBufferMAppingActor
+ * @copydoc Dali::RenderTask::GetScreenToFrameBufferMAppingActor
*/
- Actor* GetScreenToFrameBufferMappingActor() const;
+ Dali::Actor GetScreenToFrameBufferMappingActor() const;
+
+ /**
+ * @copydoc Dali::RenderTask::SetViewportGuideActor
+ */
+ void SetViewportGuideActor(Actor* actor);
+
+ /**
+ * @copydoc Dali::RenderTask::GetViewportGuideActor
+ */
+ Actor* GetViewportGuideActor() const;
+
+ /**
+ * @copydoc Dali::RenderTask::ResetViewportGuideActor
+ */
+ void ResetViewportGuideActor();
/**
* @copydoc Dali::RenderTask::SetViewportPosition
/**
* @copydoc Dali::RenderTask::SetViewport()
*/
- void SetViewport( const Viewport& viewport );
+ void SetViewport(const Viewport& viewport);
/**
* @param[out] viewPort instance to copy the values into
*/
- void GetViewport( Viewport& viewPort ) const;
+ void GetViewport(Viewport& viewPort) const;
/**
* @copydoc Dali::RenderTask::SetClearColor()
*/
- void SetClearColor( const Vector4& color );
+ void SetClearColor(const Vector4& color);
/**
* @copydoc Dali::RenderTask::GetClearColor()
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 );
+ void SetClearEnabled(bool enabled);
/**
* @copydoc Dali::RenderTask::GetClearEnabled()
/**
* @copydoc Dali::RenderTask::SetCullMode()
*/
- void SetCullMode( bool mode );
+ void SetCullMode(bool mode);
/**
* @copydoc Dali::RenderTask::GetCullMode()
/**
* @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.
* @param[in,out] screenCoords The screen coordinate, which may be converted (for hit-testing actors which are rendered off-screen).
* @return True the render-task can be used for input-handling; otherwise the output parameters are not valid.
*/
- bool IsHittable( Vector2& screenCoords ) const;
+ bool IsHittable(Vector2& screenCoords) const;
/**
* Translates screen coordinates to render task coordinates for offscreen render tasks
* @param[in,out] screenCoords The screen coordinates, which may be converted (for off-screen).
* @return false if the conversion function decides the coordinates are not inside. returns true if there is no conversion function
*/
- bool TranslateCoordinates( Vector2& screenCoords ) const;
+ 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.
+ * @copydoc Dali::RenderTask::WorldToViewport()
*/
- bool IsSystemLevel() const;
-
-public: // Used by RenderTaskList, which owns the SceneGraph::RenderTasks
+ bool WorldToViewport(const Vector3& position, float& viewportX, float& viewportY) const;
/**
- * Create the scene-graph RenderTask object.
- * @pre CreateSceneObject has not already been called.
- * @return A newly allocated scene-graph object; the caller takes ownership.
+ * @copydoc Dali::RenderTask::ViewportToLocal()
*/
- SceneGraph::RenderTask* CreateSceneObject();
+ bool ViewportToLocal(Actor* actor, float viewportX, float viewportY, float& localX, float& localY) const;
+public: // Used by RenderTaskList, which owns the SceneGraph::RenderTasks
/**
* 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::GetDefaultPropertyCount()
- */
- virtual unsigned int GetDefaultPropertyCount() const;
-
- /**
- * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndices()
- */
- virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
-
- /**
- * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName()
- */
- virtual const char* 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;
-
- /**
- * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAnimatable()
+ * @return The scene-graph object
*/
- virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
+ const SceneGraph::RenderTask& GetRenderTaskSceneObject() const;
/**
- * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAConstraintInput()
+ * Retrieve the render task list RenderTask object belongs to.
+ * @return The render task list
*/
- virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
+ RenderTaskList& GetRenderTaskList() const;
+public: // Implementation of Object
/**
- * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyType()
+ * @copydoc Dali::Internal::Object::SetDefaultProperty()
*/
- virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
+ void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue) override;
/**
- * @copydoc Dali::Internal::ProxyObject::SetDefaultProperty()
+ * @copydoc Dali::Internal::Object::GetDefaultProperty()
*/
- virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
+ Property::Value GetDefaultProperty(Property::Index index) const override;
/**
- * @copydoc Dali::Internal::ProxyObject::SetCustomProperty()
+ * @copydoc Dali::Internal::Object::GetDefaultPropertyCurrentValue()
*/
- virtual void SetCustomProperty( Property::Index index, const CustomProperty& entry, const Property::Value& value );
+ Property::Value GetDefaultPropertyCurrentValue(Property::Index index) const override;
/**
- * @copydoc Dali::Internal::ProxyObject::GetDefaultProperty()
+ * @copydoc Dali::Internal::Object::OnNotifyDefaultPropertyAnimation()
*/
- virtual Property::Value GetDefaultProperty( Property::Index index ) const;
+ void OnNotifyDefaultPropertyAnimation(Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType) override;
/**
- * @copydoc Dali::Internal::ProxyObject::InstallSceneObjectProperty()
+ * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
*/
- virtual void InstallSceneObjectProperty( SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index );
+ const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty(Property::Index index) const override;
/**
- * @copydoc Dali::Internal::ProxyObject::GetSceneObject()
+ * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
*/
- virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
-
- /**
- * @copydoc Dali::Internal::ProxyObject::GetSceneObjectAnimatableProperty()
- */
- virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::ProxyObject::GetSceneObjectInputProperty()
- */
- virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
+ const PropertyInputImpl* GetSceneObjectInputProperty(Property::Index index) const override;
public: //signals
-
/**
* Query whether a Finished signal should be emitted for this render-task.
* This should only be called by NotificationManager, before signals are emitted.
/**
* @copydoc Dali::RenderTask::FinishedSignal()
*/
- Dali::RenderTask::RenderTaskSignalV2& FinishedSignal();
+ Dali::RenderTask::RenderTaskSignalType& FinishedSignal();
/**
* Connects a callback function with the object's signals.
* @return True if the signal was connected.
* @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
*/
- static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
+ static bool DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
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
- };
-
- /**
- * Create the helper class
- */
- Connector( Type type, RenderTask& renderTask );
-
- /**
- * 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 );
+ ~RenderTask() override;
- /**
- * @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.
- };
+private: // not copyable
+ RenderTask() = delete;
+ RenderTask(const RenderTask&) = delete;
+ RenderTask& operator=(const RenderTask&) = delete;
private:
+ ActorObserver mSourceActor; ///< Source actor
+ ActorObserver mCameraActor; ///< Camera actor
+ ActorObserver mViewportGuideActor; ///< Actor to matching viewport of this render task to this Actor.
+ WeakHandle<Dali::Actor> mInputMappingActor; /// used to mapping screen to frame buffer coordinate, not kept alive by rendertask
+ RenderTaskList& mRenderTaskList; ///< The render task list
- EventToUpdate& mEventToUpdate;
-
- SceneGraph::RenderTask* mSceneObject; ///< Raw-pointer to the scene-graph object; not owned.
-
- 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
+ Vector4 mClearColor; ///< Optional clear color
- Vector4 mClearColor; ///< Optional clear color
+ Vector2 mViewportPosition; ///< The cached viewport position
+ Vector2 mViewportSize; ///< The cached viewport size
- unsigned int mRefreshRate; ///< Determines how often the task is processed.
+ uint32_t mRefreshRate; ///< Determines how often the task is processed.
- unsigned int mRefreshOnceCounter;
+ uint32_t mRefreshOnceCounter;
- Dali::FrameBufferImage mFrameBufferImage; ///< Optional off-screen render target.
+ FrameBufferPtr mFrameBuffer;
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 mCullMode : 1; ///< True if the render-task's actors should be culled
- bool mIsSystemLevel : 1; ///< True if the render-task is on the system level task list.
+ 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 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
} // namespace Dali
-#endif //__DALI_INTERNAL_RENDER_TASK_H__
+#endif // DALI_INTERNAL_RENDER_TASK_H