(Vector) Move multiple tasks into completed queue only one time 08/316308/1
authorEunki, Hong <eunkiki.hong@samsung.com>
Mon, 19 Aug 2024 07:33:17 +0000 (16:33 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Mon, 19 Aug 2024 07:36:04 +0000 (16:36 +0900)
Since we don't need to call + trace for each tasks (We already collect container!)
let we call the Move queue with container type, and print log only 1 time per
each Rasterize loop.

Change-Id: I64d6eb76c82e2b4b90476b7d5966fd3ca5420ddb
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali-toolkit/internal/visuals/animated-vector-image/vector-animation-thread.cpp
dali-toolkit/internal/visuals/animated-vector-image/vector-animation-thread.h

index eda66b96e01cfeef472334be18a4918fe6536bcf..ff9b7770fbe929b68ffecfabcd91a78ac9d99d9a 100644 (file)
@@ -286,48 +286,55 @@ bool VectorAnimationThread::MoveTasksToAnimation(VectorAnimationTaskPtr task, bo
 }
 
 /// VectorAnimationThread called
-void VectorAnimationThread::MoveTasksToCompleted(VectorAnimationTaskPtr task, bool keepAnimation)
+void VectorAnimationThread::MoveTasksToCompleted(CompletedTasksContainer&& completedTasksQueue)
 {
   // DevNote : We need to consume task queue, and notify even if mDestroyThread is true.
   // Since we should make ensure that all working tasks are completed before destroying the thread.
   DALI_TRACE_BEGIN_WITH_MESSAGE_GENERATOR(gTraceFilter, "VECTOR_ANIMATION_THREAD_COMPLETED_TASK", [&](std::ostringstream& oss) {
-    oss << "[w:" << mWorkingTasks.size() << ",c:" << mCompletedTasks.size() << "]";
+    oss << "[w:" << mWorkingTasks.size() << ",c:" << mCompletedTasks.size() << ",i:" << completedTasksQueue.size() << "]";
   });
   bool needRasterize = false;
 
-  VectorAnimationTaskSet::const_iterator workingIter = mWorkingTasks.find(task);
-  if(workingIter != mWorkingTasks.cend())
+  for(auto&& taskPair : completedTasksQueue)
   {
-    mWorkingTasks.erase(workingIter);
-  }
+    auto& task          = taskPair.first;
+    bool  keepAnimation = taskPair.second;
 
-  if(DALI_LIKELY(!mDestroyThread))
-  {
-    // Check pending task
+    VectorAnimationTaskSet::const_iterator workingIter = mWorkingTasks.find(task);
+    if(workingIter != mWorkingTasks.cend())
     {
-      Mutex::ScopedLock animationTasksLock(mAnimationTasksMutex);
-      if(mAnimationTasks.end() != std::find(mAnimationTasks.begin(), mAnimationTasks.end(), task))
-      {
-        needRasterize = true;
-      }
+      mWorkingTasks.erase(workingIter);
     }
 
-    if(keepAnimation)
+    if(DALI_LIKELY(!mDestroyThread))
     {
-      VectorAnimationTaskSet::const_iterator completedIter = mCompletedTasks.lower_bound(task);
-      if(completedIter == mCompletedTasks.cend() || task < *completedIter)
+      // Check pending task
+      if(!needRasterize)
       {
-        mCompletedTasks.insert(completedIter, task);
-        needRasterize = true;
+        Mutex::ScopedLock animationTasksLock(mAnimationTasksMutex);
+        if(mAnimationTasks.end() != std::find(mAnimationTasks.begin(), mAnimationTasks.end(), task))
+        {
+          needRasterize = true;
+        }
       }
-    }
 
-    if(needRasterize)
-    {
-      mNeedToSleep = false;
+      if(keepAnimation)
+      {
+        VectorAnimationTaskSet::const_iterator completedIter = mCompletedTasks.lower_bound(task);
+        if(completedIter == mCompletedTasks.cend() || task < *completedIter)
+        {
+          mCompletedTasks.insert(completedIter, task);
+          needRasterize = true;
+        }
+      }
     }
   }
 
+  if(needRasterize)
+  {
+    mNeedToSleep = false;
+  }
+
   DALI_TRACE_END_WITH_MESSAGE_GENERATOR(gTraceFilter, "VECTOR_ANIMATION_THREAD_COMPLETED_TASK", [&](std::ostringstream& oss) {
     oss << "[w:" << mWorkingTasks.size() << ",c:" << mCompletedTasks.size() << ",r?" << needRasterize << ",s?" << mNeedToSleep << "]";
   });
@@ -359,12 +366,7 @@ void VectorAnimationThread::Rasterize()
       }
     }
 
-    for(auto&& taskPair : completedTasksQueue)
-    {
-      auto& task          = taskPair.first;
-      bool  keepAnimation = taskPair.second;
-      MoveTasksToCompleted(task, keepAnimation);
-    }
+    MoveTasksToCompleted(std::move(completedTasksQueue));
   }
 
   mNeedToSleep = true;
index 03fa9f5abb74f45c1dd0064ce980fc892983638c..61ff71b06882d55a80d6538be98532216ab2cbe0 100644 (file)
@@ -114,10 +114,12 @@ private:
    */
   bool MoveTasksToAnimation(VectorAnimationTaskPtr task, bool useCurrentTime);
 
+  using CompletedTasksContainer = std::vector<std::pair<VectorAnimationTaskPtr, bool>>; ///< Pair of completed task, and rasterize required.
+
   /**
    * @brief Move given tasks to mCompletedTasks if required.
    */
-  void MoveTasksToCompleted(VectorAnimationTaskPtr task, bool keepAnimation);
+  void MoveTasksToCompleted(CompletedTasksContainer&& completedTasksQueue);
 
 private:
   /**