(Vector) Change ConditionalWait as Mutex at lottie task 66/306766/1
authorEunki, Hong <eunkiki.hong@samsung.com>
Tue, 27 Feb 2024 09:27:30 +0000 (18:27 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Tue, 27 Feb 2024 09:27:30 +0000 (18:27 +0900)
Change-Id: I1f652c440945a9b40a88a992018e14ae0746bc9d
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.cpp
dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.h

index 59e4e85f4a3727419e0677ee3612d0091698b5bd..cb67bc78f6f9cf5752cd66230cea2f6f5e664081 100644 (file)
@@ -73,7 +73,7 @@ VectorAnimationTask::VectorAnimationTask(VisualFactoryCache& factoryCache)
   mVectorRenderer(VectorAnimationRenderer::New()),
   mAnimationData(),
   mVectorAnimationThread(factoryCache.GetVectorAnimationManager().GetVectorAnimationThread()),
-  mConditionalWait(),
+  mMutex(),
   mResourceReadySignal(),
   mLoadCompletedCallback(MakeCallback(this, &VectorAnimationTask::OnLoadCompleted)),
   mCachedLayerInfo(),
@@ -128,23 +128,25 @@ bool VectorAnimationTask::IsReady()
 
 void VectorAnimationTask::Finalize()
 {
-  ConditionalWait::ScopedLock lock(mConditionalWait);
-
-  // Release some objects in the main thread
-  if(mAnimationFinishedCallback)
-  {
-    mVectorAnimationThread.RemoveEventTriggerCallbacks(mAnimationFinishedCallback.get());
-    mAnimationFinishedCallback.reset();
-  }
-  if(mLoadCompletedCallback)
   {
-    mVectorAnimationThread.RemoveEventTriggerCallbacks(mLoadCompletedCallback.get());
-    mLoadCompletedCallback.reset();
+    Mutex::ScopedLock lock(mMutex);
+
+    // Release some objects in the main thread
+    if(mAnimationFinishedCallback)
+    {
+      mVectorAnimationThread.RemoveEventTriggerCallbacks(mAnimationFinishedCallback.get());
+      mAnimationFinishedCallback.reset();
+    }
+    if(mLoadCompletedCallback)
+    {
+      mVectorAnimationThread.RemoveEventTriggerCallbacks(mLoadCompletedCallback.get());
+      mLoadCompletedCallback.reset();
+    }
+
+    mDestroyTask = true;
   }
 
   mVectorRenderer.Finalize();
-
-  mDestroyTask = true;
 }
 
 void VectorAnimationTask::TaskCompleted(VectorAnimationTaskPtr task)
@@ -209,7 +211,7 @@ bool VectorAnimationTask::Load(bool synchronousLoading)
     DALI_LOG_ERROR("VectorAnimationTask::Load: Load failed [%s]\n", mImageUrl.GetUrl().c_str());
     mLoadRequest = false;
     {
-      ConditionalWait::ScopedLock lock(mConditionalWait);
+      Mutex::ScopedLock lock(mMutex);
       if(!synchronousLoading && mLoadCompletedCallback)
       {
         mVectorAnimationThread.AddEventTriggerCallback(mLoadCompletedCallback.get());
@@ -240,7 +242,7 @@ bool VectorAnimationTask::Load(bool synchronousLoading)
 
   mLoadRequest = false;
   {
-    ConditionalWait::ScopedLock lock(mConditionalWait);
+    Mutex::ScopedLock lock(mMutex);
     if(!synchronousLoading && mLoadCompletedCallback)
     {
       mVectorAnimationThread.AddEventTriggerCallback(mLoadCompletedCallback.get());
@@ -268,8 +270,6 @@ bool VectorAnimationTask::Load(bool synchronousLoading)
 
 void VectorAnimationTask::SetRenderer(Renderer renderer)
 {
-  ConditionalWait::ScopedLock lock(mConditionalWait);
-
   mVectorRenderer.SetRenderer(renderer);
 
   DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetRenderer [%p]\n", this);
@@ -301,7 +301,7 @@ bool VectorAnimationTask::IsLoadRequested() const
 
 void VectorAnimationTask::SetAnimationData(const AnimationData& data)
 {
-  ConditionalWait::ScopedLock lock(mConditionalWait);
+  Mutex::ScopedLock lock(mMutex);
 
   DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetAnimationData [%p]\n", this);
 
@@ -381,7 +381,7 @@ void VectorAnimationTask::PauseAnimation()
 
 void VectorAnimationTask::SetAnimationFinishedCallback(CallbackBase* callback)
 {
-  ConditionalWait::ScopedLock lock(mConditionalWait);
+  Mutex::ScopedLock lock(mMutex);
   mAnimationFinishedCallback = std::unique_ptr<CallbackBase>(callback);
 }
 
@@ -580,7 +580,7 @@ bool VectorAnimationTask::Rasterize()
   mKeepAnimation = false;
 
   {
-    ConditionalWait::ScopedLock lock(mConditionalWait);
+    Mutex::ScopedLock lock(mMutex);
     if(mDestroyTask)
     {
       // The task will be destroyed. We don't need rasterization.
@@ -700,7 +700,7 @@ bool VectorAnimationTask::Rasterize()
 
     // Animation is finished
     {
-      ConditionalWait::ScopedLock lock(mConditionalWait);
+      Mutex::ScopedLock lock(mMutex);
       if(mNeedAnimationFinishedTrigger && mAnimationFinishedCallback)
       {
         mVectorAnimationThread.AddEventTriggerCallback(mAnimationFinishedCallback.get());
@@ -803,7 +803,7 @@ void VectorAnimationTask::ApplyAnimationData()
   uint32_t index;
 
   {
-    ConditionalWait::ScopedLock lock(mConditionalWait);
+    Mutex::ScopedLock lock(mMutex);
 
     if(!mAnimationDataUpdated || mAnimationData[mAnimationDataIndex].size() != 0)
     {
index 6d668855f7d0754f2345d3ee467ef1a4543f7875..ef895001a1907c8c46c299efb7d5cbfcebcff04f 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_VECTOR_ANIMATION_TASK_H
 
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
 // EXTERNAL INCLUDES
 #include <dali/devel-api/adaptor-framework/event-thread-callback.h>
 #include <dali/devel-api/adaptor-framework/vector-animation-renderer.h>
-#include <dali/devel-api/threading/conditional-wait.h>
+#include <dali/devel-api/threading/mutex.h>
 #include <dali/public-api/adaptor-framework/async-task-manager.h>
 #include <dali/public-api/adaptor-framework/encoded-image-buffer.h>
 #include <dali/public-api/common/vector-wrapper.h>
@@ -387,7 +387,7 @@ private:
   VectorAnimationRenderer              mVectorRenderer;
   std::vector<AnimationData>           mAnimationData[2];
   VectorAnimationThread&               mVectorAnimationThread;
-  ConditionalWait                      mConditionalWait;
+  Mutex                                mMutex;
   ResourceReadySignalType              mResourceReadySignal;
   std::unique_ptr<CallbackBase>        mAnimationFinishedCallback{};
   std::unique_ptr<CallbackBase>        mLoadCompletedCallback{};