X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Frender-tasks%2Frender-task-impl.h;h=b9396910e37f026fab13c6b1a82002114a13d1e1;hb=a3d1c0e03068de2d010009baac4007bec662ee45;hp=c45b347232795a1242f34a96bd60be72ecf41544;hpb=5bfcdb0ce73c06082873659d5bc3335f10d10d96;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 c45b347..b939691 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) 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. @@ -20,41 +20,50 @@ // INTERNAL INCLUDES #include +#include #include -#include -#include + +#include +#include +#include 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; -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. + * @return The created render task */ - static RenderTask* New( bool isSystemLevel ); + static RenderTaskPtr New(Actor* sourceActor, CameraActor* cameraActor, RenderTaskList& renderTaskList); /** * @copydoc Dali::RenderTask::SetSourceActor() */ - void SetSourceActor( Actor* actor ); + void SetSourceActor(Actor* actor); /** * @copydoc Dali::RenderTask::GetSourceActor() @@ -64,7 +73,7 @@ public: /** * @copydoc Dali::RenderTask::SetExclusive() */ - void SetExclusive( bool exclusive ); + void SetExclusive(bool exclusive); /** * @copydoc Dali::RenderTask::IsExclusive() @@ -74,7 +83,7 @@ public: /** * @copydoc Dali::RenderTask::SetInputEnabled() */ - void SetInputEnabled( bool enabled ); + void SetInputEnabled(bool enabled); /** * @copydoc Dali::RenderTask::GetInputEnabled() @@ -84,7 +93,7 @@ public: /** * @copydoc Dali::RenderTask::SetCameraActor() */ - void SetCameraActor( CameraActor* cameraActor ); + void SetCameraActor(CameraActor* cameraActor); /** * @copydoc Dali::RenderTask::GetCameraActor() @@ -92,19 +101,19 @@ 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 */ - void SetScreenToFrameBufferFunction( ScreenToFrameBufferFunction conversionFunction ); + void SetScreenToFrameBufferFunction(ScreenToFrameBufferFunction conversionFunction); /** * @copydoc Dali::RenderTask::GetScreenToFrameBufferFunction @@ -112,14 +121,29 @@ public: 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 @@ -144,17 +168,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() @@ -162,9 +186,21 @@ 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 ); + void SetClearEnabled(bool enabled); /** * @copydoc Dali::RenderTask::GetClearEnabled() @@ -174,7 +210,7 @@ public: /** * @copydoc Dali::RenderTask::SetCullMode() */ - void SetCullMode( bool mode ); + void SetCullMode(bool mode); /** * @copydoc Dali::RenderTask::GetCullMode() @@ -184,132 +220,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; + 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. @@ -327,7 +313,7 @@ public: //signals /** * @copydoc Dali::RenderTask::FinishedSignal() */ - Dali::RenderTask::RenderTaskSignalV2& FinishedSignal(); + Dali::RenderTask::RenderTaskSignalType& FinishedSignal(); /** * Connects a callback function with the object's signals. @@ -338,119 +324,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] 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 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 @@ -477,4 +399,4 @@ inline const Internal::RenderTask& GetImplementation(const Dali::RenderTask& tas } // namespace Dali -#endif //__DALI_INTERNAL_RENDER_TASK_H__ +#endif // DALI_INTERNAL_RENDER_TASK_H