Revert "[Tizen](Vector) Ensure that all animation data is applied at once"
authorJoogab Yun <joogab.yun@samsung.com>
Fri, 27 Dec 2019 08:41:04 +0000 (17:41 +0900)
committerJoogab Yun <joogab.yun@samsung.com>
Fri, 27 Dec 2019 08:41:04 +0000 (17:41 +0900)
This reverts commit 175d74ab98dd2f89726ce6594a08d65e0d01056f.

automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor-impl.h
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-test-application.cpp
automated-tests/src/dali-toolkit/utc-Dali-AnimatedVectorImageVisual.cpp
dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.cpp
dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.h
dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.cpp
dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.h

index c3616b2..7d6e853 100644 (file)
@@ -26,7 +26,6 @@ class EglInterface;
 class DisplayConnection;
 class ThreadSynchronizationInterface;
 class Window;
-class TestApplication;
 
 namespace Integration
 {
@@ -84,11 +83,6 @@ public:
   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();
@@ -103,7 +97,6 @@ private:
   Dali::Adaptor::AdaptorSignalType mResizedSignal;
   Dali::Adaptor::AdaptorSignalType mLanguageChangedSignal;
   Dali::Adaptor::WindowCreatedSignalType mWindowCreatedSignal;
-  TestApplication* mTestApplication;
 };
 
 } // namespace Adaptor
index f84726b..5890d58 100644 (file)
@@ -196,23 +196,6 @@ void Adaptor::RemoveWindow( Internal::Adaptor::SceneHolder* window )
   }
 }
 
-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;
@@ -374,14 +357,4 @@ const LogFactoryInterface& Adaptor::GetLogFactory()
   return *gLogFactory;
 }
 
-void Adaptor::RegisterProcessor( Integration::Processor& processor )
-{
-  mImpl->RegisterProcessor( processor );
-}
-
-void Adaptor::UnregisterProcessor( Integration::Processor& processor )
-{
-  mImpl->UnregisterProcessor( processor );
-}
-
 } // namespace Dali
index e77fc88..f75123d 100644 (file)
@@ -54,7 +54,6 @@ ToolkitTestApplication::ToolkitTestApplication( size_t surfaceWidth, size_t surf
 
   // 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();
index af1fbb0..1fe89ea 100644 (file)
@@ -1353,9 +1353,6 @@ int UtcDaliAnimatedVectorImageVisualControlVisibilityChanged(void)
   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 );
@@ -1400,9 +1397,6 @@ int UtcDaliAnimatedVectorImageVisualWindowVisibilityChanged(void)
   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 );
index 9fd1277..2ed0502 100644 (file)
@@ -22,7 +22,6 @@
 #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
@@ -47,8 +46,19 @@ namespace Internal
 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 )
@@ -86,15 +96,18 @@ AnimatedVectorImageVisualPtr AnimatedVectorImageVisual::New( VisualFactoryCache&
 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 ),
-  mRendererAdded( false ),
-  mRasterizationTriggered( false )
+  mStopBehavior( DevelImageVisual::StopBehavior::CURRENT_FRAME ),
+  mLoopingMode( DevelImageVisual::LoopingMode::RESTART ),
+  mRendererAdded( false )
 {
   // the rasterized image is with pre-multiplied alpha format
   mImpl->mFlags |= Impl::IS_PREMULTIPLIED_ALPHA;
@@ -105,13 +118,7 @@ AnimatedVectorImageVisual::AnimatedVectorImageVisual( VisualFactoryCache& factor
 
 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 );
+  // Finalize animation task in the main thread
   mVectorAnimationTask->Finalize();
 }
 
@@ -140,7 +147,7 @@ void AnimatedVectorImageVisual::DoCreatePropertyMap( Property::Map& map ) const
   {
     map.Insert( Toolkit::ImageVisual::Property::URL, mUrl.GetUrl() );
   }
-  map.Insert( Toolkit::DevelImageVisual::Property::LOOP_COUNT, mAnimationData.loopCount );
+  map.Insert( Toolkit::DevelImageVisual::Property::LOOP_COUNT, mLoopCount );
 
   uint32_t startFrame, endFrame;
   mVectorAnimationTask->GetPlayRange( startFrame, endFrame );
