+
+ // Upload shared resources
+ mCore.PreRender( renderStatus, mForceClear, mUploadWithoutRendering );
+
+ if ( !mUploadWithoutRendering )
+ {
+ // Go through each window
+ WindowContainer windows;
+ mAdaptorInterfaces.GetWindowContainerInterface( windows );
+
+ for( auto&& window : windows )
+ {
+ Dali::Integration::Scene scene = window->GetScene();
+ Dali::RenderSurfaceInterface* windowSurface = window->GetSurface();
+
+ if ( scene && windowSurface )
+ {
+ Integration::RenderStatus windowRenderStatus;
+
+ windowSurface->InitializeGraphics();
+
+ // clear previous frame damaged render items rects, buffer history is tracked on surface level
+ mDamagedRects.clear();
+
+ // Collect damage rects
+ mCore.PreRender( scene, mDamagedRects );
+
+ // Render off-screen frame buffers first if any
+ mCore.RenderScene( windowRenderStatus, scene, true );
+
+ Rect<int> clippingRect; // Empty for fbo rendering
+
+ // Switch to the EGL context of the surface, merge damaged areas for previous frames
+ windowSurface->PreRender( surfaceResized, mDamagedRects, clippingRect ); // Switch GL context
+
+ if (clippingRect.IsEmpty())
+ {
+ mDamagedRects.clear();
+ }
+
+ // Render the surface
+ mCore.RenderScene( windowRenderStatus, scene, false, clippingRect );
+
+ if( windowRenderStatus.NeedsPostRender() )
+ {
+ windowSurface->PostRender( false, false, surfaceResized, mDamagedRects ); // Swap Buffer with damage
+ }
+ }
+ }
+ }
+
+ mCore.PostRender( mUploadWithoutRendering );
+
+ //////////////////////////////
+ // DELETE SURFACE
+ //////////////////////////////
+
+ Dali::RenderSurfaceInterface* deletedSurface = ShouldSurfaceBeDeleted();
+ if( DALI_UNLIKELY( deletedSurface ) )
+ {
+ LOG_UPDATE_RENDER_TRACE_FMT( "Deleting Surface" );
+
+ deletedSurface->DestroySurface();
+
+ SurfaceDeleted();
+ }
+