From: Heeyong Song Date: Mon, 10 Jul 2017 14:43:18 +0000 (+0900) Subject: Added APIs to support Launchpad and set window transparency X-Git-Tag: dali_1.2.49~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F99%2F137999%2F3;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git Added APIs to support Launchpad and set window transparency Change-Id: I3206d7b9485bc516d0e90da92f37f627b3072455 --- diff --git a/adaptors/common/application-impl.cpp b/adaptors/common/application-impl.cpp index cd05c95..d10e60c 100644 --- a/adaptors/common/application-impl.cpp +++ b/adaptors/common/application-impl.cpp @@ -48,6 +48,8 @@ namespace Internal namespace Adaptor { +ApplicationPtr Application::gPreInitializedApplication( NULL ); + ApplicationPtr Application::New( int* argc, char **argv[], @@ -60,6 +62,16 @@ ApplicationPtr Application::New( return application; } +void Application::PreInitialize( int* argc, char** argv[] ) +{ + if( !gPreInitializedApplication ) + { + gPreInitializedApplication = new Application ( argc, argv, "", Dali::Application::OPAQUE, PositionSize(), Framework::NORMAL ); + + gPreInitializedApplication->CreateWindow(); // Only create window + } +} + Application::Application( int* argc, char** argv[], const std::string& stylesheet, Dali::Application::WINDOW_MODE windowMode, const PositionSize& positionSize, Framework::Type applicationType ) : mInitSignal(), @@ -85,6 +97,7 @@ Application::Application( int* argc, char** argv[], const std::string& styleshee mStylesheet( stylesheet ), mEnvironmentOptions(), mWindowPositionSize( positionSize ), + mLaunchpadState( Launchpad::NONE ), mSlotDelegate( this ) { // Get mName from environment options @@ -176,7 +189,12 @@ void Application::QuitFromMainLoop() void Application::DoInit() { - CreateWindow(); + // If an application was pre-initialized, a window was made in advance + if( mLaunchpadState == Launchpad::NONE ) + { + CreateWindow(); + } + CreateAdaptor(); // Run the adaptor @@ -395,6 +413,17 @@ std::string Application::GetResourcePath() return Internal::Adaptor::Framework::GetResourcePath(); } +void Application::SetStyleSheet( const std::string& stylesheet ) +{ + mStylesheet = stylesheet; +} + + +ApplicationPtr Application::GetPreInitializedApplication() +{ + return gPreInitializedApplication; +} + } // namespace Adaptor } // namespace Internal diff --git a/adaptors/common/application-impl.h b/adaptors/common/application-impl.h index 509cb54..621facc 100644 --- a/adaptors/common/application-impl.h +++ b/adaptors/common/application-impl.h @@ -40,6 +40,22 @@ namespace Internal namespace Adaptor { + +namespace Launchpad +{ + +/** + * @brief Launchpad is used to improve application launch performance. + * When an application is pre-initialized, so files are preloaded, some functions are initialized and a window is made in advance. + */ +enum State +{ + NONE, ///< The default state + PRE_INITIALIZED ///< Application is pre-initialized. +}; + +} // namespace Launchpad + class CommandLineOptions; class EventLoop; @@ -54,6 +70,7 @@ typedef IntrusivePtr ApplicationPtr; class Application : public BaseObject, public Framework::Observer { public: + typedef Dali::Application::AppSignalType AppSignalType; typedef Dali::Application::AppControlSignalType AppControlSignalType; typedef Dali::Application::WINDOW_MODE WINDOW_MODE; @@ -70,6 +87,11 @@ public: static ApplicationPtr New( int* argc, char **argv[], const std::string& stylesheet, WINDOW_MODE windowMode, const PositionSize& positionSize, Framework::Type applicationType ); + /** + * @copydoc Dali::DevelApplication::PreInitialize() + */ + static void PreInitialize( int* argc, char** argv[] ); + public: /** @@ -112,6 +134,13 @@ public: */ static std::string GetResourcePath(); + /** + * Retrieves the pre-initialized application. + * + * @return A pointer to the pre-initialized application + */ + static ApplicationPtr GetPreInitializedApplication(); + public: // Stereoscopy /** @@ -227,6 +256,13 @@ public: */ void OnResize(Dali::Adaptor& adaptor); + /** + * Sets a user defined theme file. + * This should be called before initialization. + * @param[in] stylesheet The path to user defined theme file + */ + void SetStyleSheet( const std::string& stylesheet ); + public: // Signals /** @@ -350,9 +386,12 @@ private: std::string mStylesheet; EnvironmentOptions mEnvironmentOptions; PositionSize mWindowPositionSize; + Launchpad::State mLaunchpadState; bool mUseRemoteSurface; SlotDelegate< Application > mSlotDelegate; + + static ApplicationPtr gPreInitializedApplication; }; inline Application& GetImplementation(Dali::Application& application) diff --git a/adaptors/common/window-impl.h b/adaptors/common/window-impl.h index 9ef6140..4207cae 100644 --- a/adaptors/common/window-impl.h +++ b/adaptors/common/window-impl.h @@ -296,6 +296,11 @@ public: Dali::DevelWindow::WindowPosition GetPosition(); /** + * @copydoc Dali::DevelWindow::SetTransparency() + */ + void SetTransparency( bool transparent ); + + /** * Called from Orientation after the Change signal has been sent */ void RotationDone( int orientation, int width, int height ); diff --git a/adaptors/devel-api/adaptor-framework/application-devel.cpp b/adaptors/devel-api/adaptor-framework/application-devel.cpp index 2c30c72..51b379c 100644 --- a/adaptors/devel-api/adaptor-framework/application-devel.cpp +++ b/adaptors/devel-api/adaptor-framework/application-devel.cpp @@ -17,6 +17,7 @@ // INTERNAL INCLUDES #include +#include #include namespace Dali @@ -27,8 +28,31 @@ namespace DevelApplication Application New( int* argc, char **argv[], const std::string& stylesheet, Application::WINDOW_MODE windowMode, PositionSize positionSize ) { - Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::New( argc, argv, stylesheet, windowMode, positionSize, Internal::Adaptor::Framework::NORMAL ); - return Application( internal.Get() ); + Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication(); + if( internal ) + { + if( argc && ( *argc > 0 ) ) + { + internal->GetWindow().SetClass( (*argv)[0], "" ); + } + internal->SetStyleSheet( stylesheet ); + + DevelWindow::SetTransparency( internal->GetWindow(), ( windowMode == Application::OPAQUE ? false : true ) ); + DevelWindow::SetSize( internal->GetWindow(), DevelWindow::WindowSize( positionSize.width, positionSize.height ) ); + DevelWindow::SetPosition( internal->GetWindow(), DevelWindow::WindowPosition( positionSize.x, positionSize.y ) ); + + return Application( internal.Get() ); + } + else + { + internal = Internal::Adaptor::Application::New( argc, argv, stylesheet, windowMode, positionSize, Internal::Adaptor::Framework::NORMAL ); + return Application( internal.Get() ); + } +} + +void PreInitialize( int* argc, char** argv[] ) +{ + Internal::Adaptor::Application::PreInitialize( argc, argv ); } } // namespace DevelApplication diff --git a/adaptors/devel-api/adaptor-framework/application-devel.h b/adaptors/devel-api/adaptor-framework/application-devel.h index 6360011..d29c487 100644 --- a/adaptors/devel-api/adaptor-framework/application-devel.h +++ b/adaptors/devel-api/adaptor-framework/application-devel.h @@ -46,6 +46,15 @@ namespace DevelApplication */ DALI_IMPORT_API Application New( int* argc, char **argv[], const std::string& stylesheet, Application::WINDOW_MODE windowMode, PositionSize positionSize ); +/** + * @brief This is used to improve application launch performance. + * It preloads so files, initializes some functions in advance and makes a window in advance. + * + * @param[in,out] argc A pointer to the number of arguments + * @param[in,out] argv A pointer to the argument list + */ +DALI_IMPORT_API void PreInitialize( int* argc, char** argv[] ); + } // namespace DevelApplication } // namespace Dali diff --git a/adaptors/devel-api/adaptor-framework/window-devel.cpp b/adaptors/devel-api/adaptor-framework/window-devel.cpp index 0ad934e..0094e61 100644 --- a/adaptors/devel-api/adaptor-framework/window-devel.cpp +++ b/adaptors/devel-api/adaptor-framework/window-devel.cpp @@ -170,6 +170,11 @@ WindowPosition GetPosition( Window window ) return GetImplementation( window ).GetPosition(); } +void SetTransparency( Window window, bool transparent ) +{ + GetImplementation( window ).SetTransparency( transparent ); +} + } // namespace DevelWindow } // namespace Dali diff --git a/adaptors/devel-api/adaptor-framework/window-devel.h b/adaptors/devel-api/adaptor-framework/window-devel.h index 0357be8..1c7c3fd 100644 --- a/adaptors/devel-api/adaptor-framework/window-devel.h +++ b/adaptors/devel-api/adaptor-framework/window-devel.h @@ -344,6 +344,14 @@ DALI_IMPORT_API void SetPosition( Window window, WindowPosition position ); */ DALI_IMPORT_API WindowPosition GetPosition( Window window ); +/** + * @brief Sets whether the window is transparent or not. + * + * @param[in] window The window to set transparency + * @param[in] transparent Whether the window is transparent + */ +DALI_IMPORT_API void SetTransparency( Window window, bool transparent ); + } // namespace DevelWindow } // namespace Dali diff --git a/adaptors/ecore/wayland/window-impl-ecore-wl.cpp b/adaptors/ecore/wayland/window-impl-ecore-wl.cpp index f090ad1..73c0c5a 100644 --- a/adaptors/ecore/wayland/window-impl-ecore-wl.cpp +++ b/adaptors/ecore/wayland/window-impl-ecore-wl.cpp @@ -1515,6 +1515,12 @@ Dali::DevelWindow::WindowPosition Window::GetPosition() return Dali::DevelWindow::WindowPosition( positionSize.x, positionSize.y ); } +void Window::SetTransparency( bool transparent ) +{ + ECore::WindowRenderSurface* wlSurface( dynamic_cast< ECore::WindowRenderSurface * >( mSurface ) ); + wlSurface->SetTransparency( transparent ); +} + } // Adaptor } // Internal diff --git a/adaptors/ecore/wayland/window-render-surface-ecore-wl.cpp b/adaptors/ecore/wayland/window-render-surface-ecore-wl.cpp index 6fc7677..1df0faa 100644 --- a/adaptors/ecore/wayland/window-render-surface-ecore-wl.cpp +++ b/adaptors/ecore/wayland/window-render-surface-ecore-wl.cpp @@ -176,6 +176,11 @@ void WindowRenderSurface::RequestRotation( Dali::Window::WindowOrientation orien } } +void WindowRenderSurface::SetTransparency( bool transparent ) +{ + ecore_wl_window_alpha_set( mWlWindow, transparent ); +} + void WindowRenderSurface::InitializeEgl( EglInterface& eglIf ) { DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter ); diff --git a/adaptors/ecore/wayland/window-render-surface.h b/adaptors/ecore/wayland/window-render-surface.h index b5a9e81..aa4eb9b 100644 --- a/adaptors/ecore/wayland/window-render-surface.h +++ b/adaptors/ecore/wayland/window-render-surface.h @@ -87,6 +87,13 @@ public: // API */ void RequestRotation( Dali::Window::WindowOrientation orientation, int width, int height ); + /** + * @brief Sets whether the surface is transparent or not. + * + * @param[in] transparent Whether the surface is transparent + */ + void SetTransparency( bool transparent ); + public: // from Dali::RenderSurface /** diff --git a/adaptors/public-api/adaptor-framework/application.cpp b/adaptors/public-api/adaptor-framework/application.cpp index 3530906..146c9be 100644 --- a/adaptors/public-api/adaptor-framework/application.cpp +++ b/adaptors/public-api/adaptor-framework/application.cpp @@ -34,23 +34,66 @@ Application Application::New() Application Application::New( int* argc, char **argv[] ) { - Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::New( argc, argv, "", OPAQUE, PositionSize(), - Internal::Adaptor::Framework::NORMAL); - return Application(internal.Get()); + Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication(); + if( internal ) + { + if( argc && ( *argc > 0 ) ) + { + internal->GetWindow().SetClass( (*argv)[0], "" ); + } + + return Application( internal.Get() ); + } + else + { + internal = Internal::Adaptor::Application::New( argc, argv, "", OPAQUE, PositionSize(), + Internal::Adaptor::Framework::NORMAL); + return Application(internal.Get()); + } } Application Application::New( int* argc, char **argv[], const std::string& stylesheet ) { - Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::New( argc, argv, stylesheet, OPAQUE, PositionSize(), - Internal::Adaptor::Framework::NORMAL); - return Application(internal.Get()); + Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication(); + if( internal ) + { + if( argc && ( *argc > 0 ) ) + { + internal->GetWindow().SetClass( (*argv)[0], "" ); + } + internal->SetStyleSheet( stylesheet ); + + return Application( internal.Get() ); + } + else + { + internal = Internal::Adaptor::Application::New( argc, argv, stylesheet, OPAQUE, PositionSize(), + Internal::Adaptor::Framework::NORMAL); + return Application(internal.Get()); + } } Application Application::New( int* argc, char **argv[], const std::string& stylesheet, WINDOW_MODE windowMode ) { - Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::New( argc, argv, stylesheet, windowMode, PositionSize(), - Internal::Adaptor::Framework::NORMAL); - return Application(internal.Get()); + Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication(); + if( internal ) + { + if( argc && ( *argc > 0 ) ) + { + internal->GetWindow().SetClass( (*argv)[0], "" ); + } + internal->SetStyleSheet( stylesheet ); + + DevelWindow::SetTransparency( internal->GetWindow(), ( windowMode == Application::OPAQUE ? false : true ) ); + + return Application( internal.Get() ); + } + else + { + internal = Internal::Adaptor::Application::New( argc, argv, stylesheet, windowMode, PositionSize(), + Internal::Adaptor::Framework::NORMAL); + return Application(internal.Get()); + } } Application::~Application() diff --git a/adaptors/wayland/window-impl-wl.cpp b/adaptors/wayland/window-impl-wl.cpp index 51d5899..4683b4c 100644 --- a/adaptors/wayland/window-impl-wl.cpp +++ b/adaptors/wayland/window-impl-wl.cpp @@ -452,6 +452,10 @@ Dali::DevelWindow::WindowPosition Window::GetPosition() return Dali::DevelWindow::WindowPosition( positionSize.x, positionSize.y ); } +void Window::SetTransparency( bool transparent ) +{ +} + } // Adaptor } // Internal } // Dali diff --git a/adaptors/x11/window-impl-x.cpp b/adaptors/x11/window-impl-x.cpp index b6a0b8a..50281f3 100644 --- a/adaptors/x11/window-impl-x.cpp +++ b/adaptors/x11/window-impl-x.cpp @@ -957,6 +957,10 @@ Dali::DevelWindow::WindowPosition Window::GetPosition() return Dali::DevelWindow::WindowPosition( positionSize.x, positionSize.y ); } +void Window::SetTransparency( bool transparent ) +{ +} + } // Adaptor } // Internal