(Vector) Minor optimization during move RenderData and Texture 26/320126/2
authorEunki, Hong <eunkiki.hong@samsung.com>
Fri, 8 Nov 2024 04:45:32 +0000 (13:45 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Mon, 11 Nov 2024 00:52:57 +0000 (09:52 +0900)
- Use std::move for shared_ptr<RenderData> instead copy & reset.
- Check finalization for ubuntu renderer

Change-Id: I79197e38d844f6ac6285ae952e8615119589571d
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali-extension/vector-animation-renderer/vector-animation-renderer-tizen.cpp
dali-extension/vector-animation-renderer/vector-animation-renderer-x.cpp

index ade1da7452846fa2ed0e609b2bf945117ff9675c..8064296565e6832248971039e0aa38b949720473 100644 (file)
@@ -82,7 +82,7 @@ bool VectorAnimationRendererTizen::Render(uint32_t frameNumber)
       if(mPreparedRenderingData)
       {
         mPreviousRenderingData.push_back(mCurrentRenderingData);
-        mCurrentRenderingData = mPreparedRenderingData;
+        mCurrentRenderingData = std::move(mPreparedRenderingData);
         mPreparedRenderingData.reset();
         mResourceReady = false;
       }
@@ -223,14 +223,15 @@ bool VectorAnimationRendererTizen::Render(uint32_t frameNumber)
 
   if(!mResourceReady)
   {
-    mPreviousTextures.push_back(mRenderedTexture); // It is used to destroy the object in the main thread.
-
-    if(renderingDataImpl->mTexture)
+    // Only move the ownership of the texture to the renderer when it is valid.
+    if(renderingDataImpl->mTexture && mRenderedTexture != renderingDataImpl->mTexture)
     {
-      // Only move the ownership of the texture to the renderer when it is valid.
+      mPreviousTextures.push_back(mRenderedTexture); // It is used to destroy the object in the main thread.
+
       mRenderedTexture = std::move(renderingDataImpl->mTexture);
     }
 
+    // Don't need to keep reference of texture.
     renderingDataImpl->mTexture.Reset();
 
     mResourceReady          = true;
index 8566eb90763eab813bc1642e4811a0dc16cf4908..73f95725bdad8ccc21b01159527f6ba895b51dbd 100644 (file)
@@ -77,7 +77,7 @@ bool VectorAnimationRendererX::Render(uint32_t frameNumber)
       if(mPreparedRenderingData)
       {
         mPreviousRenderingData.push_back(mCurrentRenderingData);
-        mCurrentRenderingData = mPreparedRenderingData;
+        mCurrentRenderingData = std::move(mPreparedRenderingData);
         mPreparedRenderingData.reset();
         mResourceReady = false;
       }
@@ -91,6 +91,12 @@ bool VectorAnimationRendererX::Render(uint32_t frameNumber)
   }
 
   Dali::Mutex::ScopedLock lock(mMutex);
+  if(DALI_UNLIKELY(mFinalized))
+  {
+    // Fast-out if finalized.
+    return false;
+  }
+
   if(!mVectorRenderer || !renderingDataImpl->mPixelBuffer)
   {
     return false;