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 mAppliedPlayStateId(0u),
96 mLoopCount(LOOP_FOREVER),
99 mUpdateFrameNumber(false),
100 mNeedAnimationFinishedTrigger(true),
101 mAnimationDataUpdated(false),
106 mKeepAnimation(false),
107 mLayerInfoCached(false),
108 mMarkerInfoCached(false),
109 mEnableFrameCache(false),
112 mVectorRenderer.UploadCompletedSignal().Connect(this, &VectorAnimationTask::OnUploadCompleted);
115 VectorAnimationTask::~VectorAnimationTask()
117 DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::~VectorAnimationTask: destructor [%p]\n", this);
120 void VectorAnimationTask::Process()
122 mRasterized = Rasterize();
125 bool VectorAnimationTask::IsReady()
130 void VectorAnimationTask::Finalize()
133 Mutex::ScopedLock lock(mMutex);
135 // Release some objects in the main thread
136 if(mAnimationFinishedCallback)
138 mVectorAnimationThread.RemoveEventTriggerCallbacks(mAnimationFinishedCallback.get());
139 mAnimationFinishedCallback.reset();
141 if(mLoadCompletedCallback)
143 mVectorAnimationThread.RemoveEventTriggerCallbacks(mLoadCompletedCallback.get());
144 mLoadCompletedCallback.reset();
150 mVectorRenderer.Finalize();
153 void VectorAnimationTask::TaskCompleted(VectorAnimationTaskPtr task)
155 mVectorAnimationThread.OnTaskCompleted(task, task->IsRasterized(), task->IsAnimating());
158 bool VectorAnimationTask::IsRasterized()
163 bool VectorAnimationTask::IsAnimating()
165 return mKeepAnimation;
168 bool VectorAnimationTask::Load(bool synchronousLoading)
171 uint64_t mStartTimeNanoSceonds = 0;
172 uint64_t mEndTimeNanoSceonds = 0;
173 if(gTraceFilter && gTraceFilter->IsTraceEnabled())
175 mStartTimeNanoSceonds = GetNanoseconds();
176 std::ostringstream oss;
177 oss << "[u:" << mImageUrl.GetEllipsedUrl() << "]";
178 // DALI_TRACE_BEGIN(gTraceFilter, "DALI_LOTTIE_LOADING_TASK"); ///< TODO : Open it if we can control trace log level
179 DALI_LOG_RELEASE_INFO("BEGIN: DALI_LOTTIE_LOADING_TASK %s", oss.str().c_str());
183 if(mEncodedImageBuffer)
185 if(!mVectorRenderer.Load(mEncodedImageBuffer.GetRawBuffer()))
190 // We don't need to hold image buffer anymore.
191 mEncodedImageBuffer.Reset();
193 else if(mImageUrl.IsLocalResource())
195 if(!mVectorRenderer.Load(mImageUrl.GetUrl()))
202 Dali::Vector<uint8_t> remoteData;
203 if(!Dali::FileLoader::DownloadFileSynchronously(mImageUrl.GetUrl(), remoteData) || // Failed if we fail to download json file,
204 !mVectorRenderer.Load(remoteData)) // or download data is not valid vector animation file.
212 DALI_LOG_ERROR("VectorAnimationTask::Load: Load failed [%s]\n", mImageUrl.GetUrl().c_str());
213 mLoadRequest = false;
215 Mutex::ScopedLock lock(mMutex);
216 if(!synchronousLoading && mLoadCompletedCallback)
218 mVectorAnimationThread.AddEventTriggerCallback(mLoadCompletedCallback.get(), 0u);
222 if(gTraceFilter && gTraceFilter->IsTraceEnabled())
224 mEndTimeNanoSceonds = GetNanoseconds();
225 std::ostringstream oss;
226 oss << std::fixed << std::setprecision(3);
228 oss << "d:" << static_cast<float>(mEndTimeNanoSceonds - mStartTimeNanoSceonds) / 1000000.0f << "ms ";
229 oss << "u:" << mImageUrl.GetEllipsedUrl() << "]";
230 // DALI_TRACE_END(gTraceFilter, "DALI_LOTTIE_LOADING_TASK"); ///< TODO : Open it if we can control trace log level
231 DALI_LOG_RELEASE_INFO("END: DALI_LOTTIE_LOADING_TASK %s", oss.str().c_str());
237 mTotalFrame = mVectorRenderer.GetTotalFrameNumber();
239 mEndFrame = mTotalFrame - 1;
241 mFrameRate = mVectorRenderer.GetFrameRate();
242 mFrameDurationMicroSeconds = MICROSECONDS_PER_SECOND / mFrameRate;
244 mLoadRequest = false;
246 Mutex::ScopedLock lock(mMutex);
247 if(!synchronousLoading && mLoadCompletedCallback)
249 mVectorAnimationThread.AddEventTriggerCallback(mLoadCompletedCallback.get(), 0u);
253 DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::Load: file = %s [%d frames, %f fps] [%p]\n", mImageUrl.GetUrl().c_str(), mTotalFrame, mFrameRate, this);
256 if(gTraceFilter && gTraceFilter->IsTraceEnabled())
258 mEndTimeNanoSceonds = GetNanoseconds();
259 std::ostringstream oss;
260 oss << std::fixed << std::setprecision(3);
262 oss << "d:" << static_cast<float>(mEndTimeNanoSceonds - mStartTimeNanoSceonds) / 1000000.0f << "ms ";
263 oss << "u:" << mImageUrl.GetEllipsedUrl() << "]";
264 // DALI_TRACE_END(gTraceFilter, "DALI_LOTTIE_LOADING_TASK"); ///< TODO : Open it if we can control trace log level
265 DALI_LOG_RELEASE_INFO("END: DALI_LOTTIE_LOADING_TASK %s", oss.str().c_str());
272 void VectorAnimationTask::SetRenderer(Renderer renderer)
274 mVectorRenderer.SetRenderer(renderer);
276 DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetRenderer [%p]\n", this);
279 void VectorAnimationTask::RequestLoad(const VisualUrl& url, EncodedImageBuffer encodedImageBuffer, bool synchronousLoading)
282 mEncodedImageBuffer = encodedImageBuffer;
284 if(!synchronousLoading)
288 mVectorAnimationThread.AddTask(this);
298 bool VectorAnimationTask::IsLoadRequested() const
303 void VectorAnimationTask::SetAnimationData(const AnimationData& data)
305 Mutex::ScopedLock lock(mMutex);
307 DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetAnimationData [%p]\n", this);
309 uint32_t index = mAnimationDataIndex == 0 ? 1 : 0; // Use the other buffer
311 mAnimationData[index].push_back(data);
312 mAnimationDataUpdated = true;
314 if(data.resendFlag & VectorAnimationTask::RESEND_SIZE)
316 // The size should be changed in the main thread.
317 SetSize(data.width, data.height);
320 mVectorAnimationThread.AddTask(this);
323 void VectorAnimationTask::SetSize(uint32_t width, uint32_t height)
325 if(mWidth != width || mHeight != height)
327 mVectorRenderer.SetSize(width, height);
332 // If fixedCache is enabled, Call KeepRasterizedBuffer()
333 if(mEnableFrameCache)
335 if(mTotalFrame > 0 && !mLoadFailed)
337 mVectorRenderer.KeepRasterizedBuffer();
341 // If Load is not yet, update the size later.
346 DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetSize: width = %d, height = %d [%p]\n", width, height, this);
350 void VectorAnimationTask::PlayAnimation()
352 if(mPlayState != PlayState::PLAYING)
354 mNeedAnimationFinishedTrigger = true;
355 mUpdateFrameNumber = false;
356 mPlayState = PlayState::PLAYING;
358 DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::PlayAnimation: Play [%p]\n", this);
362 void VectorAnimationTask::StopAnimation()
364 if(mPlayState != PlayState::STOPPING)
366 mNeedAnimationFinishedTrigger = false;
367 mPlayState = PlayState::STOPPING;
369 DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::StopAnimation: Stop [%p]\n", this);
373 void VectorAnimationTask::PauseAnimation()
375 if(mPlayState == PlayState::PLAYING)
377 mPlayState = PlayState::PAUSED;
379 DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::PauseAnimation: Pause [%p]\n", this);
383 void VectorAnimationTask::SetAnimationFinishedCallback(CallbackBase* callback)
385 Mutex::ScopedLock lock(mMutex);
386 mAnimationFinishedCallback = std::unique_ptr<CallbackBase>(callback);
389 void VectorAnimationTask::SetLoopCount(int32_t count)
391 if(mLoopCount != count)
396 DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetLoopCount: [%d] [%p]\n", count, this);
400 void VectorAnimationTask::SetPlayRange(const Property::Array& playRange)
403 uint32_t startFrame = 0, endFrame = 0;
404 size_t count = playRange.Count();
408 int32_t start = 0, end = 0;
409 if(playRange.GetElementAt(0).Get(start) && playRange.GetElementAt(1).Get(end))
411 startFrame = static_cast<uint32_t>(start);
412 endFrame = static_cast<uint32_t>(end);
417 std::string startMarker, endMarker;
418 if(playRange.GetElementAt(0).Get(startMarker) && playRange.GetElementAt(1).Get(endMarker))
422 uint32_t frame; // We don't use this later
423 if(mVectorRenderer.GetMarkerInfo(startMarker, startFrame, frame) && mVectorRenderer.GetMarkerInfo(endMarker, frame, endFrame))
434 if(playRange.GetElementAt(0).Get(marker))
436 if(mVectorRenderer && mVectorRenderer.GetMarkerInfo(marker, startFrame, endFrame))
445 DALI_LOG_ERROR("VectorAnimationTask::SetPlayRange: Invalid range [%p]\n", this);
449 // Make sure the range specified is between 0 and the total frame number
450 startFrame = std::min(startFrame, mTotalFrame - 1);
451 endFrame = std::min(endFrame, mTotalFrame - 1);
453 // If the range is not in order swap values
454 if(startFrame > endFrame)
456 uint32_t temp = startFrame;
457 startFrame = endFrame;
461 if(startFrame != mStartFrame || endFrame != mEndFrame)
463 mStartFrame = startFrame;
464 mEndFrame = endFrame;
466 // If the current frame is out of the range, change the current frame also.
467 if(mStartFrame > mCurrentFrame)
469 mCurrentFrame = mStartFrame;
471 else if(mEndFrame < mCurrentFrame)
473 mCurrentFrame = mEndFrame;
476 DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetPlayRange: [%d, %d] [%s] [%p]\n", mStartFrame, mEndFrame, mImageUrl.GetUrl().c_str(), this);
480 void VectorAnimationTask::GetPlayRange(uint32_t& startFrame, uint32_t& endFrame)
482 startFrame = mStartFrame;
483 endFrame = mEndFrame;
486 void VectorAnimationTask::SetCurrentFrameNumber(uint32_t frameNumber)
488 if(mCurrentFrame == frameNumber)
490 DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetCurrentFrameNumber: Set same frame [%d] [%p]\n", frameNumber, this);
494 if(frameNumber >= mStartFrame && frameNumber <= mEndFrame)
496 mCurrentFrame = frameNumber;
497 mUpdateFrameNumber = false;
499 DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetCurrentFrameNumber: frame number = %d [%p]\n", mCurrentFrame, this);
503 DALI_LOG_ERROR("Invalid frame number [%d (%d, %d)] [%p]\n", frameNumber, mStartFrame, mEndFrame, this);
507 uint32_t VectorAnimationTask::GetCurrentFrameNumber() const
509 return mCurrentFrame;
512 uint32_t VectorAnimationTask::GetTotalFrameNumber() const
517 void VectorAnimationTask::GetDefaultSize(uint32_t& width, uint32_t& height) const
519 mVectorRenderer.GetDefaultSize(width, height);
522 void VectorAnimationTask::SetStopBehavior(DevelImageVisual::StopBehavior::Type stopBehavior)
524 mStopBehavior = stopBehavior;
526 DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetStopBehavior: stop behavor = %d [%p]\n", mStopBehavior, this);
529 void VectorAnimationTask::SetLoopingMode(DevelImageVisual::LoopingMode::Type loopingMode)
531 mLoopingMode = loopingMode;
533 DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetLoopingMode: looping mode = %d [%p]\n", mLoopingMode, this);
536 void VectorAnimationTask::GetLayerInfo(Property::Map& map) const
538 // Fast-out if file is loading, or load failed.
539 if(mLoadFailed || IsLoadRequested())
544 if(DALI_UNLIKELY(!mLayerInfoCached))
546 // Update only 1 time.
547 mLayerInfoCached = true;
548 mVectorRenderer.GetLayerInfo(mCachedLayerInfo);
551 map = mCachedLayerInfo;
554 void VectorAnimationTask::GetMarkerInfo(Property::Map& map) const
556 // Fast-out if file is loading, or load failed.
557 if(mLoadFailed || IsLoadRequested())
562 if(DALI_UNLIKELY(!mMarkerInfoCached))
564 // Update only 1 time.
565 mMarkerInfoCached = true;
566 mVectorRenderer.GetMarkerInfo(mCachedMarkerInfo);
569 map = mCachedMarkerInfo;
572 VectorAnimationTask::ResourceReadySignalType& VectorAnimationTask::ResourceReadySignal()
574 return mResourceReadySignal;
577 bool VectorAnimationTask::Rasterize()
579 bool stopped = false;
580 uint32_t currentFrame;
581 mKeepAnimation = false;
584 Mutex::ScopedLock lock(mMutex);
587 // The task will be destroyed. We don't need rasterization.
603 uint64_t mStartTimeNanoSceonds = 0;
604 uint64_t mEndTimeNanoSceonds = 0;
606 DALI_TRACE_BEGIN_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_LOTTIE_RASTERIZE_TASK", [&](std::ostringstream& oss) {
607 mStartTimeNanoSceonds = GetNanoseconds();
608 oss << "[s:" << mWidth << "x" << mHeight << " ";
609 oss << "u:" << mImageUrl.GetEllipsedUrl() << "]";
612 ApplyAnimationData();
614 if(mPlayState == PlayState::PLAYING && mUpdateFrameNumber)
616 mCurrentFrame = mForward ? mCurrentFrame + mDroppedFrames + 1 : (mCurrentFrame > mDroppedFrames ? mCurrentFrame - mDroppedFrames - 1 : 0);
617 Dali::ClampInPlace(mCurrentFrame, mStartFrame, mEndFrame);
620 currentFrame = mCurrentFrame;
622 mUpdateFrameNumber = true;
624 if(mPlayState == PlayState::STOPPING)
626 mCurrentFrame = GetStoppedFrame(mStartFrame, mEndFrame, mCurrentFrame);
627 currentFrame = mCurrentFrame;
630 else if(mPlayState == PlayState::PLAYING)
632 bool animationFinished = false;
634 if(currentFrame >= mEndFrame) // last frame
636 if(mLoopingMode == DevelImageVisual::LoopingMode::AUTO_REVERSE)
642 if(mLoopCount < 0 || ++mCurrentLoop < mLoopCount) // repeat forever or before the last loop
644 mCurrentFrame = mStartFrame;
645 mUpdateFrameNumber = false;
649 animationFinished = true; // end of animation
653 else if(currentFrame == mStartFrame && !mForward) // first frame
655 if(mLoopCount < 0 || ++mCurrentLoop < mLoopCount) // repeat forever or before the last loop
661 animationFinished = true; // end of animation
665 if(animationFinished)
667 if(mStopBehavior == DevelImageVisual::StopBehavior::CURRENT_FRAME)
673 mPlayState = PlayState::STOPPING;
679 bool renderSuccess = false;
682 renderSuccess = mVectorRenderer.Render(currentFrame);
685 DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::Rasterize: Rendering failed. Try again later.[%d] [%p]\n", currentFrame, this);
686 mUpdateFrameNumber = false;
690 if(stopped && renderSuccess)
692 mPlayState = PlayState::STOPPED;
698 // Notify the Renderer that rendering is stopped.
699 mVectorRenderer.RenderStopped();
702 // Animation is finished
704 Mutex::ScopedLock lock(mMutex);
705 if(mNeedAnimationFinishedTrigger && mAnimationFinishedCallback)
707 mVectorAnimationThread.AddEventTriggerCallback(mAnimationFinishedCallback.get(), mAppliedPlayStateId);
711 DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::Rasterize: Animation is finished [current = %d] [%p]\n", currentFrame, this);
714 if(mPlayState != PlayState::PAUSED && mPlayState != PlayState::STOPPED)
716 mKeepAnimation = true;
719 DALI_TRACE_END_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_LOTTIE_RASTERIZE_TASK", [&](std::ostringstream& oss) {
720 mEndTimeNanoSceonds = GetNanoseconds();
721 oss << std::fixed << std::setprecision(3);
723 oss << "d:" << static_cast<float>(mEndTimeNanoSceonds - mStartTimeNanoSceonds) / 1000000.0f << "ms ";
724 oss << "s:" << mWidth << "x" << mHeight << " ";
725 oss << "f:" << mCurrentFrame << " ";
726 oss << "l:" << mCurrentLoop << " ";
727 oss << "p:" << mPlayState << " ";
728 oss << "u:" << mImageUrl.GetEllipsedUrl() << "]";
734 uint32_t VectorAnimationTask::GetStoppedFrame(uint32_t startFrame, uint32_t endFrame, uint32_t currentFrame)
736 uint32_t frame = currentFrame;
738 switch(mStopBehavior)
740 case DevelImageVisual::StopBehavior::FIRST_FRAME:
745 case DevelImageVisual::StopBehavior::LAST_FRAME:
747 if(mLoopingMode == DevelImageVisual::LoopingMode::AUTO_REVERSE)
757 case DevelImageVisual::StopBehavior::CURRENT_FRAME:
759 frame = currentFrame;
767 VectorAnimationTask::TimePoint VectorAnimationTask::CalculateNextFrameTime(bool renderNow)
769 // std::chrono::time_point template has second parameter duration which defaults to the std::chrono::steady_clock supported
770 // duration. In some C++11 implementations it is a milliseconds duration, so it fails to compile unless mNextFrameStartTime
771 // is casted to use the default duration.
772 mNextFrameStartTime = std::chrono::time_point_cast<TimePoint::duration>(mNextFrameStartTime + std::chrono::microseconds(mFrameDurationMicroSeconds));
773 auto current = std::chrono::steady_clock::now();
778 mNextFrameStartTime = current;
780 else if(mNextFrameStartTime < current)
782 uint32_t droppedFrames = 0;
784 while(current > std::chrono::time_point_cast<TimePoint::duration>(mNextFrameStartTime + std::chrono::microseconds(mFrameDurationMicroSeconds)) && droppedFrames < mTotalFrame)
787 mNextFrameStartTime = std::chrono::time_point_cast<TimePoint::duration>(mNextFrameStartTime + std::chrono::microseconds(mFrameDurationMicroSeconds));
790 mNextFrameStartTime = current;
791 mDroppedFrames = droppedFrames;
794 return mNextFrameStartTime;
797 VectorAnimationTask::TimePoint VectorAnimationTask::GetNextFrameTime()
799 return mNextFrameStartTime;
802 void VectorAnimationTask::ApplyAnimationData()
807 Mutex::ScopedLock lock(mMutex);
809 if(!mAnimationDataUpdated || mAnimationData[mAnimationDataIndex].size() != 0)
811 // Data is not updated or the previous data is not applied yet.
815 mAnimationDataIndex = mAnimationDataIndex == 0 ? 1 : 0; // Swap index
816 mAnimationDataUpdated = false;
818 index = mAnimationDataIndex;
821 for(const auto& animationData : mAnimationData[index])
823 if(animationData.resendFlag & VectorAnimationTask::RESEND_LOOP_COUNT)
825 SetLoopCount(animationData.loopCount);
828 if(animationData.resendFlag & VectorAnimationTask::RESEND_PLAY_RANGE)
830 SetPlayRange(animationData.playRange);
833 if(animationData.resendFlag & VectorAnimationTask::RESEND_STOP_BEHAVIOR)
835 SetStopBehavior(animationData.stopBehavior);
838 if(animationData.resendFlag & VectorAnimationTask::RESEND_LOOPING_MODE)
840 SetLoopingMode(animationData.loopingMode);
843 if(animationData.resendFlag & VectorAnimationTask::RESEND_CURRENT_FRAME)
845 SetCurrentFrameNumber(animationData.currentFrame);
848 if(animationData.resendFlag & VectorAnimationTask::RESEND_NEED_RESOURCE_READY)
850 mVectorRenderer.InvalidateBuffer();
853 if(animationData.resendFlag & VectorAnimationTask::RESEND_DYNAMIC_PROPERTY)
855 for(auto&& iter : animationData.dynamicProperties)
857 mVectorRenderer.AddPropertyValueCallback(iter.keyPath, static_cast<VectorAnimationRenderer::VectorProperty>(iter.property), iter.callback, iter.id);
861 if(animationData.resendFlag & VectorAnimationTask::RESEND_PLAY_STATE)
863 mAppliedPlayStateId = animationData.playStateId;
864 if(animationData.playState == DevelImageVisual::PlayState::PLAYING)
868 else if(animationData.playState == DevelImageVisual::PlayState::PAUSED)
872 else if(animationData.playState == DevelImageVisual::PlayState::STOPPED)
880 mAnimationData[index].clear();
883 void VectorAnimationTask::OnUploadCompleted()
885 mResourceReadySignal.Emit(ResourceStatus::READY);
888 void VectorAnimationTask::OnLoadCompleted(uint32_t /* not used */)
892 if(mEnableFrameCache && mSizeUpdated)
894 mVectorRenderer.KeepRasterizedBuffer();
895 mSizeUpdated = false;
897 mResourceReadySignal.Emit(ResourceStatus::LOADED);
901 mResourceReadySignal.Emit(ResourceStatus::FAILED);
904 } // namespace Internal
906 } // namespace Toolkit