class DisplayConnection;
class ThreadSynchronizationInterface;
class Window;
+class TestApplication;
namespace Integration
{
void AddWindow( Internal::Adaptor::SceneHolder* window );
void RemoveWindow( Internal::Adaptor::SceneHolder* window );
+ void RegisterProcessor( Integration::Processor& processor );
+ void UnregisterProcessor( Integration::Processor& processor );
+
+ void SetApplication( Dali::TestApplication& testApplication );
+
Dali::Adaptor::AdaptorSignalType& ResizedSignal();
Dali::Adaptor::AdaptorSignalType& LanguageChangedSignal();
Dali::Adaptor::WindowCreatedSignalType& WindowCreatedSignal();
Dali::Adaptor::AdaptorSignalType mResizedSignal;
Dali::Adaptor::AdaptorSignalType mLanguageChangedSignal;
Dali::Adaptor::WindowCreatedSignalType mWindowCreatedSignal;
+ TestApplication* mTestApplication;
};
} // namespace Adaptor
}
}
+void Adaptor::RegisterProcessor( Integration::Processor& processor )
+{
+ Integration::Core& core = mTestApplication->GetCore();
+ core.RegisterProcessor( processor );
+}
+
+void Adaptor::UnregisterProcessor( Integration::Processor& processor )
+{
+ Integration::Core& core = mTestApplication->GetCore();
+ core.UnregisterProcessor( processor );
+}
+
+void Adaptor::SetApplication( Dali::TestApplication& testApplication )
+{
+ mTestApplication = &testApplication;
+}
+
Dali::Adaptor::AdaptorSignalType& Adaptor::ResizedSignal()
{
return mResizedSignal;
return *gLogFactory;
}
+void Adaptor::RegisterProcessor( Integration::Processor& processor )
+{
+ mImpl->RegisterProcessor( processor );
+}
+
+void Adaptor::UnregisterProcessor( Integration::Processor& processor )
+{
+ mImpl->UnregisterProcessor( processor );
+}
+
} // namespace Dali
// This will also emit the window created signals
AdaptorImpl::GetImpl( *mAdaptor ).Start( *mMainWindow );
+ AdaptorImpl::GetImpl( *mAdaptor ).SetApplication( *this );
Dali::LifecycleController lifecycleController = Dali::LifecycleController::Get();
lifecycleController.InitSignal().Emit();
Property::Map attributes;
DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
+ application.SendNotification();
+ application.Render();
+
// Check rendering behavior
DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
Renderer renderer = actor.GetRendererAt( 0u );
Property::Map attributes;
DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
+ application.SendNotification();
+ application.Render();
+
// Check rendering behavior
DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
Renderer renderer = actor.GetRendererAt( 0u );
#include <dali/public-api/common/stage.h>
#include <dali/devel-api/rendering/renderer-devel.h>
#include <dali/devel-api/adaptor-framework/window-devel.h>
+#include <dali/integration-api/adaptor-framework/adaptor.h>
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
namespace
{
-constexpr auto LOOP_FOREVER = -1;
-
const Dali::Vector4 FULL_TEXTURE_RECT( 0.f, 0.f, 1.f, 1.f );
-// Flags for re-sending data to the rasterize thread
-enum Flags
-{
- RESEND_PLAY_RANGE = 1 << 0,
- RESEND_LOOP_COUNT = 1 << 1,
- RESEND_STOP_BEHAVIOR = 1 << 2,
- RESEND_LOOPING_MODE = 1 << 3
-};
-
// stop behavior
DALI_ENUM_TO_STRING_TABLE_BEGIN( STOP_BEHAVIOR )
DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::Toolkit::DevelImageVisual::StopBehavior, CURRENT_FRAME )
AnimatedVectorImageVisual::AnimatedVectorImageVisual( VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl )
: Visual::Base( factoryCache, Visual::FittingMode::FILL ),
mUrl( imageUrl ),
+ mAnimationData(),
mVectorAnimationTask( new VectorAnimationTask( factoryCache, imageUrl.GetUrl() ) ),
mImageVisualShaderFactory( shaderFactory ),
mVisualSize(),
mVisualScale( Vector2::ONE ),
- mPlayRange(),
mPlacementActor(),
- mLoopCount( LOOP_FOREVER ),
- mResendFlag( 0 ),
mActionStatus( DevelAnimatedVectorImageVisual::Action::STOP ),
- mStopBehavior( DevelImageVisual::StopBehavior::CURRENT_FRAME ),
- mLoopingMode( DevelImageVisual::LoopingMode::RESTART ),
- mRendererAdded( false )
+ mRendererAdded( false ),
+ mRasterizationTriggered( false )
{
// the rasterized image is with pre-multiplied alpha format
mImpl->mFlags |= Impl::IS_PREMULTIPLIED_ALPHA;
AnimatedVectorImageVisual::~AnimatedVectorImageVisual()
{
- // Finalize animation task in the main thread
+ if( mRasterizationTriggered && Adaptor::IsAvailable() )
+ {
+ Adaptor::Get().UnregisterProcessor( *this );
+ }
+
+ // Finalize animation task and disconnect the signal in the main thread
+ mVectorAnimationTask->UploadCompletedSignal().Disconnect( this, &AnimatedVectorImageVisual::OnUploadCompleted );
mVectorAnimationTask->Finalize();
}
{
map.Insert( Toolkit::ImageVisual::Property::URL, mUrl.GetUrl() );
}
- map.Insert( Toolkit::DevelImageVisual::Property::LOOP_COUNT, mLoopCount );
+ map.Insert( Toolkit::DevelImageVisual::Property::LOOP_COUNT, mAnimationData.loopCount );
uint32_t startFrame, endFrame;
mVectorAnimationTask->GetPlayRange( startFrame, endFrame );
map.Insert( Toolkit::DevelImageVisual::Property::CURRENT_FRAME_NUMBER, static_cast< int32_t >( mVectorAnimationTask->GetCurrentFrameNumber() ) );
map.Insert( Toolkit::DevelImageVisual::Property::TOTAL_FRAME_NUMBER, static_cast< int32_t >( mVectorAnimationTask->GetTotalFrameNumber() ) );
- map.Insert( Toolkit::DevelImageVisual::Property::STOP_BEHAVIOR, mStopBehavior );
- map.Insert( Toolkit::DevelImageVisual::Property::LOOPING_MODE, mLoopingMode );
+ map.Insert( Toolkit::DevelImageVisual::Property::STOP_BEHAVIOR, mAnimationData.stopBehavior );
+ map.Insert( Toolkit::DevelImageVisual::Property::LOOPING_MODE, mAnimationData.loopingMode );
Property::Map layerInfo;
mVectorAnimationTask->GetLayerInfo( layerInfo );
}
}
}
+
+ TriggerVectorRasterization();
}
void AnimatedVectorImageVisual::DoSetProperty( Property::Index index, const Property::Value& value )
int32_t loopCount;
if( value.Get( loopCount ) )
{
- mLoopCount = loopCount;
- mResendFlag |= RESEND_LOOP_COUNT;
+ mAnimationData.loopCount = loopCount;
+ mAnimationData.resendFlag |= VectorAnimationTask::RESEND_LOOP_COUNT;
}
break;
}
Property::Array* array = value.GetArray();
if( array )
{
- mPlayRange = *array;
- mResendFlag |= RESEND_PLAY_RANGE;
+ mAnimationData.playRange = *array;
+ mAnimationData.resendFlag |= VectorAnimationTask::RESEND_PLAY_RANGE;
}
break;
}
case Toolkit::DevelImageVisual::Property::STOP_BEHAVIOR:
{
- int32_t stopBehavior = mStopBehavior;
+ int32_t stopBehavior = mAnimationData.stopBehavior;
if( Scripting::GetEnumerationProperty( value, STOP_BEHAVIOR_TABLE, STOP_BEHAVIOR_TABLE_COUNT, stopBehavior ) )
{
- mStopBehavior = DevelImageVisual::StopBehavior::Type( stopBehavior );
- mResendFlag |= RESEND_STOP_BEHAVIOR;
+ mAnimationData.stopBehavior = DevelImageVisual::StopBehavior::Type( stopBehavior );
+ mAnimationData.resendFlag |= VectorAnimationTask::RESEND_STOP_BEHAVIOR;
}
break;
}
case Toolkit::DevelImageVisual::Property::LOOPING_MODE:
{
- int32_t loopingMode = mLoopingMode;
+ int32_t loopingMode = mAnimationData.loopingMode;
if( Scripting::GetEnumerationProperty( value, LOOPING_MODE_TABLE, LOOPING_MODE_TABLE_COUNT, loopingMode ) )
{
- mLoopingMode = DevelImageVisual::LoopingMode::Type( loopingMode );
- mResendFlag |= RESEND_LOOPING_MODE;
+ mAnimationData.loopingMode = DevelImageVisual::LoopingMode::Type( loopingMode );
+ mAnimationData.resendFlag |= VectorAnimationTask::RESEND_LOOPING_MODE;
}
break;
}
void AnimatedVectorImageVisual::DoSetOffStage( Actor& actor )
{
StopAnimation();
+ SendAnimationData();
if( mImpl->mRenderer )
{
SetVectorImageSize();
- SendAnimationData();
-
- if( mActionStatus == DevelAnimatedVectorImageVisual::Action::PLAY )
+ if( mActionStatus == DevelAnimatedVectorImageVisual::Action::PLAY && mAnimationData.playState != DevelImageVisual::PlayState::PLAYING )
{
- mVectorAnimationTask->PlayAnimation();
-
- mImpl->mRenderer.SetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::CONTINUOUSLY );
- }
- else
- {
- // Render one frame
- mVectorAnimationTask->RenderFrame();
+ mAnimationData.playState = DevelImageVisual::PlayState::PLAYING;
+ mAnimationData.resendFlag |= VectorAnimationTask::RESEND_PLAY_STATE;
}
+
+ SendAnimationData();
}
}
{
if( IsOnStage() && mVisualSize != Vector2::ZERO )
{
- mVectorAnimationTask->PlayAnimation();
-
- mImpl->mRenderer.SetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::CONTINUOUSLY );
+ if( mAnimationData.playState != DevelImageVisual::PlayState::PLAYING )
+ {
+ mAnimationData.playState = DevelImageVisual::PlayState::PLAYING;
+ mAnimationData.resendFlag |= VectorAnimationTask::RESEND_PLAY_STATE;
+ }
}
mActionStatus = DevelAnimatedVectorImageVisual::Action::PLAY;
break;
}
case DevelAnimatedVectorImageVisual::Action::PAUSE:
{
- mVectorAnimationTask->PauseAnimation();
-
- if( mImpl->mRenderer )
+ if( mAnimationData.playState == DevelImageVisual::PlayState::PLAYING )
{
- mImpl->mRenderer.SetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::IF_REQUIRED );
+ mAnimationData.playState = DevelImageVisual::PlayState::PAUSED;
+ mAnimationData.resendFlag |= VectorAnimationTask::RESEND_PLAY_STATE;
}
-
mActionStatus = DevelAnimatedVectorImageVisual::Action::PAUSE;
break;
}
case DevelAnimatedVectorImageVisual::Action::STOP:
{
- if( mVectorAnimationTask->GetPlayState() != DevelImageVisual::PlayState::STOPPED )
+ if( mAnimationData.playState != DevelImageVisual::PlayState::STOPPED )
{
- mVectorAnimationTask->StopAnimation();
+ mAnimationData.playState = DevelImageVisual::PlayState::STOPPED;
+ mAnimationData.resendFlag |= VectorAnimationTask::RESEND_PLAY_STATE;
}
-
- if( mImpl->mRenderer )
- {
- mImpl->mRenderer.SetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::IF_REQUIRED );
- }
-
mActionStatus = DevelAnimatedVectorImageVisual::Action::STOP;
break;
}
int32_t frameNumber;
if( attributes.Get( frameNumber ) )
{
- mVectorAnimationTask->SetCurrentFrameNumber( frameNumber );
-
- if( IsOnStage() && mVectorAnimationTask->GetPlayState() != DevelImageVisual::PlayState::PLAYING )
- {
- mVectorAnimationTask->RenderFrame();
- Stage::GetCurrent().KeepRendering( 0.0f ); // Trigger rendering
- }
+ mAnimationData.currentFrame = frameNumber;
+ mAnimationData.resendFlag |= VectorAnimationTask::RESEND_CURRENT_FRAME;
}
break;
}
if( map )
{
DoSetProperties( *map );
-
- SendAnimationData();
}
break;
}
}
+
+ TriggerVectorRasterization();
+}
+
+void AnimatedVectorImageVisual::Process()
+{
+ SendAnimationData();
+
+ mRasterizationTriggered = false;
+
+ Adaptor::Get().UnregisterProcessor( *this );
}
void AnimatedVectorImageVisual::OnUploadCompleted()
{
mActionStatus = DevelAnimatedVectorImageVisual::Action::STOP;
+ mAnimationData.playState = DevelImageVisual::PlayState::STOPPED;
+
if( mImpl->mEventObserver )
{
mImpl->mEventObserver->NotifyVisualEvent( *this, DevelAnimatedVectorImageVisual::Signal::ANIMATION_FINISHED );
void AnimatedVectorImageVisual::SendAnimationData()
{
- if( mResendFlag )
+ if( mAnimationData.resendFlag )
{
- bool isPlaying = false;
- if( mVectorAnimationTask->GetPlayState() == DevelImageVisual::PlayState::PLAYING )
- {
- mVectorAnimationTask->PauseAnimation();
- isPlaying = true;
- }
-
- if( mResendFlag & RESEND_LOOP_COUNT )
- {
- mVectorAnimationTask->SetLoopCount( mLoopCount );
- }
-
- if( mResendFlag & RESEND_PLAY_RANGE )
- {
- mVectorAnimationTask->SetPlayRange( mPlayRange );
- }
+ mVectorAnimationTask->SetAnimationData( mAnimationData );
- if( mResendFlag & RESEND_STOP_BEHAVIOR )
- {
- mVectorAnimationTask->SetStopBehavior( mStopBehavior );
- }
-
- if( mResendFlag & RESEND_LOOPING_MODE )
- {
- mVectorAnimationTask->SetLoopingMode( mLoopingMode );
- }
-
- if( IsOnStage() )
+ if( mImpl->mRenderer )
{
- if( isPlaying )
+ if( mAnimationData.playState == DevelImageVisual::PlayState::PLAYING )
{
- mVectorAnimationTask->PlayAnimation();
+ mImpl->mRenderer.SetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::CONTINUOUSLY );
}
else
{
- mVectorAnimationTask->RenderFrame();
- Stage::GetCurrent().KeepRendering( 0.0f );
+ mImpl->mRenderer.SetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::IF_REQUIRED );
}
}
- mResendFlag = 0;
+ mAnimationData.resendFlag = 0;
}
}
uint32_t width = static_cast< uint32_t >( mVisualSize.width * mVisualScale.width );
uint32_t height = static_cast< uint32_t >( mVisualSize.height * mVisualScale.height );
- mVectorAnimationTask->SetSize( width, height );
-
- if( IsOnStage() && mVectorAnimationTask->GetPlayState() != DevelImageVisual::PlayState::PLAYING )
- {
- mVectorAnimationTask->RenderFrame();
- Stage::GetCurrent().KeepRendering( 0.0f ); // Trigger rendering
- }
+ mAnimationData.width = width;
+ mAnimationData.height = height;
+ mAnimationData.resendFlag |= VectorAnimationTask::RESEND_SIZE;
}
void AnimatedVectorImageVisual::StopAnimation()
{
- if( mActionStatus != DevelAnimatedVectorImageVisual::Action::STOP )
+ if( mAnimationData.playState != DevelImageVisual::PlayState::STOPPED )
{
- mVectorAnimationTask->StopAnimation();
+ mAnimationData.playState = DevelImageVisual::PlayState::STOPPED;
+ mAnimationData.resendFlag |= VectorAnimationTask::RESEND_PLAY_STATE;
mActionStatus = DevelAnimatedVectorImageVisual::Action::STOP;
+ }
+}
- if( mImpl->mRenderer )
- {
- mImpl->mRenderer.SetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::IF_REQUIRED );
- }
+void AnimatedVectorImageVisual::TriggerVectorRasterization()
+{
+ if( !mRasterizationTriggered )
+ {
+ Stage::GetCurrent().KeepRendering( 0.0f ); // Trigger event processing
+
+ Adaptor::Get().RegisterProcessor( *this );
+ mRasterizationTriggered = true;
}
}
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::OnScaleNotification: scale = %f, %f [%p]\n", mVisualScale.width, mVisualScale.height, this );
SetVectorImageSize();
+ SendAnimationData();
+
+ Stage::GetCurrent().KeepRendering( 0.0f ); // Trigger event processing
}
}
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::OnSizeNotification: size = %f, %f [%p]\n", mVisualSize.width, mVisualSize.height, this );
SetVectorImageSize();
+ SendAnimationData();
+
+ Stage::GetCurrent().KeepRendering( 0.0f ); // Trigger event processing
}
}
if( !visible )
{
StopAnimation();
+ TriggerVectorRasterization();
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::OnControlVisibilityChanged: invisibile. Pause animation [%p]\n", this );
}
if( !visible )
{
StopAnimation();
+ TriggerVectorRasterization();
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::OnWindowVisibilityChanged: invisibile. Pause animation [%p]\n", this );
}
#include <dali/public-api/common/intrusive-ptr.h>
#include <dali/public-api/object/weak-handle.h>
#include <dali/public-api/object/property-notification.h>
-#include <dali/devel-api/actors/actor-devel.h>
#include <dali/public-api/adaptor-framework/window.h>
+#include <dali/devel-api/actors/actor-devel.h>
+#include <dali/integration-api/processor-interface.h>
// INTERNAL INCLUDES
#include <dali-toolkit/internal/visuals/visual-base-impl.h>
* | url | STRING |
*
*/
-class AnimatedVectorImageVisual: public Visual::Base, public ConnectionTracker
+class AnimatedVectorImageVisual: public Visual::Base, public ConnectionTracker, public Integration::Processor
{
public:
*/
void OnDoAction( const Property::Index actionId, const Property::Value& attributes ) override;
+protected: // Implementation of Processor
+
+ /**
+ * @copydoc Dali::Integration::Processor::Process()
+ */
+ void Process() override;
+
private:
/**
void StopAnimation();
/**
+ * @brief Trigger rasterization of the vector content.
+ */
+ void TriggerVectorRasterization();
+
+ /**
* @brief Callback when the world scale factor changes.
*/
void OnScaleNotification( PropertyNotification& source );
private:
VisualUrl mUrl;
+ VectorAnimationTask::AnimationData mAnimationData;
VectorAnimationTaskPtr mVectorAnimationTask;
ImageVisualShaderFactory& mImageVisualShaderFactory;
PropertyNotification mScaleNotification;
PropertyNotification mSizeNotification;
Vector2 mVisualSize;
Vector2 mVisualScale;
- Property::Array mPlayRange;
WeakHandle< Actor > mPlacementActor;
- int32_t mLoopCount;
- uint32_t mResendFlag;
DevelAnimatedVectorImageVisual::Action::Type mActionStatus;
- DevelImageVisual::StopBehavior::Type mStopBehavior;
- DevelImageVisual::LoopingMode::Type mLoopingMode;
bool mRendererAdded;
+ bool mRasterizationTriggered;
};
} // namespace Internal
void VectorAnimationTask::Finalize()
{
+ ConditionalWait::ScopedLock lock( mConditionalWait );
+
// Release some objects in the main thread
if( mAnimationFinishedTrigger )
{
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( Property::Array& playRange )
+void VectorAnimationTask::SetPlayRange( const Property::Array& playRange )
{
- ConditionalWait::ScopedLock lock( mConditionalWait );
-
bool valid = false;
uint32_t startFrame = 0, endFrame = 0;
size_t count = playRange.Count();
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;
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;
*/
// EXTERNAL INCLUDES
+#include <dali/public-api/object/property-array.h>
#include <dali/devel-api/adaptor-framework/event-thread-callback.h>
#include <dali/devel-api/adaptor-framework/vector-animation-renderer.h>
#include <dali/devel-api/threading/conditional-wait.h>
using UploadCompletedSignalType = Dali::VectorAnimationRenderer::UploadCompletedSignalType;
/**
+ * Flags for re-sending data to the vector animation thread
+ */
+ enum ResendFlags
+ {
+ RESEND_PLAY_RANGE = 1 << 0,
+ RESEND_LOOP_COUNT = 1 << 1,
+ RESEND_STOP_BEHAVIOR = 1 << 2,
+ RESEND_LOOPING_MODE = 1 << 3,
+ RESEND_CURRENT_FRAME = 1 << 4,
+ RESEND_SIZE = 1 << 5,
+ RESEND_PLAY_STATE = 1 << 6
+ };
+
+ /**
+ * @brief Structure used to pass parameters to the vector animation task
+ */
+ struct AnimationData
+ {
+ AnimationData()
+ : resendFlag( 0 ),
+ playRange(),
+ playState(),
+ stopBehavior( DevelImageVisual::StopBehavior::CURRENT_FRAME ),
+ loopingMode( DevelImageVisual::LoopingMode::RESTART ),
+ currentFrame( 0 ),
+ width( 0 ),
+ height( 0 ),
+ loopCount( -1 )
+ {
+ }
+
+ uint32_t resendFlag;
+ Property::Array playRange;
+ DevelImageVisual::PlayState::Type playState;
+ DevelImageVisual::StopBehavior::Type stopBehavior;
+ DevelImageVisual::LoopingMode::Type loopingMode;
+ uint32_t currentFrame;
+ uint32_t width;
+ uint32_t height;
+ int32_t loopCount;
+ };
+
+ /**
* @brief Constructor.
*
* @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
void SetRenderer( Renderer renderer );
/**
- * @brief Sets the target image size.
- *
- * @param[in] width The target image width
- * @param[in] height The target image height
- */
- void SetSize( uint32_t width, uint32_t height );
-
- /**
- * @brief Play the vector animation.
- */
- void PlayAnimation();
-
- /**
- * @brief Stop the vector animation.
- */
- void StopAnimation();
-
- /**
- * @brief Pause the vector animation.
+ * @brief Sets data to specify animation playback.
+ * @param[in] data The animation data
*/
- void PauseAnimation();
-
- /**
- * @brief Render one frame. The current frame number will be increased.
- */
- void RenderFrame();
+ void SetAnimationData( const AnimationData& data );
/**
* @brief This callback is called after the animation is finished.
void SetAnimationFinishedCallback( EventThreadCallback* callback );
/**
- * @brief Enable looping for 'count' repeats. -1 means to repeat forever.
- * @param[in] count The number of times to loop
- */
- void SetLoopCount( int32_t count );
-
- /**
- * @brief Set the playing range in frame number.
- * @param[in] playRange The array to specify minimum and maximum progress.
- * The animation will play between those values.
- */
- void SetPlayRange( Property::Array& playRange );
-
- /**
* @brief Gets the playing range in frame number.
* @param[out] startFrame The frame number to specify minimum progress.
* @param[out] endFrame The frame number to specify maximum progress.
DevelImageVisual::PlayState::Type GetPlayState() const;
/**
- * @brief Sets the current frame number of the animation.
- * @param[in] frameNumber The new frame number between [0, the maximum frame number] or between the play range if specified.
- */
- void SetCurrentFrameNumber( uint32_t frameNumber );
-
- /**
* @brief Retrieves the current frame number of the animation.
* @return The current frame number
*/
void GetDefaultSize( uint32_t& width, uint32_t& height ) const;
/**
- * @brief Sets the stop behavior of the animation. This is performed when the animation is stopped.
- * @param[in] stopBehavior The stop behavior
- */
- void SetStopBehavior( DevelImageVisual::StopBehavior::Type stopBehavior );
-
- /**
- * @brief Sets the looping mode.
- * Animation plays forwards and then restarts from the beginning or runs backwards again.
- * @param[in] loopingMode The looping mode
- */
- void SetLoopingMode( DevelImageVisual::LoopingMode::Type loopingMode );
-
- /**
* @brief Gets the layer information of all the child layers.
* @param[out] map The layer information
*/
void Initialize();
/**
+ * @brief Play the vector animation.
+ */
+ void PlayAnimation();
+
+ /**
+ * @brief Stop the vector animation.
+ */
+ void StopAnimation();
+
+ /**
+ * @brief Pause the vector animation.
+ */
+ void PauseAnimation();
+
+ /**
+ * @brief Render one frame. The current frame number will be increased.
+ */
+ void RenderFrame();
+
+ /**
+ * @brief Sets the target image size.
+ *
+ * @param[in] width The target image width
+ * @param[in] height The target image height
+ */
+ void SetSize( uint32_t width, uint32_t height );
+
+ /**
+ * @brief Enable looping for 'count' repeats. -1 means to repeat forever.
+ * @param[in] count The number of times to loop
+ */
+ void SetLoopCount( int32_t count );
+
+ /**
+ * @brief Set the playing range in frame number.
+ * @param[in] playRange The array to specify minimum and maximum progress.
+ * The animation will play between those values.
+ */
+ void SetPlayRange( const Property::Array& playRange );
+
+ /**
+ * @brief Sets the current frame number of the animation.
+ * @param[in] frameNumber The new frame number between [0, the maximum frame number] or between the play range if specified.
+ */
+ void SetCurrentFrameNumber( uint32_t frameNumber );
+
+ /**
+ * @brief Sets the stop behavior of the animation. This is performed when the animation is stopped.
+ * @param[in] stopBehavior The stop behavior
+ */
+ void SetStopBehavior( DevelImageVisual::StopBehavior::Type stopBehavior );
+
+ /**
+ * @brief Sets the looping mode.
+ * Animation plays forwards and then restarts from the beginning or runs backwards again.
+ * @param[in] loopingMode The looping mode
+ */
+ void SetLoopingMode( DevelImageVisual::LoopingMode::Type loopingMode );
+
+ /**
* @brief Gets the frame number when the animation is stopped according to the stop behavior.
*/
uint32_t GetStoppedFrame( uint32_t startFrame, uint32_t endFrame, uint32_t currentFrame );
VectorAnimationThread& mVectorAnimationThread;
ConditionalWait mConditionalWait;
std::unique_ptr< EventThreadCallback > mAnimationFinishedTrigger;
- Vector2 mPlayRange;
PlayState mPlayState;
DevelImageVisual::StopBehavior::Type mStopBehavior;
DevelImageVisual::LoopingMode::Type mLoopingMode;