Overlay RenderTaskList should be created by the Window instead of the Overlay
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / common / window-impl.cpp
index 0d84262..8412d53 100644 (file)
@@ -21,6 +21,8 @@
 // EXTERNAL HEADERS
 #include <dali/integration-api/core.h>
 #include <dali/integration-api/system-overlay.h>
+#include <dali/integration-api/render-task-list-integ.h>
+#include <dali/public-api/actors/camera-actor.h>
 #include <dali/public-api/render-tasks/render-task.h>
 #include <dali/public-api/render-tasks/render-task-list.h>
 #include <dali/devel-api/adaptor-framework/orientation.h>
@@ -61,7 +63,7 @@ Window* Window::New( const PositionSize& positionSize, const std::string& name,
 Window::Window()
 : mSurface( NULL ),
   mWindowBase(),
-  mIndicatorVisible( Dali::Window::VISIBLE ),
+  mIndicatorVisible( Dali::Window::INVISIBLE ),   // TODO: Enable this after indicator implementation based on tizen 5.
   mIndicatorIsShown( false ),
   mShowRotatedIndicatorOnClose( false ),
   mStarted( false ),
@@ -109,17 +111,22 @@ Window::~Window()
 
 void Window::Initialize(const PositionSize& positionSize, const std::string& name, const std::string& className)
 {
-  // create a window render surface
+  // Create a window render surface
   Any surface;
   auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
-  auto windowRenderSurface = renderSurfaceFactory->CreateWindowRenderSurface( positionSize, surface, name, className, mIsTransparent );
+  auto windowRenderSurface = renderSurfaceFactory->CreateWindowRenderSurface( positionSize, surface, mIsTransparent );
   mSurface = windowRenderSurface.release();
 
-  // create a window base
-  auto windowFactory = Dali::Internal::Adaptor::GetWindowFactory();
-  mWindowBase = windowFactory->CreateWindowBase( this, mSurface );
+  // Get a window base
+  mWindowBase = mSurface->GetWindowBase();
 
-  mWindowBase->Initialize();
+  // Connect signals
+  mWindowBase->IconifyChangedSignal().Connect( this, &Window::OnIconifyChanged );
+  mWindowBase->FocusChangedSignal().Connect( this, &Window::OnFocusChanged );
+  mWindowBase->DeleteRequestSignal().Connect( this, &Window::OnDeleteRequest );
+  mWindowBase->IndicatorFlickedSignal().Connect( this, &Window::OnIndicatorFlicked );
+
+  mSurface->OutputTransformedSignal().Connect( this, &Window::OnOutputTransformed );
 
   if( !positionSize.IsEmpty() )
   {
@@ -139,13 +146,22 @@ void Window::SetAdaptor(Dali::Adaptor& adaptor)
   DALI_ASSERT_ALWAYS( !mStarted && "Adaptor already started" );
   mStarted = true;
 
-  // Only create one overlay per window
+  // Create one overlay for the main window only
   Internal::Adaptor::Adaptor& adaptorImpl = Internal::Adaptor::Adaptor::GetImplementation(adaptor);
   Integration::Core& core = adaptorImpl.GetCore();
   mOverlay = &core.GetSystemOverlay();
 
-  Dali::RenderTaskList taskList = mOverlay->GetOverlayRenderTasks();
-  taskList.CreateTask();
+  // Only create render task list for the overlay once
+  if (!mOverlay->GetOverlayRenderTasks())
+  {
+    Dali::RenderTaskList overlayRenderTaskList = Integration::RenderTaskList::New();
+
+    Dali::Actor overlayRootActor = mOverlay->GetDefaultRootActor();
+    Dali::CameraActor overlayCameraActor = mOverlay->GetDefaultCameraActor();
+    Integration::RenderTaskList::CreateTask( overlayRenderTaskList, overlayRootActor, overlayCameraActor );
+
+    mOverlay->SetOverlayRenderTasks( overlayRenderTaskList );
+  }
 
   mAdaptor = &adaptorImpl;
   mAdaptor->AddObserver( *this );
@@ -172,7 +188,8 @@ WindowRenderSurface* Window::GetSurface()
 
 void Window::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode )
 {
-  mIndicatorVisible = visibleMode;
+  // TODO: Enable this after indicator implementation based on tizen 5.
+//  mIndicatorVisible = visibleMode;
 
   mWindowBase->ShowIndicator( mIndicatorVisible, mIndicatorOpacityMode );
 
@@ -191,7 +208,8 @@ void Window::SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacityMode
 
 void Window::SetIndicatorVisibleMode( Dali::Window::IndicatorVisibleMode mode )
 {
-  mIndicatorVisible = mode;
+  // TODO: Enable this after indicator implementation based on tizen 5.
+//  mIndicatorVisible = mode;
 }
 
 void Window::RotateIndicator( Dali::Window::WindowOrientation orientation )
@@ -295,7 +313,7 @@ Dali::DragAndDropDetector Window::GetDragAndDropDetector() const
 
 Dali::Any Window::GetNativeHandle() const
 {
-  return mSurface->GetWindow();
+  return mSurface->GetNativeWindow();
 }
 
 void Window::SetAcceptFocus( bool accept )
@@ -558,49 +576,6 @@ void Window::RotationDone( int orientation, int width, int height )
   mAdaptor->SurfaceResizeComplete( Adaptor::SurfaceSize( width, height ) );
 }
 
-void Window::OnIconifyChanged( bool iconified )
-{
-  if( iconified )
-  {
-    mIconified = true;
-
-    if( mVisible )
-    {
-      WindowVisibilityObserver* observer( mAdaptor );
-      observer->OnWindowHidden();
-      DALI_LOG_RELEASE_INFO( "Window (%p) Iconified\n", this );
-    }
-  }
-  else
-  {
-    mIconified = false;
-
-    if( mVisible )
-    {
-      WindowVisibilityObserver* observer( mAdaptor );
-      observer->OnWindowShown();
-      DALI_LOG_RELEASE_INFO( "Window (%p) Deiconified\n", this );
-    }
-  }
-}
-
-void Window::OnFocusChanged( bool focusIn )
-{
-  mFocusChangedSignal.Emit( focusIn );
-}
-
-void Window::OnOutputTransformed()
-{
-  PositionSize positionSize = mSurface->GetPositionSize();
-  mAdaptor->SurfaceResizePrepare( Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
-  mAdaptor->SurfaceResizeComplete( Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
-}
-
-void Window::OnDeleteRequest()
-{
-  mDeleteRequestSignal.Emit();
-}
-
 void Window::DoShowIndicator( Dali::Window::WindowOrientation lastOrientation )
 {
   if( mIndicator == NULL )
@@ -701,6 +676,57 @@ void Window::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientatio
   mWindowBase->SetIndicatorProperties( isShow, lastOrientation );
 }
 
+void Window::OnIconifyChanged( bool iconified )
+{
+  if( iconified )
+  {
+    mIconified = true;
+
+    if( mVisible )
+    {
+      WindowVisibilityObserver* observer( mAdaptor );
+      observer->OnWindowHidden();
+      DALI_LOG_RELEASE_INFO( "Window (%p) Iconified\n", this );
+    }
+  }
+  else
+  {
+    mIconified = false;
+
+    if( mVisible )
+    {
+      WindowVisibilityObserver* observer( mAdaptor );
+      observer->OnWindowShown();
+      DALI_LOG_RELEASE_INFO( "Window (%p) Deiconified\n", this );
+    }
+  }
+}
+
+void Window::OnFocusChanged( bool focusIn )
+{
+  mFocusChangedSignal.Emit( focusIn );
+}
+
+void Window::OnOutputTransformed()
+{
+  PositionSize positionSize = mSurface->GetPositionSize();
+  mAdaptor->SurfaceResizePrepare( Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
+  mAdaptor->SurfaceResizeComplete( Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
+}
+
+void Window::OnDeleteRequest()
+{
+  mDeleteRequestSignal.Emit();
+}
+
+void Window::OnIndicatorFlicked()
+{
+  if( mIndicator )
+  {
+    mIndicator->Flicked();
+  }
+}
+
 void Window::IndicatorTypeChanged( IndicatorInterface::Type type )
 {
   mWindowBase->IndicatorTypeChanged( type );