From cee55d80552e14744faa75c87607cb951adf9f9f Mon Sep 17 00:00:00 2001 From: Victor Cebollada Date: Tue, 28 Jan 2020 08:41:40 +0000 Subject: [PATCH] New Window constructor added. * Can receive a surface where to render as a parameter. The surface can be created outside a DALi application and be passed to DALi to render on it. Change-Id: Ia0c582be359972ea93a8cae064710cea1161b07e Signed-off-by: Victor Cebollada --- dali/devel-api/adaptor-framework/window-devel.cpp | 38 ++++++++++++++++++++++ dali/devel-api/adaptor-framework/window-devel.h | 25 ++++++++++++++ dali/internal/adaptor/common/application-impl.cpp | 4 +-- dali/internal/window-system/common/window-impl.cpp | 13 +++++--- dali/internal/window-system/common/window-impl.h | 15 +++++++-- 5 files changed, 87 insertions(+), 8 deletions(-) diff --git a/dali/devel-api/adaptor-framework/window-devel.cpp b/dali/devel-api/adaptor-framework/window-devel.cpp index ad84d95..e2f503e 100644 --- a/dali/devel-api/adaptor-framework/window-devel.cpp +++ b/dali/devel-api/adaptor-framework/window-devel.cpp @@ -30,6 +30,44 @@ namespace Dali namespace DevelWindow { +Window New(Any surface, PositionSize windowPosition, const std::string& name, bool isTransparent) +{ + return DevelWindow::New(surface, windowPosition, name, "", isTransparent); +} + +Window New(Any surface, PositionSize windowPosition, const std::string& name, const std::string& className, bool isTransparent) +{ + Window newWindow; + + const bool isAdaptorAvailable = Dali::Adaptor::IsAvailable(); + bool isNewWindowAllowed = true; + + if (isAdaptorAvailable) + { + Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get(); + isNewWindowAllowed = Internal::Adaptor::Adaptor::GetImplementation(adaptor).IsMultipleWindowSupported(); + } + + if (isNewWindowAllowed) + { + Internal::Adaptor::Window* window = Internal::Adaptor::Window::New(surface, windowPosition, name, className, isTransparent); + + Integration::SceneHolder sceneHolder = Integration::SceneHolder(window); + if (isAdaptorAvailable) + { + Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get(); + Internal::Adaptor::Adaptor::GetImplementation(adaptor).AddWindow(sceneHolder, name, className, isTransparent); + } + newWindow = Window(window); + } + else + { + DALI_LOG_ERROR("This device can't support multiple windows.\n"); + } + + return newWindow; +} + void SetPositionSize( Window window, PositionSize positionSize ) { GetImplementation( window ).SetPositionSize( positionSize ); diff --git a/dali/devel-api/adaptor-framework/window-devel.h b/dali/devel-api/adaptor-framework/window-devel.h index 9418282..4687503 100644 --- a/dali/devel-api/adaptor-framework/window-devel.h +++ b/dali/devel-api/adaptor-framework/window-devel.h @@ -63,6 +63,31 @@ typedef Signal< void ( Window, bool ) > VisibilityChangedSignalType; ///< Visibi typedef Signal< void (Window, EffectState, EffectType) > TransitionEffectEventSignalType; ///< Effect signal type and state /** + * @brief Creates an initialized handle to a new Window. + * + * @param[in] surface Can be a window or pixmap. + * @param[in] windowPosition The position and size of the Window + * @param[in] name The Window title + * @param[in] isTransparent Whether Window is transparent + * @return A new window + * @note This creates an extra window in addition to the default main window +*/ +DALI_ADAPTOR_API Window New(Any surface, PositionSize windowPosition, const std::string& name, bool isTransparent = false); + +/** + * @brief Creates an initialized handle to a new Window. + * + * @param[in] surface Can be a window or pixmap. + * @param[in] windowPosition The position and size of the Window + * @param[in] name The Window title + * @param[in] className The Window class name + * @param[in] isTransparent Whether Window is transparent + * @note This creates an extra window in addition to the default main window + * @return A new Window + */ +DALI_ADAPTOR_API Window New(Any surface, PositionSize windowPosition, const std::string& name, const std::string& className, bool isTransparent = false); + +/** * @brief Sets position and size of the window. This API guarantees that both moving and resizing of window will appear on the screen at once. * * @param[in] window The window instance diff --git a/dali/internal/adaptor/common/application-impl.cpp b/dali/internal/adaptor/common/application-impl.cpp index 3f4ed25..65d562b 100755 --- a/dali/internal/adaptor/common/application-impl.cpp +++ b/dali/internal/adaptor/common/application-impl.cpp @@ -168,7 +168,7 @@ void Application::CreateWindow() const std::string& windowClassName = mEnvironmentOptions.GetWindowClassName(); - Internal::Adaptor::Window* window = Internal::Adaptor::Window::New( mWindowPositionSize, mMainWindowName, windowClassName, mMainWindowMode == Dali::Application::TRANSPARENT ); + Internal::Adaptor::Window* window = Internal::Adaptor::Window::New(mWindowPositionSize, mMainWindowName, windowClassName, mMainWindowMode == Dali::Application::TRANSPARENT); mMainWindow = Dali::Window( window ); // Quit the application when the window is closed @@ -398,7 +398,7 @@ Dali::Window Application::GetWindow() // just for backward compatibility to make the test case pass if ( mMainWindowReplaced ) { - Internal::Adaptor::Window* window = Internal::Adaptor::Window::New( PositionSize(), "ReplacedWindow", "", false ); + Internal::Adaptor::Window* window = Internal::Adaptor::Window::New(PositionSize(), "ReplacedWindow", "", false); return Dali::Window( window ); } else diff --git a/dali/internal/window-system/common/window-impl.cpp b/dali/internal/window-system/common/window-impl.cpp index be836c1..9c734f5 100644 --- a/dali/internal/window-system/common/window-impl.cpp +++ b/dali/internal/window-system/common/window-impl.cpp @@ -56,11 +56,17 @@ Debug::Filter* gWindowLogFilter = Debug::Filter::New( Debug::NoLogging, false, " } // unnamed namespace -Window* Window::New( const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent ) +Window* Window::New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent) +{ + Any surface; + return Window::New(surface, positionSize, name, className, isTransparent); +} + +Window* Window::New(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent) { Window* window = new Window(); window->mIsTransparent = isTransparent; - window->Initialize( positionSize, name, className ); + window->Initialize(surface, positionSize, name, className); return window; } @@ -98,10 +104,9 @@ Window::~Window() } } -void Window::Initialize(const PositionSize& positionSize, const std::string& name, const std::string& className) +void Window::Initialize(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className) { // Create a window render surface - Any surface; auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory(); mSurface = renderSurfaceFactory->CreateWindowRenderSurface( positionSize, surface, mIsTransparent ); mWindowSurface = static_cast( mSurface.get() ); diff --git a/dali/internal/window-system/common/window-impl.h b/dali/internal/window-system/common/window-impl.h index 0705340..0d4a4e1 100644 --- a/dali/internal/window-system/common/window-impl.h +++ b/dali/internal/window-system/common/window-impl.h @@ -68,7 +68,7 @@ public: typedef Signal< void () > SignalType; /** - * Create a new Window. This should only be called once by the Application class + * @brief Create a new Window. This should only be called once by the Application class * @param[in] positionSize The position and size of the window * @param[in] name The window title * @param[in] className The window class name @@ -78,6 +78,17 @@ public: static Window* New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent = false); /** + * @brief Create a new Window. This should only be called once by the Application class + * @param[in] surface The surface used to render on. + * @param[in] positionSize The position and size of the window + * @param[in] name The window title + * @param[in] className The window class name + * @param[in] isTransparent Whether window is transparent + * @return A newly allocated Window + */ + static Window* New(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent = false); + + /** * @copydoc Dali::Window::ShowIndicator() */ void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode ); @@ -388,7 +399,7 @@ private: /** * Second stage initialization */ - void Initialize(const PositionSize& positionSize, const std::string& name, const std::string& className); + void Initialize(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className); /** * Called when the window becomes iconified or deiconified. -- 2.7.4