X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fanimated-vector-image%2Fvector-animation-task.cpp;h=ac448c022638886aba975689b0f162254d5d649a;hb=1e96141086594b45635f880aa31163db803bb9c6;hp=cb67bc78f6f9cf5752cd66230cea2f6f5e664081;hpb=d5c773fdca3200e53736b2843e819b6c8eff7cdd;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.cpp b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.cpp index cb67bc7..ac448c0 100644 --- a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.cpp +++ b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.cpp @@ -92,11 +92,13 @@ VectorAnimationTask::VectorAnimationTask(VisualFactoryCache& factoryCache) 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), @@ -106,6 +108,7 @@ VectorAnimationTask::VectorAnimationTask(VisualFactoryCache& factoryCache) mLayerInfoCached(false), mMarkerInfoCached(false), mEnableFrameCache(false), + mNotifyAfterRasterization(false), mSizeUpdated(false) { mVectorRenderer.UploadCompletedSignal().Connect(this, &VectorAnimationTask::OnUploadCompleted); @@ -214,7 +217,7 @@ bool VectorAnimationTask::Load(bool synchronousLoading) Mutex::ScopedLock lock(mMutex); if(!synchronousLoading && mLoadCompletedCallback) { - mVectorAnimationThread.AddEventTriggerCallback(mLoadCompletedCallback.get()); + mVectorAnimationThread.AddEventTriggerCallback(mLoadCompletedCallback.get(), 0u); } } #ifdef TRACE_ENABLED @@ -245,7 +248,7 @@ bool VectorAnimationTask::Load(bool synchronousLoading) Mutex::ScopedLock lock(mMutex); if(!synchronousLoading && mLoadCompletedCallback) { - mVectorAnimationThread.AddEventTriggerCallback(mLoadCompletedCallback.get()); + mVectorAnimationThread.AddEventTriggerCallback(mLoadCompletedCallback.get(), 0u); } } @@ -290,7 +293,7 @@ void VectorAnimationTask::RequestLoad(const VisualUrl& url, EncodedImageBuffer e { Load(true); - OnLoadCompleted(); + OnLoadCompleted(0u); } } @@ -375,6 +378,9 @@ void VectorAnimationTask::PauseAnimation() { mPlayState = PlayState::PAUSED; + // Ensure to render paused frame. + mNeedForceRenderOnceTrigger = true; + DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::PauseAnimation: Pause [%p]\n", this); } } @@ -466,10 +472,22 @@ void VectorAnimationTask::SetPlayRange(const Property::Array& playRange) 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); @@ -495,6 +513,12 @@ void VectorAnimationTask::SetCurrentFrameNumber(uint32_t frameNumber) 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 @@ -692,6 +716,8 @@ bool VectorAnimationTask::Rasterize() mForward = true; mCurrentLoop = 0; + mNeedForceRenderOnceTrigger = true; + if(mVectorRenderer) { // Notify the Renderer that rendering is stopped. @@ -703,13 +729,21 @@ bool VectorAnimationTask::Rasterize() 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; @@ -844,6 +878,11 @@ void VectorAnimationTask::ApplyAnimationData() SetCurrentFrameNumber(animationData.currentFrame); } + if(animationData.resendFlag & VectorAnimationTask::RESEND_NOTIFY_AFTER_RASTERIZATION) + { + mNotifyAfterRasterization = animationData.notifyAfterRasterization; + } + if(animationData.resendFlag & VectorAnimationTask::RESEND_NEED_RESOURCE_READY) { mVectorRenderer.InvalidateBuffer(); @@ -859,6 +898,7 @@ void VectorAnimationTask::ApplyAnimationData() if(animationData.resendFlag & VectorAnimationTask::RESEND_PLAY_STATE) { + mAppliedPlayStateId = animationData.playStateId; if(animationData.playState == DevelImageVisual::PlayState::PLAYING) { PlayAnimation(); @@ -883,7 +923,7 @@ void VectorAnimationTask::OnUploadCompleted() mResourceReadySignal.Emit(ResourceStatus::READY); } -void VectorAnimationTask::OnLoadCompleted() +void VectorAnimationTask::OnLoadCompleted(uint32_t /* not used */) { if(!mLoadFailed) {