(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 719808e..b02764a 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 0a65690..f883ae8 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 42de53c..460f198 100644 (file)
@@ -227,16 +227,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.
  *
  * @param[in] window The window instance
index b514cb6..205c959 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 e13ce0b..a30abd3 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 410395c..5ddfbfb 100644 (file)
@@ -126,11 +126,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.
    */
   void SetFullSwapNextFrame();
index d0d272b..6e39644 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 b505352..73d11bb 100644 (file)
@@ -135,16 +135,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.
    */
   void SetFullSwapNextFrame();
@@ -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 1e287a0..be1c3ad 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 2b9b603..11ea92a 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
 
   /**