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();
#include <dali/public-api/object/base-object.h>
#include <toolkit-application.h>
#include <toolkit-vector-animation-renderer.h>
+#include <toolkit-event-thread-callback.h>
+#include <memory>
namespace Dali
{
mWidth( 0 ),
mHeight( 0 ),
mPreviousFrame( 0 ),
- mFrameRate( 60.0f )
+ mFrameRate( 60.0f ),
+ mEventThreadCallback( new EventThreadCallback( MakeCallback( this, &VectorAnimationRenderer::OnTriggered ) ) )
{
mCount++;
bool Render( uint32_t frameNumber )
{
+ if( mNeedTrigger )
+ {
+ mEventThreadCallback->Trigger();
+ mNeedTrigger = false;
+ }
+
if( frameNumber == 1 && mPreviousFrame != frameNumber )
{
mPreviousFrame = frameNumber;
return mUploadCompletedSignal;
}
+ void OnTriggered()
+ {
+ }
+
public:
static uint32_t mCount;
+ static bool mNeedTrigger;
std::string mUrl;
Dali::Renderer mRenderer;
uint32_t mPreviousFrame;
float mFrameRate;
Dali::VectorAnimationRenderer::UploadCompletedSignalType mUploadCompletedSignal;
+ std::unique_ptr< EventThreadCallback > mEventThreadCallback;
};
uint32_t VectorAnimationRenderer::mCount = 0;
+bool VectorAnimationRenderer::mNeedTrigger = true;
inline VectorAnimationRenderer& GetImplementation( Dali::VectorAnimationRenderer& renderer )
{
return Internal::Adaptor::GetImplementation( *this ).UploadCompletedSignal();
}
-} // namespace Dali;
+} // namespace Dali
+
+namespace Test
+{
+namespace VectorAnimationRenderer
+{
+
+void RequestTrigger()
+{
+ Dali::Internal::Adaptor::VectorAnimationRenderer::mNeedTrigger = true;
+}
+
+} // VectorAnimationRenderer
+} // Test
namespace Test
{
+namespace VectorAnimationRenderer
+{
#define VECTOR_ANIMATION_TOTAL_FRAME_NUMBER 5
#define VECTOR_ANIMATION_MARKER_NAME_1 "marker1"
#define VECTOR_ANIMATION_MARKER_START_FRAME_2 2
#define VECTOR_ANIMATION_MARKER_END_FRAME_2 3
+void RequestTrigger();
+
+} // VectorAnimationRenderer
} // Test
application.SendNotification();
application.Render( 16 );
- std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) ); // wait for one animation loop (16fps, 5frames, need 80ms)
-
Property::Map map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
Property::Value* value = map.Find( DevelImageVisual::Property::PLAY_STATE );
DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::PLAYING );
application.SendNotification();
application.Render(16);
- std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
-
map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
value = map.Find( DevelImageVisual::Property::PLAY_STATE );
DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::PAUSED );
application.SendNotification();
application.Render();
- // Trigger count is 1 - animation finished
+ // Trigger count is 1 - render a frame
DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
// renderer is added to actor
application.SendNotification();
application.Render();
+ std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
+
// renderer is added to actor
DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
Renderer renderer = actor.GetRendererAt( 0u );
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 );
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::CURRENT_FRAME_NUMBER );
DALI_TEST_EQUALS( value->Get< int >(), 3, TEST_LOCATION );
application.SendNotification();
application.Render();
+ std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
+
// renderer is added to actor
DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
Renderer renderer = actor.GetRendererAt( 0u );
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 );
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 );
application.Render();
// Wait for animation finish
- DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
Property::Map map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
Property::Value* value = map.Find( DevelImageVisual::Property::PLAY_STATE );
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::CURRENT_FRAME_NUMBER );
DALI_TEST_EQUALS( value->Get< int >(), 3, TEST_LOCATION );
int UtcDaliAnimatedVectorImageVisualUpdateProperty(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliAnimatedVectorImageVisualJumpToCurrentProgress" );
+ tet_infoline( "UtcDaliAnimatedVectorImageVisualUpdateProperty" );
int startFrame = 1, endFrame = 3;
Property::Array playRange;
application.SendNotification();
application.Render();
+ std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
+
Property::Map map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
Property::Value* value = map.Find( DevelImageVisual::Property::LOOP_COUNT );
DALI_TEST_EQUALS( value->Get< int >(), 3, TEST_LOCATION );
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::LOOP_COUNT );
DALI_TEST_EQUALS( value->Get< int >(), 5, TEST_LOCATION );
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 );
application.Render();
// Trigger count is 1 - animation finished
- DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
Property::Map map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
Property::Value* value = map.Find( DevelImageVisual::Property::CURRENT_FRAME_NUMBER );
application.Render();
// Trigger count is 1 - animation finished
- DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
Property::Map map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
Property::Value* value = map.Find( DevelImageVisual::Property::CURRENT_FRAME_NUMBER );
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 );
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#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 )
+ mPlayState( DevelImageVisual::PlayState::STOPPED ),
+ mRendererAdded( false ),
+ mRasterizationTriggered( false )
{
// the rasterized image is with pre-multiplied alpha format
mImpl->mFlags |= Impl::IS_PREMULTIPLIED_ALPHA;
AnimatedVectorImageVisual::~AnimatedVectorImageVisual()
{
+ 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 );
playRange.PushBack( static_cast< int32_t >( endFrame ) );
map.Insert( Toolkit::DevelImageVisual::Property::PLAY_RANGE, playRange );
- map.Insert( Toolkit::DevelImageVisual::Property::PLAY_STATE, static_cast< int32_t >( mVectorAnimationTask->GetPlayState() ) );
+ map.Insert( Toolkit::DevelImageVisual::Property::PLAY_STATE, static_cast< int32_t >( mPlayState ) );
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( mPlayState == DevelImageVisual::PlayState::PLAYING && 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;
+ mPlayState = DevelImageVisual::PlayState::PLAYING;
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;
+ mPlayState = DevelImageVisual::PlayState::PAUSED;
break;
}
case DevelAnimatedVectorImageVisual::Action::STOP:
{
- if( mVectorAnimationTask->GetPlayState() != DevelImageVisual::PlayState::STOPPED )
+ if( mAnimationData.playState != DevelImageVisual::PlayState::STOPPED )
{
- mVectorAnimationTask->StopAnimation();
- }
-
- if( mImpl->mRenderer )
- {
- mImpl->mRenderer.SetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::IF_REQUIRED );
+ mAnimationData.playState = DevelImageVisual::PlayState::STOPPED;
+ mAnimationData.resendFlag |= VectorAnimationTask::RESEND_PLAY_STATE;
}
-
- mActionStatus = DevelAnimatedVectorImageVisual::Action::STOP;
+ mPlayState = DevelImageVisual::PlayState::STOPPED;
break;
}
case DevelAnimatedVectorImageVisual::Action::JUMP_TO:
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()
void AnimatedVectorImageVisual::OnAnimationFinished()
{
- DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::OnAnimationFinished: action state = %d [%p]\n", mActionStatus, this );
+ DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::OnAnimationFinished: action state = %d [%p]\n", mPlayState, this );
- if( mActionStatus != DevelAnimatedVectorImageVisual::Action::STOP )
+ if( mPlayState != DevelImageVisual::PlayState::STOPPED )
{
- mActionStatus = DevelAnimatedVectorImageVisual::Action::STOP;
+ mPlayState = DevelImageVisual::PlayState::STOPPED;
+
+ mAnimationData.playState = DevelImageVisual::PlayState::STOPPED;
if( mImpl->mEventObserver )
{
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 );
- }
-
- if( mResendFlag & RESEND_STOP_BEHAVIOR )
- {
- mVectorAnimationTask->SetStopBehavior( mStopBehavior );
- }
-
- if( mResendFlag & RESEND_LOOPING_MODE )
- {
- mVectorAnimationTask->SetLoopingMode( mLoopingMode );
- }
+ mVectorAnimationTask->SetAnimationData( mAnimationData );
- 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 );
+ mAnimationData.width = width;
+ mAnimationData.height = height;
+ mAnimationData.resendFlag |= VectorAnimationTask::RESEND_SIZE;
+}
- if( IsOnStage() && mVectorAnimationTask->GetPlayState() != DevelImageVisual::PlayState::PLAYING )
+void AnimatedVectorImageVisual::StopAnimation()
+{
+ if( mAnimationData.playState != DevelImageVisual::PlayState::STOPPED )
{
- mVectorAnimationTask->RenderFrame();
- Stage::GetCurrent().KeepRendering( 0.0f ); // Trigger rendering
+ mAnimationData.playState = DevelImageVisual::PlayState::STOPPED;
+ mAnimationData.resendFlag |= VectorAnimationTask::RESEND_PLAY_STATE;
+
+ mPlayState = DevelImageVisual::PlayState::STOPPED;
}
}
-void AnimatedVectorImageVisual::StopAnimation()
+void AnimatedVectorImageVisual::TriggerVectorRasterization()
{
- if( mActionStatus != DevelAnimatedVectorImageVisual::Action::STOP )
+ if( !mRasterizationTriggered )
{
- mVectorAnimationTask->StopAnimation();
+ Stage::GetCurrent().KeepRendering( 0.0f ); // Trigger event processing
- mActionStatus = DevelAnimatedVectorImageVisual::Action::STOP;
-
- if( mImpl->mRenderer )
- {
- mImpl->mRenderer.SetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::IF_REQUIRED );
- }
+ 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 );
}
#define DALI_TOOLKIT_INTERNAL_ANIMATED_VECTOR_IMAGE_VISUAL_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#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;
+ DevelImageVisual::PlayState::Type mPlayState;
bool mRendererAdded;
+ bool mRasterizationTriggered;
};
} // namespace Internal
Debug::Filter* gVectorAnimationLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_VECTOR_ANIMATION" );
#endif
-template< typename T >
-inline void ResetValue( bool& updated, T& value, T newValue, ConditionalWait& conditionalWait )
-{
- ConditionalWait::ScopedLock lock( conditionalWait );
- if( !updated )
- {
- value = newValue;
- updated = true;
- }
-}
-
} // unnamed namespace
VectorAnimationTask::VectorAnimationTask( VisualFactoryCache& factoryCache, const std::string& url )
: mUrl( url ),
mVectorRenderer(),
+ mAnimationData(),
mVectorAnimationThread( factoryCache.GetVectorAnimationThread() ),
mConditionalWait(),
mAnimationFinishedTrigger(),
mEndFrame( 0 ),
mWidth( 0 ),
mHeight( 0 ),
+ mAnimationDataIndex( 0 ),
mLoopCount( LOOP_FOREVER ),
mCurrentLoop( 0 ),
mResourceReady( false ),
- mCurrentFrameUpdated( false ),
- mCurrentLoopUpdated( false ),
mForward( true ),
mUpdateFrameNumber( false ),
- mNeedAnimationFinishedTrigger( true )
+ mNeedAnimationFinishedTrigger( true ),
+ mAnimationDataUpdated( false )
{
Initialize();
}
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 );
+
+ uint32_t index = mAnimationDataIndex == 0 ? 1 : 0; // Use the other buffer
+
+ mAnimationData[index] = data;
+ mAnimationDataUpdated = true;
+
+ if( data.resendFlag & VectorAnimationTask::RESEND_SIZE )
+ {
+ // The size should be changed in the main thread.
+ SetSize( data.width, data.height );
+ }
+
+ mVectorAnimationThread.AddTask( this );
+}
+
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;
mPlayState = PlayState::PLAYING;
- mVectorAnimationThread.AddTask( this );
-
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::PlayAnimation: Play [%p]\n", this );
}
}
void VectorAnimationTask::StopAnimation()
{
- ConditionalWait::ScopedLock lock( mConditionalWait );
- if( mPlayState != PlayState::STOPPED && mPlayState != PlayState::STOPPING )
+ if( mPlayState != PlayState::STOPPING )
{
mNeedAnimationFinishedTrigger = false;
mPlayState = PlayState::STOPPING;
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 );
-
- DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::RenderFrame: Render [%p]\n", this );
- }
-}
-
void VectorAnimationTask::SetAnimationFinishedCallback( EventThreadCallback* callback )
{
ConditionalWait::ScopedLock lock( mConditionalWait );
{
if( mLoopCount != count )
{
- ConditionalWait::ScopedLock lock( mConditionalWait );
-
mLoopCount = count;
mCurrentLoop = 0;
- mCurrentLoopUpdated = true;
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetLoopCount: [%d] [%p]\n", count, this );
}
}
-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();
if( mStartFrame > mCurrentFrame )
{
mCurrentFrame = mStartFrame;
-
- mCurrentFrameUpdated = true;
mResourceReady = false;
}
else if( mEndFrame < mCurrentFrame )
{
mCurrentFrame = mEndFrame;
-
- mCurrentFrameUpdated = true;
mResourceReady = false;
}
endFrame = mEndFrame;
}
-DevelImageVisual::PlayState::Type VectorAnimationTask::GetPlayState() const
-{
- DevelImageVisual::PlayState::Type state = DevelImageVisual::PlayState::STOPPED;
-
- switch( mPlayState )
- {
- case PlayState::PLAYING:
- {
- state = DevelImageVisual::PlayState::PLAYING;
- break;
- }
- case PlayState::PAUSED:
- {
- state = DevelImageVisual::PlayState::PAUSED;
- break;
- }
- case PlayState::STOPPING:
- case PlayState::STOPPED:
- {
- state = DevelImageVisual::PlayState::STOPPED;
- break;
- }
- }
-
- return state;
-}
-
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 );
if( frameNumber >= mStartFrame && frameNumber <= mEndFrame )
{
mCurrentFrame = frameNumber;
- mCurrentFrameUpdated = true;
-
mUpdateFrameNumber = false;
mResourceReady = false;
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, resourceReady;
- uint32_t currentFrame, startFrame, endFrame;
- int32_t loopCount, currentLoopCount;
- PlayState playState;
+ bool stopped = false;
+ uint32_t currentFrame;
+
+ ApplyAnimationData();
+ if( mPlayState == PlayState::PLAYING && mUpdateFrameNumber )
{
- ConditionalWait::ScopedLock lock( mConditionalWait );
+ mCurrentFrame = mForward ? mCurrentFrame + 1 : mCurrentFrame - 1;
+ Dali::ClampInPlace( mCurrentFrame, mStartFrame, mEndFrame );
+ }
- if( mPlayState == PlayState::PLAYING && mUpdateFrameNumber )
- {
- mCurrentFrame = mForward ? mCurrentFrame + 1 : mCurrentFrame - 1;
- Dali::ClampInPlace( mCurrentFrame, mStartFrame, mEndFrame );
- }
+ currentFrame = mCurrentFrame;
- currentFrame = mCurrentFrame;
- startFrame = mStartFrame;
- endFrame = mEndFrame;
- loopCount = mLoopCount;
- currentLoopCount = mCurrentLoop;
- needAnimationFinishedTrigger = mNeedAnimationFinishedTrigger;
- playState = mPlayState;
- resourceReady = mResourceReady;
-
- mResourceReady = true;
- mCurrentFrameUpdated = false;
- mCurrentLoopUpdated = false;
- mUpdateFrameNumber = true;
- mNeedAnimationFinishedTrigger = true;
- }
+ // Reset values
+ mResourceReady = true;
+ mUpdateFrameNumber = true;
+ mNeedAnimationFinishedTrigger = true;
- if( playState == PlayState::STOPPING )
+ if( mPlayState == PlayState::STOPPING )
{
- currentFrame = GetStoppedFrame( startFrame, endFrame, currentFrame );
- ResetValue( mCurrentFrameUpdated, mCurrentFrame, currentFrame, mConditionalWait );
-
+ mCurrentFrame = GetStoppedFrame( mStartFrame, mEndFrame, mCurrentFrame );
+ currentFrame = mCurrentFrame;
stopped = true;
}
- else if( playState == PlayState::PLAYING )
+ else if( mPlayState == PlayState::PLAYING )
{
bool animationFinished = false;
- if( currentFrame >= endFrame ) // last frame
+ if( currentFrame >= mEndFrame ) // last frame
{
if( mLoopingMode == DevelImageVisual::LoopingMode::AUTO_REVERSE )
{
}
else
{
- if( loopCount < 0 || ++currentLoopCount < loopCount ) // repeat forever or before the last loop
+ if( mLoopCount < 0 || ++mCurrentLoop < mLoopCount ) // repeat forever or before the last loop
{
- ResetValue( mCurrentFrameUpdated, mCurrentFrame, startFrame, mConditionalWait ); // If the current frame is changed in the event thread, don't overwrite it.
+ mCurrentFrame = mStartFrame;
mUpdateFrameNumber = false;
}
else
{
animationFinished = true; // end of animation
}
- ResetValue( mCurrentLoopUpdated, mCurrentLoop, currentLoopCount, mConditionalWait );
}
}
- else if( currentFrame == startFrame && !mForward ) // first frame
+ else if( currentFrame == mStartFrame && !mForward ) // first frame
{
- if( loopCount < 0 || ++currentLoopCount < loopCount ) // repeat forever or before the last loop
+ if( mLoopCount < 0 || ++mCurrentLoop < mLoopCount ) // repeat forever or before the last loop
{
mForward = true;
}
{
animationFinished = true; // end of animation
}
- ResetValue( mCurrentLoopUpdated, mCurrentLoop, currentLoopCount, mConditionalWait );
}
if( animationFinished )
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::Rasterize: Rendering failed. Try again later.[%d] [%p]\n", currentFrame, this );
mUpdateFrameNumber = false;
- if( !resourceReady )
+ if( !mResourceReady )
{
- ConditionalWait::ScopedLock lock( mConditionalWait );
mResourceReady = false;
}
}
if( stopped && renderSuccess )
{
- ConditionalWait::ScopedLock lock( mConditionalWait );
-
mPlayState = PlayState::STOPPED;
mForward = true;
mCurrentLoop = 0;
// Animation is finished
- if( needAnimationFinishedTrigger && mAnimationFinishedTrigger )
{
- mAnimationFinishedTrigger->Trigger();
+ ConditionalWait::ScopedLock lock( mConditionalWait );
+ if( mNeedAnimationFinishedTrigger && mAnimationFinishedTrigger )
+ {
+ mAnimationFinishedTrigger->Trigger();
+ }
}
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::Rasterize: Animation is finished [current = %d] [%p]\n", currentFrame, this );
}
bool keepAnimation = true;
- if( playState == PlayState::PAUSED || playState == PlayState::STOPPED )
+ if( mPlayState == PlayState::PAUSED || mPlayState == PlayState::STOPPED )
{
keepAnimation = false;
}
return mNextFrameStartTime;
}
+void VectorAnimationTask::ApplyAnimationData()
+{
+ uint32_t index;
+
+ {
+ ConditionalWait::ScopedLock lock( mConditionalWait );
+
+ if( !mAnimationDataUpdated || mAnimationData[mAnimationDataIndex].resendFlag != 0 )
+ {
+ // Data is not updated or the previous data is not applied yet.
+ return;
+ }
+
+ mAnimationDataIndex = mAnimationDataIndex == 0 ? 1 : 0; // Swap index
+ mAnimationDataUpdated = false;
+
+ index = mAnimationDataIndex;
+ }
+
+ if( mAnimationData[index].resendFlag & VectorAnimationTask::RESEND_LOOP_COUNT )
+ {
+ SetLoopCount( mAnimationData[index].loopCount );
+ }
+
+ if( mAnimationData[index].resendFlag & VectorAnimationTask::RESEND_PLAY_RANGE )
+ {
+ SetPlayRange( mAnimationData[index].playRange );
+ }
+
+ if( mAnimationData[index].resendFlag & VectorAnimationTask::RESEND_STOP_BEHAVIOR )
+ {
+ SetStopBehavior( mAnimationData[index].stopBehavior );
+ }
+
+ if( mAnimationData[index].resendFlag & VectorAnimationTask::RESEND_LOOPING_MODE )
+ {
+ SetLoopingMode( mAnimationData[index].loopingMode );
+ }
+
+ if( mAnimationData[index].resendFlag & VectorAnimationTask::RESEND_CURRENT_FRAME )
+ {
+ SetCurrentFrameNumber( mAnimationData[index].currentFrame );
+ }
+
+ if( mAnimationData[index].resendFlag & VectorAnimationTask::RESEND_PLAY_STATE )
+ {
+ if( mAnimationData[index].playState == DevelImageVisual::PlayState::PLAYING )
+ {
+ PlayAnimation();
+ }
+ else if( mAnimationData[index].playState == DevelImageVisual::PlayState::PAUSED )
+ {
+ PauseAnimation();
+ }
+ else if( mAnimationData[index].playState == DevelImageVisual::PlayState::STOPPED )
+ {
+ StopAnimation();
+ }
+ }
+
+ mAnimationData[index].resendFlag = 0;
+}
+
} // namespace Internal
} // namespace Toolkit
#define DALI_TOOLKIT_VECTOR_ANIMATION_TASK_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// 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 )
+ {
+ }
+
+ AnimationData& operator= ( const AnimationData& rhs )
+ {
+ resendFlag |= rhs.resendFlag; // OR resend flag
+ playRange = rhs.playRange;
+ playState = rhs.playState;
+ stopBehavior = rhs.stopBehavior;
+ loopingMode = rhs.loopingMode;
+ currentFrame = rhs.currentFrame;
+ width = rhs.width;
+ height = rhs.height;
+ loopCount = rhs.loopCount;
+ return *this;
+ }
+
+ 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.
- */
- void PauseAnimation();
-
- /**
- * @brief Render one frame. The current frame number will be increased.
+ * @brief Sets data to specify animation playback.
+ * @param[in] data The animation data
*/
- 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.
void GetPlayRange( uint32_t& startFrame, uint32_t& endFrame );
/**
- * @brief Get the play state
- * @return The play state
- */
- 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 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 );
+ /**
+ * @brief Applies the animation data set by the main thread.
+ */
+ void ApplyAnimationData();
+
// Undefined
VectorAnimationTask( const VectorAnimationTask& task ) = delete;
std::string mUrl;
VectorAnimationRenderer mVectorRenderer;
+ AnimationData mAnimationData[2];
VectorAnimationThread& mVectorAnimationThread;
ConditionalWait mConditionalWait;
std::unique_ptr< EventThreadCallback > mAnimationFinishedTrigger;
- Vector2 mPlayRange;
PlayState mPlayState;
DevelImageVisual::StopBehavior::Type mStopBehavior;
DevelImageVisual::LoopingMode::Type mLoopingMode;
uint32_t mEndFrame;
uint32_t mWidth;
uint32_t mHeight;
+ uint32_t mAnimationDataIndex;
int32_t mLoopCount;
int32_t mCurrentLoop;
bool mResourceReady;
- bool mCurrentFrameUpdated;
- bool mCurrentLoopUpdated;
bool mForward;
bool mUpdateFrameNumber;
bool mNeedAnimationFinishedTrigger;
+ bool mAnimationDataUpdated;
};