(Partial update) Fix surface damage area 56/241456/4
authorHeeyong Song <heeyong.song@samsung.com>
Thu, 20 Aug 2020 08:20:51 +0000 (17:20 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Mon, 31 Aug 2020 02:21:08 +0000 (11:21 +0900)
- eglSwapBuffersWithDamageKHR doesn't need to consider the buffer age.
  The surface damage for frame n is the difference between frame n and frame (n-1).
- Remove SetDamageAreas

Change-Id: I470fafe564d7e9ef8cef1c2347c452fc0f1f8413

automated-tests/src/dali-adaptor/utc-Dali-Window.cpp
dali/devel-api/adaptor-framework/window-devel.cpp
dali/devel-api/adaptor-framework/window-devel.h
dali/internal/adaptor/common/combined-update-render-controller.cpp
dali/internal/graphics/gles/egl-graphics.cpp
dali/internal/graphics/gles/egl-graphics.h
dali/internal/graphics/gles/egl-implementation.cpp
dali/internal/graphics/gles/egl-implementation.h
dali/internal/window-system/common/window-impl.cpp
dali/internal/window-system/common/window-impl.h

index 719808eed4fdd01ceea4f1b0518538e7da6c931b..b02764a07c9c22b38910307b24124b53db0db883 100644 (file)
@@ -329,20 +329,3 @@ int UtcDaliWindowFocusChangeSignalN(void)
 
   END_TEST;
 }
-
-int UtcDaliWindowPartialUpdate(void)
-{
-  Dali::Window window;
-  try
-  {
-    std::vector<Rect<int>> damagedAreas;
-    DevelWindow::SetDamagedAreas(window, damagedAreas);
-    DALI_TEST_CHECK( false ); // Should not reach here!
-  }
-  catch( ... )
-  {
-    DALI_TEST_CHECK( true );
-  }
-
-  END_TEST;
-}
index 0a656902530a830315b0e6d420bb46abd78c0bd4..f883ae8bde8784d39cb4ab13f5d773c41d50d06b 100644 (file)
@@ -137,11 +137,6 @@ int32_t GetNativeId( Window window )
   return GetImplementation( window ).GetNativeId();
 }
 
