[Tizen]Transfer uploadOnly flag to the core and update manager
[platform/core/uifw/dali-adaptor.git] / dali / internal / adaptor / common / combined-update-render-controller.cpp
index 2f970cb..a06def3 100644 (file)
@@ -544,6 +544,9 @@ void CombinedUpdateRenderController::UpdateRenderThread()
   {
     LOG_UPDATE_RENDER_TRACE;
 
+    // For thread safe
+    bool uploadOnly = mUploadWithoutRendering;
+
     // Performance statistics are logged upon a VSYNC tick so use this point for a VSync marker
     AddPerformanceMarker(PerformanceInterface::VSYNC);
 
@@ -574,8 +577,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.
@@ -622,7 +624,8 @@ void CombinedUpdateRenderController::UpdateRenderThread()
                  nextFrameTime,
                  updateStatus,
                  renderToFboEnabled,
-                 isRenderingToFbo);
+                 isRenderingToFbo,
+                 uploadOnly);
     AddPerformanceMarker(PerformanceInterface::UPDATE_END);
 
     unsigned int keepUpdatingStatus = updateStatus.KeepUpdating();
@@ -668,9 +671,9 @@ void CombinedUpdateRenderController::UpdateRenderThread()
     AddPerformanceMarker(PerformanceInterface::RENDER_START);
 
     // Upload shared resources
-    mCore.PreRender(renderStatus, mForceClear, mUploadWithoutRendering);
+    mCore.PreRender(renderStatus, mForceClear);
 
-    if(!mUploadWithoutRendering)
+    if(!uploadOnly)
     {
       // Go through each window
       WindowContainer windows;
@@ -689,14 +692,13 @@ 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();
 
           // Collect damage rects
-          mCore.PreRender(scene, mDamagedRects);
+          mCore.PreRender(windowRenderStatus, scene, mDamagedRects);
 
           // Render off-screen frame buffers first if any
           mCore.RenderScene(windowRenderStatus, scene, true);
@@ -704,20 +706,15 @@ void CombinedUpdateRenderController::UpdateRenderThread()
           Rect<int> clippingRect; // Empty for fbo rendering
 
           // Switch to the context of the surface, merge damaged areas for previous frames
-          windowSurface->PreRender(sceneSurfaceResized, mDamagedRects, clippingRect); // Switch GL context
-
-          if(clippingRect.IsEmpty())
+          if(windowRenderStatus.NeedsUpdate())
           {
-            mDamagedRects.clear();
+            windowSurface->PreRender(sceneSurfaceResized, mDamagedRects, clippingRect); // Switch GL context
           }
 
           // 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,7 +725,12 @@ void CombinedUpdateRenderController::UpdateRenderThread()
       }
     }
 
-    mCore.PostRender(mUploadWithoutRendering);
+    if(!uploadOnly)
+    {
+      graphics.PostRender();
+    }
+
+    mCore.PostRender();
 
     //////////////////////////////
     // DELETE SURFACE