@@ -154,8 +161,8 @@ void AnimatedVectorImageVisual::DoCreatePropertyMap( Property::Map& map ) const
   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, mAnimationData.stopBehavior );
-  map.Insert( Toolkit::DevelImageVisual::Property::LOOPING_MODE, mAnimationData.loopingMode );
+  map.Insert( Toolkit::DevelImageVisual::Property::STOP_BEHAVIOR, mStopBehavior );
+  map.Insert( Toolkit::DevelImageVisual::Property::LOOPING_MODE, mLoopingMode );
 
   Property::Map layerInfo;
   mVectorAnimationTask->GetLayerInfo( layerInfo );
@@ -197,8 +204,6 @@ void AnimatedVectorImageVisual::DoSetProperties( const Property::Map& propertyMa
        }
     }
   }
-
-  TriggerVectorRasterization();
 }
 
 void AnimatedVectorImageVisual::DoSetProperty( Property::Index index, const Property::Value& value )
@@ -210,8 +215,8 @@ void AnimatedVectorImageVisual::DoSetProperty( Property::Index index, const Prop
       int32_t loopCount;
       if( value.Get( loopCount ) )
       {
-        mAnimationData.loopCount = loopCount;
-        mAnimationData.resendFlag |= VectorAnimationTask::RESEND_LOOP_COUNT;
+        mLoopCount = loopCount;
+        mResendFlag |= RESEND_LOOP_COUNT;
       }
       break;
     }
@@ -220,28 +225,28 @@ void AnimatedVectorImageVisual::DoSetProperty( Property::Index index, const Prop
       Property::Array* array = value.GetArray();
       if( array )
       {
-        mAnimationData.playRange = *array;
-        mAnimationData.resendFlag |= VectorAnimationTask::RESEND_PLAY_RANGE;
+        mPlayRange = *array;
+        mResendFlag |= RESEND_PLAY_RANGE;
       }
       break;
     }
     case Toolkit::DevelImageVisual::Property::STOP_BEHAVIOR:
     {
-      int32_t stopBehavior = mAnimationData.stopBehavior;
+      int32_t stopBehavior = mStopBehavior;
       if( Scripting::GetEnumerationProperty( value, STOP_BEHAVIOR_TABLE, STOP_BEHAVIOR_TABLE_COUNT, stopBehavior ) )
       {
-        mAnimationData.stopBehavior = DevelImageVisual::StopBehavior::Type( stopBehavior );
-        mAnimationData.resendFlag |= VectorAnimationTask::RESEND_STOP_BEHAVIOR;
+        mStopBehavior = DevelImageVisual::StopBehavior::Type( stopBehavior );
+        mResendFlag |= RESEND_STOP_BEHAVIOR;
       }
       break;
     }
     case Toolkit::DevelImageVisual::Property::LOOPING_MODE:
     {
-      int32_t loopingMode = mAnimationData.loopingMode;
+      int32_t loopingMode = mLoopingMode;
       if( Scripting::GetEnumerationProperty( value, LOOPING_MODE_TABLE, LOOPING_MODE_TABLE_COUNT, loopingMode ) )
       {
-        mAnimationData.loopingMode = DevelImageVisual::LoopingMode::Type( loopingMode );
-        mAnimationData.resendFlag |= VectorAnimationTask::RESEND_LOOPING_MODE;
+        mLoopingMode = DevelImageVisual::LoopingMode::Type( loopingMode );
+        mResendFlag |= RESEND_LOOPING_MODE;
       }
       break;
     }
