From: Adeel Kazmi Date: Fri, 3 May 2019 13:52:52 +0000 (+0000) Subject: Merge "Remove CXX03 Build & old Tizen Version Builds" into devel/master X-Git-Tag: dali_1.4.19~5 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git;a=commitdiff_plain;h=34aec01c5e704ac218b08d007426da6f941b801e;hp=25cfbb615d6b4080d1d7f18be8710317c06dfe1a Merge "Remove CXX03 Build & old Tizen Version Builds" into devel/master --- diff --git a/build/tizen/adaptor/Makefile.am b/build/tizen/adaptor/Makefile.am index 4f91b9c..ef77c19 100644 --- a/build/tizen/adaptor/Makefile.am +++ b/build/tizen/adaptor/Makefile.am @@ -45,6 +45,7 @@ LIBDALI_ADAPTOR_LA_SOURCES = \ $(adaptor_imaging_ubuntu_x11_src_files) \ $(adaptor_input_common_src_files) \ $(adaptor_input_ubuntu_x11_src_files) \ + $(adaptor_integration_api_src_files) \ $(adaptor_legacy_common_src_files) \ $(adaptor_network_common_src_files) \ $(adaptor_public_api_src_files) \ @@ -100,6 +101,7 @@ LIBDALI_ADAPTOR_LA_SOURCES = \ $(adaptor_imaging_tizen_src_files) \ $(adaptor_input_common_src_files) \ $(adaptor_input_tizen_wayland_src_files) \ + $(adaptor_integration_api_src_files) \ $(adaptor_legacy_common_src_files) \ $(adaptor_network_common_src_files) \ $(adaptor_public_api_src_files) \ @@ -164,6 +166,7 @@ LIBDALI_ADAPTOR_LA_SOURCES = \ $(adaptor_imaging_tizen_src_files) \ $(adaptor_input_common_src_files) \ $(adaptor_input_tizen_wayland_src_files) \ + $(adaptor_integration_api_src_files) \ $(adaptor_legacy_common_src_files) \ $(adaptor_network_common_src_files) \ $(adaptor_public_api_src_files) \ @@ -227,6 +230,7 @@ LIBDALI_ADAPTOR_LA_SOURCES = \ $(adaptor_imaging_tizen_src_files) \ $(adaptor_input_common_src_files) \ $(adaptor_input_tizen_wayland_src_files) \ + $(adaptor_integration_api_src_files) \ $(adaptor_legacy_common_src_files) \ $(adaptor_network_common_src_files) \ $(adaptor_public_api_src_files) \ @@ -289,6 +293,7 @@ LIBDALI_ADAPTOR_LA_SOURCES = \ $(adaptor_imaging_tizen_src_files) \ $(adaptor_input_common_src_files) \ $(adaptor_input_tizen_wayland_src_files) \ + $(adaptor_integration_api_src_files) \ $(adaptor_legacy_common_src_files) \ $(adaptor_network_common_src_files) \ $(adaptor_public_api_src_files) \ @@ -354,6 +359,7 @@ LIBDALI_ADAPTOR_LA_SOURCES = \ $(adaptor_imaging_tizen_src_files) \ $(adaptor_input_common_src_files) \ $(adaptor_input_tizen_wayland_src_files) \ + $(adaptor_integration_api_src_files) \ $(adaptor_legacy_common_src_files) \ $(adaptor_network_common_src_files) \ $(adaptor_public_api_src_files) \ diff --git a/dali/devel-api/adaptor-framework/application-devel.cpp b/dali/devel-api/adaptor-framework/application-devel.cpp index 196664a..b9ef5dd 100644 --- a/dali/devel-api/adaptor-framework/application-devel.cpp +++ b/dali/devel-api/adaptor-framework/application-devel.cpp @@ -19,6 +19,12 @@ #include #include +#ifdef DALI_ADAPTOR_COMPILATION +#include +#else +#include +#endif + namespace Dali { diff --git a/dali/integration-api/adaptor.h b/dali/integration-api/adaptor.h index 8b5e658..279ccb8 100755 --- a/dali/integration-api/adaptor.h +++ b/dali/integration-api/adaptor.h @@ -2,7 +2,7 @@ #define DALI_INTEGRATION_ADAPTOR_H /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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 // INTERNAL INCLUDES @@ -43,6 +44,12 @@ namespace Dali class RenderSurfaceInterface; +namespace Integration +{ +class SceneHolder; +} + + namespace Internal { namespace Adaptor @@ -154,6 +161,42 @@ public: static Adaptor& New( Window window, const Dali::RenderSurfaceInterface& surface, Configuration::ContextLoss configuration = Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS); /** + * @brief Create a new adaptor using the SceneHolder. + * + * @param[in] sceneHolder The SceneHolder to draw onto + * @return a reference to the adaptor handle + */ + static Adaptor& New( Dali::Integration::SceneHolder sceneHolder ); + + /** + * @brief Create a new adaptor using the SceneHolder. + * + * @param[in] sceneHolder The SceneHolder to draw onto + * @param[in] configuration The context loss configuration. + * @return a reference to the adaptor handle + */ + static Adaptor& New( Dali::Integration::SceneHolder sceneHolder, Configuration::ContextLoss configuration ); + + /** + * @brief Create a new adaptor using render surface. + * + * @param[in] sceneHolder The SceneHolder to draw onto + * @param[in] surface The surface to draw onto + * @return a reference to the adaptor handle + */ + static Adaptor& New( Dali::Integration::SceneHolder sceneHolder, const Dali::RenderSurfaceInterface& surface ); + + /** + * @brief Create a new adaptor using render surface. + * + * @param[in] sceneHolder The SceneHolder to draw onto + * @param[in] surface The surface to draw onto + * @param[in] configuration The context loss configuration. + * @return a reference to the adaptor handle + */ + static Adaptor& New( Dali::Integration::SceneHolder sceneHolder, const Dali::RenderSurfaceInterface& surface, Configuration::ContextLoss configuration = Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS); + + /** * @brief Virtual Destructor. */ virtual ~Adaptor(); @@ -224,6 +267,14 @@ public: void ReplaceSurface( Window window, Dali::RenderSurfaceInterface& surface ); /** + * @brief Replaces the rendering surface + * + * @param[in] sceneHolder The SceneHolder to replace the surface for + * @param[in] surface to use + */ + void ReplaceSurface( Dali::Integration::SceneHolder sceneHolder, Dali::RenderSurfaceInterface& surface ); + + /** * @brief Get the render surface the adaptor is using to render to. * * @return reference to current render surface diff --git a/dali/integration-api/file.list b/dali/integration-api/file.list index 40f91cf..08e5df8 100755 --- a/dali/integration-api/file.list +++ b/dali/integration-api/file.list @@ -1,3 +1,7 @@ +adaptor_integration_api_src_files = \ + $(adaptor_integration_api_dir)/scene-holder.cpp \ + $(adaptor_integration_api_dir)/scene-holder-impl.cpp + adaptor_integration_api_header_files = \ $(adaptor_integration_api_dir)/adaptor.h \ $(adaptor_integration_api_dir)/egl-interface.h \ @@ -5,6 +9,8 @@ adaptor_integration_api_header_files = \ $(adaptor_integration_api_dir)/native-render-surface.h \ $(adaptor_integration_api_dir)/native-render-surface-factory.h \ $(adaptor_integration_api_dir)/render-surface-interface.h \ + $(adaptor_integration_api_dir)/scene-holder.h \ + $(adaptor_integration_api_dir)/scene-holder-impl.h \ $(adaptor_integration_api_dir)/thread-synchronization-interface.h \ $(adaptor_integration_api_dir)/trigger-event-interface.h \ $(adaptor_integration_api_dir)/trigger-event-factory-interface.h \ diff --git a/dali/integration-api/scene-holder-impl.cpp b/dali/integration-api/scene-holder-impl.cpp new file mode 100644 index 0000000..e085ed3 --- /dev/null +++ b/dali/integration-api/scene-holder-impl.cpp @@ -0,0 +1,209 @@ +/* + * Copyright (c) 2019 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +// EXTERNAL HEADERS +#include +#include + +// INTERNAL HEADERS +#include + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ + +uint32_t SceneHolder::mSceneHolderCounter = 0; + +class SceneHolder::SceneHolderLifeCycleObserver : public LifeCycleObserver +{ +public: + + SceneHolderLifeCycleObserver(Adaptor*& adaptor) + : mAdaptor( adaptor ) + { + }; + +private: // Adaptor::LifeCycleObserver interface + + void OnStart() override {}; + void OnPause() override {}; + void OnResume() override {}; + void OnStop() override {}; + void OnDestroy() override + { + mAdaptor = nullptr; + }; + +private: + Adaptor*& mAdaptor; +}; + + +SceneHolder::SceneHolder() +: mLifeCycleObserver( new SceneHolderLifeCycleObserver( mAdaptor ) ), + mId( mSceneHolderCounter++ ), + mSurface( nullptr ), + mAdaptor( nullptr ), + mAdaptorStarted( false ), + mVisible( true ) +{ +} + +SceneHolder::~SceneHolder() +{ + if ( mAdaptor ) + { + mAdaptor->RemoveObserver( *mLifeCycleObserver.get() ); + mAdaptor->RemoveWindow( this ); + mAdaptor = nullptr; + } +} + +void SceneHolder::Add( Dali::Actor actor ) +{ + if ( mScene ) + { + mScene.Add( actor ); + } +} + +void SceneHolder::Remove( Dali::Actor actor ) +{ + if ( mScene ) + { + mScene.Remove( actor ); + } +} + +Dali::Layer SceneHolder::GetRootLayer() const +{ + return mScene ? mScene.GetRootLayer() : Dali::Layer(); +} + +uint32_t SceneHolder::GetId() const +{ + return mId; +} + +std::string SceneHolder::GetName() const +{ + return mName; +} + +bool SceneHolder::IsVisible() const +{ + return mVisible; +} + +Dali::Integration::Scene SceneHolder::GetScene() +{ + return mScene; +} + +void SceneHolder::SetSurface(Dali::RenderSurfaceInterface* surface) +{ + mSurface.reset( surface ); + + mScene.SetSurface( *mSurface.get() ); + + unsigned int dpiHorizontal, dpiVertical; + dpiHorizontal = dpiVertical = 0; + + mSurface->GetDpi( dpiHorizontal, dpiVertical ); + mScene.SetDpi( Vector2( static_cast( dpiHorizontal ), static_cast( dpiVertical ) ) ); + + mSurface->SetAdaptor( *mAdaptor ); + + OnSurfaceSet( surface ); +} + +Dali::RenderSurfaceInterface* SceneHolder::GetSurface() const +{ + return mSurface.get(); +} + +void SceneHolder::SetBackgroundColor( Vector4 color ) +{ + if ( mSurface ) + { + mSurface->SetBackgroundColor( color ); + } +} + +Vector4 SceneHolder::GetBackgroundColor() const +{ + return mSurface ? mSurface->GetBackgroundColor() : Vector4(); +} + +void SceneHolder::SetAdaptor(Dali::Adaptor& adaptor) +{ + // Avoid doing this more than once + if( mAdaptorStarted ) + { + return; + } + + mAdaptorStarted = true; + + // Create the scene + PositionSize positionSize = mSurface->GetPositionSize(); + mScene = Dali::Integration::Scene::New( Vector2( positionSize.width, positionSize.height ) ); + mScene.SetSurface( *mSurface.get() ); + + Internal::Adaptor::Adaptor& adaptorImpl = Internal::Adaptor::Adaptor::GetImplementation( adaptor ); + mAdaptor = &adaptorImpl; + + // 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 ) ) ); + + mSurface->SetAdaptor( *mAdaptor ); + } + + OnAdaptorSet( adaptor ); +} + +void SceneHolder::Pause() +{ + OnPause(); +} + +void SceneHolder::Resume() +{ + OnResume(); +} + +}// Adaptor + +}// Internal + +} // Dali diff --git a/dali/integration-api/scene-holder-impl.h b/dali/integration-api/scene-holder-impl.h new file mode 100644 index 0000000..d720f7f --- /dev/null +++ b/dali/integration-api/scene-holder-impl.h @@ -0,0 +1,255 @@ +#ifndef DALI_INTEGRATION_INTERNAL_SCENEHOLDER_H +#define DALI_INTEGRATION_INTERNAL_SCENEHOLDER_H + +/* + * Copyright (c) 2019 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// EXTERNAL INCLUDES +#include +#include +#include + +// INTERNAL INCLUDES +#include +#include + +#ifdef DALI_ADAPTOR_COMPILATION +#include +#else +#include +#endif + +#include + +namespace Dali +{ + +class Any; +class Adaptor; +class Actor; +class Layer; +struct TouchPoint; +struct WheelEvent; +struct KeyEvent; + +namespace Integration +{ + +class Scene; + +} + +namespace Internal +{ + +namespace Adaptor +{ + +class SceneHolder; +using SceneHolderPtr = IntrusivePtr< SceneHolder >; + +/** + * @brief SceneHolder creates a Scene for rendering. + */ +class SceneHolder : public BaseObject +{ + +public: + + /** + * @copydoc Dali::Integration::SceneHolder::Add + */ + void Add( Dali::Actor actor ); + + /** + * @copydoc Dali::Integration::SceneHolder::Remove + */ + void Remove( Dali::Actor actor ); + + /** + * @copydoc Dali::Integration::SceneHolder::GetRootLayer + */ + Dali::Layer GetRootLayer() const; + + /** + * @brief Gets the window name. + * @return The name of the window + */ + std::string GetName() const; + + /** + * @brief Retrieve the unique ID of the window. + * @return The ID + */ + uint32_t GetId() const; + + /** + * @brief Retrieve the Scene. + * @return The Scene + */ + Dali::Integration::Scene GetScene(); + + /** + * @brief Set the render surface + * @param[in] surface The render surface + */ + void SetSurface( Dali::RenderSurfaceInterface* surface ); + + /** + * @brief Get the render surface + * @return The render surface + */ + Dali::RenderSurfaceInterface* GetSurface() const; + + /** + * @brief Set the adaptor to the scene holder + * @param[in] adaptor An initialized adaptor + */ + void SetAdaptor( Dali::Adaptor& adaptor ); + + /** + * @copydoc Dali::Integration::SceneHolder::SetBackgroundColor + */ + void SetBackgroundColor( Dali::Vector4 color ); + + /** + * @copydoc Dali::Integration::SceneHolder::GetBackgroundColor + */ + Vector4 GetBackgroundColor() const; + + /** + * @brief Pause the rendering of the scene holder. + */ + void Pause(); + + /** + * @brief Resume the rendering of the scene holder (from pause). + */ + void Resume(); + +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. + */ + virtual bool IsVisible() const; + +public: // The following methods must be overridden + + /** + * @copydoc Dali::Integration::SceneHolder::GetNativeHandle + */ + virtual Dali::Any GetNativeHandle() const = 0; + + /** + * @copydoc Dali::Integration::SceneHolder::FeedTouchPoint + */ + virtual void FeedTouchPoint( Dali::TouchPoint& point, int timeStamp ) = 0; + + /** + * @copydoc Dali::Integration::SceneHolder::FeedWheelEvent + */ + virtual void FeedWheelEvent( Dali::WheelEvent& wheelEvent ) = 0; + + /** + * @copydoc Dali::Integration::SceneHolder::FeedKeyEvent + */ + virtual void FeedKeyEvent( Dali::KeyEvent& keyEvent ) = 0; + +protected: + + // Constructor + SceneHolder(); + + // Undefined + SceneHolder(const SceneHolder&) = delete; + + // Undefined + SceneHolder& operator=(const SceneHolder& rhs) = delete; + + /** + * virtual destructor + */ + virtual ~SceneHolder(); + +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 ) {}; + + /** + * @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 ) {}; + + /** + * @brief Called by the base class to inform deriving classes that we are being paused. + */ + virtual void OnPause() {}; + + /** + * @brief Called by the base class to inform deriving classes that we are resuming from a paused state. + */ + virtual void OnResume() {}; + +private: + + static uint32_t mSceneHolderCounter; ///< A counter to track the SceneHolder creation + + class SceneHolderLifeCycleObserver; + std::unique_ptr< SceneHolderLifeCycleObserver > 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< Dali::RenderSurfaceInterface > mSurface; ///< The window rendering surface + Adaptor* mAdaptor; ///< The adaptor + + bool mAdaptorStarted:1; ///< Whether the adaptor has started or not + bool mVisible:1; ///< Whether the scene is visible or not +}; + +} // Adaptor + +} // Internal + +// Get impl of handle +inline Internal::Adaptor::SceneHolder& GetImplementation( Dali::Integration::SceneHolder& sceneHolder ) +{ + DALI_ASSERT_ALWAYS( sceneHolder && "SceneHolder handle is empty" ); + Dali::RefObject& object = sceneHolder.GetBaseObject(); + return static_cast( object ); +} + +inline const Internal::Adaptor::SceneHolder& GetImplementation( const Dali::Integration::SceneHolder& sceneHolder ) +{ + DALI_ASSERT_ALWAYS( sceneHolder && "SceneHolder handle is empty" ); + const Dali::RefObject& object = sceneHolder.GetBaseObject(); + return static_cast( object ); +} + +} // Dali + +#endif // DALI_INTEGRATION_INTERNAL_SCENEHOLDER_H diff --git a/dali/integration-api/scene-holder.cpp b/dali/integration-api/scene-holder.cpp new file mode 100644 index 0000000..9b6c91e --- /dev/null +++ b/dali/integration-api/scene-holder.cpp @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2019 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +// INTERNAL INCLUDES +#include +#include + +namespace Dali +{ + +namespace Integration +{ + +SceneHolder::SceneHolder() +{ +} + +SceneHolder::~SceneHolder() +{ +} + +SceneHolder::SceneHolder( const SceneHolder& handle ) +:BaseHandle(handle) +{ +} + +SceneHolder::SceneHolder( Internal::Adaptor::SceneHolder* internal ) +: BaseHandle(internal) +{ +} + +SceneHolder& SceneHolder::operator=( const SceneHolder& rhs ) +{ + BaseHandle::operator=(rhs); + return *this; +} + +void SceneHolder::Add( Actor actor ) +{ + GetImplementation(*this).Add( actor ); +} + +void SceneHolder::Remove( Actor actor ) +{ + GetImplementation(*this).Remove( actor ); +} + +Layer SceneHolder::GetRootLayer() const +{ + return GetImplementation(*this).GetRootLayer(); +} + +void SceneHolder::SetBackgroundColor( Vector4 color ) +{ + GetImplementation(*this).SetBackgroundColor( color ); +} + +Vector4 SceneHolder::GetBackgroundColor() const +{ + return GetImplementation(*this).GetBackgroundColor(); +} + +void SceneHolder::FeedTouchPoint( Dali::TouchPoint& point, int timeStamp ) +{ + GetImplementation(*this).FeedTouchPoint( point, timeStamp ); +} + +void SceneHolder::FeedWheelEvent( Dali::WheelEvent& wheelEvent ) +{ + GetImplementation(*this).FeedWheelEvent( wheelEvent ); +} + +void SceneHolder::FeedKeyEvent( Dali::KeyEvent& keyEvent ) +{ + GetImplementation(*this).FeedKeyEvent( keyEvent ); +} + +}// Integration + +} // Dali diff --git a/dali/integration-api/scene-holder.h b/dali/integration-api/scene-holder.h new file mode 100644 index 0000000..57c648b --- /dev/null +++ b/dali/integration-api/scene-holder.h @@ -0,0 +1,168 @@ +#ifndef DALI_INTEGRATION_SCENEHOLDER_H +#define DALI_INTEGRATION_SCENEHOLDER_H + +/* + * Copyright (c) 2019 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// EXTERNAL INCLUDES +#include +#include +#include + +namespace Dali +{ + +class Actor; +class Layer; +class Any; +struct TouchPoint; +struct WheelEvent; +struct KeyEvent; + +namespace Internal DALI_INTERNAL +{ + +namespace Adaptor +{ + +class SceneHolder; + +} + +} + +namespace Integration +{ + +/** + * @brief SceneHolder is responsible for creating a Scene for rendering. + */ +class DALI_ADAPTOR_API SceneHolder : public BaseHandle +{ +public: + + /** + * @brief Create an uninitialized SceneHolder handle. + */ + SceneHolder(); + + /** + * @brief Destructor + * + * This is non-virtual since derived Handle types must not contain data or virtual methods. + */ + ~SceneHolder(); + + /** + * @brief This copy constructor is required for (smart) pointer semantics. + * + * @param [in] handle A reference to the copied handle + */ + SceneHolder( const SceneHolder& handle ); + + /** + * @brief This assignment operator is required for (smart) pointer semantics. + * + * @param [in] rhs A reference to the copied handle + * @return A reference to this + */ + SceneHolder& operator=( const SceneHolder& rhs ); + + /** + * @brief Adds a child Actor to the SceneHolder. + * + * The child will be referenced. + * @param[in] actor The child + * @pre The actor has been initialized. + * @pre The actor does not have a parent. + */ + void Add( Actor actor ); + + /** + * @brief Removes a child Actor from the SceneHolder. + * + * The child will be unreferenced. + * @param[in] actor The child + * @pre The actor has been added to the SceneHolder. + */ + void Remove( Actor actor ); + + /** + * @brief Returns the Scene's Root Layer. + * + * @return The root layer + */ + Layer GetRootLayer() const; + + /** + * @brief Sets the background color. + * + * @param[in] color The new background color + */ + void SetBackgroundColor( Vector4 color ); + + /** + * @brief Gets the background color. + * + * @return The background color + */ + Vector4 GetBackgroundColor() const; + + /** + * @brief Gets the native handle. + * + * When users call this function, it wraps the actual type used by the underlying system. + * + * @return The native handle or an empty handle + */ + Any GetNativeHandle() const; + + /** + * @brief Feed (Send) touch event to core + * @param[in] point The touch point + * @param[in] timeStamp The time stamp + */ + void FeedTouchPoint( Dali::TouchPoint& point, int timeStamp ); + + /** + * @brief Feed (Send) wheel event to core + * @param[in] wheelEvent The wheel event + */ + void FeedWheelEvent( Dali::WheelEvent& wheelEvent ); + + /** + * @brief Feed (Send) key event to core + * @param[in] keyEvent The key event holding the key information. + */ + void FeedKeyEvent( Dali::KeyEvent& keyEvent ); + +public: // Not intended for application developers + + /** + * @brief This constructor is used internally to create additional SceneHolder handles. + * + * @param[in] sceneHolder A pointer to a newly allocated Dali resource + */ + explicit DALI_INTERNAL SceneHolder( Internal::Adaptor::SceneHolder* sceneHolder ); + +}; + +} // namespace Integration + +} // namespace Dali + +#endif // DALI_INTEGRATION_SCENEHOLDER_H diff --git a/dali/internal/adaptor/common/adaptor-impl.cpp b/dali/internal/adaptor/common/adaptor-impl.cpp index d943263..a28c2c0 100755 --- a/dali/internal/adaptor/common/adaptor-impl.cpp +++ b/dali/internal/adaptor/common/adaptor-impl.cpp @@ -82,7 +82,7 @@ namespace thread_local Adaptor* gThreadLocalAdaptor = NULL; // raw thread specific pointer to allow Adaptor::Get } // unnamed namespace -Dali::Adaptor* Adaptor::New( Dali::Window window, Dali::RenderSurfaceInterface *surface, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions ) +Dali::Adaptor* Adaptor::New( Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface *surface, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions ) { Dali::Adaptor* adaptor = new Dali::Adaptor; Adaptor* impl = new Adaptor( window, *adaptor, surface, environmentOptions ); @@ -97,15 +97,15 @@ Dali::Adaptor* Adaptor::New( Dali::Window window, Dali::RenderSurfaceInterface * return adaptor; } -Dali::Adaptor* Adaptor::New( Dali::Window window, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions ) +Dali::Adaptor* Adaptor::New( Dali::Integration::SceneHolder window, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions ) { - Window& windowImpl = Dali::GetImplementation( window ); + Internal::Adaptor::SceneHolder& windowImpl = Dali::GetImplementation( window ); Dali::Adaptor* adaptor = New( window, windowImpl.GetSurface(), configuration, environmentOptions ); windowImpl.SetAdaptor( *adaptor ); return adaptor; } -Dali::Adaptor* Adaptor::New( GraphicsFactory& graphicsFactory, Dali::Window window, Dali::RenderSurfaceInterface *surface, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions ) +Dali::Adaptor* Adaptor::New( GraphicsFactory& graphicsFactory, Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface *surface, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions ) { Dali::Adaptor* adaptor = new Dali::Adaptor; // Public adaptor Adaptor* impl = new Adaptor( window, *adaptor, surface, environmentOptions ); // Impl adaptor @@ -116,9 +116,9 @@ Dali::Adaptor* Adaptor::New( GraphicsFactory& graphicsFactory, Dali::Window wind return adaptor; } // Called second -Dali::Adaptor* Adaptor::New( GraphicsFactory& graphicsFactory, Dali::Window window, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions ) +Dali::Adaptor* Adaptor::New( GraphicsFactory& graphicsFactory, Dali::Integration::SceneHolder window, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions ) { - Window& windowImpl = Dali::GetImplementation( window ); + Internal::Adaptor::SceneHolder& windowImpl = Dali::GetImplementation( window ); Dali::Adaptor* adaptor = New( graphicsFactory, window, windowImpl.GetSurface(), configuration, environmentOptions ); windowImpl.SetAdaptor( *adaptor ); return adaptor; @@ -155,7 +155,7 @@ void Adaptor::Initialize( GraphicsFactory& graphicsFactory, Dali::Configuration: mCallbackManager = CallbackManager::New(); - WindowPtr defaultWindow = mWindows.front(); + SceneHolderPtr defaultWindow = mWindows.front(); DALI_ASSERT_DEBUG( defaultWindow->GetSurface() && "Surface not initialized" ); @@ -184,7 +184,7 @@ void Adaptor::Initialize( GraphicsFactory& graphicsFactory, Dali::Configuration: mGraphics->GetDepthBufferRequired(), mGraphics->GetStencilBufferRequired() ); - defaultWindow->SetAdaptor( *this ); + defaultWindow->SetAdaptor( Get() ); const unsigned int timeInterval = mEnvironmentOptions->GetObjectProfilerInterval(); if( 0u < timeInterval ) @@ -328,7 +328,7 @@ void Adaptor::Start() // Start the callback manager mCallbackManager->Start(); - WindowPtr defaultWindow = mWindows.front(); + SceneHolderPtr defaultWindow = mWindows.front(); unsigned int dpiHor, dpiVer; dpiHor = dpiVer = 0; @@ -369,7 +369,7 @@ void Adaptor::Pause() } // Pause all windows event handlers when adaptor paused - for( WindowPtr window : mWindows ) + for( SceneHolderPtr window : mWindows ) { window->Pause(); } @@ -397,7 +397,7 @@ void Adaptor::Resume() mState = RUNNING; // Reset the event handlers when adaptor resumed - for( WindowPtr window : mWindows ) + for( SceneHolderPtr window : mWindows ) { window->Resume(); } @@ -486,10 +486,10 @@ void Adaptor::FeedKeyEvent( KeyEvent& keyEvent ) mWindows.front()->FeedKeyEvent( keyEvent ); } -void Adaptor::ReplaceSurface( Dali::Window window, Dali::RenderSurfaceInterface& newSurface ) +void Adaptor::ReplaceSurface( Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface& newSurface ) { - Window* windowImpl = &Dali::GetImplementation( window ); - for( WindowPtr windowPtr : mWindows ) + Internal::Adaptor::SceneHolder* windowImpl = &Dali::GetImplementation( window ); + for( SceneHolderPtr windowPtr : mWindows ) { if( windowPtr.Get() == windowImpl ) // the window is not deleted { @@ -498,7 +498,7 @@ void Adaptor::ReplaceSurface( Dali::Window window, Dali::RenderSurfaceInterface& mResizedSignal.Emit( mAdaptor ); - windowImpl->SetSurface( static_cast( &newSurface ) ); + windowImpl->SetSurface( &newSurface ); // Flush the event queue to give the update-render thread chance // to start processing messages for new camera setup etc as soon as possible @@ -555,19 +555,19 @@ void Adaptor::SetPreRenderCallback( CallbackBase* callback ) mThreadController->SetPreRenderCallback( callback ); } -bool Adaptor::AddWindow( Dali::Window* childWindow, const std::string& childWindowName, const std::string& childWindowClassName, const bool& childWindowMode ) +bool Adaptor::AddWindow( Dali::Integration::SceneHolder* childWindow, const std::string& childWindowName, const std::string& childWindowClassName, const bool& childWindowMode ) { - Window& windowImpl = Dali::GetImplementation( *childWindow ); + Internal::Adaptor::SceneHolder& windowImpl = Dali::GetImplementation( *childWindow ); windowImpl.SetAdaptor( Get() ); // Add the new Window to the container - the order is not important - mWindows.push_back( WindowPtr( &windowImpl ) ); + mWindows.push_back( SceneHolderPtr( &windowImpl ) ); return true; } -bool Adaptor::RemoveWindow( Dali::Window* childWindow ) +bool Adaptor::RemoveWindow( Dali::Integration::SceneHolder* childWindow ) { - Window& windowImpl = Dali::GetImplementation( *childWindow ); + Internal::Adaptor::SceneHolder& windowImpl = Dali::GetImplementation( *childWindow ); for ( WindowContainer::iterator iter = mWindows.begin(); iter != mWindows.end(); ++iter ) { if( *iter == &windowImpl ) @@ -594,7 +594,7 @@ bool Adaptor::RemoveWindow( std::string childWindowName ) return false; } -bool Adaptor::RemoveWindow( Window* childWindow ) +bool Adaptor::RemoveWindow( Internal::Adaptor::SceneHolder* childWindow ) { for ( WindowContainer::iterator iter = mWindows.begin(); iter != mWindows.end(); ++iter ) { @@ -861,7 +861,7 @@ void Adaptor::OnWindowHidden() { bool allWindowsHidden = true; - for( WindowPtr window : mWindows ) + for( SceneHolderPtr window : mWindows ) { if ( window->IsVisible() ) { @@ -971,7 +971,7 @@ bool Adaptor::ProcessCoreEventsFromIdle() return false; } -Adaptor::Adaptor(Dali::Window window, Dali::Adaptor& adaptor, Dali::RenderSurfaceInterface* surface, EnvironmentOptions* environmentOptions) +Adaptor::Adaptor(Dali::Integration::SceneHolder window, Dali::Adaptor& adaptor, Dali::RenderSurfaceInterface* surface, EnvironmentOptions* environmentOptions) : mResizedSignal(), mLanguageChangedSignal(), mAdaptor( adaptor ), @@ -1003,7 +1003,7 @@ Adaptor::Adaptor(Dali::Window window, Dali::Adaptor& adaptor, Dali::RenderSurfac mUseRemoteSurface( false ) { DALI_ASSERT_ALWAYS( !IsAvailable() && "Cannot create more than one Adaptor per thread" ); - mWindows.insert( mWindows.begin(), WindowPtr( &Dali::GetImplementation( window ) ) ); + mWindows.insert( mWindows.begin(), SceneHolderPtr( &Dali::GetImplementation( window ) ) ); gThreadLocalAdaptor = this; } diff --git a/dali/internal/adaptor/common/adaptor-impl.h b/dali/internal/adaptor/common/adaptor-impl.h index 9b61083..4453269 100755 --- a/dali/internal/adaptor/common/adaptor-impl.h +++ b/dali/internal/adaptor/common/adaptor-impl.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_ADAPTOR_IMPL_H /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -29,6 +29,13 @@ // INTERNAL INCLUDES #include #include + +#ifdef DALI_ADAPTOR_COMPILATION +#include +#else +#include +#endif + #include #include @@ -40,7 +47,6 @@ #include #include #include -#include #include #include #include @@ -52,7 +58,6 @@ namespace Dali { class RenderSurfaceInterface; -class Window; namespace Integration { @@ -80,6 +85,7 @@ class VSyncMonitor; class PerformanceInterface; class LifeCycleObserver; class ObjectProfiler; +class SceneHolder; /** * Implementation of the Adaptor class. @@ -105,7 +111,7 @@ public: * @param[in] configuration The context loss configuration ( to choose resource discard policy ) * @param[in] environmentOptions A pointer to the environment options. If NULL then one is created. */ - static Dali::Adaptor* New( Dali::Window window, + static Dali::Adaptor* New( Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface* surface, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions ); @@ -116,7 +122,7 @@ public: * @param[in] configuration The context loss configuration ( to choose resource discard policy ) * @param[in] environmentOptions A pointer to the environment options. If NULL then one is created. */ - static Dali::Adaptor* New( Dali::Window window, + static Dali::Adaptor* New( Dali::Integration::SceneHolder window, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions ); @@ -131,7 +137,7 @@ public: * @param[in] environmentOptions A pointer to the environment options. If NULL then one is created. */ static Dali::Adaptor* New( GraphicsFactory& graphicsFactory, - Dali::Window window, + Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface* surface, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions ); @@ -144,7 +150,7 @@ public: * @param[in] environmentOptions A pointer to the environment options. If NULL then one is created. */ static Dali::Adaptor* New( GraphicsFactory& graphicsFactory, - Dali::Window window, + Dali::Integration::SceneHolder window, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions ); @@ -222,9 +228,9 @@ public: // AdaptorInternalServices implementation virtual void FeedKeyEvent( KeyEvent& keyEvent ); /** - * @copydoc AdaptorInterface::ReplaceSurface() + * @copydoc Dali::Adaptor::ReplaceSurface() */ - virtual void ReplaceSurface( Dali::Window window, Dali::RenderSurfaceInterface& surface ); + virtual void ReplaceSurface( Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface& surface ); /** * @copydoc Dali::Adaptor::GetSurface() @@ -255,7 +261,7 @@ public: // AdaptorInternalServices implementation * @param[in] childWindowClassName The class name that the child window belongs to * @param[in] childWindowMode The mode of the child window */ - virtual bool AddWindow( Dali::Window* childWindow, + virtual bool AddWindow( Dali::Integration::SceneHolder* childWindow, const std::string& childWindowName, const std::string& childWindowClassName, const bool& childWindowMode ); @@ -264,7 +270,7 @@ public: // AdaptorInternalServices implementation * Removes an existing Window instance from the Adaptor * @param[in] window The Window instance */ - virtual bool RemoveWindow( Dali::Window* childWindow ); + virtual bool RemoveWindow( Dali::Integration::SceneHolder* childWindow ); /** * Removes an existing Window instance from the Adaptor @@ -287,7 +293,7 @@ public: // AdaptorInternalServices implementation * Removes an existing Window instance from the Adaptor * @param[in] childWindow The Window instance */ - bool RemoveWindow( Dali::Internal::Adaptor::Window* childWindow ); + bool RemoveWindow( Dali::Internal::Adaptor::SceneHolder* childWindow ); public: @@ -618,7 +624,7 @@ private: * - Window, adaptor will use existing Window to draw on to * @param[in] environmentOptions A pointer to the environment options. If NULL then one is created. */ - Adaptor( Dali::Window window, Dali::Adaptor& adaptor, Dali::RenderSurfaceInterface* surface, EnvironmentOptions* environmentOptions ); + Adaptor( Dali::Integration::SceneHolder window, Dali::Adaptor& adaptor, Dali::RenderSurfaceInterface* surface, EnvironmentOptions* environmentOptions ); private: // Types @@ -631,8 +637,8 @@ private: // Types STOPPED, ///< Adaptor has been stopped. }; - using WindowPtr = IntrusivePtr< Window >; - using WindowContainer = std::vector; + using SceneHolderPtr = IntrusivePtr< Dali::Internal::Adaptor::SceneHolder >; + using WindowContainer = std::vector; using ObserverContainer = std::vector; private: // Data diff --git a/dali/internal/adaptor/common/adaptor.cpp b/dali/internal/adaptor/common/adaptor.cpp index 82382d8..9c7cfed 100755 --- a/dali/internal/adaptor/common/adaptor.cpp +++ b/dali/internal/adaptor/common/adaptor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -26,6 +26,13 @@ #include #include #include +#include + +#ifdef DALI_ADAPTOR_COMPILATION +#include +#else +#include +#endif namespace Dali { @@ -37,7 +44,8 @@ Adaptor& Adaptor::New( Window window ) Adaptor& Adaptor::New( Window window, Configuration::ContextLoss configuration ) { - Adaptor* adaptor = Internal::Adaptor::Adaptor::New( window, configuration, NULL ); + Internal::Adaptor::SceneHolder* sceneHolder = &Dali::GetImplementation( window ); + Adaptor* adaptor = Internal::Adaptor::Adaptor::New( Dali::Integration::SceneHolder( sceneHolder ), configuration, NULL ); return *adaptor; } @@ -48,6 +56,30 @@ Adaptor& Adaptor::New( Window window, const Dali::RenderSurfaceInterface& surfac Adaptor& Adaptor::New( Window window, const Dali::RenderSurfaceInterface& surface, Configuration::ContextLoss configuration ) { + Internal::Adaptor::SceneHolder* sceneHolder = &Dali::GetImplementation( window ); + Dali::RenderSurfaceInterface* pSurface = const_cast(&surface); + Adaptor* adaptor = Internal::Adaptor::Adaptor::New( Dali::Integration::SceneHolder( sceneHolder ), pSurface, configuration, NULL ); + return *adaptor; +} + +Adaptor& Adaptor::New( Dali::Integration::SceneHolder window ) +{ + return New( window, Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS ); +} + +Adaptor& Adaptor::New( Dali::Integration::SceneHolder window, Configuration::ContextLoss configuration ) +{ + Adaptor* adaptor = Internal::Adaptor::Adaptor::New( window, configuration, NULL ); + return *adaptor; +} + +Adaptor& Adaptor::New( Dali::Integration::SceneHolder window, const Dali::RenderSurfaceInterface& surface ) +{ + return New( window, surface, Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS ); +} + +Adaptor& Adaptor::New( Dali::Integration::SceneHolder window, const Dali::RenderSurfaceInterface& surface, Configuration::ContextLoss configuration ) +{ Dali::RenderSurfaceInterface* pSurface = const_cast(&surface); Adaptor* adaptor = Internal::Adaptor::Adaptor::New( window, pSurface, configuration, NULL ); return *adaptor; @@ -90,6 +122,12 @@ void Adaptor::RemoveIdle( CallbackBase* callback ) void Adaptor::ReplaceSurface( Window window, Dali::RenderSurfaceInterface& surface ) { + Internal::Adaptor::SceneHolder* sceneHolder = &Dali::GetImplementation( window ); + mImpl->ReplaceSurface( Dali::Integration::SceneHolder( sceneHolder ), surface ); +} + +void Adaptor::ReplaceSurface( Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface& surface ) +{ mImpl->ReplaceSurface( window, surface ); } diff --git a/dali/internal/adaptor/common/application-impl.cpp b/dali/internal/adaptor/common/application-impl.cpp index ce49e60..6f58fba 100755 --- a/dali/internal/adaptor/common/application-impl.cpp +++ b/dali/internal/adaptor/common/application-impl.cpp @@ -181,11 +181,13 @@ void Application::CreateAdaptor() auto graphicsFactory = mAdaptorBuilder->GetGraphicsFactory(); - mAdaptor = Dali::Internal::Adaptor::Adaptor::New( graphicsFactory, mMainWindow, mContextLossConfiguration, &mEnvironmentOptions ); + Integration::SceneHolder sceneHolder = Integration::SceneHolder( &Dali::GetImplementation( mMainWindow ) ); + + mAdaptor = Adaptor::New( graphicsFactory, sceneHolder, mContextLossConfiguration, &mEnvironmentOptions ); mAdaptor->ResizedSignal().Connect( mSlotDelegate, &Application::OnResize ); - Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).SetUseRemoteSurface( mUseRemoteSurface ); + Adaptor::GetImplementation( *mAdaptor ).SetUseRemoteSurface( mUseRemoteSurface ); } void Application::CreateAdaptorBuilder() diff --git a/dali/internal/adaptor/common/combined-update-render-controller.cpp b/dali/internal/adaptor/common/combined-update-render-controller.cpp index 5c11f02..4486766 100644 --- a/dali/internal/adaptor/common/combined-update-render-controller.cpp +++ b/dali/internal/adaptor/common/combined-update-render-controller.cpp @@ -214,9 +214,13 @@ void CombinedUpdateRenderController::Resume() mRunning = TRUE; mForceClear = TRUE; - } - DALI_LOG_RELEASE_INFO( "CombinedUpdateRenderController::Resume\n" ); + DALI_LOG_RELEASE_INFO( "CombinedUpdateRenderController::Resume\n" ); + } + else + { + DALI_LOG_RELEASE_INFO( "CombinedUpdateRenderController::Resume: Already resumed [%d, %d, %d]\n", mRunning, mUpdateRenderRunCount, mUpdateRenderThreadCanSleep ); + } } void CombinedUpdateRenderController::Stop() diff --git a/dali/internal/window-system/common/window-impl.cpp b/dali/internal/window-system/common/window-impl.cpp index 564ff14..503d662 100644 --- a/dali/internal/window-system/common/window-impl.cpp +++ b/dali/internal/window-system/common/window-impl.cpp @@ -29,6 +29,12 @@ #include #include +#ifdef DALI_ADAPTOR_COMPILATION +#include +#else +#include +#endif + // INTERNAL HEADERS #include #include @@ -46,8 +52,6 @@ namespace Internal namespace Adaptor { -uint32_t Window::mWindowCounter = 0; - namespace { @@ -66,17 +70,13 @@ Window* Window::New( const PositionSize& positionSize, const std::string& name, } Window::Window() -: mId( mWindowCounter++ ), - mSurface( nullptr ), +: mWindowSurface( nullptr ), mWindowBase(), - mStarted( false ), mIsTransparent( false ), mIsFocusAcceptable( true ), - mVisible( true ), mIconified( false ), mOpaqueState( false ), mResizeEnabled( false ), - mAdaptor( NULL ), mType( Dali::Window::NORMAL ), mPreferredOrientation( Dali::Window::PORTRAIT ), mFocusChangedSignal(), @@ -87,13 +87,6 @@ Window::Window() Window::~Window() { - if ( mAdaptor ) - { - mAdaptor->RemoveObserver( *this ); - mAdaptor->RemoveWindow( this ); - mAdaptor = NULL; - } - if ( mEventHandler ) { mEventHandler->SetRotationObserver( nullptr ); @@ -106,16 +99,17 @@ void Window::Initialize(const PositionSize& positionSize, const std::string& nam Any surface; auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory(); mSurface = renderSurfaceFactory->CreateWindowRenderSurface( positionSize, surface, mIsTransparent ); + mWindowSurface = static_cast( mSurface.get() ); // Get a window base - mWindowBase = mSurface->GetWindowBase(); + mWindowBase = mWindowSurface->GetWindowBase(); // Connect signals mWindowBase->IconifyChangedSignal().Connect( this, &Window::OnIconifyChanged ); mWindowBase->FocusChangedSignal().Connect( this, &Window::OnFocusChanged ); mWindowBase->DeleteRequestSignal().Connect( this, &Window::OnDeleteRequest ); - mSurface->OutputTransformedSignal().Connect( this, &Window::OnOutputTransformed ); + mWindowSurface->OutputTransformedSignal().Connect( this, &Window::OnOutputTransformed ); if( !positionSize.IsEmpty() ) { @@ -125,45 +119,16 @@ void Window::Initialize(const PositionSize& positionSize, const std::string& nam SetClass( name, className ); - mSurface->Map(); + mWindowSurface->Map(); mOrientation = Orientation::New( this ); } -void Window::SetAdaptor(Dali::Adaptor& adaptor) -{ - Window::SetAdaptor( Internal::Adaptor::Adaptor::GetImplementation( adaptor ) ); -} - -void Window::SetAdaptor(Adaptor& adaptor) +void Window::OnAdaptorSet(Dali::Adaptor& adaptor) { - if( mStarted ) - { - return; - } - - mStarted = true; - - // Create scene for the window - PositionSize positionSize = mSurface->GetPositionSize(); - mScene = Dali::Integration::Scene::New( Vector2( positionSize.width, positionSize.height ) ); - mScene.SetSurface( *mSurface.get() ); - - unsigned int dpiHorizontal, dpiVertical; - dpiHorizontal = dpiVertical = 0; - - mSurface->GetDpi( dpiHorizontal, dpiVertical ); - mScene.SetDpi( Vector2( static_cast( dpiHorizontal ), static_cast( dpiVertical ) ) ); - - // Add the window to the adaptor observers - mAdaptor = &adaptor; - mAdaptor->AddObserver( *this ); - // Can only create the detector when we know the Core has been instantiated. mDragAndDropDetector = DragAndDropDetector::New(); - mSurface->SetAdaptor( *mAdaptor ); - mEventHandler = EventHandlerPtr( new EventHandler( mScene, *mAdaptor, *mAdaptor->GetGestureManager(), *mAdaptor ) ); @@ -174,24 +139,9 @@ void Window::SetAdaptor(Adaptor& adaptor) } } -WindowRenderSurface* Window::GetSurface() const -{ - return mSurface.get(); -} - -void Window::SetSurface(WindowRenderSurface* surface) +void Window::OnSurfaceSet( Dali::RenderSurfaceInterface* surface ) { - mSurface.reset( surface ); - - mScene.SetSurface( *mSurface.get() ); - - unsigned int dpiHorizontal, dpiVertical; - dpiHorizontal = dpiVertical = 0; - - mSurface->GetDpi( dpiHorizontal, dpiVertical ); - mScene.SetDpi( Vector2( static_cast( dpiHorizontal ), static_cast( dpiVertical ) ) ); - - mSurface->SetAdaptor( *mAdaptor ); + mWindowSurface = static_cast( surface ); } void Window::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode ) @@ -213,11 +163,6 @@ void Window::SetClass( std::string name, std::string className ) mWindowBase->SetClass( name, className ); } -std::string Window::GetName() const -{ - return mName; -} - std::string Window::GetClassName() const { return mClassName; @@ -238,21 +183,6 @@ void Window::Activate() mWindowBase->Activate(); } -void Window::Add( Dali::Actor actor ) -{ - mScene.Add( actor ); -} - -void Window::Remove( Dali::Actor actor ) -{ - mScene.Remove( actor ); -} - -Dali::Layer Window::GetRootLayer() const -{ - return mScene.GetRootLayer(); -} - uint32_t Window::GetLayerCount() const { return mScene.GetLayerCount(); @@ -263,19 +193,6 @@ Dali::Layer Window::GetLayer( uint32_t depth ) const return mScene.GetLayer( depth ); } -void Window::SetBackgroundColor( Vector4 color ) -{ - if ( mSurface ) - { - mSurface->SetBackgroundColor( color ); - } -} - -Vector4 Window::GetBackgroundColor() const -{ - return mSurface ? mSurface->GetBackgroundColor() : Vector4(); -} - void Window::AddAvailableOrientation( Dali::Window::WindowOrientation orientation ) { bool found = false; @@ -350,7 +267,7 @@ Dali::DragAndDropDetector Window::GetDragAndDropDetector() const Dali::Any Window::GetNativeHandle() const { - return mSurface->GetNativeWindow(); + return mWindowSurface->GetNativeWindow(); } void Window::SetAcceptFocus( bool accept ) @@ -397,7 +314,7 @@ void Window::Hide() bool Window::IsVisible() const { - return mVisible; + return mVisible && !mIconified; } unsigned int Window::GetSupportedAuxiliaryHintCount() const @@ -529,7 +446,7 @@ void Window::SetSize( Dali::Window::WindowSize size ) PositionSize oldRect = mSurface->GetPositionSize(); - mSurface->MoveResize( PositionSize( oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight() ) ); + mWindowSurface->MoveResize( PositionSize( oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight() ) ); PositionSize newRect = mSurface->GetPositionSize(); @@ -563,7 +480,7 @@ void Window::SetPosition( Dali::Window::WindowPosition position ) PositionSize oldRect = mSurface->GetPositionSize(); - mSurface->MoveResize( PositionSize( position.GetX(), position.GetY(), oldRect.width, oldRect.height ) ); + mWindowSurface->MoveResize( PositionSize( position.GetX(), position.GetY(), oldRect.width, oldRect.height ) ); } Dali::Window::WindowPosition Window::GetPosition() const @@ -583,7 +500,7 @@ void Window::SetPositionSize( PositionSize positionSize ) PositionSize oldRect = mSurface->GetPositionSize(); - mSurface->MoveResize( positionSize ); + mWindowSurface->MoveResize( positionSize ); PositionSize newRect = mSurface->GetPositionSize(); @@ -607,7 +524,7 @@ Dali::Layer Window::GetRootLayer() void Window::SetTransparency( bool transparent ) { - mSurface->SetTransparency( transparent ); + mWindowSurface->SetTransparency( transparent ); } bool Window::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode ) @@ -632,7 +549,7 @@ bool Window::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< void Window::RotationDone( int orientation, int width, int height ) { - mSurface->RequestRotation( orientation, width, height ); + mWindowSurface->RequestRotation( orientation, width, height ); mAdaptor->SurfaceResizePrepare( mSurface.get(), Adaptor::SurfaceSize( width, height ) ); @@ -687,32 +604,6 @@ void Window::OnDeleteRequest() mDeleteRequestSignal.Emit(); } -void Window::OnStart() -{ -} - -void Window::OnPause() -{ -} - -void Window::OnResume() -{ -} - -void Window::OnStop() -{ -} - -void Window::OnDestroy() -{ - mAdaptor = NULL; -} - -uint32_t Window::GetId() const -{ - return mId; -} - void Window::FeedTouchPoint( TouchPoint& point, int timeStamp ) { if( mEventHandler ) @@ -737,7 +628,7 @@ void Window::FeedKeyEvent( KeyEvent& keyEvent ) } } -void Window::Pause() +void Window::OnPause() { if( mEventHandler ) { @@ -745,7 +636,7 @@ void Window::Pause() } } -void Window::Resume() +void Window::OnResume() { if( mEventHandler ) { diff --git a/dali/internal/window-system/common/window-impl.h b/dali/internal/window-system/common/window-impl.h index 414af24..cf21b18 100644 --- a/dali/internal/window-system/common/window-impl.h +++ b/dali/internal/window-system/common/window-impl.h @@ -23,11 +23,14 @@ #include #include #include -#include + +#ifdef DALI_ADAPTOR_COMPILATION +#include +#else +#include +#endif // INTERNAL INCLUDES -#include -#include #include #include #include @@ -37,6 +40,7 @@ namespace Dali { class Adaptor; class Actor; +class RenderSurfaceInterface; namespace Internal { @@ -56,7 +60,7 @@ using EventHandlerPtr = IntrusivePtr< EventHandler >; /** * Window provides a surface to render onto with orientation & indicator properties. */ -class Window : public Dali::BaseObject, public LifeCycleObserver, public ConnectionTracker +class Window : public Dali::Internal::Adaptor::SceneHolder, public ConnectionTracker { public: typedef Dali::Window::IndicatorSignalType IndicatorSignalType; @@ -75,30 +79,6 @@ public: static Window* New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent = false); /** - * Pass the adaptor back to the overlay. This allows the window to access Core's overlay. - * @param[in] adaptor An initialized adaptor - */ - void SetAdaptor(Dali::Adaptor& adaptor); - - /** - * Pass the adaptor back to the overlay. This allows the window to access Core's overlay. - * @param[in] adaptor implementation An initialized adaptor implementation - */ - void SetAdaptor(Adaptor& adaptor); - - /** - * Get the window surface - * @return The render surface - */ - WindowRenderSurface* GetSurface() const; - - /** - * Set the window surface - * @param[in] surface The surface - */ - void SetSurface(WindowRenderSurface* surface); - - /** * @copydoc Dali::Window::ShowIndicator() */ void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode ); @@ -119,12 +99,6 @@ public: void SetClass( std::string name, std::string className ); /** - * @brief Gets the window name. - * @return The name of the window - */ - std::string GetName() const; - - /** * @brief Gets the window class name. * @return The class of the window */ @@ -146,31 +120,6 @@ public: void Activate(); /** - * @copydoc Dali::Window::Add() - */ - void Add( Dali::Actor actor ); - - /** - * @copydoc Dali::Window::Remove() - */ - void Remove( Dali::Actor remove ); - - /** - * @copydoc Dali::Window::SetBackgroundColor() - */ - void SetBackgroundColor(Vector4 color); - - /** - * @copydoc Dali::Window::GetBackgroundColor() - */ - Vector4 GetBackgroundColor() const; - - /** - * @copydoc Dali::Window::GetRootLayer() - */ - Dali::Layer GetRootLayer() const; - - /** * @copydoc Dali::Window::GetLayerCount() */ uint32_t GetLayerCount() const; @@ -216,11 +165,6 @@ public: Dali::DragAndDropDetector GetDragAndDropDetector() const; /** - * @copydoc Dali::Window::GetNativeHandle() const - */ - Dali::Any GetNativeHandle() const; - - /** * @copydoc Dali::Window::SetAcceptFocus() */ void SetAcceptFocus( bool accept ); @@ -241,11 +185,6 @@ public: void Hide(); /** - * @copydoc Dali::Window::IsVisible() const - */ - bool IsVisible() const; - - /** * @copydoc Dali::Window::GetSupportedAuxiliaryHintCount() */ unsigned int GetSupportedAuxiliaryHintCount() const; @@ -396,45 +335,23 @@ public: void RotationDone( int orientation, int width, int height ); /** - * @brief Retrieves the unique ID of the window. - * @return The ID - */ - uint32_t GetId() const; - - /** - * Feed (Send) touch event to core and gesture manager - * @param[in] touchEvent The touch event holding the touch point information. - */ - void FeedTouchPoint( TouchPoint& point, int timeStamp ); - - /** - * Feed (Send) wheel event to core and gesture manager - * @param[in] wheelEvent The wheel event - */ - void FeedWheelEvent( WheelEvent& wheelEvent ); - - /** - * Feed (Send) key event to core - * @param[in] keyEvent The key event holding the key information. + * Set the rotation observer (note, some adaptors may not have a rotation observer) + * @param[in] observer The rotation observer + * @return If the rotation observer is set */ - void FeedKeyEvent( KeyEvent& keyEvent ); + bool SetRotationObserver( RotationObserver* observer ); - /** - * Called when the adaptor is paused. - */ - void Pause(); +public: // Dali::Internal::Adaptor::SceneHolder /** - * Called when the adaptor is resumed (from pause). + * @copydoc Dali::Internal::Adaptor::SceneHolder::GetNativeHandle */ - void Resume(); + Dali::Any GetNativeHandle() const override; /** - * Set the rotation observer (note, some adaptors may not have a rotation observer) - * @param[in] observer The rotation observer - * @return If the rotation observer is set + * @copydoc Dali::Internal::Adaptor::SceneHolder::IsVisible */ - bool SetRotationObserver( RotationObserver* observer ); + bool IsVisible() const override; private: @@ -474,32 +391,42 @@ private: */ void OnDeleteRequest(); -private: // Adaptor::Observer interface +private: // Dali::Internal::Adaptor::SceneHolder /** - * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStart() + * @copydoc Dali::Internal::Adaptor::SceneHolder::FeedTouchPoint */ - virtual void OnStart(); + void FeedTouchPoint( TouchPoint& point, int timeStamp ) override; /** - * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnPause() + * @copydoc Dali::Internal::Adaptor::SceneHolder::FeedWheelEvent */ - virtual void OnPause(); + void FeedWheelEvent( WheelEvent& wheelEvent ) override; /** - * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnResume() + * @copydoc Dali::Internal::Adaptor::SceneHolder::FeedKeyEvent */ - virtual void OnResume(); + void FeedKeyEvent( KeyEvent& keyEvent ) override; /** - * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStop() + * @copydoc Dali::Internal::Adaptor::SceneHolder::OnAdaptorSet */ - virtual void OnStop(); + void OnAdaptorSet( Dali::Adaptor& adaptor ) override; /** - * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnDestroy() + * @copydoc Dali::Internal::Adaptor::SceneHolder::OnSurfaceSet */ - virtual void OnDestroy(); + void OnSurfaceSet( Dali::RenderSurfaceInterface* surface ) override; + + /** + * @copydoc Dali::Internal::Adaptor::SceneHolder::OnPause + */ + void OnPause() override; + + /** + * @copydoc Dali::Internal::Adaptor::SceneHolder::OnResume + */ + void OnResume() override; public: // Signals @@ -545,21 +472,15 @@ public: // Signals private: - static uint32_t mWindowCounter; ///< A counter to track the window creation - uint32_t mId; ///< A unique ID to identify the window starting from 0 - std::unique_ptr< WindowRenderSurface >mSurface; ///< The window rendering surface - Dali::Integration::Scene mScene; + WindowRenderSurface* mWindowSurface; ///< The window rendering surface WindowBase* mWindowBase; std::string mName; std::string mClassName; - bool mStarted:1; bool mIsTransparent:1; bool mIsFocusAcceptable:1; - bool mVisible:1; bool mIconified:1; bool mOpaqueState:1; bool mResizeEnabled:1; - Adaptor* mAdaptor; Dali::DragAndDropDetector mDragAndDropDetector; Dali::Window::Type mType; @@ -569,8 +490,6 @@ private: EventHandlerPtr mEventHandler; ///< The window events handler - Vector4 mBackgroundColor; - // Signals IndicatorSignalType mIndicatorVisibilityChangedSignal; FocusSignalType mFocusChangedSignal; diff --git a/dali/public-api/adaptor-framework/window.cpp b/dali/public-api/adaptor-framework/window.cpp index 34eb7b0..eb0b58d 100644 --- a/dali/public-api/adaptor-framework/window.cpp +++ b/dali/public-api/adaptor-framework/window.cpp @@ -28,22 +28,22 @@ namespace Dali Window Window::New(PositionSize posSize, const std::string& name, bool isTransparent) { - Internal::Adaptor::Window* windowImpl = Internal::Adaptor::Window::New(posSize, name, "", isTransparent); + Internal::Adaptor::Window* window = Internal::Adaptor::Window::New(posSize, name, "", isTransparent); Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get(); - Dali::Window window = Dali::Window( windowImpl ); - Internal::Adaptor::Adaptor::GetImplementation( adaptor ).AddWindow( &window, name, "", isTransparent ); + Integration::SceneHolder sceneHolder = Integration::SceneHolder( window ); + Internal::Adaptor::Adaptor::GetImplementation( adaptor ).AddWindow( &sceneHolder, name, "", isTransparent ); return Window(window); } Window Window::New(PositionSize posSize, const std::string& name, const std::string& className, bool isTransparent) { - Internal::Adaptor::Window* windowImpl = Internal::Adaptor::Window::New(posSize, name, className, isTransparent); + Internal::Adaptor::Window* window = Internal::Adaptor::Window::New(posSize, name, className, isTransparent); Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get(); - Dali::Window window = Dali::Window( windowImpl ); - Internal::Adaptor::Adaptor::GetImplementation( adaptor ).AddWindow( &window, name, className, isTransparent ); + Integration::SceneHolder sceneHolder = Integration::SceneHolder( window ); + Internal::Adaptor::Adaptor::GetImplementation( adaptor ).AddWindow( &sceneHolder, name, className, isTransparent ); return Window(window); }