(Partial update) Fix surface damage area
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / common / window-impl.cpp
old mode 100644 (file)
new mode 100755 (executable)
index a0fd809..be1c3ad
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -32,6 +32,7 @@
 
 // INTERNAL HEADERS
 #include <dali/integration-api/adaptor-framework/render-surface-interface.h>
+#include <dali/internal/graphics/gles/egl-graphics.h>
 #include <dali/internal/window-system/common/event-handler.h>
 #include <dali/internal/window-system/common/orientation-impl.h>
 #include <dali/internal/window-system/common/render-surface-factory.h>
@@ -87,25 +88,17 @@ Window::Window()
   mWindowHeight( 0 ),
   mOrientationMode( Internal::Adaptor::Window::OrientationMode::PORTRAIT ),
   mNativeWindowId( -1 ),
-  mFocusChangedSignal(),
-  mResizedSignal(),
   mDeleteRequestSignal(),
   mFocusChangeSignal(),
   mResizeSignal(),
   mVisibilityChangedSignal(),
-  mTransitionEffectEventSignal()
+  mTransitionEffectEventSignal(),
+  mKeyboardRepeatSettingsChangedSignal()
 {
 }
 
 Window::~Window()
 {
-  mIsBeingDeleted = true;
-
-  while ( mAdaptor && mAdaptor->IsRenderingWindows() )
-  {
-    std::this_thread::yield(); // to allow other threads to run
-  }
-
   if ( mEventHandler )
   {
     mEventHandler->RemoveObserver( *this );
@@ -127,6 +120,7 @@ void Window::Initialize(Any surface, const PositionSize& positionSize, const std
   mWindowBase->FocusChangedSignal().Connect( this, &Window::OnFocusChanged );
   mWindowBase->DeleteRequestSignal().Connect( this, &Window::OnDeleteRequest );
   mWindowBase->TransitionEffectEventSignal().Connect( this, &Window::OnTransitionEffectEvent );
+  mWindowBase->KeyboardRepeatSettingsChangedSignal().Connect( this, &Window::OnKeyboardRepeatSettingsChanged );
 
   mWindowSurface->OutputTransformedSignal().Connect( this, &Window::OnOutputTransformed );
 
@@ -168,18 +162,6 @@ void Window::OnSurfaceSet( Dali::RenderSurfaceInterface* surface )
   mWindowSurface = static_cast<WindowRenderSurface*>( surface );
 }
 
-void Window::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode )
-{
-}
-
-void Window::SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacityMode )
-{
-}
-
-void Window::RotateIndicator( Dali::Window::WindowOrientation orientation )
-{
-}
-
 void Window::SetClass( std::string name, std::string className )
 {
   mName = name;
@@ -195,18 +177,42 @@ std::string Window::GetClassName() const
 void Window::Raise()
 {
   mWindowBase->Raise();
+
+  GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
+  EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
+  if (eglGraphics)
+  {
+    eglGraphics->SetFullSwapNextFrame();
+  }
+
   DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId );
 }
 
 void Window::Lower()
 {
   mWindowBase->Lower();
+
+  GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
+  EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
+  if (eglGraphics)
+  {
+    eglGraphics->SetFullSwapNextFrame();
+  }
+
   DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId );
 }
 
 void Window::Activate()
 {
   mWindowBase->Activate();
+
+  GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
+  EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
+  if (eglGraphics)
+  {
+    eglGraphics->SetFullSwapNextFrame();
+  }
+
   DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId );
 }
 
@@ -419,6 +425,13 @@ void Window::Show()
     mVisibilityChangedSignal.Emit( handle, true );
   }
 
+  GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
+  EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
+  if (eglGraphics)
+  {
+    eglGraphics->SetFullSwapNextFrame();
+  }
+
   DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible );
 }
 
@@ -437,6 +450,14 @@ void Window::Hide()
     mVisibilityChangedSignal.Emit( handle, false );
   }
 
+
+  GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
+  EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
+  if (eglGraphics)
+  {
+    eglGraphics->SetFullSwapNextFrame();
+  }
+
   DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible );
 }
 
@@ -485,6 +506,13 @@ void Window::SetInputRegion( const Rect< int >& inputRegion )
 {
   mWindowBase->SetInputRegion( inputRegion );
 
+  GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
+  EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
+  if (eglGraphics)
+  {
+    eglGraphics->SetFullSwapNextFrame();
+  }
+
   DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetInputRegion: x = %d, y = %d, w = %d, h = %d\n", inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height );
 }
 