@@ -303,7 +308,6 @@ void AnimatedVectorImageVisual::DoSetOnStage( Actor& actor )
 void AnimatedVectorImageVisual::DoSetOffStage( Actor& actor )
 {
   StopAnimation();
-  SendAnimationData();
 
   if( mImpl->mRenderer )
   {
@@ -346,13 +350,19 @@ void AnimatedVectorImageVisual::OnSetTransform()
 
     SetVectorImageSize();
 
-    if( mActionStatus == DevelAnimatedVectorImageVisual::Action::PLAY && mAnimationData.playState != DevelImageVisual::PlayState::PLAYING )
+    SendAnimationData();
+
+    if( mActionStatus == DevelAnimatedVectorImageVisual::Action::PLAY )
     {
-      mAnimationData.playState = DevelImageVisual::PlayState::PLAYING;
-      mAnimationData.resendFlag |= VectorAnimationTask::RESEND_PLAY_STATE;
-    }
+      mVectorAnimationTask->PlayAnimation();
 
-    SendAnimationData();
+      mImpl->mRenderer.SetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::CONTINUOUSLY );
+    }
+    else
+    {
+      // Render one frame
+      mVectorAnimationTask->RenderFrame();
+    }
   }
 }
 
@@ -365,32 +375,37 @@ void AnimatedVectorImageVisual::OnDoAction( const Property::Index actionId, cons
     {
       if( IsOnStage() && mVisualSize != Vector2::ZERO )
       {
-        if( mAnimationData.playState != DevelImageVisual::PlayState::PLAYING )
-        {
-          mAnimationData.playState = DevelImageVisual::PlayState::PLAYING;
-          mAnimationData.resendFlag |= VectorAnimationTask::RESEND_PLAY_STATE;
-        }
+        mVectorAnimationTask->PlayAnimation();
+
+        mImpl->mRenderer.SetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::CONTINUOUSLY );
       }
       mActionStatus = DevelAnimatedVectorImageVisual::Action::PLAY;
       break;
     }
     case DevelAnimatedVectorImageVisual::Action::PAUSE:
     {
-      if( mAnimationData.playState == DevelImageVisual::PlayState::PLAYING )
+      mVectorAnimationTask->PauseAnimation();
+
+      if( mImpl->mRenderer )
       {
-        mAnimationData.playState = DevelImageVisual::PlayState::PAUSED;
-        mAnimationData.resendFlag |= VectorAnimationTask::RESEND_PLAY_STATE;
+        mImpl->mRenderer.SetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::IF_REQUIRED );
       }
+
       mActionStatus = DevelAnimatedVectorImageVisual::Action::PAUSE;
       break;
     }
     case DevelAnimatedVectorImageVisual::Action::STOP:
     {
-      if( mAnimationData.playState != DevelImageVisual::PlayState::STOPPED )
+      if( mVectorAnimationTask->GetPlayState() != DevelImageVisual::PlayState::STOPPED )
       {
-        mAnimationData.playState = DevelImageVisual::PlayState::STOPPED;
-        mAnimationData.resendFlag |= VectorAnimationTask::RESEND_PLAY_STATE;
+        mVectorAnimationTask->StopAnimation();
       }
+
+      if( mImpl->mRenderer )
+      {
+        mImpl->mRenderer.SetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::IF_REQUIRED );
+      }
+
       mActionStatus = DevelAnimatedVectorImageVisual::Action::STOP;
       break;
     }
@@ -399,8 +414,13 @@ void AnimatedVectorImageVisual::OnDoAction( const Property::Index actionId, cons
       int32_t frameNumber;
       if( attributes.Get( frameNumber ) )
       {
-        mAnimationData.currentFrame = frameNumber;
-        mAnimationData.resendFlag |= VectorAnimationTask::RESEND_CURRENT_FRAME;
+        mVectorAnimationTask->SetCurrentFrameNumber( frameNumber );
+
+        if( IsOnStage() && mVectorAnimationTask->GetPlayState() != DevelImageVisual::PlayState::PLAYING )
+        {
+          mVectorAnimationTask->RenderFrame();
+          Stage::GetCurrent().KeepRendering( 0.0f );    // Trigger rendering
+        }
       }
       break;
     }
@@ -410,21 +430,12 @@ void AnimatedVectorImageVisual::OnDoAction( const Property::Index actionId, cons
       if( map )
       {
         DoSetProperties( *map );
+
+        SendAnimationData();
       }
       break;
     }
   }
