+void AnimatedVectorImageVisual::OnResourceReady(VectorAnimationTask::ResourceStatus status)
+{
+ if(status == VectorAnimationTask::ResourceStatus::LOADED)
+ {
+ if(mImpl->mEventObserver)
+ {
+ mImpl->mEventObserver->RelayoutRequest(*this);
+ }
+ }
+ else
+ {
+ mLoadFailed = status == VectorAnimationTask::ResourceStatus::FAILED ? true : false;
+
+ // If weak handle is holding a placement actor, it is the time to add the renderer to actor.
+ Actor actor = mPlacementActor.GetHandle();
+ if(actor && !mRendererAdded)
+ {
+ if(!mLoadFailed)
+ {
+ actor.AddRenderer(mImpl->mRenderer);
+ ResourceReady(Toolkit::Visual::ResourceStatus::READY);
+ }
+ else
+ {
+ Vector2 imageSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector2>();
+ mFactoryCache.UpdateBrokenImageRenderer(mImpl->mRenderer, imageSize, false);
+ actor.AddRenderer(mImpl->mRenderer);
+ ResourceReady(Toolkit::Visual::ResourceStatus::FAILED);
+ }
+
+ mRendererAdded = true;
+ }
+ }
+
+ DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "status = %d [%p]\n", status, this);
+}
+
+void AnimatedVectorImageVisual::OnAnimationFinished()
+{
+ DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::OnAnimationFinished: action state = %d [%p]\n", mPlayState, this);
+
+ if(mPlayState != DevelImageVisual::PlayState::STOPPED)
+ {
+ mPlayState = DevelImageVisual::PlayState::STOPPED;
+
+ mAnimationData.playState = DevelImageVisual::PlayState::STOPPED;
+
+ if(mImpl->mEventObserver)
+ {
+ mImpl->mEventObserver->NotifyVisualEvent(*this, DevelAnimatedVectorImageVisual::Signal::ANIMATION_FINISHED);
+ }
+ }
+
+ if(mImpl->mRenderer)
+ {
+ mImpl->mRenderer.SetProperty(DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::IF_REQUIRED);
+ }
+}
+
+void AnimatedVectorImageVisual::SendAnimationData()
+{
+ if(mAnimationData.resendFlag)
+ {
+ mVectorAnimationTask->SetAnimationData(mAnimationData);
+
+ if(mImpl->mRenderer)
+ {
+ if(mAnimationData.playState == DevelImageVisual::PlayState::PLAYING)
+ {
+ mImpl->mRenderer.SetProperty(DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::CONTINUOUSLY);
+ }
+ else
+ {
+ mImpl->mRenderer.SetProperty(DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::IF_REQUIRED);
+ }
+ }
+
+ mAnimationData.resendFlag = 0;
+ }
+}
+
+void AnimatedVectorImageVisual::SetVectorImageSize()
+{
+ uint32_t width, height;
+ if(mDesiredSize.GetWidth() > 0 && mDesiredSize.GetHeight() > 0)
+ {
+ width = mDesiredSize.GetWidth();
+ height = mDesiredSize.GetHeight();
+ }
+ else
+ {
+ width = static_cast<uint32_t>(mVisualSize.width * mVisualScale.width);
+ height = static_cast<uint32_t>(mVisualSize.height * mVisualScale.height);
+ }
+
+ if(mAnimationData.width != width || mAnimationData.height != height)
+ {
+ mAnimationData.width = width;
+ mAnimationData.height = height;
+ mAnimationData.resendFlag |= VectorAnimationTask::RESEND_SIZE;
+ }
+}
+
+void AnimatedVectorImageVisual::StopAnimation()
+{
+ if(mAnimationData.playState != DevelImageVisual::PlayState::STOPPED)
+ {
+ mAnimationData.playState = DevelImageVisual::PlayState::STOPPED;
+ mAnimationData.resendFlag |= VectorAnimationTask::RESEND_PLAY_STATE;
+
+ mPlayState = DevelImageVisual::PlayState::STOPPED;
+ }
+}
+
+void AnimatedVectorImageVisual::TriggerVectorRasterization()
+{
+ if(!mEventCallback && !mCoreShutdown)
+ {
+ mEventCallback = MakeCallback(this, &AnimatedVectorImageVisual::OnProcessEvents);
+ auto& vectorAnimationManager = mFactoryCache.GetVectorAnimationManager();
+ vectorAnimationManager.RegisterEventCallback(mEventCallback);
+ Stage::GetCurrent().KeepRendering(0.0f); // Trigger event processing
+ }
+}
+
+void AnimatedVectorImageVisual::OnScaleNotification(PropertyNotification& source)
+{
+ Actor actor = mPlacementActor.GetHandle();
+ if(actor)
+ {
+ Vector3 scale = actor.GetProperty<Vector3>(Actor::Property::WORLD_SCALE);
+
+ if((!Dali::Equals(mVisualScale.width, scale.width) || !Dali::Equals(mVisualScale.height, scale.height)) && (mRedrawInScalingDown || scale.width >= 1.0f || scale.height >= 1.0f))
+ {
+ mVisualScale.width = scale.width;
+ mVisualScale.height = scale.height;
+
+ DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::OnScaleNotification: scale = %f, %f [%p]\n", mVisualScale.width, mVisualScale.height, this);
+
+ SetVectorImageSize();
+ SendAnimationData();
+
+ Stage::GetCurrent().KeepRendering(0.0f); // Trigger event processing
+ }
+ }
+}
+
+void AnimatedVectorImageVisual::OnSizeNotification(PropertyNotification& source)