Add partial update support. 02/234102/8
authorAnton Obzhirov <a.obzhirov@samsung.com>
Wed, 20 May 2020 19:53:44 +0000 (20:53 +0100)
committerAnton Obzhirov <a.obzhirov@samsung.com>
Fri, 19 Jun 2020 15:34:07 +0000 (16:34 +0100)
Change-Id: I0b6129903affd0fa0b22ef319ff9d78720f8fdc3

automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-application.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-application.h
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-scene-holder-impl.h

index e8c0d12..b2a3fb9 100644 (file)
@@ -26,13 +26,15 @@ TestApplication::TestApplication( uint32_t surfaceWidth,
                                   uint32_t surfaceHeight,
                                   uint32_t  horizontalDpi,
                                   uint32_t  verticalDpi,
-                                  bool initialize )
+                                  bool initialize,
+                                  bool enablePartialUpdate )
 : mCore( NULL ),
   mSurfaceWidth( surfaceWidth ),
   mSurfaceHeight( surfaceHeight ),
   mFrame( 0u ),
   mDpi{ horizontalDpi, verticalDpi },
-  mLastVSyncTime(0u)
+  mLastVSyncTime(0u),
+  mPartialUpdateEnabled(enablePartialUpdate)
 {
   if( initialize )
   {
@@ -59,7 +61,8 @@ void TestApplication::CreateCore()
                                         mGlContextHelperAbstraction,
                                         Integration::RenderToFrameBuffer::FALSE,
                                         Integration::DepthBufferAvailable::TRUE,
-                                        Integration::StencilBufferAvailable::TRUE );
+                                        Integration::StencilBufferAvailable::TRUE,
+                                        mPartialUpdateEnabled ? Integration::PartialUpdateAvailable::TRUE : Integration::PartialUpdateAvailable::FALSE );
 
   mCore->ContextCreated();
 
@@ -193,8 +196,8 @@ bool TestApplication::Render( uint32_t intervalMilliseconds, const char* locatio
   mRenderStatus.SetNeedsPostRender( false );
 
   mCore->PreRender( mRenderStatus, false /*do not force clear*/, false /*do not skip rendering*/ );
-  mCore->RenderScene( mRenderStatus, mScene, true /*render the off-screen buffers*/);
-  mCore->RenderScene( mRenderStatus, mScene, false /*render the surface*/);
+  mCore->RenderScene( mRenderStatus, mScene, true /*render the off-screen buffers*/ );
+  mCore->RenderScene( mRenderStatus, mScene, false /*render the surface*/ );
   mCore->PostRender( false /*do not skip rendering*/ );
 
   mFrame++;
@@ -202,6 +205,27 @@ bool TestApplication::Render( uint32_t intervalMilliseconds, const char* locatio
   return mStatus.KeepUpdating() || mRenderStatus.NeedsUpdate();
 }
 
+bool TestApplication::PreRenderWithPartialUpdate(uint32_t intervalMilliseconds, const char* location, std::vector<Rect<int>>& damagedRects)
+{
+  DoUpdate(intervalMilliseconds, location);
+
+  mCore->PreRender(mRenderStatus, false /*do not force clear*/, false /*do not skip rendering*/ );
+  mCore->PreRender(mScene, damagedRects);
+
+  return mStatus.KeepUpdating() || mRenderStatus.NeedsUpdate();
+}
+
+bool TestApplication::RenderWithPartialUpdate(std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect)
+{
+  mCore->RenderScene(mRenderStatus, mScene, true /*render the off-screen buffers*/, clippingRect);
+  mCore->RenderScene(mRenderStatus, mScene, false /*render the surface*/, clippingRect);
+  mCore->PostRender(false /*do not skip rendering*/);
+
+  mFrame++;
+
+  return mStatus.KeepUpdating() || mRenderStatus.NeedsUpdate();
+}
+
 uint32_t TestApplication::GetUpdateStatus()
 {
   return mStatus.KeepUpdating();
@@ -227,8 +251,8 @@ bool TestApplication::RenderOnly( )
 {
   // Update Time values
   mCore->PreRender( mRenderStatus, false /*do not force clear*/, false /*do not skip rendering*/ );
-  mCore->RenderScene( mRenderStatus, mScene, true /*render the off-screen buffers*/);
-  mCore->RenderScene( mRenderStatus, mScene, false /*render the surface*/);
+  mCore->RenderScene( mRenderStatus, mScene, true /*render the off-screen buffers*/ );
+  mCore->RenderScene( mRenderStatus, mScene, false /*render the surface*/ );
   mCore->PostRender( false /*do not skip rendering*/ );
 
   mFrame++;
index e96f759..1df0743 100644 (file)
@@ -51,7 +51,8 @@ public:
                    uint32_t surfaceHeight = DEFAULT_SURFACE_HEIGHT,
                    uint32_t horizontalDpi = DEFAULT_HORIZONTAL_DPI,
                    uint32_t verticalDpi   = DEFAULT_VERTICAL_DPI,
-                   bool initialize = true );
+                   bool initialize = true,
+                   bool enablePartialUpdate = false );
 
   void Initialize();
   void CreateCore();
@@ -69,6 +70,8 @@ public:
   void ProcessEvent(const Integration::Event& event);
   void SendNotification();
   bool Render( uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL, const char* location=NULL );
+  bool PreRenderWithPartialUpdate(uint32_t intervalMilliseconds, const char* location, std::vector<Rect<int>>& damagedRects);
+  bool RenderWithPartialUpdate(std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect);
   uint32_t GetUpdateStatus();
   bool UpdateOnly( uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL );
   bool RenderOnly( );
@@ -108,6 +111,7 @@ protected:
 
   struct { uint32_t x; uint32_t y; } mDpi;
   uint32_t mLastVSyncTime;
+  bool mPartialUpdateEnabled;
   static bool mLoggingEnabled;
 };
 
index b466cfc..52c11c2 100644 (file)
@@ -49,9 +49,9 @@ public:
 
   virtual void StartRender() {};
 
-  virtual bool PreRender( bool resizingSurface ) { return false; };
+  virtual bool PreRender( bool resizingSurface, const std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect  ) { return false; };
 
-  virtual void PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface ) {};
+  virtual void PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface, const std::vector<Rect<int>>& damagedRects ) {};
 
   virtual void StopRender() {};