From 3c39cd383a91b443f0aa8ecb0a3b976585cf2139 Mon Sep 17 00:00:00 2001 From: Adeel Kazmi Date: Wed, 8 Jul 2020 18:11:38 +0100 Subject: [PATCH] (Window) Move methods from Devel to Public API & add a new GetDpi method Change-Id: I83eabbc3334bdd717e818eabac9330bd4c0a2062 --- dali/devel-api/adaptor-framework/window-devel.cpp | 12 +--- dali/devel-api/adaptor-framework/window-devel.h | 30 ---------- .../adaptor-framework/scene-holder-impl.cpp | 39 ++++++++----- .../adaptor-framework/scene-holder-impl.h | 17 +++++- dali/public-api/adaptor-framework/window.cpp | 20 +++++++ dali/public-api/adaptor-framework/window.h | 64 ++++++++++++++++++++-- 6 files changed, 120 insertions(+), 62 deletions(-) mode change 100755 => 100644 dali/devel-api/adaptor-framework/window-devel.cpp mode change 100755 => 100644 dali/devel-api/adaptor-framework/window-devel.h mode change 100755 => 100644 dali/public-api/adaptor-framework/window.h diff --git a/dali/devel-api/adaptor-framework/window-devel.cpp b/dali/devel-api/adaptor-framework/window-devel.cpp old mode 100755 new mode 100644 index 7d046ec..cd0819f --- a/dali/devel-api/adaptor-framework/window-devel.cpp +++ b/dali/devel-api/adaptor-framework/window-devel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * 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. @@ -88,16 +88,6 @@ EventProcessingFinishedSignalType& EventProcessingFinishedSignal( Window window return GetImplementation( window ).EventProcessingFinishedSignal(); } -KeyEventSignalType& KeyEventSignal( Window window ) -{ - return GetImplementation( window ).KeyEventSignal(); -} - -TouchSignalType& TouchSignal( Window window ) -{ - return GetImplementation( window ).TouchSignal(); -} - WheelEventSignalType& WheelEventSignal( Window window ) { return GetImplementation( window ).WheelEventSignal(); diff --git a/dali/devel-api/adaptor-framework/window-devel.h b/dali/devel-api/adaptor-framework/window-devel.h old mode 100755 new mode 100644 index 3c97559..b70876d --- a/dali/devel-api/adaptor-framework/window-devel.h +++ b/dali/devel-api/adaptor-framework/window-devel.h @@ -124,36 +124,6 @@ DALI_ADAPTOR_API Window Get( Actor actor ); DALI_ADAPTOR_API EventProcessingFinishedSignalType& EventProcessingFinishedSignal( Window window ); /** - * @brief This signal is emitted when key event is received. - * - * A callback of the following type may be connected: - * @code - * void YourCallbackName(const KeyEvent& event); - * @endcode - * @param[in] window The window instance - * @return The signal to connect to - */ -DALI_ADAPTOR_API KeyEventSignalType& KeyEventSignal( Window window ); - -/** - * @brief This signal is emitted when the screen is touched and when the touch ends - * (i.e. the down & up touch events only). - * - * If there are multiple touch points, then this will be emitted when the first touch occurs and - * then when the last finger is lifted. - * An interrupted event will also be emitted (if it occurs). - * A callback of the following type may be connected: - * @code - * void YourCallbackName( TouchData event ); - * @endcode - * - * @param[in] window The window instance - * @return The touch signal to connect to - * @note Motion events are not emitted. - */ -DALI_ADAPTOR_API TouchSignalType& TouchSignal( Window window ); - -/** * @brief This signal is emitted when wheel event is received. * * A callback of the following type may be connected: diff --git a/dali/integration-api/adaptor-framework/scene-holder-impl.cpp b/dali/integration-api/adaptor-framework/scene-holder-impl.cpp index e296ea1..e545376 100644 --- a/dali/integration-api/adaptor-framework/scene-holder-impl.cpp +++ b/dali/integration-api/adaptor-framework/scene-holder-impl.cpp @@ -20,6 +20,7 @@ // EXTERNAL INCLUDES #include +#include #include #include #include @@ -121,6 +122,7 @@ SceneHolder::SceneHolder() mId( mSceneHolderCounter++ ), mSurface( nullptr ), mAdaptor( nullptr ), + mDpi(), mIsBeingDeleted( false ), mAdaptorStarted( false ), mVisible( true ) @@ -186,6 +188,11 @@ Dali::Integration::Scene SceneHolder::GetScene() return mScene; } +Uint16Pair SceneHolder::GetDpi() const +{ + return mDpi; +} + void SceneHolder::SetSurface(Dali::RenderSurfaceInterface* surface) { mSurface.reset( surface ); @@ -194,11 +201,7 @@ void SceneHolder::SetSurface(Dali::RenderSurfaceInterface* surface) SurfaceResized(); - unsigned int dpiHorizontal, dpiVertical; - dpiHorizontal = dpiVertical = 0; - - mSurface->GetDpi( dpiHorizontal, dpiVertical ); - mScene.SetDpi( Vector2( static_cast( dpiHorizontal ), static_cast( dpiVertical ) ) ); + InitializeDpi(); mSurface->SetAdaptor( *mAdaptor ); mSurface->SetScene( mScene ); @@ -252,6 +255,8 @@ void SceneHolder::SetAdaptor(Dali::Adaptor& adaptor) return; } + DALI_ASSERT_DEBUG(mSurface && "Surface needs to be set before calling this method\n"); + mAdaptorStarted = true; // Create the scene @@ -264,17 +269,10 @@ void SceneHolder::SetAdaptor(Dali::Adaptor& adaptor) // Create an observer for the adaptor lifecycle mAdaptor->AddObserver( *mLifeCycleObserver ); - if ( mSurface ) - { - unsigned int dpiHorizontal, dpiVertical; - dpiHorizontal = dpiVertical = 0; - - mSurface->GetDpi( dpiHorizontal, dpiVertical ); - mScene.SetDpi( Vector2( static_cast( dpiHorizontal ), static_cast( dpiVertical ) ) ); + InitializeDpi(); - mSurface->SetAdaptor( *mAdaptor ); - mSurface->SetScene( mScene ); - } + mSurface->SetAdaptor( *mAdaptor ); + mSurface->SetScene( mScene ); OnAdaptorSet( adaptor ); } @@ -403,6 +401,17 @@ void SceneHolder::Reset() mAdaptor->ProcessCoreEvents(); } +void SceneHolder::InitializeDpi() +{ + unsigned int dpiHorizontal, dpiVertical; + dpiHorizontal = dpiVertical = 0; + + mSurface->GetDpi( dpiHorizontal, dpiVertical ); + mScene.SetDpi( Vector2( static_cast( dpiHorizontal ), static_cast( dpiVertical ) ) ); + + mDpi.SetX( dpiHorizontal ); + mDpi.SetY( dpiVertical ); +} }// Adaptor diff --git a/dali/integration-api/adaptor-framework/scene-holder-impl.h b/dali/integration-api/adaptor-framework/scene-holder-impl.h index 38560cf..9b14bfc 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) 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. @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -106,6 +107,12 @@ 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 */ @@ -295,6 +302,11 @@ private: */ void Reset(); + /** + * Initializes the DPI for this object. + */ + void InitializeDpi(); + private: static uint32_t mSceneHolderCounter; ///< A counter to track the SceneHolder creation @@ -313,6 +325,9 @@ protected: Dali::Integration::TouchEventCombiner mCombiner; ///< Combines multi-touch events. + + Uint16Pair mDpi; ///< The DPI for this SceneHolder. + 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 diff --git a/dali/public-api/adaptor-framework/window.cpp b/dali/public-api/adaptor-framework/window.cpp index 554ab88..c073254 100644 --- a/dali/public-api/adaptor-framework/window.cpp +++ b/dali/public-api/adaptor-framework/window.cpp @@ -122,6 +122,11 @@ Layer Window::GetLayer( uint32_t depth ) const return GetImplementation( *this ).GetLayer( depth ); } +Uint16Pair Window::GetDpi() const +{ + return GetImplementation(*this).GetDpi(); +} + void Window::SetClass( std::string name, std::string klass ) { GetImplementation(*this).SetClass( name, klass ); @@ -323,6 +328,21 @@ void Window::SetTransparency( bool transparent ) GetImplementation(*this).SetTransparency( transparent ); } +Dali::RenderTaskList Window::GetRenderTaskList() +{ + return GetImplementation(*this).GetRenderTaskList(); +} + +Window::KeyEventSignalType& Window::KeyEventSignal() +{ + return GetImplementation(*this).KeyEventSignal(); +} + +Window::TouchSignalType& Window::TouchSignal() +{ + return GetImplementation(*this).TouchSignal(); +} + Window::Window( Internal::Adaptor::Window* window ) : BaseHandle( window ) { diff --git a/dali/public-api/adaptor-framework/window.h b/dali/public-api/adaptor-framework/window.h old mode 100755 new mode 100644 index 421b65d..05a86de --- a/dali/public-api/adaptor-framework/window.h +++ b/dali/public-api/adaptor-framework/window.h @@ -55,6 +55,9 @@ class DragAndDropDetector; class Orientation; class Actor; class Layer; +class RenderTaskList; +class TouchData; +struct KeyEvent; /** * @brief The window class is used internally for drawing. @@ -67,12 +70,15 @@ class DALI_ADAPTOR_API Window : public BaseHandle { public: - typedef Uint16Pair WindowSize; ///< Window size type @SINCE_1_2.60 - typedef Uint16Pair WindowPosition; ///< Window position type @SINCE_1_2.60 + using WindowSize = Uint16Pair ; ///< Window size type @SINCE_1_2.60 + using WindowPosition = Uint16Pair; ///< Window position type @SINCE_1_2.60 + + using ResizedSignalType = Signal< void (WindowSize) >; ///< @DEPRECATED_1_4.35 @brief Window resized signal type @SINCE_1_2.60 + using FocusChangeSignalType = Signal< void (Window,bool) >; ///< Window focus signal type @SINCE_1_4.35 + using ResizeSignalType = Signal< void (Window,WindowSize) >; ///< Window resized signal type @SINCE_1_4.35 + using KeyEventSignalType = Signal< void (const KeyEvent&) >; ///< Key event signal type + using TouchSignalType = Signal< void (const TouchData&) >; ///< Touch signal type - typedef Signal< void (WindowSize) > ResizedSignalType; ///< @DEPRECATED_1_4.35 @brief Window resized signal type @SINCE_1_2.60 - typedef Signal< void (Window,bool) > FocusChangeSignalType; ///< Window focus signal type @SINCE_1_4.35 - typedef Signal< void (Window,WindowSize) > ResizeSignalType; ///< Window resized signal type @SINCE_1_4.35 public: // Enumerations @@ -271,6 +277,14 @@ public: Layer GetLayer( uint32_t depth ) const; /** + * @brief Retrieves the DPI of the window. + * + * @SINCE_1_9.21 + * @return The DPI of the window + */ + Uint16Pair GetDpi() const; + + /** * @brief Sets the window name and class string. * @SINCE_1_0.0 * @param[in] name The name of the window @@ -576,6 +590,14 @@ public: */ void SetTransparency( bool transparent ); + /** + * @brief Retrieves the list of render-tasks in the window. + * + * @SINCE_1_9.21 + * @return A valid handle to a RenderTaskList + */ + RenderTaskList GetRenderTaskList(); + public: // Signals /** @@ -622,6 +644,38 @@ public: // Signals */ ResizeSignalType& ResizeSignal(); + /** + * @brief This signal is emitted when key event is received. + * + * A callback of the following type may be connected: + * @code + * void YourCallbackName(const KeyEvent& event); + * @endcode + * + * @SINCE_1_9.21 + * @return The signal to connect to + */ + KeyEventSignalType& KeyEventSignal(); + + /** + * @brief This signal is emitted when the screen is touched and when the touch ends + * (i.e. the down & up touch events only). + * + * If there are multiple touch points, then this will be emitted when the first touch occurs and + * then when the last finger is lifted. + * An interrupted event will also be emitted (if it occurs). + * A callback of the following type may be connected: + * @code + * void YourCallbackName(const TouchData& event); + * @endcode + * + * @SINCE_1_9.21 + * @return The touch signal to connect to + * + * @note Motion events are not emitted. + */ + TouchSignalType& TouchSignal(); + public: // Not intended for application developers /// @cond internal /** -- 2.7.4