-
-  TriggerVectorRasterization();
-}
-
-void AnimatedVectorImageVisual::Process()
-{
-  SendAnimationData();
-
-  mRasterizationTriggered = false;
-
-  Adaptor::Get().UnregisterProcessor( *this );
 }
 
 void AnimatedVectorImageVisual::OnUploadCompleted()
@@ -450,8 +461,6 @@ void AnimatedVectorImageVisual::OnAnimationFinished()
   {
     mActionStatus = DevelAnimatedVectorImageVisual::Action::STOP;
 
-    mAnimationData.playState = DevelImageVisual::PlayState::STOPPED;
-
     if( mImpl->mEventObserver )
     {
       mImpl->mEventObserver->NotifyVisualEvent( *this, DevelAnimatedVectorImageVisual::Signal::ANIMATION_FINISHED );
@@ -466,20 +475,49 @@ void AnimatedVectorImageVisual::OnAnimationFinished()
 
 void AnimatedVectorImageVisual::SendAnimationData()
 {
-  if( mAnimationData.resendFlag )
+  if( mResendFlag )
   {
-    mVectorAnimationTask->SetAnimationData( mAnimationData );
+    bool isPlaying = false;
+    if( mVectorAnimationTask->GetPlayState() == DevelImageVisual::PlayState::PLAYING )
+    {
+      mVectorAnimationTask->PauseAnimation();
+      isPlaying = true;
+    }
 
-    if( mAnimationData.playState == DevelImageVisual::PlayState::PLAYING )
+    if( mResendFlag & RESEND_LOOP_COUNT )
     {
-      mImpl->mRenderer.SetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::CONTINUOUSLY );
+      mVectorAnimationTask->SetLoopCount( mLoopCount );
     }
-    else
+
+    if( mResendFlag & RESEND_PLAY_RANGE )
     {
-      mImpl->mRenderer.SetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::IF_REQUIRED );
+      mVectorAnimationTask->SetPlayRange( mPlayRange );
+    }
+
+    if( mResendFlag & RESEND_STOP_BEHAVIOR )
+    {
+      mVectorAnimationTask->SetStopBehavior( mStopBehavior );
     }
 
-    mAnimationData.resendFlag = 0;
+    if( mResendFlag & RESEND_LOOPING_MODE )
+    {
+      mVectorAnimationTask->SetLoopingMode( mLoopingMode );
+    }
+
+    if( IsOnStage() )
+    {
+      if( isPlaying )
+      {
+        mVectorAnimationTask->PlayAnimation();
+      }
+      else
+      {
+        mVectorAnimationTask->RenderFrame();
+        Stage::GetCurrent().KeepRendering( 0.0f );
+      }
+    }
+
+    mResendFlag = 0;
   }
 }
 
@@ -488,30 +526,27 @@ void AnimatedVectorImageVisual::SetVectorImageSize()
   uint32_t width = static_cast< uint32_t >( mVisualSize.width * mVisualScale.width );
   uint32_t height = static_cast< uint32_t >( mVisualSize.height * mVisualScale.height );
 
-  mAnimationData.width = width;
-  mAnimationData.height = height;
-  mAnimationData.resendFlag |= VectorAnimationTask::RESEND_SIZE;
-}
+  mVectorAnimationTask->SetSize( width, height );
 
-void AnimatedVectorImageVisual::StopAnimation()
-{
-  if( mAnimationData.playState != DevelImageVisual::PlayState::STOPPED )
+  if( IsOnStage() && mVectorAnimationTask->GetPlayState() != DevelImageVisual::PlayState::PLAYING )
   {
-    mAnimationData.playState = DevelImageVisual::PlayState::STOPPED;
-    mAnimationData.resendFlag |= VectorAnimationTask::RESEND_PLAY_STATE;
-
-    mActionStatus = DevelAnimatedVectorImageVisual::Action::STOP;
+    mVectorAnimationTask->RenderFrame();
+    Stage::GetCurrent().KeepRendering( 0.0f );    // Trigger rendering
   }
 }
 
