(Partial update) Change calculation of damaged rects 00/265200/4
authorHeeyong Song <heeyong.song@samsung.com>
Tue, 12 Oct 2021 14:46:29 +0000 (23:46 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Fri, 15 Oct 2021 16:43:45 +0000 (01:43 +0900)
Separate the empty damaged rect case and the full damaged rect case

Change-Id: I6f515504f95b32c0d1a01b3851ecbc2044020a05

automated-tests/src/dali-adaptor/dali-test-suite-utils/test-application.cpp
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-application.h
dali/internal/window-system/common/window-render-surface.cpp

index 5e69c95111296bbd9ae29b1f680198a6c02d945e..440270aec9adb9013716cb23d379b7d1cd0edc80 100644 (file)
@@ -19,6 +19,8 @@
 
 namespace Dali
 {
+const Rect<int> TestApplication::DEFAULT_SURFACE_RECT = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
+
 bool TestApplication::mLoggingEnabled = true;
 
 TestApplication::TestApplication(uint32_t surfaceWidth,
@@ -225,7 +227,7 @@ bool TestApplication::PreRenderWithPartialUpdate(uint32_t intervalMilliseconds,
 
 bool TestApplication::RenderWithPartialUpdate(std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect)
 {
-  mCore->RenderScene(mRenderStatus, mScene, true /*render the off-screen buffers*/, clippingRect);
+  mCore->RenderScene(mRenderStatus, mScene, true /*render the off-screen buffers*/);
   mCore->RenderScene(mRenderStatus, mScene, false /*render the surface*/, clippingRect);
   mCore->PostRender(false /*do not skip rendering*/);
 
index 4f32cd889790d9ba0406d2da959aaa2eb7cbe2d8..02143a75d8dae19a8aa3136f6fff2f3aa5ef1cf1 100644 (file)
@@ -38,6 +38,8 @@ public:
   static const uint32_t DEFAULT_SURFACE_WIDTH  = 480;
   static const uint32_t DEFAULT_SURFACE_HEIGHT = 800;
 
+  static const Rect<int> DEFAULT_SURFACE_RECT;
+
   static constexpr uint32_t DEFAULT_HORIZONTAL_DPI = 220;
   static constexpr uint32_t DEFAULT_VERTICAL_DPI   = 217;
 
index 23ffcd9464eac11a2f12ce57644e2ab988c3d8f7..4a449517c1e8cc4c99dcd43934e0830b21bb531e 100644 (file)
@@ -554,9 +554,16 @@ bool WindowRenderSurface::PreRender(bool resizingSurface, const std::vector<Rect
 
   SetBufferDamagedRects(mDamagedRects, clippingRect);
 
-  if(clippingRect.IsEmpty())
+  Rect<int> surfaceRect(0, 0, mPositionSize.width, mPositionSize.height);
+  if(clippingRect == surfaceRect)
   {
-    mDamagedRects.clear();
+    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
@@ -749,18 +756,13 @@ void WindowRenderSurface::SetBufferDamagedRects(const std::vector<Rect<int>>& da
   auto eglGraphics = static_cast<EglGraphics*>(mGraphics);
   if(eglGraphics)
   {
-    Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
-    if(!eglImpl.IsPartialUpdateRequired())
-    {
-      return;
-    }
-
     Rect<int> surfaceRect(0, 0, mPositionSize.width, mPositionSize.height);
 
-    if(mFullSwapNextFrame)
+    Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
+    if(!eglImpl.IsPartialUpdateRequired() || mFullSwapNextFrame)
     {
       InsertRects(mBufferDamagedRects, std::vector<Rect<int>>(1, surfaceRect));
-      clippingRect = Rect<int>();
+      clippingRect = surfaceRect;
       return;
     }
 
@@ -769,10 +771,10 @@ void WindowRenderSurface::SetBufferDamagedRects(const std::vector<Rect<int>>& da
     EGLint bufferAge = eglImpl.GetBufferAge(mEGLSurface);
 
     // Buffer age 0 means the back buffer in invalid and requires full swap
-    if(!damagedRects.size() || bufferAge == 0)
+    if(bufferAge == 0)
     {
       InsertRects(mBufferDamagedRects, std::vector<Rect<int>>(1, surfaceRect));
-      clippingRect = Rect<int>();
+      clippingRect = surfaceRect;
       return;
     }
 
@@ -790,22 +792,25 @@ void WindowRenderSurface::SetBufferDamagedRects(const std::vector<Rect<int>>& da
     if(!clippingRect.Intersect(surfaceRect) || clippingRect.Area() > surfaceRect.Area() * FULL_UPDATE_RATIO)
     {
       // clipping area too big or doesn't intersect surface rect
-      clippingRect = Rect<int>();
+      clippingRect = surfaceRect;
       return;
     }
 
-    std::vector<Rect<int>>   damagedRegion;
-    Dali::Integration::Scene scene = mScene.GetHandle();
-    if(scene)
+    if(!clippingRect.IsEmpty())
     {
-      damagedRegion.push_back(RecalculateRect[std::min(scene.GetCurrentSurfaceOrientation() / 90, 3)](clippingRect, scene.GetCurrentSurfaceRect()));
-    }
-    else
-    {
-      damagedRegion.push_back(clippingRect);
-    }
+      std::vector<Rect<int>>   damagedRegion;
+      Dali::Integration::Scene scene = mScene.GetHandle();
+      if(scene)
+      {
+        damagedRegion.push_back(RecalculateRect[std::min(scene.GetCurrentSurfaceOrientation() / 90, 3)](clippingRect, scene.GetCurrentSurfaceRect()));
+      }
+      else
+      {
+        damagedRegion.push_back(clippingRect);
+      }
 
-    eglImpl.SetDamageRegion(mEGLSurface, damagedRegion);
+      eglImpl.SetDamageRegion(mEGLSurface, damagedRegion);
+    }
   }
 }
 
@@ -826,7 +831,7 @@ void WindowRenderSurface::SwapBuffers(const std::vector<Rect<int>>& damagedRects
 
     Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
 
-    if(!eglImpl.IsPartialUpdateRequired() || mFullSwapNextFrame || !damagedRects.size() || (damagedRects[0].Area() > surfaceRect.Area() * FULL_UPDATE_RATIO))
+    if(!eglImpl.IsPartialUpdateRequired() || mFullSwapNextFrame || (damagedRects.size() != 0 && damagedRects[0].Area() > surfaceRect.Area() * FULL_UPDATE_RATIO))
     {
       mFullSwapNextFrame = false;
       eglImpl.SwapBuffers(mEGLSurface);
@@ -879,6 +884,8 @@ void WindowRenderSurface::SwapBuffers(const std::vector<Rect<int>>& damagedRects
 
     if(!mergedRects.size() || (mergedRects[0].Area() > surfaceRect.Area() * FULL_UPDATE_RATIO))
     {
+      // In normal cases, WindowRenderSurface::SwapBuffers() will not be called if mergedRects.size() is 0.
+      // For exceptional cases, swap full area.
       eglImpl.SwapBuffers(mEGLSurface);
     }
     else