+ DALI_LOG_RELEASE_INFO("WindowRenderSurface::OnFileDescriptorEventDispatched: Frame rendered [%d]\n", fileDescriptor);
+
+ std::unique_ptr<FrameCallbackInfo> callbackInfo;
+ {
+ Dali::Mutex::ScopedLock lock(mMutex);
+ auto frameCallbackInfo = std::find_if(mFrameCallbackInfoContainer.begin(), mFrameCallbackInfoContainer.end(), [fileDescriptor](std::unique_ptr<FrameCallbackInfo>& callbackInfo) {
+ return callbackInfo->fileDescriptor == fileDescriptor;
+ });
+ if(frameCallbackInfo != mFrameCallbackInfoContainer.end())
+ {
+ callbackInfo = std::move(*frameCallbackInfo);
+
+ mFrameCallbackInfoContainer.erase(frameCallbackInfo);
+ }
+ }
+
+ // Call the connected callback
+ if(callbackInfo)
+ {
+ for(auto&& iter : (callbackInfo)->callbacks)
+ {
+ CallbackBase::Execute(*(iter.first), iter.second);
+ }
+ }
+}
+
+void WindowRenderSurface::SetBufferDamagedRects(const std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect)
+{
+ 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)
+ {
+ InsertRects(mBufferDamagedRects, std::vector<Rect<int>>(1, surfaceRect));
+ clippingRect = Rect<int>();
+ return;
+ }
+
+ EGLint bufferAge = eglImpl.GetBufferAge(mEGLSurface);
+
+ // Buffer age 0 means the back buffer in invalid and requires full swap
+ if(!damagedRects.size() || bufferAge == 0)
+ {
+ InsertRects(mBufferDamagedRects, std::vector<Rect<int>>(1, surfaceRect));
+ clippingRect = Rect<int>();
+ return;
+ }
+
+ // 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);
+ }
+
+ if(!clippingRect.Intersect(surfaceRect) || clippingRect.Area() > surfaceRect.Area() * FULL_UPDATE_RATIO)
+ {
+ // clipping area too big or doesn't intersect surface rect
+ clippingRect = Rect<int>();
+ return;
+ }
+
+ 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);
+ }
+}