X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fanimated-vector-image%2Fanimated-vector-image-visual.cpp;h=3e8378b36cf3717a7e76c70fdb2dd8afec51b204;hb=bec8f2280d8b1a136a643c2129bb29079ea18fd2;hp=de415dfdfcb2d3cc852ada85efa7c5d67db6c919;hpb=6d7478148da18b02ad6b8ddaae148c95e10f006d;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.cpp b/dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.cpp index de415df..3e8378b 100644 --- a/dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.cpp +++ b/dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.cpp @@ -21,6 +21,7 @@ // EXTERNAL INCLUDES #include #include +#include #include // INTERNAL INCLUDES @@ -118,6 +119,8 @@ AnimatedVectorImageVisual::AnimatedVectorImageVisual( VisualFactoryCache& factor AnimatedVectorImageVisual::~AnimatedVectorImageVisual() { + // Finalize animation task in the main thread + mVectorAnimationTask->Finalize(); } void AnimatedVectorImageVisual::GetNaturalSize( Vector2& naturalSize ) @@ -161,6 +164,10 @@ void AnimatedVectorImageVisual::DoCreatePropertyMap( Property::Map& map ) const map.Insert( Toolkit::DevelImageVisual::Property::STOP_BEHAVIOR, mStopBehavior ); map.Insert( Toolkit::DevelImageVisual::Property::LOOPING_MODE, mLoopingMode ); + + Property::Map layerInfo; + mVectorAnimationTask->GetLayerInfo( layerInfo ); + map.Insert( Toolkit::DevelImageVisual::Property::CONTENT_INFO, layerInfo ); } void AnimatedVectorImageVisual::DoCreateInstancePropertyMap( Property::Map& map ) const @@ -305,21 +312,23 @@ void AnimatedVectorImageVisual::DoSetOnStage( Actor& actor ) mSizeNotification = actor.AddPropertyNotification( Actor::Property::SIZE, StepCondition( 3.0f ) ); mSizeNotification.NotifySignal().Connect( this, &AnimatedVectorImageVisual::OnSizeNotification ); - DevelActor::VisibilityChangedSignal( actor ).Connect( this, &AnimatedVectorImageVisual::OnVisibilityChanged ); + DevelActor::VisibilityChangedSignal( actor ).Connect( this, &AnimatedVectorImageVisual::OnControlVisibilityChanged ); + + Window window = DevelWindow::Get( actor ); + if( window ) + { + DevelWindow::VisibilityChangedSignal( window ).Connect( this, &AnimatedVectorImageVisual::OnWindowVisibilityChanged ); + } DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::DoSetOnStage [%p]\n", this ); } void AnimatedVectorImageVisual::DoSetOffStage( Actor& actor ) { - mVectorAnimationTask->PauseAnimation(); - - mActionStatus = DevelAnimatedVectorImageVisual::Action::PAUSE; + PauseAnimation(); if( mImpl->mRenderer ) { - mImpl->mRenderer.SetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::IF_REQUIRED ); - actor.RemoveRenderer( mImpl->mRenderer ); mImpl->mRenderer.Reset(); @@ -330,7 +339,13 @@ void AnimatedVectorImageVisual::DoSetOffStage( Actor& actor ) actor.RemovePropertyNotification( mScaleNotification ); actor.RemovePropertyNotification( mSizeNotification ); - DevelActor::VisibilityChangedSignal( actor ).Connect( this, &AnimatedVectorImageVisual::OnVisibilityChanged ); + DevelActor::VisibilityChangedSignal( actor ).Disconnect( this, &AnimatedVectorImageVisual::OnControlVisibilityChanged ); + + Window window = DevelWindow::Get( actor ); + if( window ) + { + DevelWindow::VisibilityChangedSignal( window ).Disconnect( this, &AnimatedVectorImageVisual::OnWindowVisibilityChanged ); + } mPlacementActor.Reset(); @@ -422,7 +437,7 @@ void AnimatedVectorImageVisual::OnDoAction( const Property::Index actionId, cons if( IsOnStage() && mVectorAnimationTask->GetPlayState() != DevelImageVisual::PlayState::PLAYING ) { mVectorAnimationTask->RenderFrame(); - Stage::GetCurrent().KeepRendering( 0.0f ); // Trigger rendering + Stage::GetCurrent().KeepRendering( 1.0f ); // Trigger rendering } } break; @@ -449,11 +464,11 @@ void AnimatedVectorImageVisual::OnUploadCompleted() { actor.AddRenderer( mImpl->mRenderer ); mRendererAdded = true; - } - ResourceReady( Toolkit::Visual::ResourceStatus::READY ); + ResourceReady( Toolkit::Visual::ResourceStatus::READY ); - DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::OnUploadCompleted: Renderer is added [%p]\n", this ); + DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::OnUploadCompleted: Renderer is added [%p]\n", this ); + } } void AnimatedVectorImageVisual::OnAnimationFinished() @@ -516,7 +531,7 @@ void AnimatedVectorImageVisual::SendAnimationData() else { mVectorAnimationTask->RenderFrame(); - Stage::GetCurrent().KeepRendering( 0.0f ); + Stage::GetCurrent().KeepRendering( 1.0f ); } } @@ -534,7 +549,22 @@ void AnimatedVectorImageVisual::SetVectorImageSize() if( IsOnStage() && mVectorAnimationTask->GetPlayState() != DevelImageVisual::PlayState::PLAYING ) { mVectorAnimationTask->RenderFrame(); - Stage::GetCurrent().KeepRendering( 0.0f ); // Trigger rendering + Stage::GetCurrent().KeepRendering( 1.0f ); // Trigger rendering + } +} + +void AnimatedVectorImageVisual::PauseAnimation() +{ + if( mActionStatus == DevelAnimatedVectorImageVisual::Action::PLAY ) + { + mVectorAnimationTask->PauseAnimation(); + + mActionStatus = DevelAnimatedVectorImageVisual::Action::PAUSE; + + if( mImpl->mRenderer ) + { + mImpl->mRenderer.SetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::IF_REQUIRED ); + } } } @@ -568,23 +598,23 @@ void AnimatedVectorImageVisual::OnSizeNotification( PropertyNotification& source } } -void AnimatedVectorImageVisual::OnVisibilityChanged( Actor actor, bool visible, DevelActor::VisibilityChange::Type type ) +void AnimatedVectorImageVisual::OnControlVisibilityChanged( Actor actor, bool visible, DevelActor::VisibilityChange::Type type ) { if( !visible ) { - if( mActionStatus == DevelAnimatedVectorImageVisual::Action::PLAY ) - { - mVectorAnimationTask->PauseAnimation(); + PauseAnimation(); - if( mImpl->mRenderer ) - { - mImpl->mRenderer.SetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::IF_REQUIRED ); - } + DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::OnControlVisibilityChanged: invisibile. Pause animation [%p]\n", this ); + } +} - mActionStatus = DevelAnimatedVectorImageVisual::Action::PAUSE; +void AnimatedVectorImageVisual::OnWindowVisibilityChanged( Window window, bool visible ) +{ + if( !visible ) + { + PauseAnimation(); - DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::OnVisibilityChanged: invisibile. Pause animation [%p]\n", this ); - } + DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::OnWindowVisibilityChanged: invisibile. Pause animation [%p]\n", this ); } }