2 * Copyright (c) 2024 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.h>
22 #include <dali/devel-api/adaptor-framework/file-loader.h>
23 #include <dali/integration-api/debug.h>
24 #include <dali/integration-api/trace.h>
25 #include <dali/public-api/math/math-utils.h>
26 #include <dali/public-api/object/property-array.h>
29 #include <dali-toolkit/internal/visuals/animated-vector-image/vector-animation-manager.h>
30 #include <dali-toolkit/internal/visuals/animated-vector-image/vector-animation-thread.h>
31 #include <dali-toolkit/internal/visuals/image-visual-shader-factory.h>
48 constexpr auto LOOP_FOREVER = -1;
49 constexpr auto MICROSECONDS_PER_SECOND(1e+6);
51 #if defined(DEBUG_ENABLED)
52 Debug::Filter* gVectorAnimationLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_VECTOR_ANIMATION");
55 DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_IMAGE_PERFORMANCE_MARKER, false);
58 uint64_t GetNanoseconds()
60 // Get the time of a monotonic clock since its epoch.
61 auto epoch = std::chrono::steady_clock::now().time_since_epoch();
62 auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(epoch);
63 return static_cast<uint64_t>(duration.count());
67 } // unnamed namespace
69 VectorAnimationTask::VectorAnimationTask(VisualFactoryCache& factoryCache)
70 : AsyncTask(MakeCallback(this, &VectorAnimationTask::TaskCompleted), AsyncTask::PriorityType::HIGH, AsyncTask::ThreadType::WORKER_THREAD),
72 mEncodedImageBuffer(),
73 mVectorRenderer(VectorAnimationRenderer::New()),
75 mVectorAnimationThread(factoryCache.GetVectorAnimationManager().GetVectorAnimationThread()),
77 mResourceReadySignal(),
78 mLoadCompletedCallback(MakeCallback(this, &VectorAnimationTask::OnLoadCompleted)),
81 mPlayState(PlayState::STOPPED),
82 mStopBehavior(DevelImageVisual::StopBehavior::CURRENT_FRAME),
83 mLoopingMode(DevelImageVisual::LoopingMode::RESTART),
84 mNextFrameStartTime(),
85 mFrameDurationMicroSeconds(MICROSECONDS_PER_SECOND / 60.0f),
94 mAnimationDataIndex(0),
95 mLoopCount(LOOP_FOREVER),
98 mUpdateFrameNumber(false),
99 mNeedAnimationFinishedTrigger(true),
100 mAnimationDataUpdated(false),
105 mKeepAnimation(false),
106 mLayerInfoCached(false),
107 mMarkerInfoCached(false),
108 mEnableFrameCache(false),
111 mVectorRenderer.UploadCompletedSignal().Connect(this, &VectorAnimationTask::OnUploadCompleted);
114 VectorAnimationTask::~VectorAnimationTask()
116 DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::~VectorAnimationTask: destructor [%p]\n", this);
119 void VectorAnimationTask::Process()
121 mRasterized = Rasterize();
124 bool VectorAnimationTask::IsReady()
129 void VectorAnimationTask::Finalize()
132 Mutex::ScopedLock lock(mMutex);
134 // Release some objects in the main thread
135 if(mAnimationFinishedCallback)
137 mVectorAnimationThread.RemoveEventTriggerCallbacks(mAnimationFinishedCallback.get());
138 mAnimationFinishedCallback.reset();
140 if(mLoadCompletedCallback)
142 mVectorAnimationThread.RemoveEventTriggerCallbacks(mLoadCompletedCallback.get());
143 mLoadCompletedCallback.reset();
149 mVectorRenderer.Finalize();
152 void VectorAnimationTask::TaskCompleted(VectorAnimationTaskPtr task)
154 mVectorAnimationThread.OnTaskCompleted(task, task->IsRasterized(), task->IsAnimating());
157 bool VectorAnimationTask::IsRasterized()
162 bool VectorAnimationTask::IsAnimating()
164 return mKeepAnimation;
167 bool VectorAnimationTask::Load(bool synchronousLoading)
170 uint64_t mStartTimeNanoSceonds = 0;
171 uint64_t mEndTimeNanoSceonds = 0;
172 if(gTraceFilter && gTraceFilter->IsTraceEnabled())
174 mStartTimeNanoSceonds = GetNanoseconds();
175 std::ostringstream oss;
176 oss << "[u:" << mImageUrl.GetEllipsedUrl() << "]";
177 // DALI_TRACE_BEGIN(gTraceFilter, "DALI_LOTTIE_LOADING_TASK"); ///< TODO : Open it if we can control trace log level
178 DALI_LOG_RELEASE_INFO("BEGIN: DALI_LOTTIE_LOADING_TASK %s", oss.str().c_str());
182 if(mEncodedImageBuffer)
184 if(!mVectorRenderer.Load(mEncodedImageBuffer.GetRawBuffer()))
189 // We don't need to hold image buffer anymore.
190 mEncodedImageBuffer.Reset();
192 else if(mImageUrl.IsLocalResource())
194 if(!mVectorRenderer.Load(mImageUrl.GetUrl()))
201 Dali::Vector<uint8_t> remoteData;
202 if(!Dali::FileLoader::DownloadFileSynchronously(mImageUrl.GetUrl(), remoteData) || // Failed if we fail to download json file,
203 !mVectorRenderer.Load(remoteData)) // or download data is not valid vector animation file.
211 DALI_LOG_ERROR("VectorAnimationTask::Load: Load failed [%s]\n", mImageUrl.GetUrl().c_str());
212 mLoadRequest = false;
214 Mutex::ScopedLock lock(mMutex);
215 if(!synchronousLoading && mLoadCompletedCallback)
217 mVectorAnimationThread.AddEventTriggerCallback(mLoadCompletedCallback.get());
221 if(gTraceFilter && gTraceFilter->IsTraceEnabled())
223 mEndTimeNanoSceonds = GetNanoseconds();
224 std::ostringstream oss;
225 oss << std::fixed << std::setprecision(3);
227 oss << "d:" << static_cast<float>(mEndTimeNanoSceonds - mStartTimeNanoSceonds) / 1000000.0f << "ms ";
228 oss << "u:" << mImageUrl.GetEllipsedUrl() << "]";
229 // DALI_TRACE_END(gTraceFilter, "DALI_LOTTIE_LOADING_TASK"); ///< TODO : Open it if we can control trace log level
230 DALI_LOG_RELEASE_INFO("END: DALI_LOTTIE_LOADING_TASK %s", oss.str().c_str());
236 mTotalFrame = mVectorRenderer.GetTotalFrameNumber();
238 mEndFrame = mTotalFrame - 1;
240 mFrameRate = mVectorRenderer.GetFrameRate();
241 mFrameDurationMicroSeconds = MICROSECONDS_PER_SECOND / mFrameRate;
243 mLoadRequest = false;
245 Mutex::ScopedLock lock(mMutex);
246 if(!synchronousLoading && mLoadCompletedCallback)
248 mVectorAnimationThread.AddEventTriggerCallback(mLoadCompletedCallback.get());
252 DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::Load: file = %s [%d frames, %f fps] [%p]\n", mImageUrl.GetUrl().c_str(), mTotalFrame, mFrameRate, this);
255 if(gTraceFilter && gTraceFilter->IsTraceEnabled())
257 mEndTimeNanoSceonds = GetNanoseconds();
258 std::ostringstream oss;
259 oss << std::fixed << std::setprecision(3);
261 oss << "d:" << static_cast<float>(mEndTimeNanoSceonds - mStartTimeNanoSceonds) / 1000000.0f << "ms ";
262 oss << "u:" << mImageUrl.GetEllipsedUrl() << "]";
263 // DALI_TRACE_END(gTraceFilter, "DALI_LOTTIE_LOADING_TASK"); ///< TODO : Open it if we can control trace log level
264 DALI_LOG_RELEASE_INFO("END: DALI_LOTTIE_LOADING_TASK %s", oss.str().c_str());
271 void VectorAnimationTask::SetRenderer(Renderer renderer)
273 mVectorRenderer.SetRenderer(renderer);
275 DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetRenderer [%p]\n", this);
278 void VectorAnimationTask::RequestLoad(const VisualUrl& url, EncodedImageBuffer encodedImageBuffer, bool synchronousLoading)
281 mEncodedImageBuffer = encodedImageBuffer;
283 if(!synchronousLoading)
287 mVectorAnimationThread.AddTask(this);
297 bool VectorAnimationTask::IsLoadRequested() const
302 void VectorAnimationTask::SetAnimationData(const AnimationData& data)
304 Mutex::ScopedLock lock(mMutex);
306 DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetAnimationData [%p]\n", this);
308 uint32_t index = mAnimationDataIndex == 0 ? 1 : 0; // Use the other buffer
310 mAnimationData[index].push_back(data);
311 mAnimationDataUpdated = true;
313 if(data.resendFlag & VectorAnimationTask::RESEND_SIZE)
315 // The size should be changed in the main thread.
316 SetSize(data.width, data.height);
319 mVectorAnimationThread.AddTask(this);
322 void VectorAnimationTask::SetSize(uint32_t width, uint32_t height)
324 if(mWidth != width || mHeight != height)
326 mVectorRenderer.SetSize(width, height);
331 // If fixedCache is enabled, Call KeepRasterizedBuffer()
332 if(mEnableFrameCache)
334 if(mTotalFrame > 0 && !mLoadFailed)
336 mVectorRenderer.KeepRasterizedBuffer();
340 // If Load is not yet, update the size later.
345 DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetSize: width = %d, height = %d [%p]\n", width, height, this);
349 void VectorAnimationTask::PlayAnimation()
351 if(mPlayState != PlayState::PLAYING)
353 mNeedAnimationFinishedTrigger = true;
354 mUpdateFrameNumber = false;
355 mPlayState = PlayState::PLAYING;
357 DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::PlayAnimation: Play [%p]\n", this);
361 void VectorAnimationTask::StopAnimation()
363 if(mPlayState != PlayState::STOPPING)
365 mNeedAnimationFinishedTrigger = false;
366 mPlayState = PlayState::STOPPING;
368 DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::StopAnimation: Stop [%p]\n", this);
372 void VectorAnimationTask::PauseAnimation()
374 if(mPlayState == PlayState::PLAYING)
376 mPlayState = PlayState::PAUSED;
378 DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::PauseAnimation: Pause [%p]\n", this);
382 void VectorAnimationTask::SetAnimationFinishedCallback(CallbackBase* callback)
384 Mutex::ScopedLock lock(mMutex);
385 mAnimationFinishedCallback = std::unique_ptr<CallbackBase>(callback);
388 void VectorAnimationTask::SetLoopCount(int32_t count)
390 if(mLoopCount != count)
395 DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetLoopCount: [%d] [%p]\n", count, this);
399 void VectorAnimationTask::SetPlayRange(const Property::Array& playRange)
402 uint32_t startFrame = 0, endFrame = 0;
403 size_t count = playRange.Count();
407 int32_t start = 0, end = 0;
408 if(playRange.GetElementAt(0).Get(start) && playRange.GetElementAt(1).Get(end))
410 startFrame = static_cast<uint32_t>(start);
411 endFrame = static_cast<uint32_t>(end);
416 std::string startMarker, endMarker;
417 if(playRange.GetElementAt(0).Get(startMarker) && playRange.GetElementAt(1).Get(endMarker))
421 uint32_t frame; // We don't use this later
422 if(mVectorRenderer.GetMarkerInfo(startMarker, startFrame, frame) && mVectorRenderer.GetMarkerInfo(endMarker, frame, endFrame))
433 if(playRange.GetElementAt(0).Get(marker))
435 if(mVectorRenderer && mVectorRenderer.GetMarkerInfo(marker, startFrame, endFrame))
444 DALI_LOG_ERROR("VectorAnimationTask::SetPlayRange: Invalid range [%p]\n", this);
448 // Make sure the range specified is between 0 and the total frame number
449 startFrame = std::min(startFrame, mTotalFrame - 1);
450 endFrame = std::min(endFrame, mTotalFrame - 1);
452 // If the range is not in order swap values
453 if(startFrame > endFrame)
455 uint32_t temp = startFrame;
456 startFrame = endFrame;
460 if(startFrame != mStartFrame || endFrame != mEndFrame)
462 mStartFrame = startFrame;
463 mEndFrame = endFrame;
465 // If the current frame is out of the range, change the current frame also.
466 if(mStartFrame > mCurrentFrame)
468 mCurrentFrame = mStartFrame;
470 else if(mEndFrame < mCurrentFrame)
472 mCurrentFrame = mEndFrame;
475 DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetPlayRange: [%d, %d] [%s] [%p]\n", mStartFrame, mEndFrame, mImageUrl.GetUrl().c_str(), this);
479 void VectorAnimationTask::GetPlayRange(uint32_t& startFrame, uint32_t& endFrame)
481 startFrame = mStartFrame;
482 endFrame = mEndFrame;
485 void VectorAnimationTask::SetCurrentFrameNumber(uint32_t frameNumber)
487 if(mCurrentFrame == frameNumber)
489 DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetCurrentFrameNumber: Set same frame [%d] [%p]\n", frameNumber, this);
493 if(frameNumber >= mStartFrame && frameNumber <= mEndFrame)
495 mCurrentFrame = frameNumber;
496 mUpdateFrameNumber = false;
498 DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetCurrentFrameNumber: frame number = %d [%p]\n", mCurrentFrame, this);
502 DALI_LOG_ERROR("Invalid frame number [%d (%d, %d)] [%p]\n", frameNumber, mStartFrame, mEndFrame, this);
506 uint32_t VectorAnimationTask::GetCurrentFrameNumber() const
508 return mCurrentFrame;
511 uint32_t VectorAnimationTask::GetTotalFrameNumber() const
516 void VectorAnimationTask::GetDefaultSize(uint32_t& width, uint32_t& height) const
518 mVectorRenderer.GetDefaultSize(width, height);
521 void VectorAnimationTask::SetStopBehavior(DevelImageVisual::StopBehavior::Type stopBehavior)
523 mStopBehavior = stopBehavior;
525 DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetStopBehavior: stop behavor = %d [%p]\n", mStopBehavior, this);
528 void VectorAnimationTask::SetLoopingMode(DevelImageVisual::LoopingMode::Type loopingMode)
530 mLoopingMode = loopingMode;
532 DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetLoopingMode: looping mode = %d [%p]\n", mLoopingMode, this);
535 void VectorAnimationTask::GetLayerInfo(Property::Map& map) const
537 // Fast-out if file is loading, or load failed.
538 if(mLoadFailed || IsLoadRequested())
543 if(DALI_UNLIKELY(!mLayerInfoCached))
545 // Update only 1 time.
546 mLayerInfoCached = true;
547 mVectorRenderer.GetLayerInfo(mCachedLayerInfo);
550 map = mCachedLayerInfo;
553 void VectorAnimationTask::GetMarkerInfo(Property::Map& map) const
555 // Fast-out if file is loading, or load failed.
556 if(mLoadFailed || IsLoadRequested())
561 if(DALI_UNLIKELY(!mMarkerInfoCached))
563 // Update only 1 time.
564 mMarkerInfoCached = true;
565 mVectorRenderer.GetMarkerInfo(mCachedMarkerInfo);
568 map = mCachedMarkerInfo;
571 VectorAnimationTask::ResourceReadySignalType& VectorAnimationTask::ResourceReadySignal()
573 return mResourceReadySignal;
576 bool VectorAnimationTask::Rasterize()
578 bool stopped = false;
579 uint32_t currentFrame;
580 mKeepAnimation = false;
583 Mutex::ScopedLock lock(mMutex);
586 // The task will be destroyed. We don't need rasterization.
602 uint64_t mStartTimeNanoSceonds = 0;
603 uint64_t mEndTimeNanoSceonds = 0;
605 DALI_TRACE_BEGIN_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_LOTTIE_RASTERIZE_TASK", [&](std::ostringstream& oss) {
606 mStartTimeNanoSceonds = GetNanoseconds();
607 oss << "[s:" << mWidth << "x" << mHeight << " ";
608 oss << "u:" << mImageUrl.GetEllipsedUrl() << "]";
611 ApplyAnimationData();
613 if(mPlayState == PlayState::PLAYING && mUpdateFrameNumber)
615 mCurrentFrame = mForward ? mCurrentFrame + mDroppedFrames + 1 : (mCurrentFrame > mDroppedFrames ? mCurrentFrame - mDroppedFrames - 1 : 0);
616 Dali::ClampInPlace(mCurrentFrame, mStartFrame, mEndFrame);
619 currentFrame = mCurrentFrame;
621 mUpdateFrameNumber = true;
623 if(mPlayState == PlayState::STOPPING)
625 mCurrentFrame = GetStoppedFrame(mStartFrame, mEndFrame, mCurrentFrame);
626 currentFrame = mCurrentFrame;
629 else if(mPlayState == PlayState::PLAYING)
631 bool animationFinished = false;
633 if(currentFrame >= mEndFrame) // last frame
635 if(mLoopingMode == DevelImageVisual::LoopingMode::AUTO_REVERSE)
641 if(mLoopCount < 0 || ++mCurrentLoop < mLoopCount) // repeat forever or before the last loop
643 mCurrentFrame = mStartFrame;
644 mUpdateFrameNumber = false;
648 animationFinished = true; // end of animation
652 else if(currentFrame == mStartFrame && !mForward) // first frame
654 if(mLoopCount < 0 || ++mCurrentLoop < mLoopCount) // repeat forever or before the last loop
660 animationFinished = true; // end of animation
664 if(animationFinished)
666 if(mStopBehavior == DevelImageVisual::StopBehavior::CURRENT_FRAME)
672 mPlayState = PlayState::STOPPING;
678 bool renderSuccess = false;
681 renderSuccess = mVectorRenderer.Render(currentFrame);
684 DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::Rasterize: Rendering failed. Try again later.[%d] [%p]\n", currentFrame, this);
685 mUpdateFrameNumber = false;
689 if(stopped && renderSuccess)
691 mPlayState = PlayState::STOPPED;
697 // Notify the Renderer that rendering is stopped.
698 mVectorRenderer.RenderStopped();
701 // Animation is finished
703 Mutex::ScopedLock lock(mMutex);
704 if(mNeedAnimationFinishedTrigger && mAnimationFinishedCallback)
706 mVectorAnimationThread.AddEventTriggerCallback(mAnimationFinishedCallback.get());
710 DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::Rasterize: Animation is finished [current = %d] [%p]\n", currentFrame, this);
713 if(mPlayState != PlayState::PAUSED && mPlayState != PlayState::STOPPED)
715 mKeepAnimation = true;
718 DALI_TRACE_END_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_LOTTIE_RASTERIZE_TASK", [&](std::ostringstream& oss) {
719 mEndTimeNanoSceonds = GetNanoseconds();
720 oss << std::fixed << std::setprecision(3);
722 oss << "d:" << static_cast<float>(mEndTimeNanoSceonds - mStartTimeNanoSceonds) / 1000000.0f << "ms ";
723 oss << "s:" << mWidth << "x" << mHeight << " ";
724 oss << "f:" << mCurrentFrame << " ";
725 oss << "l:" << mCurrentLoop << " ";
726 oss << "p:" << mPlayState << " ";
727 oss << "u:" << mImageUrl.GetEllipsedUrl() << "]";
733 uint32_t VectorAnimationTask::GetStoppedFrame(uint32_t startFrame, uint32_t endFrame, uint32_t currentFrame)
735 uint32_t frame = currentFrame;
737 switch(mStopBehavior)
739 case DevelImageVisual::StopBehavior::FIRST_FRAME:
744 case DevelImageVisual::StopBehavior::LAST_FRAME:
746 if(mLoopingMode == DevelImageVisual::LoopingMode::AUTO_REVERSE)
756 case DevelImageVisual::StopBehavior::CURRENT_FRAME:
758 frame = currentFrame;
766 VectorAnimationTask::TimePoint VectorAnimationTask::CalculateNextFrameTime(bool renderNow)
768 // std::chrono::time_point template has second parameter duration which defaults to the std::chrono::steady_clock supported
769 // duration. In some C++11 implementations it is a milliseconds duration, so it fails to compile unless mNextFrameStartTime
770 // is casted to use the default duration.
771 mNextFrameStartTime = std::chrono::time_point_cast<TimePoint::duration>(mNextFrameStartTime + std::chrono::microseconds(mFrameDurationMicroSeconds));
772 auto current = std::chrono::steady_clock::now();
777 mNextFrameStartTime = current;
779 else if(mNextFrameStartTime < current)
781 uint32_t droppedFrames = 0;
783 while(current > std::chrono::time_point_cast<TimePoint::duration>(mNextFrameStartTime + std::chrono::microseconds(mFrameDurationMicroSeconds)) && droppedFrames < mTotalFrame)
786 mNextFrameStartTime = std::chrono::time_point_cast<TimePoint::duration>(mNextFrameStartTime + std::chrono::microseconds(mFrameDurationMicroSeconds));
789 mNextFrameStartTime = current;
790 mDroppedFrames = droppedFrames;
793 return mNextFrameStartTime;
796 VectorAnimationTask::TimePoint VectorAnimationTask::GetNextFrameTime()
798 return mNextFrameStartTime;
801 void VectorAnimationTask::ApplyAnimationData()
806 Mutex::ScopedLock lock(mMutex);
808 if(!mAnimationDataUpdated || mAnimationData[mAnimationDataIndex].size() != 0)
810 // Data is not updated or the previous data is not applied yet.
814 mAnimationDataIndex = mAnimationDataIndex == 0 ? 1 : 0; // Swap index
815 mAnimationDataUpdated = false;
817 index = mAnimationDataIndex;
820 for(const auto& animationData : mAnimationData[index])
822 if(animationData.resendFlag & VectorAnimationTask::RESEND_LOOP_COUNT)
824 SetLoopCount(animationData.loopCount);
827 if(animationData.resendFlag & VectorAnimationTask::RESEND_PLAY_RANGE)
829 SetPlayRange(animationData.playRange);
832 if(animationData.resendFlag & VectorAnimationTask::RESEND_STOP_BEHAVIOR)
834 SetStopBehavior(animationData.stopBehavior);
837 if(animationData.resendFlag & VectorAnimationTask::RESEND_LOOPING_MODE)
839 SetLoopingMode(animationData.loopingMode);
842 if(animationData.resendFlag & VectorAnimationTask::RESEND_CURRENT_FRAME)
844 SetCurrentFrameNumber(animationData.currentFrame);
847 if(animationData.resendFlag & VectorAnimationTask::RESEND_NEED_RESOURCE_READY)
849 mVectorRenderer.InvalidateBuffer();
852 if(animationData.resendFlag & VectorAnimationTask::RESEND_DYNAMIC_PROPERTY)
854 for(auto&& iter : animationData.dynamicProperties)
856 mVectorRenderer.AddPropertyValueCallback(iter.keyPath, static_cast<VectorAnimationRenderer::VectorProperty>(iter.property), iter.callback, iter.id);
860 if(animationData.resendFlag & VectorAnimationTask::RESEND_PLAY_STATE)
862 if(animationData.playState == DevelImageVisual::PlayState::PLAYING)
866 else if(animationData.playState == DevelImageVisual::PlayState::PAUSED)
870 else if(animationData.playState == DevelImageVisual::PlayState::STOPPED)
878 mAnimationData[index].clear();
881 void VectorAnimationTask::OnUploadCompleted()
883 mResourceReadySignal.Emit(ResourceStatus::READY);
886 void VectorAnimationTask::OnLoadCompleted()
890 if(mEnableFrameCache && mSizeUpdated)
892 mVectorRenderer.KeepRasterizedBuffer();
893 mSizeUpdated = false;
895 mResourceReadySignal.Emit(ResourceStatus::LOADED);
899 mResourceReadySignal.Emit(ResourceStatus::FAILED);
902 } // namespace Internal
904 } // namespace Toolkit