Add to get the status whether window is rotating or not
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / common / window-render-surface.cpp
index 8e3c997..c6cee4a 100644 (file)
@@ -211,7 +211,7 @@ void WindowRenderSurface::SetTransparency(bool transparent)
   mWindowBase->SetTransparency(transparent);
 }
 
-void WindowRenderSurface::RequestRotation(int angle, int width, int height)
+void WindowRenderSurface::RequestRotation(int angle, PositionSize positionSize)
 {
   if(!mPostRenderTrigger)
   {
@@ -219,8 +219,7 @@ void WindowRenderSurface::RequestRotation(int angle, int width, int height)
                                                                                                       TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER));
   }
 
-  mPositionSize.width  = width;
-  mPositionSize.height = height;
+  mPositionSize = positionSize;
 
   mWindowRotationAngle    = angle;
   mWindowRotationFinished = false;
@@ -228,7 +227,7 @@ void WindowRenderSurface::RequestRotation(int angle, int width, int height)
 
   mWindowBase->SetWindowRotationAngle(mWindowRotationAngle);
 
-  DALI_LOG_INFO(gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::Rotate: angle = %d screen rotation = %d\n", mWindowRotationAngle, mScreenRotationAngle);
+  DALI_LOG_RELEASE_INFO("angle = %d screen rotation = %d, flag = %d\n", mWindowRotationAngle, mScreenRotationAngle, mWindowRotationFinished);
 }
 
 WindowBase* WindowRenderSurface::GetWindowBase()
@@ -316,8 +315,9 @@ void WindowRenderSurface::CreateSurface()
   Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
   mEGLSurface                                   = eglImpl.CreateSurfaceWindow(window, mColorDepth);
 
