AnimatedVectorImageVisual::~AnimatedVectorImageVisual()
{
+ // Finalize animation task in the main thread
+ mVectorAnimationTask->Finalize();
}
void AnimatedVectorImageVisual::GetNaturalSize( Vector2& naturalSize )
{
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()
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::~VectorAnimationTask: destructor [%p]\n", this );
}
+void VectorAnimationTask::Finalize()
+{
+ // Release some objects in the main thread
+ if( mAnimationFinishedTrigger )
+ {
+ mAnimationFinishedTrigger.reset();
+ }
+
+ mVectorRenderer.Reset();
+}
+
void VectorAnimationTask::SetRenderer( Renderer renderer )
{
ConditionalWait::ScopedLock lock( mConditionalWait );
void VectorAnimationTask::SetAnimationFinishedCallback( EventThreadCallback* callback )
{
ConditionalWait::ScopedLock lock( mConditionalWait );
- mAnimationFinishedTrigger = std::unique_ptr< EventThreadCallback >( callback );
+ if( callback )
+ {
+ mAnimationFinishedTrigger = std::unique_ptr< EventThreadCallback >( callback );
+ }
}
void VectorAnimationTask::SetLoopCount( int32_t count )
mCurrentFrame = frameNumber;
mCurrentFrameUpdated = true;
+ mUpdateFrameNumber = false;
mResourceReady = false;
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetCurrentFrameNumber: frame number = %d [%p]\n", mCurrentFrame, this );
}
// Rasterize
- bool renderSuccess = mVectorRenderer.Render( currentFrame );
- if( !renderSuccess )
+ bool renderSuccess = false;
+ if( mVectorRenderer )
{
- DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::Rasterize: Rendering failed. Try again later.[%d] [%p]\n", currentFrame, this );
- mUpdateFrameNumber = false;
+ renderSuccess = mVectorRenderer.Render( currentFrame );
+ if( !renderSuccess )
+ {
+ DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::Rasterize: Rendering failed. Try again later.[%d] [%p]\n", currentFrame, this );
+ mUpdateFrameNumber = false;
+ }
}
if( stopped && renderSuccess )
{
ConditionalWait::ScopedLock lock( mConditionalWait );
- if( mAnimationTasks.end() == std::find( mAnimationTasks.begin(), mAnimationTasks.end(), task ) )
+ if( mCompletedTasks.end() == std::find( mCompletedTasks.begin(), mCompletedTasks.end(), task ) )
{
mCompletedTasks.push_back( task );
mCompletedTasks.clear();
// pop out the next task from the queue
- if( !mAnimationTasks.empty() && !mNeedToSleep )
+ while( !mAnimationTasks.empty() && !mNeedToSleep )
{
std::vector< VectorAnimationTaskPtr >::iterator next = mAnimationTasks.begin();
VectorAnimationTaskPtr nextTask = *next;