- 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());
- }
-
- // 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++)
- {
- if (mCombinedDamagedRects[i].IsEmpty())
- {
- continue;
- }
-
- for (int j = i+1; j < n; j++)
- {
- if (mCombinedDamagedRects[j].IsEmpty())
- {
- continue;
- }
-
- if (mCombinedDamagedRects[i].Intersects(mCombinedDamagedRects[j]))
- {
- mCombinedDamagedRects[i].Merge(mCombinedDamagedRects[j]);
- mCombinedDamagedRects[j].width = 0;
- mCombinedDamagedRects[j].height = 0;
- }
- }
- }
-
- int j = 0;
- for (int i = 0; i < n; i++)
- {
- if (!mCombinedDamagedRects[i].IsEmpty())
- {
- mCombinedDamagedRects[j++] = mCombinedDamagedRects[i];
- }
- }
-
- if (j != 0)
- {
- mCombinedDamagedRects.resize(j);
- }
-
- if (!mCombinedDamagedRects.size() || (mCombinedDamagedRects[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());