-  DALI_LOG_RELEASE_INFO("WindowRenderSurface::CreateSurface: WinId (%d), w = %d h = %d angle = %d screen rotation = %d\n",
+  DALI_LOG_RELEASE_INFO("WindowRenderSurface::CreateSurface: WinId (%d), EGLSurface (%p), w = %d h = %d angle = %d screen rotation = %d\n",
                         mWindowBase->GetNativeWindowId(),
+                        mEGLSurface,
                         mPositionSize.width,
                         mPositionSize.height,
                         mWindowRotationAngle,
@@ -377,6 +377,41 @@ bool WindowRenderSurface::ReplaceGraphicsSurface()
   return eglImpl.ReplaceSurfaceWindow(window, mEGLSurface, mEGLContext);
 }
 
+void WindowRenderSurface::UpdatePositionSize(Dali::PositionSize positionSize)
+{
+  bool needToMove   = false;
+  bool needToResize = false;
+
+  // Check moving
+  if((fabs(positionSize.x - mPositionSize.x) >= MINIMUM_DIMENSION_CHANGE) ||
+     (fabs(positionSize.y - mPositionSize.y) >= MINIMUM_DIMENSION_CHANGE))
+  {
+    needToMove = true;
+  }
+
+  // Check resizing
+  if((fabs(positionSize.width - mPositionSize.width) >= MINIMUM_DIMENSION_CHANGE) ||
+     (fabs(positionSize.height - mPositionSize.height) >= MINIMUM_DIMENSION_CHANGE))
+  {
+    needToResize = true;
+  }
+
+  if(needToResize)
+  {
+    mResizeFinished = false;
+    mPositionSize   = positionSize;
+  }
+  else
+  {
+    if(needToMove)
+    {
+      mPositionSize = positionSize;
+    }
+  }
+
+  DALI_LOG_INFO(gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::MoveResize: %d, %d, %d, %d\n", mPositionSize.x, mPositionSize.y, mPositionSize.width, mPositionSize.height);
+}
+
 void WindowRenderSurface::MoveResize(Dali::PositionSize positionSize)
 {
   bool needToMove   = false;
@@ -546,7 +581,7 @@ bool WindowRenderSurface::PreRender(bool resizingSurface, const std::vector<Rect
       mWindowBase->ResizeEglWindow(positionSize);
       mResizeFinished = true;
 
-      DALI_LOG_RELEASE_INFO("WindowRenderSurface::PreRender: Set resize, x: %d, y: %d, w: %d, h:%d\n", positionSize.x, positionSize.y, positionSize.width, positionSize.height);
+      DALI_LOG_RELEASE_INFO("WindowRenderSurface::PreRender: Set resize, totalAngle: %d, x: %d, y: %d, w: %d, h:%d\n", totalAngle, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
     }
 
     SetFullSwapNextFrame();
@@ -555,16 +590,19 @@ bool WindowRenderSurface::PreRender(bool resizingSurface, const std::vector<Rect
 
   SetBufferDamagedRects(mDamagedRects, clippingRect);
 
-  Rect<int> surfaceRect(0, 0, mPositionSize.width, mPositionSize.height);
-  if(clippingRect == surfaceRect)
-  {
-    mDamagedRects.assign(1, surfaceRect);
-  }
-  else if(mDamagedRects.empty() && !clippingRect.IsEmpty())
+  if(scene)
   {
-    // We will render clippingRect area but mDamagedRects is empty.
-    // So make mDamagedRects same with clippingRect to swap buffers.
-    mDamagedRects.assign(1, clippingRect);
+    Rect<int> surfaceRect = scene.GetCurrentSurfaceRect();
+    if(clippingRect == surfaceRect)
+    {
+      mDamagedRects.assign(1, surfaceRect);
+    }
+    else if(mDamagedRects.empty() && !clippingRect.IsEmpty())
+    {
+      // We will render clippingRect area but mDamagedRects is empty.
+      // So make mDamagedRects same with clippingRect to swap buffers.
+      mDamagedRects.assign(1, clippingRect);
+    }
   }
 
   // This is now done when the render pass for the render surface begins
@@ -709,13 +747,18 @@ void WindowRenderSurface::OutputTransformed()
   }
 }
 
+bool WindowRenderSurface::IsWindowRotating() const
+{
+  return !(mWindowRotationFinished);
+}
+
 void WindowRenderSurface::ProcessPostRender()
 {
   if(!mWindowRotationFinished)
   {
     mWindowBase->WindowRotationCompleted(mWindowRotationAngle, mPositionSize.width, mPositionSize.height);
-    DALI_LOG_RELEASE_INFO("WindowRenderSurface::ProcessPostRender: Rotation Done\n");
     mWindowRotationFinished = true;
+    DALI_LOG_RELEASE_INFO("WindowRenderSurface::ProcessPostRender: Rotation Done, flag = %d\n", mWindowRotationFinished);
   }
 
   if(mIsImeWindowSurface)
@@ -786,8 +829,15 @@ void WindowRenderSurface::SetBufferDamagedRects(const std::vector<Rect<int>>& da
   auto eglGraphics = static_cast<EglGraphics*>(mGraphics);
   if(eglGraphics)
   {
+    // If scene is not exist, just use stored mPositionSize.
     Rect<int> surfaceRect(0, 0, mPositionSize.width, mPositionSize.height);
 
+    Dali::Integration::Scene scene = mScene.GetHandle();
+    if(scene)
+    {
+      surfaceRect = scene.GetCurrentSurfaceRect();
+    }
+
     Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
     if(!eglImpl.IsPartialUpdateRequired() || mFullSwapNextFrame)
     {
@@ -828,8 +878,7 @@ void WindowRenderSurface::SetBufferDamagedRects(const std::vector<Rect<int>>& da
 
     if(!clippingRect.IsEmpty())
     {
-      std::vector<Rect<int>>   damagedRegion;
-      Dali::Integration::Scene scene = mScene.GetHandle();
+      std::vector<Rect<int>> damagedRegion;
       if(scene)
       {
         damagedRegion.push_back(RecalculateRect[std::min(scene.GetCurrentSurfaceOrientation() / 90, 3)](clippingRect, scene.GetCurrentSurfaceRect()));