Merge branch 'devel/master' into tizen
[platform/core/uifw/dali-adaptor.git] / dali / internal / adaptor / common / combined-update-render-controller.cpp
index 2f970cb..cd81f5c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -574,8 +574,7 @@ void CombinedUpdateRenderController::UpdateRenderThread()
       // Then create a new pixmap/window and new surface
       // If the new surface has a different display connection, then the context will be lost
       mAdaptorInterfaces.GetDisplayConnectionInterface().Initialize();
-      newSurface->InitializeGraphics();
-      newSurface->MakeContextCurrent();
+      graphics.ActivateSurfaceContext(newSurface);
       // TODO: ReplaceGraphicsSurface doesn't work, InitializeGraphics()
       // already creates new surface window, the surface and the context.
       // We probably don't need ReplaceGraphicsSurface at all.
@@ -617,12 +616,14 @@ void CombinedUpdateRenderController::UpdateRenderThread()
     Integration::UpdateStatus updateStatus;
 
     AddPerformanceMarker(PerformanceInterface::UPDATE_START);
+    TRACE_UPDATE_RENDER_BEGIN("DALI_UPDATE");
     mCore.Update(frameDelta,
                  currentTime,
                  nextFrameTime,
                  updateStatus,
                  renderToFboEnabled,
                  isRenderingToFbo);
+    TRACE_UPDATE_RENDER_END("DALI_UPDATE");
     AddPerformanceMarker(PerformanceInterface::UPDATE_END);
 
     unsigned int keepUpdatingStatus = updateStatus.KeepUpdating();
@@ -666,6 +667,7 @@ void CombinedUpdateRenderController::UpdateRenderThread()
     Integration::RenderStatus renderStatus;
 
     AddPerformanceMarker(PerformanceInterface::RENDER_START);
+    TRACE_UPDATE_RENDER_BEGIN("DALI_RENDER");
 
     // Upload shared resources
     mCore.PreRender(renderStatus, mForceClear, mUploadWithoutRendering);
@@ -689,8 +691,7 @@ void CombinedUpdateRenderController::UpdateRenderThread()
 
           // Get Surface Resized flag
           sceneSurfaceResized = scene.IsSurfaceRectChanged();
-
-          windowSurface->InitializeGraphics();
+          windowSurface->SetIsResizing(sceneSurfaceResized);
 
           // clear previous frame damaged render items rects, buffer history is tracked on surface level
           mDamagedRects.clear();
@@ -706,18 +707,10 @@ void CombinedUpdateRenderController::UpdateRenderThread()
           // Switch to the context of the surface, merge damaged areas for previous frames
           windowSurface->PreRender(sceneSurfaceResized, 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, sceneSurfaceResized, mDamagedRects); // Swap Buffer with damage
-          }
+          // Buffer swapping now happens when the surface render target is presented.
 
           // If surface is resized, the surface resized count is decreased.
           if(DALI_UNLIKELY(sceneSurfaceResized))
@@ -728,6 +721,11 @@ void CombinedUpdateRenderController::UpdateRenderThread()
       }
     }
 
+    if(!mUploadWithoutRendering)
+    {
+      graphics.PostRender();
+    }
+
     mCore.PostRender(mUploadWithoutRendering);
 
     //////////////////////////////
@@ -744,6 +742,7 @@ void CombinedUpdateRenderController::UpdateRenderThread()
       SurfaceDeleted();
     }
 
+    TRACE_UPDATE_RENDER_END("DALI_RENDER");
     AddPerformanceMarker(PerformanceInterface::RENDER_END);
 
     mForceClear = false;