-void AnimatedVectorImageVisual::TriggerVectorRasterization()
+void AnimatedVectorImageVisual::StopAnimation()
 {
-  if( !mRasterizationTriggered )
+  if( mActionStatus != DevelAnimatedVectorImageVisual::Action::STOP )
   {
-    Stage::GetCurrent().KeepRendering( 0.0f );  // Trigger event processing
+    mVectorAnimationTask->StopAnimation();
 
-    Adaptor::Get().RegisterProcessor( *this );
-    mRasterizationTriggered = true;
+    mActionStatus = DevelAnimatedVectorImageVisual::Action::STOP;
+
+    if( mImpl->mRenderer )
+    {
+      mImpl->mRenderer.SetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::IF_REQUIRED );
+    }
   }
 }
 
@@ -527,9 +562,6 @@ void AnimatedVectorImageVisual::OnScaleNotification( PropertyNotification& sourc
     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
   }
 }
 
@@ -545,9 +577,6 @@ void AnimatedVectorImageVisual::OnSizeNotification( PropertyNotification& source
     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
   }
 }
 
@@ -556,7 +585,6 @@ void AnimatedVectorImageVisual::OnControlVisibilityChanged( Actor actor, bool vi
   if( !visible )
   {
     StopAnimation();
-    TriggerVectorRasterization();
 
     DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::OnControlVisibilityChanged: invisibile. Pause animation [%p]\n", this );
   }
@@ -567,7 +595,6 @@ void AnimatedVectorImageVisual::OnWindowVisibilityChanged( Window window, bool v
   if( !visible )
   {
     StopAnimation();
-    TriggerVectorRasterization();
 
     DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::OnWindowVisibilityChanged: invisibile. Pause animation [%p]\n", this );
   }
index 0152869..8aaed9c 100644 (file)
@@ -22,9 +22,8 @@
 #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/public-api/adaptor-framework/window.h>
 #include <dali/devel-api/actors/actor-devel.h>
-#include <dali/integration-api/processor-interface.h>
+#include <dali/public-api/adaptor-framework/window.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
@@ -56,7 +55,7 @@ using AnimatedVectorImageVisualPtr = IntrusivePtr< AnimatedVectorImageVisual >;
  * | url                      | STRING           |
  *
  */
-class AnimatedVectorImageVisual: public Visual::Base, public ConnectionTracker, public Integration::Processor
+class AnimatedVectorImageVisual: public Visual::Base, public ConnectionTracker
 {
 public:
 
@@ -139,13 +138,6 @@ protected:
    */
   void OnDoAction( const Property::Index actionId, const Property::Value& attributes ) override;
 
-protected: // Implementation of Processor
-
-  /**
-   * @copydoc Dali::Integration::Processor::Process()
-   */
-  void Process() override;
-
 private:
 
   /**
@@ -181,11 +173,6 @@ private:
   void StopAnimation();
 
   /**
-   * @brief Trigger rasterization of the vector content.
-   */
-  void TriggerVectorRasterization();
-
-  /**
    * @brief Callback when the world scale factor changes.
    */
   void OnScaleNotification( PropertyNotification& source );
@@ -213,17 +200,20 @@ private:
 
 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
index bb6fb7e..f8598ab 100644 (file)
@@ -96,8 +96,6 @@ VectorAnimationTask::~VectorAnimationTask()
 
 void VectorAnimationTask::Finalize()
 {
-  ConditionalWait::ScopedLock lock( mConditionalWait );
-
   // Release some objects in the main thread
   if( mAnimationFinishedTrigger )
   {
@@ -116,71 +114,11 @@ 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;
@@ -194,6 +132,8 @@ void VectorAnimationTask::SetSize( uint32_t width, uint32_t height )
 
 void VectorAnimationTask::PlayAnimation()
 {
+  ConditionalWait::ScopedLock lock( mConditionalWait );
+
   if( mPlayState != PlayState::PLAYING )
   {
     mUpdateFrameNumber = false;
@@ -207,6 +147,7 @@ void VectorAnimationTask::PlayAnimation()
 
 void VectorAnimationTask::StopAnimation()
 {
+  ConditionalWait::ScopedLock lock( mConditionalWait );
   if( mPlayState != PlayState::STOPPED && mPlayState != PlayState::STOPPING )
   {
     mNeedAnimationFinishedTrigger = false;
@@ -218,6 +159,7 @@ void VectorAnimationTask::StopAnimation()
 
 void VectorAnimationTask::PauseAnimation()
 {
+  ConditionalWait::ScopedLock lock( mConditionalWait );
   if( mPlayState == PlayState::PLAYING )
   {
     mPlayState = PlayState::PAUSED;
@@ -228,6 +170,8 @@ void VectorAnimationTask::PauseAnimation()
 
 void VectorAnimationTask::RenderFrame()
 {
+  ConditionalWait::ScopedLock lock( mConditionalWait );
+
   if( !mResourceReady )
   {
     mVectorAnimationThread.AddTask( this );
@@ -249,6 +193,8 @@ void VectorAnimationTask::SetLoopCount( int32_t count )
 {
   if( mLoopCount != count )
   {
+    ConditionalWait::ScopedLock lock( mConditionalWait );
+
     mLoopCount = count;
     mCurrentLoop = 0;
     mCurrentLoopUpdated = true;
@@ -257,8 +203,10 @@ void VectorAnimationTask::SetLoopCount( int32_t count )
   }
 }
 
-void VectorAnimationTask::SetPlayRange( const Property::Array& playRange )
+void VectorAnimationTask::SetPlayRange( Property::Array& playRange )
 {
+  ConditionalWait::ScopedLock lock( mConditionalWait );
+
   bool valid = false;
   uint32_t startFrame = 0, endFrame = 0;
   size_t count = playRange.Count();
@@ -384,6 +332,8 @@ 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 );
@@ -423,6 +373,7 @@ 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 );
@@ -430,6 +381,7 @@ 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 );
@@ -466,7 +418,7 @@ void VectorAnimationTask::Initialize()
 
 bool VectorAnimationTask::Rasterize()
 {
-  bool stopped = false, needAnimationFinishedTrigger, resourceReady;
+  bool stopped = false, needAnimationFinishedTrigger;
   uint32_t currentFrame, startFrame, endFrame;
   int32_t loopCount, currentLoopCount;
   PlayState playState;
@@ -487,7 +439,6 @@ bool VectorAnimationTask::Rasterize()
     currentLoopCount = mCurrentLoop;
     needAnimationFinishedTrigger = mNeedAnimationFinishedTrigger;
     playState = mPlayState;
-    resourceReady = mResourceReady;
 
     mResourceReady = true;
     mCurrentFrameUpdated = false;
@@ -562,19 +513,11 @@ bool VectorAnimationTask::Rasterize()
     {
       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;
index 6fbd293..f2e3042 100644 (file)
@@ -18,7 +18,6 @@
  */
 
 // 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>
@@ -52,49 +51,6 @@ public:
   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
@@ -120,10 +76,32 @@ public:
   void SetRenderer( Renderer renderer );
 
   /**
-   * @brief Sets data to specify animation playback.
-   * @param[in] data The animation data
+   * @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 SetAnimationData( const AnimationData& data );
+  void PauseAnimation();
+
+  /**
+   * @brief Render one frame. The current frame number will be increased.
+   */
+  void RenderFrame();
 
   /**
    * @brief This callback is called after the animation is finished.
@@ -132,6 +110,19 @@ public:
   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.
@@ -145,6 +136,12 @@ public:
   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
    */
@@ -163,6 +160,19 @@ public:
   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
    */
@@ -200,66 +210,6 @@ private:
   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 );
@@ -285,6 +235,7 @@ private:
   VectorAnimationThread&                 mVectorAnimationThread;
   ConditionalWait                        mConditionalWait;
   std::unique_ptr< EventThreadCallback > mAnimationFinishedTrigger;
+  Vector2                                mPlayRange;
   PlayState                              mPlayState;
   DevelImageVisual::StopBehavior::Type   mStopBehavior;
   DevelImageVisual::LoopingMode::Type    mLoopingMode;