X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Frender-tasks%2Frender-task-impl.h;h=096991620f58df144523007b5397bdc9e8cb56d5;hb=26b548345206ce375453540e194e0f96dbe64116;hp=b76d0a2da4d790fa2f949d2b1a427a5af9189d37;hpb=81dc8fa898dcdaaf3f1780b909ad6e4f7e33bd92;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/render-tasks/render-task-impl.h b/dali/internal/event/render-tasks/render-task-impl.h index b76d0a2..0969916 100644 --- a/dali/internal/event/render-tasks/render-task-impl.h +++ b/dali/internal/event/render-tasks/render-task-impl.h @@ -1,8 +1,8 @@ -#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) 2017 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. @@ -20,43 +20,51 @@ // INTERNAL INCLUDES #include +#include #include -#include + #include +#include #include namespace Dali { - namespace Internal { - class Actor; class CameraActor; class EventThreadServices; +class RenderTaskList; namespace SceneGraph { +class RenderTaskList; class RenderTask; class Camera; -} +} // namespace SceneGraph + +using RenderTaskPtr = IntrusivePtr; 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() @@ -66,7 +74,7 @@ public: /** * @copydoc Dali::RenderTask::SetExclusive() */ - void SetExclusive( bool exclusive ); + void SetExclusive(bool exclusive); /** * @copydoc Dali::RenderTask::IsExclusive() @@ -76,7 +84,7 @@ public: /** * @copydoc Dali::RenderTask::SetInputEnabled() */ - void SetInputEnabled( bool enabled ); + void SetInputEnabled(bool enabled); /** * @copydoc Dali::RenderTask::GetInputEnabled() @@ -86,7 +94,7 @@ public: /** * @copydoc Dali::RenderTask::SetCameraActor() */ - void SetCameraActor( CameraActor* cameraActor ); + void SetCameraActor(CameraActor* cameraActor); /** * @copydoc Dali::RenderTask::GetCameraActor() @@ -94,29 +102,19 @@ public: CameraActor* GetCameraActor() const; /** - * @copydoc Dali::RenderTask::SetTargetFrameBuffer() - */ - void SetTargetFrameBuffer( FrameBufferImagePtr frameBuffer ); - - /** - * @copydoc Dali::RenderTask::GetTargetFrameBuffer - */ - FrameBufferImage* GetTargetFrameBuffer() const; - - /** * @copydoc Dali::RenderTask::SetFrameBuffer() */ - void SetFrameBuffer( FrameBufferPtr frameBuffer ); + void SetFrameBuffer(FrameBufferPtr frameBuffer); - /** + /** * @copydoc Dali::RenderTask::GetFrameBuffer */ - FrameBuffer* GetFrameBuffer() const; + FrameBuffer* GetFrameBuffer() const; /** * @copydoc Dali::RenderTask::SetScreenToFrameBufferFunction */ - void SetScreenToFrameBufferFunction( ScreenToFrameBufferFunction conversionFunction ); + void SetScreenToFrameBufferFunction(ScreenToFrameBufferFunction conversionFunction); /** * @copydoc Dali::RenderTask::GetScreenToFrameBufferFunction @@ -124,14 +122,29 @@ public: ScreenToFrameBufferFunction GetScreenToFrameBufferFunction() const; /** - * copydoc Dali::RenderTask::SetScreenToFrameBufferMappingActor + * @copydoc Dali::RenderTask::SetScreenToFrameBufferMappingActor + */ + void SetScreenToFrameBufferMappingActor(Dali::Actor& mappingActor); + + /** + * @copydoc Dali::RenderTask::GetScreenToFrameBufferMAppingActor */ - void SetScreenToFrameBufferMappingActor( Actor* mappingActor ); + Dali::Actor GetScreenToFrameBufferMappingActor() const; /** - * copydoc Dali::RenderTask::GetScreenToFrameBufferMAppingActor + * @copydoc Dali::RenderTask::SetViewportGuideActor */ - Actor* GetScreenToFrameBufferMappingActor() const; + void SetViewportGuideActor(Actor* actor); + + /** + * @copydoc Dali::RenderTask::GetViewportGuideActor + */ + Actor* GetViewportGuideActor() const; + + /** + * @copydoc Dali::RenderTask::ResetViewportGuideActor + */ + void ResetViewportGuideActor(); /** * @copydoc Dali::RenderTask::SetViewportPosition @@ -156,17 +169,17 @@ public: /** * @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() @@ -177,18 +190,18 @@ public: * Indicate whether GL sync is required for native render target. * @param[in] requiresSync whether GL sync is required. */ - void SetSyncRequired( bool requiresSync ); + 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; + bool IsSyncRequired() const; /** * @copydoc Dali::RenderTask::SetClearEnabled() */ - void SetClearEnabled( bool enabled ); + void SetClearEnabled(bool enabled); /** * @copydoc Dali::RenderTask::GetClearEnabled() @@ -198,7 +211,7 @@ public: /** * @copydoc Dali::RenderTask::SetCullMode() */ - void SetCullMode( bool mode ); + void SetCullMode(bool mode); /** * @copydoc Dali::RenderTask::GetCullMode() @@ -208,137 +221,82 @@ public: /** * @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; - - /** - * 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; + bool TranslateCoordinates(Vector2& screenCoords) const; /** * @copydoc Dali::RenderTask::WorldToViewport() */ - bool WorldToViewport(const Vector3 &position, float& viewportX, float& viewportY) const; + bool WorldToViewport(const Vector3& position, float& viewportX, float& viewportY) const; /** * @copydoc Dali::RenderTask::ViewportToLocal() */ - bool ViewportToLocal(Actor* actor, float viewportX, float viewportY, float &localX, float &localY) const; + bool ViewportToLocal(Actor* actor, float viewportX, float viewportY, float& localX, float& localY) 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. + * @return The scene-graph object */ - SceneGraph::RenderTask* GetRenderTaskSceneObject(); + const SceneGraph::RenderTask& GetRenderTaskSceneObject() const; /** - * Discard the scene-graph RenderTask object. + * Retrieve the render task list RenderTask object belongs to. + * @return The render task list */ - void DiscardSceneObject(); + RenderTaskList& GetRenderTaskList() const; public: // Implementation of Object - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyCount() - */ - virtual unsigned int GetDefaultPropertyCount() const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices() - */ - virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyName() - */ - virtual const char* GetDefaultPropertyName(Property::Index index) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex() - */ - virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable() - */ - virtual bool IsDefaultPropertyWritable(Property::Index index) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable() - */ - virtual bool IsDefaultPropertyAnimatable(Property::Index index) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput() - */ - virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyType() - */ - virtual Property::Type GetDefaultPropertyType(Property::Index index) const; - /** * @copydoc Dali::Internal::Object::SetDefaultProperty() */ - virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue); + void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue) override; /** * @copydoc Dali::Internal::Object::GetDefaultProperty() */ - virtual Property::Value GetDefaultProperty( Property::Index index ) const; + Property::Value GetDefaultProperty(Property::Index index) const override; /** * @copydoc Dali::Internal::Object::GetDefaultPropertyCurrentValue() */ - virtual Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const; + Property::Value GetDefaultPropertyCurrentValue(Property::Index index) const override; /** - * @copydoc Dali::Internal::Object::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::Object::GetSceneObjectAnimatableProperty() */ - virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const; + const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty(Property::Index index) const override; /** * @copydoc Dali::Internal::Object::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. @@ -367,123 +325,55 @@ public: //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] 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( 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 Object::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 Object::Observer - - /** - * @copydoc Dali::Internal::Object::Observer::SceneObjectAdded - */ - virtual void SceneObjectAdded( Object& object ); - - /** - * @copydoc Dali::Internal::Object::Observer::SceneObjectAdded - */ - virtual void SceneObjectRemoved( Object& object ); - - /** - * @copydoc Dali::Internal::Object::Observer::ObjectDestroyed - */ - virtual void ObjectDestroyed( Object& object ); + ~RenderTask() override; - 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. - const SceneGraph::Camera* mCamera; ///< Raw-pointer to camera scene-graph object; 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 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. - - Connector mSourceConnector; ///< Responsible for connecting/disconnecting source Nodes - Connector mCameraConnector; ///< Responsible for connecting/disconnecting camera Nodes - Connector mMappingConnector; /// Responsible for connecting/disconnecting 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. - - unsigned int mRefreshOnceCounter; + uint32_t mRefreshRate; ///< Determines how often the task is processed. - FrameBufferImagePtr mFrameBufferImage; ///< Optional off-screen render target. - FrameBufferPtr mFrameBuffer; + uint32_t mRefreshOnceCounter; + 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 mRequiresSync : 1; ///< True if the GL sync is required to track the render of. + 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::RenderTaskSignalType mSignalFinished; ///< Signal emmited when the render task has been processed. + Dali::RenderTask::RenderTaskSignalType mSignalFinished; ///< Signal emmited when the render task has been processed. }; } // namespace Internal @@ -510,4 +400,4 @@ inline const Internal::RenderTask& GetImplementation(const Dali::RenderTask& tas } // namespace Dali -#endif //__DALI_INTERNAL_RENDER_TASK_H__ +#endif // DALI_INTERNAL_RENDER_TASK_H