Change-Id: I3f023b6615ca36b40ddc3534fd8faab7985eb08e
application.SendNotification();
application.Render();
application.SendNotification();
application.Render();
+ std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
+
Property::Map resultMap;
resultMap = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
Property::Map resultMap;
resultMap = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
application.SendNotification();
application.Render();
application.SendNotification();
application.Render();
+ std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
+
map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
value = map.Find( DevelImageVisual::Property::PLAY_RANGE );
map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
value = map.Find( DevelImageVisual::Property::PLAY_RANGE );
mAnimationDataIndex( 0 ),
mLoopCount( LOOP_FOREVER ),
mCurrentLoop( 0 ),
mAnimationDataIndex( 0 ),
mLoopCount( LOOP_FOREVER ),
mCurrentLoop( 0 ),
- mResourceReady( false ),
mForward( true ),
mUpdateFrameNumber( false ),
mNeedAnimationFinishedTrigger( true ),
mForward( true ),
mUpdateFrameNumber( false ),
mNeedAnimationFinishedTrigger( true ),
mWidth = width;
mHeight = height;
mWidth = width;
mHeight = height;
- mResourceReady = false;
-
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetSize: width = %d, height = %d [%p]\n", width, height, this );
}
}
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetSize: width = %d, height = %d [%p]\n", width, height, this );
}
}
{
if( mPlayState != PlayState::PLAYING )
{
{
if( mPlayState != PlayState::PLAYING )
{
+ mNeedAnimationFinishedTrigger = true;
mUpdateFrameNumber = false;
mPlayState = PlayState::PLAYING;
mUpdateFrameNumber = false;
mPlayState = PlayState::PLAYING;
if( mStartFrame > mCurrentFrame )
{
mCurrentFrame = mStartFrame;
if( mStartFrame > mCurrentFrame )
{
mCurrentFrame = mStartFrame;
- mResourceReady = false;
}
else if( mEndFrame < mCurrentFrame )
{
mCurrentFrame = mEndFrame;
}
else if( mEndFrame < mCurrentFrame )
{
mCurrentFrame = mEndFrame;
- mResourceReady = false;
}
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetPlayRange: [%d, %d] [%p]\n", mStartFrame, mEndFrame, this );
}
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetPlayRange: [%d, %d] [%p]\n", mStartFrame, mEndFrame, this );
{
mCurrentFrame = frameNumber;
mUpdateFrameNumber = false;
{
mCurrentFrame = frameNumber;
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::SetCurrentFrameNumber: frame number = %d [%p]\n", mCurrentFrame, this );
}
currentFrame = mCurrentFrame;
currentFrame = mCurrentFrame;
- // Reset values
- mResourceReady = true;
mUpdateFrameNumber = true;
mUpdateFrameNumber = true;
- mNeedAnimationFinishedTrigger = true;
if( mPlayState == PlayState::STOPPING )
{
if( mPlayState == PlayState::STOPPING )
{
{
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::Rasterize: Rendering failed. Try again later.[%d] [%p]\n", currentFrame, this );
mUpdateFrameNumber = false;
{
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::Rasterize: Rendering failed. Try again later.[%d] [%p]\n", currentFrame, this );
mUpdateFrameNumber = false;
-
- if( !mResourceReady )
- {
- mResourceReady = false;
- }
uint32_t mAnimationDataIndex;
int32_t mLoopCount;
int32_t mCurrentLoop;
uint32_t mAnimationDataIndex;
int32_t mLoopCount;
int32_t mCurrentLoop;
bool mForward;
bool mUpdateFrameNumber;
bool mNeedAnimationFinishedTrigger;
bool mForward;
bool mUpdateFrameNumber;
bool mNeedAnimationFinishedTrigger;
VectorAnimationThread::VectorAnimationThread()
: mAnimationTasks(),
mCompletedTasks(),
VectorAnimationThread::VectorAnimationThread()
: mAnimationTasks(),
mCompletedTasks(),
mRasterizers( GetNumberOfThreads( NUMBER_OF_RASTERIZE_THREADS_ENV, DEFAULT_NUMBER_OF_RASTERIZE_THREADS ), [&]() { return RasterizeHelper( *this ); } ),
mSleepThread( MakeCallback( this, &VectorAnimationThread::OnAwakeFromSleep ) ),
mConditionalWait(),
mRasterizers( GetNumberOfThreads( NUMBER_OF_RASTERIZE_THREADS_ENV, DEFAULT_NUMBER_OF_RASTERIZE_THREADS ), [&]() { return RasterizeHelper( *this ); } ),
mSleepThread( MakeCallback( this, &VectorAnimationThread::OnAwakeFromSleep ) ),
mConditionalWait(),
{
ConditionalWait::ScopedLock lock( mConditionalWait );
mDestroyThread = true;
{
ConditionalWait::ScopedLock lock( mConditionalWait );
mDestroyThread = true;
mConditionalWait.Notify( lock );
}
mConditionalWait.Notify( lock );
}
mAnimationTasks.push_back( task );
}
mAnimationTasks.push_back( task );
}
// wake up the animation thread
mConditionalWait.Notify( lock );
}
// wake up the animation thread
mConditionalWait.Notify( lock );
}
void VectorAnimationThread::OnTaskCompleted( VectorAnimationTaskPtr task, bool keepAnimation )
{
void VectorAnimationThread::OnTaskCompleted( VectorAnimationTaskPtr task, bool keepAnimation )
{
- if( keepAnimation && !mDestroyThread )
{
ConditionalWait::ScopedLock lock( mConditionalWait );
{
ConditionalWait::ScopedLock lock( mConditionalWait );
+ bool needRasterize = false;
+
+ auto workingTask = std::find( mWorkingTasks.begin(), mWorkingTasks.end(), task );
+ if( workingTask != mWorkingTasks.end() )
+ {
+ mWorkingTasks.erase( workingTask );
+ }
- if( mCompletedTasks.end() == std::find( mCompletedTasks.begin(), mCompletedTasks.end(), task ) )
+ // Check pending task
+ if( mAnimationTasks.end() != std::find( mAnimationTasks.begin(), mAnimationTasks.end(), task ) )
- mCompletedTasks.push_back( task );
+ needRasterize = true;
+ }
+
+ if( keepAnimation )
+ {
+ if( mCompletedTasks.end() == std::find( mCompletedTasks.begin(), mCompletedTasks.end(), task ) )
+ {
+ mCompletedTasks.push_back( task );
+ needRasterize = true;
+ }
+ }
+ if( needRasterize )
+ {
+ mNeedToSleep = false;
// wake up the animation thread
mConditionalWait.Notify( lock );
}
// wake up the animation thread
mConditionalWait.Notify( lock );
}
ConditionalWait::ScopedLock lock( mConditionalWait );
// conditional wait
ConditionalWait::ScopedLock lock( mConditionalWait );
// conditional wait
- if( (mAnimationTasks.empty() && mCompletedTasks.empty() ) || mNeedToSleep )
{
mConditionalWait.Wait( lock );
}
{
mConditionalWait.Wait( lock );
}
// Process completed tasks
for( auto&& task : mCompletedTasks )
// Process completed tasks
for( auto&& task : mCompletedTasks )
mCompletedTasks.clear();
// pop out the next task from the queue
mCompletedTasks.clear();
// pop out the next task from the queue
- while( !mAnimationTasks.empty() && !mNeedToSleep )
+ for( auto it = mAnimationTasks.begin(); it != mAnimationTasks.end(); )
- std::vector< VectorAnimationTaskPtr >::iterator next = mAnimationTasks.begin();
- VectorAnimationTaskPtr nextTask = *next;
+ VectorAnimationTaskPtr nextTask = *it;
auto currentTime = std::chrono::system_clock::now();
auto nextFrameTime = nextTask->GetNextFrameTime();
auto currentTime = std::chrono::system_clock::now();
auto nextFrameTime = nextTask->GetNextFrameTime();
if( nextFrameTime <= currentTime )
{
if( nextFrameTime <= currentTime )
{
- mAnimationTasks.erase( next );
+ // If the task is not in the working list
+ if( std::find( mWorkingTasks.begin(), mWorkingTasks.end(), nextTask ) == mWorkingTasks.end() )
+ {
+ it = mAnimationTasks.erase( it );
+
+ // Add it to the working list
+ mWorkingTasks.push_back( nextTask );
- auto rasterizerHelperIt = mRasterizers.GetNext();
- DALI_ASSERT_ALWAYS( rasterizerHelperIt != mRasterizers.End() );
+ auto rasterizerHelperIt = mRasterizers.GetNext();
+ DALI_ASSERT_ALWAYS( rasterizerHelperIt != mRasterizers.End() );
- rasterizerHelperIt->Rasterize( nextTask );
+ rasterizerHelperIt->Rasterize( nextTask );
+ }
+ else
+ {
+ it++;
+ }
mSleepThread.SleepUntil( nextFrameTime );
mSleepThread.SleepUntil( nextFrameTime );
std::vector< VectorAnimationTaskPtr > mAnimationTasks;
std::vector< VectorAnimationTaskPtr > mCompletedTasks;
std::vector< VectorAnimationTaskPtr > mAnimationTasks;
std::vector< VectorAnimationTaskPtr > mCompletedTasks;
+ std::vector< VectorAnimationTaskPtr > mWorkingTasks;
RoundRobinContainerView< RasterizeHelper > mRasterizers;
SleepThread mSleepThread;
ConditionalWait mConditionalWait;
RoundRobinContainerView< RasterizeHelper > mRasterizers;
SleepThread mSleepThread;
ConditionalWait mConditionalWait;