Debug::Filter* gVectorAnimationLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_VECTOR_ANIMATION" );
#endif
-inline void ResetValue( bool& updated, uint32_t& value, uint32_t newValue, ConditionalWait& conditionalWait )
+template< typename T >
+inline void ResetValue( bool& updated, T& value, T newValue, ConditionalWait& conditionalWait )
{
ConditionalWait::ScopedLock lock( conditionalWait );
if( !updated )
mDestroyThread( false ),
mResourceReady( false ),
mCurrentFrameUpdated( false ),
+ mCurrentLoopUpdated( false ),
mForward( true ),
mUpdateFrameNumber( false ),
+ mNeedAnimationFinishedTrigger( true ),
mLogFactory( Dali::Adaptor::Get().GetLogFactory() )
{
Initialize();
if( mPlayState != PlayState::STOPPED && mPlayState != PlayState::STOPPING )
{
mNeedRender = true;
+ mNeedAnimationFinishedTrigger = false;
mPlayState = PlayState::STOPPING;
mConditionalWait.Notify( lock );
ConditionalWait::ScopedLock lock( mConditionalWait );
mLoopCount = count;
+ mCurrentLoop = 0;
+ mCurrentLoopUpdated = true;
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorRasterizeThread::SetLoopCount: [%d] [%p]\n", count, this );
}
void VectorRasterizeThread::Rasterize()
{
- bool stopped = false;
+ bool stopped = false, needAnimationFinishedTrigger;
uint32_t currentFrame, startFrame, endFrame;
- int32_t loopCount;
+ int32_t loopCount, currentLoopCount;
{
ConditionalWait::ScopedLock lock( mConditionalWait );
startFrame = mStartFrame;
endFrame = mEndFrame;
loopCount = mLoopCount;
+ currentLoopCount = mCurrentLoop;
+ needAnimationFinishedTrigger = mNeedAnimationFinishedTrigger;
mResourceReady = true;
mNeedRender = false;
mCurrentFrameUpdated = false;
+ mCurrentLoopUpdated = false;
mUpdateFrameNumber = true;
+ mNeedAnimationFinishedTrigger = true;
}
auto currentFrameStartTime = std::chrono::system_clock::now();
}
else
{
- if( loopCount < 0 || ++mCurrentLoop < loopCount ) // repeat forever or before the last loop
+ if( loopCount < 0 || ++currentLoopCount < loopCount ) // repeat forever or before the last loop
{
ResetValue( mCurrentFrameUpdated, mCurrentFrame, startFrame, mConditionalWait ); // If the current frame is changed in the event thread, don't overwrite it.
mUpdateFrameNumber = false;
{
animationFinished = true; // end of animation
}
+ ResetValue( mCurrentLoopUpdated, mCurrentLoop, currentLoopCount, mConditionalWait );
}
}
else if( currentFrame == startFrame && !mForward ) // first frame
{
- if( loopCount < 0 || ++mCurrentLoop < loopCount ) // repeat forever or before the last loop
+ if( loopCount < 0 || ++currentLoopCount < loopCount ) // repeat forever or before the last loop
{
mForward = true;
}
{
animationFinished = true; // end of animation
}
+ ResetValue( mCurrentLoopUpdated, mCurrentLoop, currentLoopCount, mConditionalWait );
}
if( animationFinished )
mCurrentLoop = 0;
// Animation is finished
- mAnimationFinishedTrigger->Trigger();
+ if( needAnimationFinishedTrigger )
+ {
+ mAnimationFinishedTrigger->Trigger();
+ }
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorRasterizeThread::Rasterize: Animation is finished [current = %d] [%p]\n", currentFrame, this );
}