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 );
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetLoopingMode: looping mode = %d [%p]\n", mLoopingMode, this );
}
-void VectorAnimationTask::GetLayerInfo( Property::Map& map ) const
+void VectorAnimationTask::GetLayerInfo( Property::Map& map )
{
mVectorRenderer.GetLayerInfo( map );
}
}
// 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 )
*/
virtual ~VectorAnimationTask();
+ /**
+ * @brief Finalizes the task.
+ */
+ void Finalize();
+
/**
* @brief Sets the renderer used to display the result image.
*
* @brief Gets the layer information of all the child layers.
* @param[out] map The layer information
*/
- void GetLayerInfo( Property::Map& map ) const;
+ void GetLayerInfo( Property::Map& map );
/**
* @brief Connect to this signal to be notified when the texture upload is completed.
{
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;