X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Fintegration-api%2Fadaptor-framework%2Fscene-holder-impl.h;h=8cb30c3226e8fcc7be9a6ae3a211bbc874cdd9b2;hb=6639efb20527a94f0cb5e2660dbb8585c95b07d2;hp=10051b90f6ba3580d4c30d0c2095e150f0606acb;hpb=5278af3f8797ae60b3a220015cf0bdb3678e7db8;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/dali/integration-api/adaptor-framework/scene-holder-impl.h b/dali/integration-api/adaptor-framework/scene-holder-impl.h index 10051b9..8cb30c3 100644 --- a/dali/integration-api/adaptor-framework/scene-holder-impl.h +++ b/dali/integration-api/adaptor-framework/scene-holder-impl.h @@ -2,7 +2,7 @@ #define DALI_INTEGRATION_INTERNAL_SCENEHOLDER_H /* - * Copyright (c) 2019 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. @@ -19,14 +19,17 @@ */ // EXTERNAL INCLUDES -#include -#include -#include -#include -#include +#include #include #include #include +#include +#include +#include +#include +#include +#include +#include // INTERNAL INCLUDES #include @@ -34,52 +37,46 @@ namespace Dali { - class Any; class Adaptor; class Actor; class Layer; +class WheelEvent; struct TouchPoint; -struct WheelEvent; -struct KeyEvent; +class KeyEvent; namespace Integration { - class Scene; struct Point; struct KeyEvent; struct WheelEvent; -} +} // namespace Integration namespace Internal { - namespace Adaptor { - class Adaptor; class SceneHolder; -using SceneHolderPtr = IntrusivePtr< SceneHolder >; +using SceneHolderPtr = IntrusivePtr; /** * @brief SceneHolder creates a Scene for rendering. */ class DALI_ADAPTOR_API SceneHolder : public BaseObject { - public: - /** * @copydoc Dali::Integration::SceneHolder::Add */ - void Add( Dali::Actor actor ); + void Add(Dali::Actor actor); /** * @copydoc Dali::Integration::SceneHolder::Remove */ - void Remove( Dali::Actor actor ); + void Remove(Dali::Actor actor); /** * @copydoc Dali::Integration::SceneHolder::GetRootLayer @@ -87,6 +84,11 @@ public: Dali::Layer GetRootLayer() const; /** + * @copydoc Dali::Integration::SceneHolder::GetOverlayLayer + */ + Dali::Layer GetOverlayLayer(); + + /** * @brief Gets the window name. * @return The name of the window */ @@ -105,15 +107,23 @@ public: Dali::Integration::Scene GetScene(); /** + * @brief Retrieves the DPI of this sceneholder. + * @return The DPI. + */ + Uint16Pair GetDpi() const; + + /** * @brief Set the render surface * @param[in] surface The render surface */ - void SetSurface( Dali::RenderSurfaceInterface* surface ); + void SetSurface(Dali::RenderSurfaceInterface* surface); /** * @brief Called when the surface set is resized. + * @param[in] width the resized window's width + * @param[in] height the resized window's height */ - void SurfaceResized(); + void SurfaceResized(float width, float height); /** * @brief Get the render surface @@ -125,12 +135,12 @@ public: * @brief Set the adaptor to the scene holder * @param[in] adaptor An initialized adaptor */ - void SetAdaptor( Dali::Adaptor& adaptor ); + void SetAdaptor(Dali::Adaptor& adaptor); /** * @copydoc Dali::Integration::SceneHolder::SetBackgroundColor */ - void SetBackgroundColor( const Dali::Vector4& color ); + void SetBackgroundColor(const Dali::Vector4& color); /** * @copydoc Dali::Integration::SceneHolder::GetBackgroundColor @@ -148,47 +158,137 @@ public: void Resume(); /** + * @brief Checks whether this scene holder is being deleted in the event thread. + * + * @return true if this scene holder is being deleted in the event thread, or false if not. + */ + bool IsBeingDeleted() const + { + return mIsBeingDeleted; + } + + /** + * @brief Informs the scene that the set surface has been rotated. + * + * @param[in] width The width of rotated surface + * @param[in] height The height of rotated surface + * @param[in] windowOrientation the current window orientation + * @param[in] screenOrientation the current screen orientation + */ + void SurfaceRotated(float width, float height, int32_t windowOrientation, int32_t screenOrientation); + + /** + * @brief Send message to acknowledge window rotation with current window orientation. + * It is to send message to render thread for completing window rotation by user. + */ + void SetRotationCompletedAcknowledgement(); + + /** * @copydoc Dali::Integration::SceneHolder::FeedTouchPoint */ - void FeedTouchPoint( Dali::Integration::Point& point, int timeStamp ); + void FeedTouchPoint(Dali::Integration::Point& point, int timeStamp); /** * @copydoc Dali::Integration::SceneHolder::FeedWheelEvent */ - void FeedWheelEvent( Dali::Integration::WheelEvent& wheelEvent ); + void FeedWheelEvent(Dali::Integration::WheelEvent& wheelEvent); /** * @copydoc Dali::Integration::SceneHolder::FeedKeyEvent */ - void FeedKeyEvent( Dali::Integration::KeyEvent& keyEvent ); + void FeedKeyEvent(Dali::Integration::KeyEvent& keyEvent); + + /** + * @brief Adds a callback that is called when the frame rendering is done by the graphics driver. + * + * @param[in] callback The function to call + * @param[in] frameId The Id to specify the frame. It will be passed when the callback is called. + * + * @note A callback of the following type may be used: + * @code + * void MyFunction( int frameId ); + * @endcode + * This callback will be deleted once it is called. + * + * @note Ownership of the callback is passed onto this class. + */ + void AddFrameRenderedCallback(std::unique_ptr callback, int32_t frameId); + + /** + * @brief Adds a callback that is called when the frame rendering is done by the graphics driver. + * + * @param[in] callback The function to call + * @param[in] frameId The Id to specify the frame. It will be passed when the callback is called. + * + * @note A callback of the following type may be used: + * @code + * void MyFunction( int frameId ); + * @endcode + * This callback will be deleted once it is called. + * + * @note Ownership of the callback is passed onto this class. + */ + void AddFramePresentedCallback(std::unique_ptr callback, int32_t frameId); + + /** + * @brief Creates the render target for the surface when the surface is created/resized/replaced. + */ + void CreateRenderTarget(); /** * @copydoc Dali::Integration::SceneHolder::Get() */ - static Dali::Integration::SceneHolder Get( Dali::Actor actor ); + static Dali::Integration::SceneHolder Get(Dali::Actor actor); /** * @copydoc Dali::Integration::SceneHolder::KeyEventSignal() */ - Dali::Integration::SceneHolder::KeyEventSignalType& KeyEventSignal() { return mScene.KeyEventSignal(); } + Dali::Integration::SceneHolder::KeyEventSignalType& KeyEventSignal() + { + return mScene.KeyEventSignal(); + } /** * @copydoc Dali::Integration::SceneHolder::KeyEventGeneratedSignal() */ - Dali::Integration::SceneHolder::KeyEventGeneratedSignalType& KeyEventGeneratedSignal() { return mScene.KeyEventGeneratedSignal(); } + Dali::Integration::SceneHolder::KeyEventGeneratedSignalType& KeyEventGeneratedSignal() + { + return mScene.KeyEventGeneratedSignal(); + } /** - * @copydoc Dali::Integration::SceneHolder::TouchSignal() + * @copydoc Dali::Integration::SceneHolder::InterceptKeyEventSignal() */ - Dali::Integration::SceneHolder::TouchSignalType& TouchSignal() { return mScene.TouchSignal(); } + Dali::Integration::SceneHolder::KeyEventGeneratedSignalType& InterceptKeyEventSignal() + { + return mScene.InterceptKeyEventSignal(); + } + + /** + * @copydoc Dali::Integration::SceneHolder::TouchedSignal() + */ + Dali::Integration::SceneHolder::TouchEventSignalType& TouchedSignal() + { + return mScene.TouchedSignal(); + } /** * @copydoc Dali::Integration::SceneHolder::WheelEventSignal() */ - Dali::Integration::SceneHolder::WheelEventSignalType& WheelEventSignal() { return mScene.WheelEventSignal(); } + Dali::Integration::SceneHolder::WheelEventSignalType& WheelEventSignal() + { + return mScene.WheelEventSignal(); + } -public: // The following methods can be overridden if required + /** + * @copydoc Dali::Integration::SceneHolder::WheelEventGeneratedSignal() + */ + Dali::Integration::SceneHolder::WheelEventGeneratedSignalType& WheelEventGeneratedSignal() + { + return mScene.WheelEventGeneratedSignal(); + } +public: // The following methods can be overridden if required /** * @brief Returns whether the Scene is visible or not. * @return True if the Scene is visible, false otherwise. @@ -196,14 +296,12 @@ public: // The following methods can be overridden if required virtual bool IsVisible() const; public: // The following methods must be overridden - /** * @copydoc Dali::Integration::SceneHolder::GetNativeHandle */ virtual Dali::Any GetNativeHandle() const = 0; protected: - // Constructor SceneHolder(); @@ -216,86 +314,95 @@ protected: /** * virtual destructor */ - virtual ~SceneHolder(); + ~SceneHolder() override; private: // The following methods can be overridden if required - /** * @brief Called by the base class to inform deriving classes that the adaptor has been set. * @param[in] adaptor The adaptor */ - virtual void OnAdaptorSet( Dali::Adaptor& adaptor ) {}; + virtual void OnAdaptorSet(Dali::Adaptor& adaptor){}; /** * @brief Called by the base class to inform deriving classes that a new surface has been set. * @param[in] surface The new render surface */ - virtual void OnSurfaceSet( Dali::RenderSurfaceInterface* surface ) {}; + virtual void OnSurfaceSet(Dali::RenderSurfaceInterface* surface){}; /** * @brief Called by the base class to inform deriving classes that we are being paused. */ - virtual void OnPause() {}; + virtual void OnPause(){}; /** * @brief Called by the base class to inform deriving classes that we are resuming from a paused state. */ - virtual void OnResume() {}; + virtual void OnResume(){}; /** - * Recalculate the touch position if required - * @param[in,out] point The touch point + * Recalculate the position if required + * @param[in] position The screen position + * @return converted position by oriention */ - virtual void RecalculateTouchPosition( Integration::Point& point ) {}; + virtual Vector2 RecalculatePosition(const Vector2& position) + { + return position; + }; private: - /** * Resets the event handling. */ void Reset(); -private: + /** + * Initializes the DPI for this object. + */ + void InitializeDpi(); - static uint32_t mSceneHolderCounter; ///< A counter to track the SceneHolder creation +private: + static uint32_t mSceneHolderCounter; ///< A counter to track the SceneHolder creation class SceneHolderLifeCycleObserver; - std::unique_ptr< SceneHolderLifeCycleObserver > mLifeCycleObserver; ///< The adaptor life cycle observer + std::unique_ptr mLifeCycleObserver; ///< The adaptor life cycle observer protected: + uint32_t mId; ///< A unique ID to identify the SceneHolder starting from 0 + Dali::Integration::Scene mScene; ///< The Scene + std::string mName; ///< The name of the SceneHolder + + std::unique_ptr mSurface; ///< The window rendering surface + Adaptor* mAdaptor; ///< The adaptor - uint32_t mId; ///< A unique ID to identify the SceneHolder starting from 0 - Dali::Integration::Scene mScene; ///< The Scene - std::string mName; ///< The name of the SceneHolder + Dali::Integration::TouchEventCombiner mCombiner; ///< Combines multi-touch events. - std::unique_ptr< Dali::RenderSurfaceInterface > mSurface; ///< The window rendering surface - Adaptor* mAdaptor; ///< The adaptor + Uint16Pair mDpi; ///< The DPI for this SceneHolder. - Dali::Integration::TouchEventCombiner mCombiner; ///< Combines multi-touch events. + std::atomic mIsBeingDeleted; ///< This is set only from the event thread and read only from the render thread - bool mAdaptorStarted:1; ///< Whether the adaptor has started or not - bool mVisible:1; ///< Whether the scene is visible or not + bool mAdaptorStarted : 1; ///< Whether the adaptor has started or not + bool mVisible : 1; ///< Whether the scene is visible or not }; -} // Adaptor +} // namespace Adaptor -} // Internal +} // namespace Internal // Get impl of handle -inline Internal::Adaptor::SceneHolder& GetImplementation( Dali::Integration::SceneHolder& sceneHolder ) +inline Internal::Adaptor::SceneHolder& GetImplementation(Dali::Integration::SceneHolder& sceneHolder) { - DALI_ASSERT_ALWAYS( sceneHolder && "SceneHolder handle is empty" ); + DALI_ASSERT_ALWAYS(sceneHolder && "SceneHolder handle is empty"); Dali::RefObject& object = sceneHolder.GetBaseObject(); - return static_cast( object ); + return static_cast(object); } -inline const Internal::Adaptor::SceneHolder& GetImplementation( const Dali::Integration::SceneHolder& sceneHolder ) +inline const Internal::Adaptor::SceneHolder& GetImplementation(const Dali::Integration::SceneHolder& sceneHolder) { - DALI_ASSERT_ALWAYS( sceneHolder && "SceneHolder handle is empty" ); + DALI_ASSERT_ALWAYS(sceneHolder && "SceneHolder handle is empty"); const Dali::RefObject& object = sceneHolder.GetBaseObject(); - return static_cast( object ); + return static_cast(object); } -} // Dali +} // namespace Dali #endif // DALI_INTEGRATION_INTERNAL_SCENEHOLDER_H