// EXTERNAL INCLUDES
#include <dali/integration-api/debug.h>
+#include <dali/public-api/object/property-array.h>
+#include <dali/public-api/math/math-utils.h>
// INTERNAL INCLUDES
#include <dali-toolkit/internal/visuals/image-visual-shader-factory.h>
void VectorAnimationTask::Finalize()
{
+ ConditionalWait::ScopedLock lock( mConditionalWait );
+
// Release some objects in the main thread
if( mAnimationFinishedTrigger )
{
mAnimationFinishedTrigger.reset();
}
- mVectorRenderer.Reset();
+ mVectorRenderer.Finalize();
}
void VectorAnimationTask::SetRenderer( Renderer renderer )
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetRenderer [%p]\n", this );
}
+void VectorAnimationTask::SetAnimationData( const AnimationData& data )
+{
+ ConditionalWait::ScopedLock lock( mConditionalWait );
+
+ DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetAnimationData [%p]\n", this );
+
+ if( data.resendFlag & VectorAnimationTask::RESEND_LOOP_COUNT )
+ {
+ SetLoopCount( data.loopCount );
+ }
+
+ if( data.resendFlag & VectorAnimationTask::RESEND_PLAY_RANGE )
+ {
+ SetPlayRange( data.playRange );
+ }
+
+ if( data.resendFlag & VectorAnimationTask::RESEND_STOP_BEHAVIOR )
+ {
+ SetStopBehavior( data.stopBehavior );
+ }
+
+ if( data.resendFlag & VectorAnimationTask::RESEND_LOOPING_MODE )
+ {
+ SetLoopingMode( data.loopingMode );
+ }
+
+ if( data.resendFlag & VectorAnimationTask::RESEND_CURRENT_FRAME )
+ {
+ SetCurrentFrameNumber( data.currentFrame );
+ }
+
+ if( data.resendFlag & VectorAnimationTask::RESEND_SIZE )
+ {
+ SetSize( data.width, data.height );
+ }
+
+ if( data.resendFlag & VectorAnimationTask::RESEND_PLAY_STATE )
+ {
+ if( data.playState == DevelImageVisual::PlayState::PLAYING )
+ {
+ PlayAnimation();
+ }
+ else if( data.playState == DevelImageVisual::PlayState::PAUSED )
+ {
+ PauseAnimation();
+ RenderFrame();
+ }
+ else if( data.playState == DevelImageVisual::PlayState::STOPPED )
+ {
+ StopAnimation();
+ }
+ }
+ else
+ {
+ if( mPlayState == PlayState::PAUSED || mPlayState == PlayState::STOPPED )
+ {
+ RenderFrame();
+ }
+ }
+}
+
void VectorAnimationTask::SetSize( uint32_t width, uint32_t height )
{
if( mWidth != width || mHeight != height )
{
- ConditionalWait::ScopedLock lock( mConditionalWait );
mVectorRenderer.SetSize( width, height );
mWidth = width;
void VectorAnimationTask::PlayAnimation()
{
- ConditionalWait::ScopedLock lock( mConditionalWait );
-
if( mPlayState != PlayState::PLAYING )
{
mUpdateFrameNumber = false;
void VectorAnimationTask::StopAnimation()
{
- ConditionalWait::ScopedLock lock( mConditionalWait );
if( mPlayState != PlayState::STOPPED && mPlayState != PlayState::STOPPING )
{
mNeedAnimationFinishedTrigger = false;
void VectorAnimationTask::PauseAnimation()
{
- ConditionalWait::ScopedLock lock( mConditionalWait );
if( mPlayState == PlayState::PLAYING )
{
mPlayState = PlayState::PAUSED;
void VectorAnimationTask::RenderFrame()
{
- ConditionalWait::ScopedLock lock( mConditionalWait );
-
if( !mResourceReady )
{
mVectorAnimationThread.AddTask( this );
{
if( mLoopCount != count )
{
- ConditionalWait::ScopedLock lock( mConditionalWait );
-
mLoopCount = count;
mCurrentLoop = 0;
mCurrentLoopUpdated = true;
}
}
-void VectorAnimationTask::SetPlayRange( uint32_t startFrame, uint32_t endFrame )
+void VectorAnimationTask::SetPlayRange( const Property::Array& playRange )
{
+ bool valid = false;
+ uint32_t startFrame = 0, endFrame = 0;
+ size_t count = playRange.Count();
+
+ if( count >= 2 )
+ {
+ int32_t start = 0, end = 0;
+ if( playRange.GetElementAt( 0 ).Get( start ) && playRange.GetElementAt( 1 ).Get( end ) )
+ {
+ startFrame = static_cast< uint32_t >( start );
+ endFrame = static_cast< uint32_t >( end );
+ valid = true;
+ }
+ else
+ {
+ std::string startMarker, endMarker;
+ if( playRange.GetElementAt( 0 ).Get( startMarker ) && playRange.GetElementAt( 1 ).Get( endMarker ) )
+ {
+ if( mVectorRenderer )
+ {
+ uint32_t frame; // We don't use this later
+ if( mVectorRenderer.GetMarkerInfo( startMarker, startFrame, frame ) && mVectorRenderer.GetMarkerInfo( endMarker, frame, endFrame ) )
+ {
+ valid = true;
+ }
+ }
+ }
+ }
+ }
+ else if( count == 1 )
+ {
+ std::string marker;
+ if( playRange.GetElementAt( 0 ).Get( marker ) )
+ {
+ if( mVectorRenderer )
+ {
+ mVectorRenderer.GetMarkerInfo( marker, startFrame, endFrame );
+ valid = true;
+ }
+ }
+ }
+
+ if( !valid )
+ {
+ DALI_LOG_ERROR( "VectorAnimationTask::SetPlayRange: Invalid range [%p]\n", this );
+ return;
+ }
+
// Make sure the range specified is between 0 and the total frame number
- if( ( startFrame < mTotalFrame ) && ( endFrame < mTotalFrame ) )
+ if( startFrame >= 0 && startFrame < mTotalFrame && endFrame >= 0 && endFrame < mTotalFrame )
{
// If the range is not in order swap values
if( startFrame > endFrame )
if( startFrame != mStartFrame || endFrame != mEndFrame )
{
- ConditionalWait::ScopedLock lock( mConditionalWait );
-
mStartFrame = startFrame;
mEndFrame = endFrame;
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetPlayRange: [%d, %d] [%p]\n", mStartFrame, mEndFrame, this );
}
}
+ else
+ {
+ DALI_LOG_ERROR( "VectorAnimationTask::SetPlayRange: Invalid range (%d, %d) [%p]\n", startFrame, endFrame, this );
+ return;
+ }
}
void VectorAnimationTask::GetPlayRange( uint32_t& startFrame, uint32_t& endFrame )
void VectorAnimationTask::SetCurrentFrameNumber( uint32_t frameNumber )
{
- ConditionalWait::ScopedLock lock( mConditionalWait );
-
if( mCurrentFrame == frameNumber )
{
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetCurrentFrameNumber: Set same frame [%d] [%p]\n", frameNumber, this );
void VectorAnimationTask::SetStopBehavior( DevelImageVisual::StopBehavior::Type stopBehavior )
{
- ConditionalWait::ScopedLock lock( mConditionalWait );
mStopBehavior = stopBehavior;
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetStopBehavior: stop behavor = %d [%p]\n", mStopBehavior, this );
void VectorAnimationTask::SetLoopingMode( DevelImageVisual::LoopingMode::Type loopingMode )
{
- ConditionalWait::ScopedLock lock( mConditionalWait );
mLoopingMode = loopingMode;
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetLoopingMode: looping mode = %d [%p]\n", mLoopingMode, this );
bool VectorAnimationTask::Rasterize()
{
- bool stopped = false, needAnimationFinishedTrigger;
+ bool stopped = false, needAnimationFinishedTrigger, resourceReady;
uint32_t currentFrame, startFrame, endFrame;
int32_t loopCount, currentLoopCount;
PlayState playState;
if( mPlayState == PlayState::PLAYING && mUpdateFrameNumber )
{
mCurrentFrame = mForward ? mCurrentFrame + 1 : mCurrentFrame - 1;
+ Dali::ClampInPlace( mCurrentFrame, mStartFrame, mEndFrame );
}
currentFrame = mCurrentFrame;
currentLoopCount = mCurrentLoop;
needAnimationFinishedTrigger = mNeedAnimationFinishedTrigger;
playState = mPlayState;
+ resourceReady = mResourceReady;
mResourceReady = true;
mCurrentFrameUpdated = false;
{
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::Rasterize: Rendering failed. Try again later.[%d] [%p]\n", currentFrame, this );
mUpdateFrameNumber = false;
+
+ if( !resourceReady )
+ {
+ ConditionalWait::ScopedLock lock( mConditionalWait );
+ mResourceReady = false;
+ }
}
}
if( stopped && renderSuccess )
{
+ ConditionalWait::ScopedLock lock( mConditionalWait );
+
mPlayState = PlayState::STOPPED;
mForward = true;
mCurrentLoop = 0;