-void SetDamagedAreas(Window window, std::vector<Dali::Rect<int>>& areas)
-{
-  GetImplementation(window).SetDamagedAreas(areas);
-}
-
 void AddFrameRenderedCallback( Window window, std::unique_ptr< CallbackBase > callback, int32_t frameId )
 {
   GetImplementation( window ).AddFrameRenderedCallback( std::move( callback ), frameId );
index 42de53c8dd70d04cbea1be4e47e195fc61415b91..460f198584a2ed9069b27234e16fa943820b1df8 100644 (file)
@@ -226,16 +226,6 @@ DALI_ADAPTOR_API void SetAvailableOrientations( Window window, const Dali::Vecto
  */
 DALI_ADAPTOR_API int32_t GetNativeId( Window window );
 
-/**
- * @brief Sets damaged areas of the window.
- *
- * This API is for setting static damaged areas of the window for partial update.
- *
- * @param[in] window The window instance
- * @param[in] areas The damaged areas list to set
- */
-DALI_ADAPTOR_API void SetDamagedAreas(Window window, std::vector<Dali::Rect<int>>& areas);
-
 /**
  * @brief Adds a callback that is called when the frame rendering is done by the graphics driver.
  *
index b514cb6c9a763b919a31856848eaca961336e52a..205c959e33721e5c3f9b7dee78ac2596d6dfdde8 100644 (file)
@@ -748,12 +748,8 @@ void CombinedUpdateRenderController::UpdateRenderThread()
           // clear previous frame damaged render items rects, buffer history is tracked on surface level
           mDamagedRects.clear();
 
-          // If user damaged areas are not set
-          if (!eglImpl.DamageAreasSet())
-          {
-            // Collect damage rects
-            mCore.PreRender( scene, mDamagedRects );
-          }
+          // Collect damage rects
+          mCore.PreRender( scene, mDamagedRects );
 
           // Render off-screen frame buffers first if any
           mCore.RenderScene( windowRenderStatus, scene, true );
index e13ce0b0cbc31b1aa8ebb26f172ffaf5bf0d7577..a30abd32dcd3d142c6141fab7e1d500c88afaab2 100644 (file)
@@ -129,11 +129,6 @@ EglImageExtensions* EglGraphics::GetImageExtensions()
   return mEglImageExtensions.get();
 }
 
-void EglGraphics::SetDamagedAreas(std::vector<Dali::Rect<int>>& areas)
-{
-  mEglImplementation->SetDamageAreas(areas);
-}
-
 void EglGraphics::SetFullSwapNextFrame()
 {
   mEglImplementation->SetFullSwapNextFrame();
index 410395c6ec01d15ba1fbfa52ed6dcf39903b68f6..5ddfbfb5ea95045c56b21097c0095d0797f8460d 100644 (file)
@@ -125,11 +125,6 @@ public:
    */
   EglImageExtensions* GetImageExtensions();
 
-  /**
-   * Sets fixed damaged areas for partial rendering. This overrides automatic partial rendering.
-   */
-  void SetDamagedAreas( std::vector<Dali::Rect<int>>& areas );
-
   /**
    * Instructs egl implementation to do full swap regardless of stored data, resets the data.
    */
index d0d272ba47c7816161af69c4abc240f5172f1bb0..6e39644ee47cbf00a6ee714bfdd27cc530ea6a0c 100755 (executable)
@@ -88,7 +88,6 @@ EglImplementation::EglImplementation( int multiSamplingLevel,
   mSwapBufferCountAfterResume( 0 ),
   mEglSetDamageRegionKHR( 0 ),
   mEglSwapBuffersWithDamageKHR( 0 ),
-  mBufferAge( 0 ),
   mFullSwapNextFrame( true )
 {
 }
@@ -394,17 +393,6 @@ EGLint EglImplementation::GetBufferAge(EGLSurface& eglSurface) const
   return age;
 }
 
-bool EglImplementation::DamageAreasSet() const
-{
-  return (mDamagedAreas.size() ? true : false);
-}
-
-void EglImplementation::SetDamageAreas( std::vector<Dali::Rect<int>>& damagedAreas )
-{
-  mFullSwapNextFrame = true;
-  mDamagedAreas = damagedAreas;
-}
-
 void EglImplementation::SetFullSwapNextFrame()
 {
   mFullSwapNextFrame = true;
@@ -459,48 +447,31 @@ void EglImplementation::SetDamage( EGLSurface& eglSurface, const std::vector<Rec
 
     if (mFullSwapNextFrame)
     {
-      mBufferAge = 0;
       insertRects(mBufferDamagedRects, std::vector<Rect<int>>(1, surfaceRect));
       clippingRect = Rect<int>();
       return;
     }
 
     EGLint bufferAge = GetBufferAge(eglSurface);
-    if (mDamagedAreas.size())
-    {
-      mBufferAge = bufferAge;
-      if (bufferAge == 0)
-      {
-        // Buffer age is reset
-        clippingRect = Rect<int>();
-        return;
-      }
 
-      mergeRects(clippingRect, mDamagedAreas);
-    }
-    else
+    // Buffer age 0 means the back buffer in invalid and requires full swap
+    if (!damagedRects.size() || bufferAge == 0)
     {
-      // Buffer age 0 means the back buffer in invalid and requires full swap
-      if (!damagedRects.size() || bufferAge != mBufferAge || bufferAge == 0)
-      {
-        // No damage or buffer is out of order or buffer age is reset
-        mBufferAge = bufferAge;
-        insertRects(mBufferDamagedRects, std::vector<Rect<int>>(1, surfaceRect));
-        clippingRect = Rect<int>();
-        return;
-      }
+      // No damage or buffer is out of order or buffer age is reset
+      insertRects(mBufferDamagedRects, std::vector<Rect<int>>(1, surfaceRect));
+      clippingRect = Rect<int>();
+      return;
+    }
 
-      // We push current frame damaged rects here, zero index for current frame
-      mBufferAge = bufferAge;
-      insertRects(mBufferDamagedRects, damagedRects);
+    // We push current frame damaged rects here, zero index for current frame
+    insertRects(mBufferDamagedRects, damagedRects);
 
-      // Merge damaged rects into clipping rect
-      auto bufferDamagedRects = mBufferDamagedRects.begin();
-      while (bufferAge-- >= 0 && bufferDamagedRects != mBufferDamagedRects.end())
-      {
-        const std::vector<Rect<int>>& rects = *bufferDamagedRects++;
-        mergeRects(clippingRect, rects);
-      }
+    // Merge damaged rects into clipping rect
+    auto bufferDamagedRects = mBufferDamagedRects.begin();
+    while (bufferAge-- >= 0 && bufferDamagedRects != mBufferDamagedRects.end())
+    {
+      const std::vector<Rect<int>>& rects = *bufferDamagedRects++;
+      mergeRects(clippingRect, rects);
     }
 
     if (!clippingRect.Intersect(surfaceRect) || clippingRect.Area() > surfaceRect.Area() * 0.8)
@@ -523,7 +494,7 @@ void EglImplementation::SwapBuffers(EGLSurface& eglSurface, const std::vector<Re
 {
   if (eglSurface != EGL_NO_SURFACE ) // skip if using surfaceless context
   {
-    if (!mPartialUpdateRequired || mFullSwapNextFrame || mBufferAge == 0 || !damagedRects.size())
+    if (!mPartialUpdateRequired || mFullSwapNextFrame || !damagedRects.size() || (damagedRects[0].Area() > mSurfaceRect.Area() * 0.8) )
     {
       SwapBuffers(eglSurface);
       return;
@@ -536,59 +507,30 @@ void EglImplementation::SwapBuffers(EGLSurface& eglSurface, const std::vector<Re
     }
 #endif //DALI_PROFILE_UBUNTU
 
-    if (mDamagedAreas.size())
-    {
-      // DALI_LOG_ERROR("EglImplementation::SwapBuffers(%d)\n", mDamagedAreas.size());
-      EGLBoolean result = mEglSwapBuffersWithDamageKHR(mEglDisplay, eglSurface, reinterpret_cast<int*>(mDamagedAreas.data()), mDamagedAreas.size());
-      if (result == EGL_FALSE)
-      {
-        DALI_LOG_ERROR("eglSwapBuffersWithDamageKHR(%d)\n", eglGetError());
-      }
-
-#ifndef DALI_PROFILE_UBUNTU
-      if( mSwapBufferCountAfterResume < THRESHOLD_SWAPBUFFER_COUNT )
-      {
-        DALI_LOG_RELEASE_INFO( "EglImplementation::SwapBuffers finished.\n" );
-        mSwapBufferCountAfterResume++;
-      }
-#endif //DALI_PROFILE_UBUNTU
-      return;
-    }
-
-    // current frame damaged rects were pushed by EglImplementation::SetDamage() to 0 index.
-    EGLint bufferAge = mBufferAge;
-    mCombinedDamagedRects.clear();
-
-    // Combine damaged rects from previous frames (beginning from bufferAge index) with the current frame (0 index)
-    auto bufferDamagedRects = mBufferDamagedRects.begin();
-    while (bufferAge-- >= 0 && bufferDamagedRects != mBufferDamagedRects.end())
-    {
-      const std::vector<Rect<int>>& rects = *bufferDamagedRects++;
-      mCombinedDamagedRects.insert(mCombinedDamagedRects.end(), rects.begin(), rects.end());
-    }
+    std::vector< Rect< int > > mergedRects = damagedRects;
 
     // Merge intersecting rects, form an array of non intersecting rects to help driver a bit
     // Could be optional and can be removed, needs to be checked with and without on platform
-    const int n = mCombinedDamagedRects.size();
-    for (int i = 0; i < n-1; i++)
+    const int n = mergedRects.size();
+    for(int i = 0; i < n-1; i++)
     {
-      if (mCombinedDamagedRects[i].IsEmpty())
+      if (mergedRects[i].IsEmpty())
       {
         continue;
       }
 
       for (int j = i+1; j < n; j++)
       {
-        if (mCombinedDamagedRects[j].IsEmpty())
+        if (mergedRects[j].IsEmpty())
         {
           continue;
         }
 
-        if (mCombinedDamagedRects[i].Intersects(mCombinedDamagedRects[j]))
+        if (mergedRects[i].Intersects(mergedRects[j]))
         {
-          mCombinedDamagedRects[i].Merge(mCombinedDamagedRects[j]);
-          mCombinedDamagedRects[j].width = 0;
-          mCombinedDamagedRects[j].height = 0;
+          mergedRects[i].Merge(mergedRects[j]);
+          mergedRects[j].width = 0;
+          mergedRects[j].height = 0;
         }
       }
     }
@@ -596,25 +538,24 @@ void EglImplementation::SwapBuffers(EGLSurface& eglSurface, const std::vector<Re
     int j = 0;
     for (int i = 0; i < n; i++)
     {
-      if (!mCombinedDamagedRects[i].IsEmpty())
+      if (!mergedRects[i].IsEmpty())
       {
-        mCombinedDamagedRects[j++] = mCombinedDamagedRects[i];
+        mergedRects[j++] = mergedRects[i];
       }
     }
 
     if (j != 0)
     {
-      mCombinedDamagedRects.resize(j);
+      mergedRects.resize(j);
     }
 
-    if (!mCombinedDamagedRects.size() || (mCombinedDamagedRects[0].Area() > mSurfaceRect.Area() * 0.8))
+    if (!mergedRects.size() || (mergedRects[0].Area() > mSurfaceRect.Area() * 0.8))
     {
       SwapBuffers(eglSurface);
       return;
     }
 
-    // DALI_LOG_ERROR("EglImplementation::SwapBuffers(%d)\n", mCombinedDamagedRects.size());
-    EGLBoolean result = mEglSwapBuffersWithDamageKHR(mEglDisplay, eglSurface, reinterpret_cast<int*>(mCombinedDamagedRects.data()), mCombinedDamagedRects.size());
+    EGLBoolean result = mEglSwapBuffersWithDamageKHR(mEglDisplay, eglSurface, reinterpret_cast<int*>(mergedRects.data()), mergedRects.size());
     if (result == EGL_FALSE)
     {
       DALI_LOG_ERROR("eglSwapBuffersWithDamageKHR(%d)\n", eglGetError());
index b50535252390a3b69ef79de1c811a610dd24918b..73d11bbd1f0354eddc174cd108d583f8ba3300b5 100644 (file)
@@ -134,16 +134,6 @@ public:
    */
   EGLint GetBufferAge( EGLSurface& eglSurface ) const;
 
-  /**
-   * Gets if user set damaged areas
-   */
-  bool DamageAreasSet() const;
-
-  /**
-   * Sets damaged areas, overrides auto calculated ones
-   */
-  void SetDamageAreas( std::vector<Dali::Rect<int>>& damagedArea );
-
   /**
    * Forces full surface swap next frame, resets current partial update state.
    */
@@ -290,10 +280,7 @@ private:
   PFNEGLSETDAMAGEREGIONKHRPROC mEglSetDamageRegionKHR;
   PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC mEglSwapBuffersWithDamageKHR;
 
-  EGLint mBufferAge;
   std::list<std::vector<Rect<int>>> mBufferDamagedRects;
-  std::vector<Rect<int>> mCombinedDamagedRects;
-  std::vector<Rect<int>> mDamagedAreas;
   Rect<int> mSurfaceRect;
   bool mFullSwapNextFrame;
 };
index 1e287a0792de0b5448c9bcf2970b8eb343a9387b..be1c3ade40dedfdf59ff6172bb93a2374b97512a 100755 (executable)
@@ -1001,16 +1001,6 @@ int32_t Window::GetNativeId() const
   return mWindowBase->GetNativeWindowId();
 }
 
-void Window::SetDamagedAreas(std::vector<Dali::Rect<int>>& areas)
-{
-  GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
-  EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
-  if (eglGraphics)
-  {
-    eglGraphics->SetDamagedAreas(areas);
-  }
-}
-
 } // Adaptor
 
 } // Internal
index 2b9b603f8530fb131b8f573341a8e90072adcb0e..11ea92a029f2d8bca34659149e9f9dac570d8203 100755 (executable)
@@ -342,11 +342,6 @@ public:
    */
   void SetAvailableOrientations( const Dali::Vector<Dali::Window::WindowOrientation>& orientations );
 
-  /**
-   * @copydoc Dali::DevelWindow::SetDamagedAreas()
-   */
-  void SetDamagedAreas(std::vector<Dali::Rect<int>>& areas);
-
 public: // Dali::Internal::Adaptor::SceneHolder
 
   /**