Performance Improvements: Remove unnecessary SwapBuffer calls 20/136220/4
authorTom Robinson <tom.robinson@samsung.com>
Wed, 28 Jun 2017 14:03:40 +0000 (15:03 +0100)
committerTom Robinson <tom.robinson@samsung.com>
Fri, 30 Jun 2017 18:33:20 +0000 (19:33 +0100)
Change-Id: I156fd428fa16de10ea2de1839893c2470da614e7

adaptors/base/combined-update-render/combined-update-render-controller.cpp
adaptors/base/separate-update-render/render-thread.cpp
adaptors/base/single-threaded/single-thread-controller.cpp
adaptors/base/single-threaded/single-thread-controller.h

index 5f9e700d6736bfaaeedf872691e198841d951595..432e1ba18d3bf7ef949c2020248f2092da855b1c 100644 (file)
@@ -459,7 +459,10 @@ void CombinedUpdateRenderController::UpdateRenderThread()
     mCore.Render( renderStatus );
     AddPerformanceMarker( PerformanceInterface::RENDER_END );
 
-    mRenderHelper.PostRender();
+    if( renderStatus.NeedsPostRender() )
+    {
+      mRenderHelper.PostRender();
+    }
 
     // Trigger event thread to request Update/Render thread to sleep if update not required
     if( ( Integration::KeepUpdating::NOT_REQUESTED == keepUpdatingStatus ) &&
index e31a98bd64941a976f09ff7af56512c5cccc5cdc..5d57c9e412db58124dc2193c85797478714bd9bd 100644 (file)
@@ -139,8 +139,11 @@ bool RenderThread::Run()
         mThreadSynchronization.RenderFinished();
 
         // Perform any post-render operations
-        DALI_LOG_INFO( gRenderLogFilter, Debug::Verbose, "RenderThread::Run. 4 - PostRender()\n");
-        mRenderHelper.PostRender();
+        if( renderStatus.NeedsPostRender() )
+        {
+          DALI_LOG_INFO( gRenderLogFilter, Debug::Verbose, "RenderThread::Run. 4 - PostRender()\n");
+          mRenderHelper.PostRender();
+        }
       }
     }
 
index b5905b69927ef3a91b1c6b1bda8efe173e109a7e..e24429a9552934f7c0cfcf1142f86730694bcb73 100644 (file)
@@ -176,10 +176,7 @@ void SingleThreadController::RequestUpdateOnce()
     Integration::UpdateStatus status;
     mCore.Update( 0.0f, mLastUpdateRenderTime, mLastUpdateRenderTime + mRefreshRate * MILLISECONDS_PER_FRAME, status );
 
-    Integration::RenderStatus renderStatus;
-    mRenderHelper.PreRender();
-    mCore.Render( renderStatus );
-    mRenderHelper.PostRender();
+    Render();
   }
 }
 
@@ -258,17 +255,10 @@ void SingleThreadController::UpdateRender( bool incrementTime )
   if( mState != State::STOPPED )
   {
     mRenderHelper.ConsumeEvents();
-    mRenderHelper.PreRender();
-
-    Integration::RenderStatus renderStatus;
-    AddPerformanceMarker( PerformanceInterface::RENDER_START );
-    mCore.Render( renderStatus );
-    AddPerformanceMarker( PerformanceInterface::RENDER_END );
 
-    mRenderHelper.PostRender();
+    const bool needsUpdate = Render();
 
-    if( ! keepUpdatingStatus &&
-        ! renderStatus.NeedsUpdate() )
+    if( !keepUpdatingStatus && !needsUpdate )
     {
       ChangeState( State::SLEEPING );
     }
@@ -337,6 +327,23 @@ void SingleThreadController::StopRendering()
   mRenderHelper.ShutdownEgl();
 }
 
+bool SingleThreadController::Render()
+{
+  mRenderHelper.PreRender();
+
+  Integration::RenderStatus renderStatus;
+  AddPerformanceMarker( PerformanceInterface::RENDER_START );
+  mCore.Render( renderStatus );
+  AddPerformanceMarker( PerformanceInterface::RENDER_END );
+
+  if( renderStatus.NeedsPostRender() )
+  {
+    mRenderHelper.PostRender();
+  }
+
+  return renderStatus.NeedsUpdate();
+}
+
 } // namespace Adaptor
 
 } // namespace Internal
index e5bf6768e8e9eeb575815498ed114cd3ed9bd69d..01dbdb19f4fe46d5ed7ef80370f21a491313381f 100644 (file)
@@ -166,6 +166,12 @@ private:
    */
   void StopRendering();
 
+  /**
+   * Runs render (along with pre & post steps as required).
+   * @return True if an update is required.
+   */
+  bool Render();
+
 private:
 
   Dali::Timer                       mTimer;                           ///< Ensures an update & render is run every frame.