New Window constructor added. 51/224151/15
authorVictor Cebollada <v.cebollada@samsung.com>
Tue, 28 Jan 2020 08:41:40 +0000 (08:41 +0000)
committerVictor Cebollada <v.cebollada@samsung.com>
Tue, 31 Mar 2020 08:07:16 +0000 (09:07 +0100)
* 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 <v.cebollada@samsung.com>
dali/devel-api/adaptor-framework/window-devel.cpp
dali/devel-api/adaptor-framework/window-devel.h
dali/internal/adaptor/common/application-impl.cpp
dali/internal/window-system/common/window-impl.cpp
dali/internal/window-system/common/window-impl.h

index ad84d95..e2f503e 100644 (file)
@@ -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 );
index 9418282..4687503 100644 (file)
@@ -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
index 8e38ca5..17d0282 100755 (executable)
@@ -166,7 +166,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
@@ -396,7 +396,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
index be836c1..9c734f5 100644 (file)
@@ -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<WindowRenderSurface*>( mSurface.get() );
index 0705340..0d4a4e1 100644 (file)
@@ -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.