@@ -591,11 +619,17 @@ void Window::SetSize( Dali::Window::WindowSize size )
     DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetSize(): resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height );
 
     Dali::Window handle( this );
-    mResizedSignal.Emit( newSize );
     mResizeSignal.Emit( handle, newSize );
 
     mAdaptor->SurfaceResizeComplete( mSurface.get(), newSize );
   }
+
+  GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
+  EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
+  if (eglGraphics)
+  {
+    eglGraphics->SetFullSwapNextFrame();
+  }
 }
 
 Dali::Window::WindowSize Window::GetSize() const
@@ -616,6 +650,13 @@ void Window::SetPosition( Dali::Window::WindowPosition position )
   PositionSize oldRect = mSurface->GetPositionSize();
 
   mWindowSurface->MoveResize( PositionSize( position.GetX(), position.GetY(), oldRect.width, oldRect.height ) );
+
+  GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
+  EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
+  if (eglGraphics)
+  {
+    eglGraphics->SetFullSwapNextFrame();
+  }
 }
 
 Dali::Window::WindowPosition Window::GetPosition() const
@@ -650,10 +691,16 @@ void Window::SetPositionSize( PositionSize positionSize )
 
     DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetPositionSize():resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height );
     Dali::Window handle( this );
-    mResizedSignal.Emit( newSize );
     mResizeSignal.Emit( handle, newSize );
     mAdaptor->SurfaceResizeComplete( mSurface.get(), newSize );
   }
+
+  GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
+  EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
+  if (eglGraphics)
+  {
+    eglGraphics->SetFullSwapNextFrame();
+  }
 }
 
 Dali::Layer Window::GetRootLayer() const
@@ -718,13 +765,26 @@ void Window::OnIconifyChanged( bool iconified )
 
     DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible );
   }
+
+  GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
+  EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
+  if (eglGraphics)
+  {
+    eglGraphics->SetFullSwapNextFrame();
+  }
 }
 
 void Window::OnFocusChanged( bool focusIn )
 {
   Dali::Window handle( this );
-  mFocusChangedSignal.Emit( focusIn );
   mFocusChangeSignal.Emit( handle, focusIn );
+
+  GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
+  EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
+  if (eglGraphics)
+  {
+    eglGraphics->SetFullSwapNextFrame();
+  }
 }
 
 void Window::OnOutputTransformed()
@@ -746,6 +806,12 @@ void Window::OnTransitionEffectEvent( DevelWindow::EffectState state, DevelWindo
   mTransitionEffectEventSignal.Emit( handle, state, type );
 }
 
+void Window::OnKeyboardRepeatSettingsChanged()
+{
+  Dali::Window handle( this );
+  mKeyboardRepeatSettingsChangedSignal.Emit();
+}
+
 void Window::OnTouchPoint( Dali::Integration::Point& point, int timeStamp )
 {
   FeedTouchPoint( point, timeStamp );
@@ -779,7 +845,6 @@ void Window::OnRotation( const RotationEvent& rotation )
   DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), OnRotation(): resize signal emit [%d x %d]\n", this, mNativeWindowId, mWindowWidth, mWindowHeight );
   // Emit signal
   Dali::Window handle( this );
-  mResizedSignal.Emit( Dali::Window::WindowSize( mWindowWidth, mWindowHeight ) );
   mResizeSignal.Emit( handle, Dali::Window::WindowSize( mWindowWidth, mWindowHeight ) );
 
   mAdaptor->SurfaceResizeComplete( mSurface.get(), Adaptor::SurfaceSize( mWindowWidth, mWindowHeight ) );
@@ -791,6 +856,13 @@ void Window::OnPause()
   {
     mEventHandler->Pause();
   }
+
+  GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
+  EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
+  if (eglGraphics)
+  {
+    eglGraphics->SetFullSwapNextFrame();
+  }
 }
 
 void Window::OnResume()
@@ -799,6 +871,13 @@ void Window::OnResume()
   {
     mEventHandler->Resume();
   }
+
+  GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
+  EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
+  if (eglGraphics)
+  {
+    eglGraphics->SetFullSwapNextFrame();
+  }
 }
 
 void Window::RecalculateTouchPosition( Integration::Point& point )
@@ -917,6 +996,11 @@ void Window::SetAvailableOrientations( const Dali::Vector<Dali::Window::WindowOr
   SetAvailableAnlges( mAvailableAngles );
 }
 
+int32_t Window::GetNativeId() const
+{
+  return mWindowBase->GetNativeWindowId();
+}
+
 } // Adaptor
 
 } // Internal