mVectorRenderer(VectorAnimationRenderer::New()),
mAnimationData(),
mVectorAnimationThread(factoryCache.GetVectorAnimationManager().GetVectorAnimationThread()),
- mConditionalWait(),
+ mMutex(),
mResourceReadySignal(),
mLoadCompletedCallback(MakeCallback(this, &VectorAnimationTask::OnLoadCompleted)),
mCachedLayerInfo(),
mWidth(0),
mHeight(0),
mAnimationDataIndex(0),
+ mAppliedPlayStateId(0u),
mLoopCount(LOOP_FOREVER),
mCurrentLoop(0),
mForward(true),
mUpdateFrameNumber(false),
mNeedAnimationFinishedTrigger(true),
+ mNeedForceRenderOnceTrigger(false),
mAnimationDataUpdated(false),
mDestroyTask(false),
mLoadRequest(false),
mLayerInfoCached(false),
mMarkerInfoCached(false),
mEnableFrameCache(false),
+ mNotifyAfterRasterization(false),
mSizeUpdated(false)
{
mVectorRenderer.UploadCompletedSignal().Connect(this, &VectorAnimationTask::OnUploadCompleted);
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)
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());
+ mVectorAnimationThread.AddEventTriggerCallback(mLoadCompletedCallback.get(), 0u);
}
}
#ifdef TRACE_ENABLED
mLoadRequest = false;
{
- ConditionalWait::ScopedLock lock(mConditionalWait);
+ Mutex::ScopedLock lock(mMutex);
if(!synchronousLoading && mLoadCompletedCallback)
{
- mVectorAnimationThread.AddEventTriggerCallback(mLoadCompletedCallback.get());
+ mVectorAnimationThread.AddEventTriggerCallback(mLoadCompletedCallback.get(), 0u);
}
}
void VectorAnimationTask::SetRenderer(Renderer renderer)
{
- ConditionalWait::ScopedLock lock(mConditionalWait);
-
mVectorRenderer.SetRenderer(renderer);
DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetRenderer [%p]\n", this);
{
Load(true);
- OnLoadCompleted();
+ OnLoadCompleted(0u);
}
}
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);
{
mPlayState = PlayState::PAUSED;
+ // Ensure to render paused frame.
+ mNeedForceRenderOnceTrigger = true;
+
DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::PauseAnimation: Pause [%p]\n", this);
}
}
void VectorAnimationTask::SetAnimationFinishedCallback(CallbackBase* callback)
{
- ConditionalWait::ScopedLock lock(mConditionalWait);
+ Mutex::ScopedLock lock(mMutex);
mAnimationFinishedCallback = std::unique_ptr<CallbackBase>(callback);
}
if(mStartFrame > mCurrentFrame)
{
mCurrentFrame = mStartFrame;
+
+ if(mPlayState != PlayState::PLAYING)
+ {
+ // Ensure to render current frame.
+ mNeedForceRenderOnceTrigger = true;
+ }
}
else if(mEndFrame < mCurrentFrame)
{
mCurrentFrame = mEndFrame;
+
+ if(mPlayState != PlayState::PLAYING)
+ {
+ // Ensure to render current frame.
+ mNeedForceRenderOnceTrigger = true;
+ }
}
DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetPlayRange: [%d, %d] [%s] [%p]\n", mStartFrame, mEndFrame, mImageUrl.GetUrl().c_str(), this);
mCurrentFrame = frameNumber;
mUpdateFrameNumber = false;
+ if(mPlayState != PlayState::PLAYING)
+ {
+ // Ensure to render current frame.
+ mNeedForceRenderOnceTrigger = true;
+ }
+
DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetCurrentFrameNumber: frame number = %d [%p]\n", mCurrentFrame, this);
}
else
mKeepAnimation = false;
{
- ConditionalWait::ScopedLock lock(mConditionalWait);
+ Mutex::ScopedLock lock(mMutex);
if(mDestroyTask)
{
// The task will be destroyed. We don't need rasterization.
mForward = true;
mCurrentLoop = 0;
+ mNeedForceRenderOnceTrigger = true;
+
if(mVectorRenderer)
{
// Notify the Renderer that rendering is stopped.
// Animation is finished
{
- ConditionalWait::ScopedLock lock(mConditionalWait);
+ Mutex::ScopedLock lock(mMutex);
if(mNeedAnimationFinishedTrigger && mAnimationFinishedCallback)
{
- mVectorAnimationThread.AddEventTriggerCallback(mAnimationFinishedCallback.get());
+ mVectorAnimationThread.AddEventTriggerCallback(mAnimationFinishedCallback.get(), mAppliedPlayStateId);
}
}
DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::Rasterize: Animation is finished [current = %d] [%p]\n", currentFrame, this);
}
+ // Forcely trigger render once if need.
+ if(mNotifyAfterRasterization || mNeedForceRenderOnceTrigger)
+ {
+ Mutex::ScopedLock lock(mMutex);
+ mVectorAnimationThread.RequestForceRenderOnce();
+ mNeedForceRenderOnceTrigger = false;
+ }
+
if(mPlayState != PlayState::PAUSED && mPlayState != PlayState::STOPPED)
{
mKeepAnimation = true;
uint32_t index;
{
- ConditionalWait::ScopedLock lock(mConditionalWait);
+ Mutex::ScopedLock lock(mMutex);
if(!mAnimationDataUpdated || mAnimationData[mAnimationDataIndex].size() != 0)
{
SetCurrentFrameNumber(animationData.currentFrame);
}
+ if(animationData.resendFlag & VectorAnimationTask::RESEND_NOTIFY_AFTER_RASTERIZATION)
+ {
+ mNotifyAfterRasterization = animationData.notifyAfterRasterization;
+ }
+
if(animationData.resendFlag & VectorAnimationTask::RESEND_NEED_RESOURCE_READY)
{
mVectorRenderer.InvalidateBuffer();
if(animationData.resendFlag & VectorAnimationTask::RESEND_PLAY_STATE)
{
+ mAppliedPlayStateId = animationData.playStateId;
if(animationData.playState == DevelImageVisual::PlayState::PLAYING)
{
PlayAnimation();
mResourceReadySignal.Emit(ResourceStatus::READY);
}
-void VectorAnimationTask::OnLoadCompleted()
+void VectorAnimationTask::OnLoadCompleted(uint32_t /* not used */)
{
if(!mLoadFailed)
{