From: Heeyong Song Date: Thu, 20 Aug 2020 08:20:51 +0000 (+0900) Subject: (Partial update) Fix surface damage area X-Git-Tag: dali_1.9.29~11^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git;a=commitdiff_plain;h=66ebc91833b3a2da6ca84c24c08f078de2d893be (Partial update) Fix surface damage area - 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 --- diff --git a/automated-tests/src/dali-adaptor/utc-Dali-Window.cpp b/automated-tests/src/dali-adaptor/utc-Dali-Window.cpp index 719808e..b02764a 100644 --- a/automated-tests/src/dali-adaptor/utc-Dali-Window.cpp +++ b/automated-tests/src/dali-adaptor/utc-Dali-Window.cpp @@ -329,20 +329,3 @@ int UtcDaliWindowFocusChangeSignalN(void) END_TEST; } - -int UtcDaliWindowPartialUpdate(void) -{ - Dali::Window window; - try - { - std::vector> damagedAreas; - DevelWindow::SetDamagedAreas(window, damagedAreas); - DALI_TEST_CHECK( false ); // Should not reach here! - } - catch( ... ) - { - DALI_TEST_CHECK( true ); - } - - END_TEST; -} diff --git a/dali/devel-api/adaptor-framework/window-devel.cpp b/dali/devel-api/adaptor-framework/window-devel.cpp index 0a65690..f883ae8 100644 --- a/dali/devel-api/adaptor-framework/window-devel.cpp +++ b/dali/devel-api/adaptor-framework/window-devel.cpp @@ -137,11 +137,6 @@ int32_t GetNativeId( Window window ) return GetImplementation( window ).GetNativeId(); } -void SetDamagedAreas(Window window, std::vector>& areas) -{ - GetImplementation(window).SetDamagedAreas(areas); -} - void AddFrameRenderedCallback( Window window, std::unique_ptr< CallbackBase > callback, int32_t frameId ) { GetImplementation( window ).AddFrameRenderedCallback( std::move( callback ), frameId ); diff --git a/dali/devel-api/adaptor-framework/window-devel.h b/dali/devel-api/adaptor-framework/window-devel.h index 42de53c..460f198 100644 --- a/dali/devel-api/adaptor-framework/window-devel.h +++ b/dali/devel-api/adaptor-framework/window-devel.h @@ -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>& areas); - -/** * @brief Adds a callback that is called when the frame rendering is done by the graphics driver. * * @param[in] window The window instance diff --git a/dali/internal/adaptor/common/combined-update-render-controller.cpp b/dali/internal/adaptor/common/combined-update-render-controller.cpp index b514cb6..205c959 100644 --- a/dali/internal/adaptor/common/combined-update-render-controller.cpp +++ b/dali/internal/adaptor/common/combined-update-render-controller.cpp @@ -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 ); diff --git a/dali/internal/graphics/gles/egl-graphics.cpp b/dali/internal/graphics/gles/egl-graphics.cpp index e13ce0b..a30abd3 100644 --- a/dali/internal/graphics/gles/egl-graphics.cpp +++ b/dali/internal/graphics/gles/egl-graphics.cpp @@ -129,11 +129,6 @@ EglImageExtensions* EglGraphics::GetImageExtensions() return mEglImageExtensions.get(); } -void EglGraphics::SetDamagedAreas(std::vector>& areas) -{ - mEglImplementation->SetDamageAreas(areas); -} - void EglGraphics::SetFullSwapNextFrame() { mEglImplementation->SetFullSwapNextFrame(); diff --git a/dali/internal/graphics/gles/egl-graphics.h b/dali/internal/graphics/gles/egl-graphics.h index 410395c..5ddfbfb 100644 --- a/dali/internal/graphics/gles/egl-graphics.h +++ b/dali/internal/graphics/gles/egl-graphics.h @@ -126,11 +126,6 @@ public: EglImageExtensions* GetImageExtensions(); /** - * Sets fixed damaged areas for partial rendering. This overrides automatic partial rendering. - */ - void SetDamagedAreas( std::vector>& areas ); - - /** * Instructs egl implementation to do full swap regardless of stored data, resets the data. */ void SetFullSwapNextFrame(); diff --git a/dali/internal/graphics/gles/egl-implementation.cpp b/dali/internal/graphics/gles/egl-implementation.cpp index d0d272b..6e39644 100755 --- a/dali/internal/graphics/gles/egl-implementation.cpp +++ b/dali/internal/graphics/gles/egl-implementation.cpp @@ -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>& damagedAreas ) -{ - mFullSwapNextFrame = true; - mDamagedAreas = damagedAreas; -} - void EglImplementation::SetFullSwapNextFrame() { mFullSwapNextFrame = true; @@ -459,48 +447,31 @@ void EglImplementation::SetDamage( EGLSurface& eglSurface, const std::vector>(1, surfaceRect)); clippingRect = Rect(); return; } EGLint bufferAge = GetBufferAge(eglSurface); - if (mDamagedAreas.size()) - { - mBufferAge = bufferAge; - if (bufferAge == 0) - { - // Buffer age is reset - clippingRect = Rect(); - 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>(1, surfaceRect)); - clippingRect = Rect(); - return; - } + // No damage or buffer is out of order or buffer age is reset + insertRects(mBufferDamagedRects, std::vector>(1, surfaceRect)); + clippingRect = Rect(); + 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>& rects = *bufferDamagedRects++; - mergeRects(clippingRect, rects); - } + // Merge damaged rects into clipping rect + auto bufferDamagedRects = mBufferDamagedRects.begin(); + while (bufferAge-- >= 0 && bufferDamagedRects != mBufferDamagedRects.end()) + { + const std::vector>& 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 mSurfaceRect.Area() * 0.8) ) { SwapBuffers(eglSurface); return; @@ -536,59 +507,30 @@ void EglImplementation::SwapBuffers(EGLSurface& eglSurface, const std::vector(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>& 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 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(mCombinedDamagedRects.data()), mCombinedDamagedRects.size()); + EGLBoolean result = mEglSwapBuffersWithDamageKHR(mEglDisplay, eglSurface, reinterpret_cast(mergedRects.data()), mergedRects.size()); if (result == EGL_FALSE) { DALI_LOG_ERROR("eglSwapBuffersWithDamageKHR(%d)\n", eglGetError()); diff --git a/dali/internal/graphics/gles/egl-implementation.h b/dali/internal/graphics/gles/egl-implementation.h index b505352..73d11bb 100644 --- a/dali/internal/graphics/gles/egl-implementation.h +++ b/dali/internal/graphics/gles/egl-implementation.h @@ -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>& 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>> mBufferDamagedRects; - std::vector> mCombinedDamagedRects; - std::vector> mDamagedAreas; Rect mSurfaceRect; bool mFullSwapNextFrame; }; diff --git a/dali/internal/window-system/common/window-impl.cpp b/dali/internal/window-system/common/window-impl.cpp index 1e287a0..be1c3ad 100755 --- a/dali/internal/window-system/common/window-impl.cpp +++ b/dali/internal/window-system/common/window-impl.cpp @@ -1001,16 +1001,6 @@ int32_t Window::GetNativeId() const return mWindowBase->GetNativeWindowId(); } -void Window::SetDamagedAreas(std::vector>& areas) -{ - GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface(); - EglGraphics* eglGraphics = static_cast(&graphics); - if (eglGraphics) - { - eglGraphics->SetDamagedAreas(areas); - } -} - } // Adaptor } // Internal diff --git a/dali/internal/window-system/common/window-impl.h b/dali/internal/window-system/common/window-impl.h index 2b9b603..11ea92a 100755 --- a/dali/internal/window-system/common/window-impl.h +++ b/dali/internal/window-system/common/window-impl.h @@ -342,11 +342,6 @@ public: */ void SetAvailableOrientations( const Dali::Vector& orientations ); - /** - * @copydoc Dali::DevelWindow::SetDamagedAreas() - */ - void SetDamagedAreas(std::vector>& areas); - public: // Dali::Internal::Adaptor::SceneHolder /**