X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fanimated-vector-image%2Fvector-animation-task.cpp;h=bb6fb7e2531ba5f4091417bc6f8f16e2f4c3e470;hb=175d74ab98dd2f89726ce6594a08d65e0d01056f;hp=ef8a18e46fb1c2dc7327f0b3db5297af36b6bb7a;hpb=ad314f8d50d653a269158e01ecf3f89b002d8876;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.cpp b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.cpp index ef8a18e..bb6fb7e 100644 --- a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.cpp +++ b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.cpp @@ -20,6 +20,8 @@ // EXTERNAL INCLUDES #include +#include +#include // INTERNAL INCLUDES #include @@ -40,8 +42,6 @@ namespace constexpr auto LOOP_FOREVER = -1; constexpr auto NANOSECONDS_PER_SECOND( 1e+9 ); -#define CLAMP( x, low, high ) ( ( ( x ) > ( high ) ) ? ( high ) : ( ( ( x ) < ( low ) ) ? ( low ) : ( x ) ) ) - #if defined(DEBUG_ENABLED) Debug::Filter* gVectorAnimationLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_VECTOR_ANIMATION" ); #endif @@ -116,11 +116,71 @@ 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; @@ -134,8 +194,6 @@ void VectorAnimationTask::SetSize( uint32_t width, uint32_t height ) void VectorAnimationTask::PlayAnimation() { - ConditionalWait::ScopedLock lock( mConditionalWait ); - if( mPlayState != PlayState::PLAYING ) { mUpdateFrameNumber = false; @@ -149,7 +207,6 @@ void VectorAnimationTask::PlayAnimation() void VectorAnimationTask::StopAnimation() { - ConditionalWait::ScopedLock lock( mConditionalWait ); if( mPlayState != PlayState::STOPPED && mPlayState != PlayState::STOPPING ) { mNeedAnimationFinishedTrigger = false; @@ -161,7 +218,6 @@ void VectorAnimationTask::StopAnimation() void VectorAnimationTask::PauseAnimation() { - ConditionalWait::ScopedLock lock( mConditionalWait ); if( mPlayState == PlayState::PLAYING ) { mPlayState = PlayState::PAUSED; @@ -172,8 +228,6 @@ void VectorAnimationTask::PauseAnimation() void VectorAnimationTask::RenderFrame() { - ConditionalWait::ScopedLock lock( mConditionalWait ); - if( !mResourceReady ) { mVectorAnimationThread.AddTask( this ); @@ -195,8 +249,6 @@ void VectorAnimationTask::SetLoopCount( int32_t count ) { if( mLoopCount != count ) { - ConditionalWait::ScopedLock lock( mConditionalWait ); - mLoopCount = count; mCurrentLoop = 0; mCurrentLoopUpdated = true; @@ -205,10 +257,58 @@ void VectorAnimationTask::SetLoopCount( int32_t count ) } } -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 ) @@ -220,8 +320,6 @@ void VectorAnimationTask::SetPlayRange( uint32_t startFrame, uint32_t endFrame ) if( startFrame != mStartFrame || endFrame != mEndFrame ) { - ConditionalWait::ScopedLock lock( mConditionalWait ); - mStartFrame = startFrame; mEndFrame = endFrame; @@ -244,6 +342,11 @@ void VectorAnimationTask::SetPlayRange( uint32_t startFrame, uint32_t 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 ) @@ -281,8 +384,6 @@ DevelImageVisual::PlayState::Type VectorAnimationTask::GetPlayState() const 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 ); @@ -322,7 +423,6 @@ void VectorAnimationTask::GetDefaultSize( uint32_t& width, uint32_t& height ) co 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 ); @@ -330,7 +430,6 @@ void VectorAnimationTask::SetStopBehavior( DevelImageVisual::StopBehavior::Type 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 ); @@ -378,7 +477,7 @@ bool VectorAnimationTask::Rasterize() if( mPlayState == PlayState::PLAYING && mUpdateFrameNumber ) { mCurrentFrame = mForward ? mCurrentFrame + 1 : mCurrentFrame - 1; - mCurrentFrame = CLAMP( mCurrentFrame, mStartFrame, mEndFrame ); + Dali::ClampInPlace( mCurrentFrame, mStartFrame, mEndFrame ); } currentFrame = mCurrentFrame;