Added APIs to support Launchpad and set window transparency 99/137999/3
authorHeeyong Song <heeyong.song@samsung.com>
Mon, 10 Jul 2017 14:43:18 +0000 (23:43 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Wed, 19 Jul 2017 05:36:13 +0000 (14:36 +0900)
Change-Id: I3206d7b9485bc516d0e90da92f37f627b3072455

13 files changed:
adaptors/common/application-impl.cpp
adaptors/common/application-impl.h
adaptors/common/window-impl.h
adaptors/devel-api/adaptor-framework/application-devel.cpp
adaptors/devel-api/adaptor-framework/application-devel.h
adaptors/devel-api/adaptor-framework/window-devel.cpp
adaptors/devel-api/adaptor-framework/window-devel.h
adaptors/ecore/wayland/window-impl-ecore-wl.cpp
adaptors/ecore/wayland/window-render-surface-ecore-wl.cpp
adaptors/ecore/wayland/window-render-surface.h
adaptors/public-api/adaptor-framework/application.cpp
adaptors/wayland/window-impl-wl.cpp
adaptors/x11/window-impl-x.cpp

index cd05c95..d10e60c 100644 (file)
@@ -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
index 509cb54..621facc 100644 (file)
@@ -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<Application> 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)
index 9ef6140..4207cae 100644 (file)
@@ -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 );
index 2c30c72..51b379c 100644 (file)
@@ -17,6 +17,7 @@
 
 // INTERNAL INCLUDES
 #include <adaptors/devel-api/adaptor-framework/application-devel.h>
+#include <adaptors/devel-api/adaptor-framework/window-devel.h>
 #include <adaptors/common/application-impl.h>
 
 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
index 6360011..d29c487 100644 (file)
@@ -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
index 0ad934e..0094e61 100644 (file)
@@ -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
index 0357be8..1c7c3fd 100644 (file)
@@ -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
index f090ad1..73c0c5a 100644 (file)
@@ -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
index 6fc7677..1df0faa 100644 (file)
@@ -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 );
index b5a9e81..aa4eb9b 100644 (file)
@@ -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
 
   /**
index 3530906..146c9be 100644 (file)
@@ -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()
index 51d5899..4683b4c 100644 (file)
@@ -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
index b6a0b8a..50281f3 100644 (file)
@@ -957,6 +957,10 @@ Dali::DevelWindow::WindowPosition Window::GetPosition()
   return Dali::DevelWindow::WindowPosition( positionSize.x, positionSize.y );
 }
 
+void Window::SetTransparency( bool transparent )
+{
+}
+
 } // Adaptor
 
 } // Internal