mVectorRenderer(),
mConditionalWait(),
mMutex(),
- mResourceReadyTrigger( NULL ),
+ mResourceReadyTrigger(),
+ mAnimationFinishedTrigger(),
mPlayRange( 0.0f, 1.0f ),
+ mPlayState( DevelImageVisual::PlayState::STOPPED ),
mCurrentFrame( 0 ),
mTotalFrame( 0 ),
mStartFrame( 0 ),
mLoopCount( LOOP_FOREVER ),
mCurrentLoop( 0 ),
mNeedRender( false ),
- mPlaying( false ),
- mPaused( false ),
mDestroyThread( false ),
mResourceReady( false ),
mLogFactory( Dali::Adaptor::Get().GetLogFactory() )
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorRasterizeThread::~VectorRasterizeThread: Join\n" );
Join();
-
- delete mResourceReadyTrigger;
}
void VectorRasterizeThread::Run()
void VectorRasterizeThread::StartAnimation()
{
ConditionalWait::ScopedLock lock( mConditionalWait );
- if( !mPlaying )
+ if( mPlayState != DevelImageVisual::PlayState::PLAYING )
{
- mPlaying = true;
- mPaused = false;
+ if( mPlayState == DevelImageVisual::PlayState::STOPPED )
+ {
+ // Reset the current frame and the current loop
+ mCurrentFrame = mStartFrame;
+ mCurrentLoop = 0;
+ }
+
+ mPlayState = DevelImageVisual::PlayState::PLAYING;
mConditionalWait.Notify( lock );
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorRasterizeThread::StartAnimation: Start\n" );
void VectorRasterizeThread::StopAnimation()
{
ConditionalWait::ScopedLock lock( mConditionalWait );
- if( mPlaying )
+ if( mPlayState != DevelImageVisual::PlayState::STOPPED )
{
- mPlaying = false;
- mPaused = false;
+ mPlayState = DevelImageVisual::PlayState::STOPPED;
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorRasterizeThread::StopAnimation: Stop\n" );
}
void VectorRasterizeThread::PauseAnimation()
{
ConditionalWait::ScopedLock lock( mConditionalWait );
- if( mPlaying && !mPaused )
+ if( mPlayState == DevelImageVisual::PlayState::PLAYING )
{
- mPaused = true;
+ mPlayState = DevelImageVisual::PlayState::PAUSED;
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorRasterizeThread::PauseAnimation: Pause\n" );
}
}
-void VectorRasterizeThread::ResumeAnimation()
-{
- ConditionalWait::ScopedLock lock( mConditionalWait );
- if( mPlaying && mPaused )
- {
- mPaused = false;
- mConditionalWait.Notify( lock );
-
- DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorRasterizeThread::ResumeAnimation: Resume\n" );
- }
-}
-
void VectorRasterizeThread::RenderFrame()
{
ConditionalWait::ScopedLock lock( mConditionalWait );
void VectorRasterizeThread::SetResourceReadyCallback( EventThreadCallback* callback )
{
ConditionalWait::ScopedLock lock( mConditionalWait );
- mResourceReadyTrigger = callback;
+ mResourceReadyTrigger = std::unique_ptr< EventThreadCallback >( callback );
+}
+
+void VectorRasterizeThread::SetAnimationFinishedCallback( EventThreadCallback* callback )
+{
+ ConditionalWait::ScopedLock lock( mConditionalWait );
+ mAnimationFinishedTrigger = std::unique_ptr< EventThreadCallback >( callback );
}
void VectorRasterizeThread::SetLoopCount( int16_t count )
}
}
+DevelImageVisual::PlayState VectorRasterizeThread::GetPlayState()
+{
+ return mPlayState;
+}
+
bool VectorRasterizeThread::IsThreadReady()
{
ConditionalWait::ScopedLock lock( mConditionalWait );
- if( ( !mPlaying || mPaused ) && !mNeedRender && !mDestroyThread )
+ if( mPlayState != DevelImageVisual::PlayState::PLAYING && !mNeedRender && !mDestroyThread )
{
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorRasterizeThread::IsThreadReady: Wait\n" );
- if( !mPlaying )
- {
- mCurrentFrame = mStartFrame;
- mCurrentLoop = 0;
- }
-
mConditionalWait.Wait( lock );
}
// Rasterize
mVectorRenderer.Render( mCurrentFrame );
- if( mPlaying && !mPaused )
+ if( mPlayState == DevelImageVisual::PlayState::PLAYING )
{
if( ++mCurrentFrame >= mEndFrame )
{
if( mCurrentLoop >= mLoopCount )
{
// Animation is finished
- mPlaying = false;
+ mPlayState = DevelImageVisual::PlayState::STOPPED;
+
+ mAnimationFinishedTrigger->Trigger();
+
+ DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorRasterizeThread::Rasterize: Animation is finished\n" );
}
else
{