[dali_1.4.35] Merge branch 'devel/master' 01/213101/1
authorGyörgy Straub <g.straub@partner.samsung.com>
Fri, 30 Aug 2019 08:01:00 +0000 (09:01 +0100)
committerGyörgy Straub <g.straub@partner.samsung.com>
Fri, 30 Aug 2019 08:01:00 +0000 (09:01 +0100)
Change-Id: Ic7b40a6f7fc67e72f791788e2bf80c35a4643b03

automated-tests/src/dali-toolkit-internal/utc-Dali-Visuals-internal.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-vector-animation-renderer.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-rasterize-thread.cpp
dali-toolkit/internal/visuals/animated-vector-image/vector-rasterize-thread.h
dali-toolkit/public-api/dali-toolkit-version.cpp
packaging/dali-toolkit.spec

index 4ead28e..87345ea 100644 (file)
@@ -346,9 +346,6 @@ int UtcDaliAnimatedVectorImageVisualSetProperties(void)
   application.SendNotification();
   application.Render();
 
-  // Wait for resource ready event callback
-  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
-
   // renderer is added to actor
   DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
   Renderer renderer = actor.GetRendererAt( 0u );
index 8e856bb..558cdec 100755 (executable)
@@ -50,6 +50,7 @@ public:
       Dali::TextureSet textureSet = mRenderer.GetTextures();
       Dali::Texture texture = Dali::Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, mWidth, mHeight );
       textureSet.SetTexture( 0, texture );
+      mUploadCompletedSignal.Emit();
     }
   }
 
@@ -63,13 +64,10 @@ public:
       Dali::TextureSet textureSet = mRenderer.GetTextures();
       Dali::Texture texture = Dali::Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, mWidth, mHeight );
       textureSet.SetTexture( 0, texture );
+      mUploadCompletedSignal.Emit();
     }
   }
 
-  void StopRender()
-  {
-  }
-
   bool Render( uint32_t frameNumber )
   {
     if( frameNumber == 1 && mPreviousFrame != frameNumber )
@@ -98,6 +96,11 @@ public:
     height = 100;
   }
 
+  Dali::VectorAnimationRenderer::UploadCompletedSignalType& UploadCompletedSignal()
+  {
+    return mUploadCompletedSignal;
+  }
+
 public:
 
   std::string mUrl;
@@ -105,6 +108,7 @@ public:
   uint32_t mWidth;
   uint32_t mHeight;
   uint32_t mPreviousFrame;
+  Dali::VectorAnimationRenderer::UploadCompletedSignalType mUploadCompletedSignal;
 };
 
 inline VectorAnimationRenderer& GetImplementation( Dali::VectorAnimationRenderer& renderer )
@@ -171,11 +175,6 @@ void VectorAnimationRenderer::SetSize( uint32_t width, uint32_t height )
   Internal::Adaptor::GetImplementation( *this ).SetSize( width, height );
 }
 
-void VectorAnimationRenderer::StopRender()
-{
-  Internal::Adaptor::GetImplementation( *this ).StopRender();
-}
-
 bool VectorAnimationRenderer::Render( uint32_t frameNumber )
 {
   return Internal::Adaptor::GetImplementation( *this ).Render( frameNumber );
@@ -196,5 +195,10 @@ void VectorAnimationRenderer::GetDefaultSize( uint32_t& width, uint32_t& height
   Internal::Adaptor::GetImplementation( *this ).GetDefaultSize( width, height );
 }
 
+VectorAnimationRenderer::UploadCompletedSignalType& VectorAnimationRenderer::UploadCompletedSignal()
+{
+  return Internal::Adaptor::GetImplementation( *this ).UploadCompletedSignal();
+}
+
 } // namespace Dali;
 
index 20ee4d7..49f665b 100644 (file)
@@ -78,9 +78,6 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual01(void)
   application.SendNotification();
   application.Render();
 
-  // Wait for resource ready event callback
-  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
-
   // renderer is added to actor
   DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
   Renderer renderer = actor.GetRendererAt( 0u );
@@ -114,9 +111,6 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual02(void)
   application.SendNotification();
   application.Render();
 
-  // Wait for resource ready event callback
-  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
-
   // renderer is added to actor
   DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
   Renderer renderer = actor.GetRendererAt( 0u );
@@ -156,9 +150,6 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual03(void)
   application.SendNotification();
   application.Render();
 
-  // Wait for resource ready event callback
-  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
-
   // renderer is added to actor
   DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
   Renderer renderer = actor.GetRendererAt( 0u );
@@ -200,9 +191,6 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual04(void)
   application.SendNotification();
   application.Render();
 
-  // Wait for resource ready event callback
-  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
-
   // renderer is added to actor
   DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
   Renderer renderer = actor.GetRendererAt( 0u );
@@ -343,8 +331,6 @@ int UtcDaliAnimatedVectorImageVisualPlayback(void)
 
     std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) );    // wait for one animation loop (16fps, 5frames, need 80ms)
 
-    DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
-
     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 );
@@ -479,8 +465,6 @@ int UtcDaliAnimatedVectorImageVisualCustomShader(void)
   application.SendNotification();
   application.Render();
 
-  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
-
   Renderer renderer = dummy.GetRendererAt( 0 );
   Shader shader2 = renderer.GetShader();
   Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
@@ -520,8 +504,6 @@ int UtcDaliAnimatedVectorImageVisualNaturalSize(void)
   application.SendNotification();
   application.Render();
 
-  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
-
   visual.GetNaturalSize( naturalSize );
 
   DALI_TEST_EQUALS( naturalSize, Vector2( 100.0f, 100.0f ), TEST_LOCATION );    // 100x100 is the content default size.
@@ -531,8 +513,6 @@ int UtcDaliAnimatedVectorImageVisualNaturalSize(void)
   application.SendNotification();
   application.Render();
 
-  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
-
   visual.GetNaturalSize( naturalSize );
 
   DALI_TEST_EQUALS( naturalSize, controlSize, TEST_LOCATION );
@@ -568,8 +548,8 @@ int UtcDaliAnimatedVectorImageVisualLoopCount(void)
   application.SendNotification();
   application.Render();
 
-  // Trigger count is 2 - resource ready and animation finished
-  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
+  // Trigger count is 1 - animation finished
+  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
 
   // renderer is added to actor
   DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
@@ -612,8 +592,6 @@ int UtcDaliAnimatedVectorImageVisualPlayRange(void)
   application.SendNotification();
   application.Render();
 
-  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
-
   // renderer is added to actor
   DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
   Renderer renderer = actor.GetRendererAt( 0u );
@@ -686,7 +664,7 @@ int UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal(void)
   application.Render();
 
   // Wait for animation finish
-  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
+  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
 
   Property::Map map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
   Property::Value* value = map.Find( DevelImageVisual::Property::PLAY_STATE );
@@ -721,8 +699,6 @@ int UtcDaliAnimatedVectorImageVisualJumpTo(void)
   application.SendNotification();
   application.Render();
 
-  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
-
   DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 2 );
 
   application.SendNotification();
@@ -777,6 +753,16 @@ int UtcDaliAnimatedVectorImageVisualJumpTo(void)
   value = map.Find( DevelImageVisual::Property::CURRENT_FRAME_NUMBER );
   DALI_TEST_EQUALS( value->Get< int >(), 3, TEST_LOCATION );
 
+  // Jump to the same position
+  DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3 );
+
+  application.SendNotification();
+  application.Render();
+
+  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 );
+
   END_TEST;
 }
 
@@ -811,8 +797,6 @@ int UtcDaliAnimatedVectorImageVisualUpdateProperty(void)
   application.SendNotification();
   application.Render();
 
-  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
-
   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 );
@@ -904,8 +888,8 @@ int UtcDaliAnimatedVectorImageVisualStopBehavior(void)
   application.SendNotification();
   application.Render();
 
-  // Trigger count is 2 - resource ready and animation finished
-  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
+  // Trigger count is 1 - animation finished
+  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
 
   Property::Map map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
   Property::Value* value = map.Find( DevelImageVisual::Property::CURRENT_FRAME_NUMBER );
@@ -999,8 +983,8 @@ int UtcDaliAnimatedVectorImageVisualLoopingMode(void)
   application.SendNotification();
   application.Render();
 
-  // Trigger count is 2 - resource ready and animation finished
-  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
+  // Trigger count is 1 - animation finished
+  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
 
   Property::Map map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
   Property::Value* value = map.Find( DevelImageVisual::Property::CURRENT_FRAME_NUMBER );
@@ -1047,3 +1031,65 @@ int UtcDaliAnimatedVectorImageVisualLoopingMode(void)
 
   END_TEST;
 }
+
+int UtcDaliAnimatedVectorImageVisualPropertyNotification(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline( "UtcDaliAnimatedVectorImageVisualPropertyNotification" );
+
+  Property::Map propertyMap;
+  propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE )
+             .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME  );
+
+  Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
+  DALI_TEST_CHECK( visual );
+
+  DummyControl actor = DummyControl::New( true );
+  DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
+  dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
+
+  Vector2 controlSize( 20.f, 30.f );
+  Vector3 controlScale( 2.0f, 2.0f, 1.0f );
+  actor.SetSize( controlSize );
+  actor.SetScale( controlScale );
+
+  Stage::GetCurrent().Add( actor );
+
+  application.SendNotification();
+  application.Render();
+
+  application.SendNotification();
+  application.Render();
+
+  Renderer renderer = actor.GetRendererAt( 0u );
+  DALI_TEST_CHECK( renderer );
+
+  auto textureSet = renderer.GetTextures();
+  auto texture = textureSet.GetTexture(0);
+
+  DALI_TEST_EQUALS( controlSize.width * controlScale.width, texture.GetWidth(), TEST_LOCATION );
+  DALI_TEST_EQUALS( controlSize.height * controlScale.height, texture.GetHeight(), TEST_LOCATION );
+
+  // Change scale and size
+  controlSize = Vector2( 50.f, 40.f );
+  controlScale= Vector3( 0.5f, 0.5f, 1.0f );
+  actor.SetSize( controlSize );
+  actor.SetScale( controlScale );
+
+  application.SendNotification();
+  application.Render();
+
+  application.SendNotification();
+  application.Render();
+
+  renderer = actor.GetRendererAt( 0u );
+  DALI_TEST_CHECK( renderer );
+
+  textureSet = renderer.GetTextures();
+  texture = textureSet.GetTexture(0);
+
+  DALI_TEST_EQUALS( controlSize.width * controlScale.width, texture.GetWidth(), TEST_LOCATION );
+  DALI_TEST_EQUALS( controlSize.height * controlScale.height, texture.GetHeight(), TEST_LOCATION );
+
+  END_TEST;
+}
index 8939729..d26787e 100644 (file)
@@ -98,6 +98,7 @@ AnimatedVectorImageVisual::AnimatedVectorImageVisual( VisualFactoryCache& factor
   mUrl( imageUrl ),
   mVectorRasterizeThread( imageUrl.GetUrl() ),
   mVisualSize(),
+  mVisualScale( Vector2::ONE ),
   mPlacementActor(),
   mLoopCount( LOOP_FOREVER ),
   mStartFrame( 0 ),
@@ -105,12 +106,13 @@ AnimatedVectorImageVisual::AnimatedVectorImageVisual( VisualFactoryCache& factor
   mResendFlag( 0 ),
   mActionStatus( DevelAnimatedVectorImageVisual::Action::STOP ),
   mStopBehavior( DevelImageVisual::StopBehavior::CURRENT_FRAME ),
-  mLoopingMode( DevelImageVisual::LoopingMode::RESTART )
+  mLoopingMode( DevelImageVisual::LoopingMode::RESTART ),
+  mRendererAdded( false )
 {
   // the rasterized image is with pre-multiplied alpha format
   mImpl->mFlags |= Impl::IS_PREMULTIPLIED_ALPHA;
 
-  mVectorRasterizeThread.SetResourceReadyCallback( new EventThreadCallback( MakeCallback( this, &AnimatedVectorImageVisual::OnResourceReady ) ) );
+  mVectorRasterizeThread.UploadCompletedSignal().Connect( this, &AnimatedVectorImageVisual::OnUploadCompleted );
   mVectorRasterizeThread.SetAnimationFinishedCallback( new EventThreadCallback( MakeCallback( this, &AnimatedVectorImageVisual::OnAnimationFinished ) ) );
 
   mVectorRasterizeThread.Start();
@@ -122,25 +124,19 @@ AnimatedVectorImageVisual::~AnimatedVectorImageVisual()
 
 void AnimatedVectorImageVisual::GetNaturalSize( Vector2& naturalSize )
 {
-  if( mImpl->mRenderer ) // Check if we have a rendered image
+  if( mVisualSize != Vector2::ZERO )
   {
-    auto textureSet = mImpl->mRenderer.GetTextures();
-    if( textureSet )
-    {
-      if( textureSet.GetTextureCount() > 0 )
-      {
-        auto texture = textureSet.GetTexture( 0 );
-        naturalSize.x = texture.GetWidth();
-        naturalSize.y = texture.GetHeight();
-        return;
-      }
-    }
+    naturalSize = mVisualSize;
+  }
+  else
+  {
+    uint32_t width, height;
+    mVectorRasterizeThread.GetDefaultSize( width, height );
+    naturalSize.x = width;
+    naturalSize.y = height;
   }
 
-  uint32_t width, height;
-  mVectorRasterizeThread.GetDefaultSize( width, height );
-  naturalSize.x = width;
-  naturalSize.y = height;
+  DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::GetNaturalSize: w = %f, h = %f [%p]\n", naturalSize.width, naturalSize.height, this );
 }
 
 void AnimatedVectorImageVisual::DoCreatePropertyMap( Property::Map& map ) const
@@ -297,6 +293,13 @@ void AnimatedVectorImageVisual::DoSetOnStage( Actor& actor )
 
   mVectorRasterizeThread.SetRenderer( mImpl->mRenderer );
 
+  // Add property notification for scaling & size
+  mScaleNotification = actor.AddPropertyNotification( Actor::Property::WORLD_SCALE, StepCondition( 0.1f, 1.0f ) );
+  mScaleNotification.NotifySignal().Connect( this, &AnimatedVectorImageVisual::OnScaleNotification );
+
+  mSizeNotification = actor.AddPropertyNotification( Actor::Property::SIZE, StepCondition( 3.0f ) );
+  mSizeNotification.NotifySignal().Connect( this, &AnimatedVectorImageVisual::OnSizeNotification );
+
   DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::DoSetOnStage [%p]\n", this );
 }
 
@@ -312,12 +315,19 @@ void AnimatedVectorImageVisual::DoSetOffStage( Actor& actor )
 
     actor.RemoveRenderer( mImpl->mRenderer );
     mImpl->mRenderer.Reset();
+
+    mRendererAdded = false;
   }
 
+  // Remove property notification
+  actor.RemovePropertyNotification( mScaleNotification );
+  actor.RemovePropertyNotification( mSizeNotification );
+
   mPlacementActor.Reset();
 
   // Reset the visual size to zero so that when adding the actor back to stage the rasterization is forced
   mVisualSize = Vector2::ZERO;
+  mVisualScale = Vector2::ONE;
 
   DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::DoSetOffStage [%p]\n", this );
 }
@@ -326,19 +336,13 @@ void AnimatedVectorImageVisual::OnSetTransform()
 {
   Vector2 visualSize = mImpl->mTransform.GetVisualSize( mImpl->mControlSize );
 
-  if( IsOnStage() )
+  if( IsOnStage() && visualSize != mVisualSize )
   {
     DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::OnSetTransform: width = %f, height = %f [%p]\n", visualSize.width, visualSize.height, this );
 
-    if( visualSize != mVisualSize )
-    {
-      mVisualSize = visualSize;
+    mVisualSize = visualSize;
 
-      uint32_t width = static_cast< uint32_t >( visualSize.width );
-      uint32_t height = static_cast< uint32_t >( visualSize.height );
-
-      mVectorRasterizeThread.SetSize( width, height );
-    }
+    SetVectorImageSize();
 
     SendAnimationData();
 
@@ -353,20 +357,6 @@ void AnimatedVectorImageVisual::OnSetTransform()
       // Render one frame
       mVectorRasterizeThread.RenderFrame();
     }
-
-    if( mVectorRasterizeThread.IsResourceReady() )
-    {
-      Actor actor = mPlacementActor.GetHandle();
-      if( actor )
-      {
-        actor.AddRenderer( mImpl->mRenderer );
-        mPlacementActor.Reset();
-
-        DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::OnSetTransform: Renderer is added [%p]\n", this );
-      }
-
-      ResourceReady( Toolkit::Visual::ResourceStatus::READY );
-    }
   }
 }
 
@@ -438,20 +428,19 @@ void AnimatedVectorImageVisual::OnDoAction( const Property::Index actionId, cons
   }
 }
 
-void AnimatedVectorImageVisual::OnResourceReady()
+void AnimatedVectorImageVisual::OnUploadCompleted()
 {
   // If weak handle is holding a placement actor, it is the time to add the renderer to actor.
   Actor actor = mPlacementActor.GetHandle();
-  if( actor )
+  if( actor && !mRendererAdded )
   {
     actor.AddRenderer( mImpl->mRenderer );
-    // reset the weak handle so that the renderer only get added to actor once
-    mPlacementActor.Reset();
+    mRendererAdded = true;
+  }
 
-    ResourceReady( Toolkit::Visual::ResourceStatus::READY );
+  ResourceReady( Toolkit::Visual::ResourceStatus::READY );
 
-    DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::OnResourceReady: Renderer is added [%p]\n", this );
-  }
+  DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::OnUploadCompleted: Renderer is added [%p]\n", this );
 }
 
 void AnimatedVectorImageVisual::OnAnimationFinished()
@@ -517,6 +506,50 @@ void AnimatedVectorImageVisual::SendAnimationData()
   }
 }
 
+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 );
+
+  mVectorRasterizeThread.SetSize( width, height );
+
+  if( IsOnStage() && mVectorRasterizeThread.GetPlayState() != DevelImageVisual::PlayState::PLAYING )
+  {
+    mVectorRasterizeThread.RenderFrame();
+    Stage::GetCurrent().KeepRendering( 0.0f );    // Trigger rendering
+  }
+}
+
+void AnimatedVectorImageVisual::OnScaleNotification( PropertyNotification& source )
+{
+  Actor actor = mPlacementActor.GetHandle();
+  if( actor )
+  {
+    Vector3 scale = actor.GetProperty< Vector3 >( Actor::Property::WORLD_SCALE );
+    mVisualScale.width = scale.width;
+    mVisualScale.height = scale.height;
+
+    DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::OnScaleNotification: scale = %f, %f [%p]\n", mVisualScale.width, mVisualScale.height, this );
+
+    SetVectorImageSize();
+  }
+}
+
+void AnimatedVectorImageVisual::OnSizeNotification( PropertyNotification& source )
+{
+  Actor actor = mPlacementActor.GetHandle();
+  if( actor )
+  {
+    Vector3 size = actor.GetCurrentSize();
+    mVisualSize.width = size.width;
+    mVisualSize.height = size.height;
+
+    DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::OnSizeNotification: size = %f, %f [%p]\n", mVisualSize.width, mVisualSize.height, this );
+
+    SetVectorImageSize();
+  }
+}
+
 } // namespace Internal
 
 } // namespace Toolkit
index 23705d8..b6837b5 100644 (file)
@@ -21,7 +21,7 @@
 // EXTERNAL INCLUDES
 #include <dali/public-api/common/intrusive-ptr.h>
 #include <dali/public-api/object/weak-handle.h>
-#include <memory>
+#include <dali/public-api/object/property-notification.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
@@ -54,7 +54,7 @@ using AnimatedVectorImageVisualPtr = IntrusivePtr< AnimatedVectorImageVisual >;
  * | url                      | STRING           |
  *
  */
-class AnimatedVectorImageVisual: public Visual::Base
+class AnimatedVectorImageVisual: public Visual::Base, public ConnectionTracker
 {
 public:
 
@@ -147,9 +147,9 @@ private:
   void DoSetProperty( Property::Index index, const Property::Value& value );
 
   /**
-   * @brief Event callback from rasterize thread. This is called after the first frame is ready.
+   * @brief Called when the texture upload is completed.
    */
-  void OnResourceReady();
+  void OnUploadCompleted();
 
   /**
    * @brief Event callback from rasterize thread. This is called after the animation is finished.
@@ -161,6 +161,21 @@ private:
    */
   void SendAnimationData();
 
+  /**
+   * @brief Set the vector image size.
+   */
+  void SetVectorImageSize();
+
+  /**
+   * @brief Callback when the world scale factor changes.
+   */
+  void OnScaleNotification( PropertyNotification& source );
+
+  /**
+   * @brief Callback when the size changes.
+   */
+  void OnSizeNotification( PropertyNotification& source );
+
   // Undefined
   AnimatedVectorImageVisual( const AnimatedVectorImageVisual& visual ) = delete;
 
@@ -171,7 +186,10 @@ private:
   ImageVisualShaderFactory&                    mImageVisualShaderFactory;
   VisualUrl                                    mUrl;
   VectorRasterizeThread                        mVectorRasterizeThread;
+  PropertyNotification                         mScaleNotification;
+  PropertyNotification                         mSizeNotification;
   Vector2                                      mVisualSize;
+  Vector2                                      mVisualScale;
   WeakHandle< Actor >                          mPlacementActor;
   int32_t                                      mLoopCount;
   int32_t                                      mStartFrame;
@@ -180,6 +198,7 @@ private:
   DevelAnimatedVectorImageVisual::Action::Type mActionStatus;
   DevelImageVisual::StopBehavior::Type         mStopBehavior;
   DevelImageVisual::LoopingMode::Type          mLoopingMode;
+  bool                                         mRendererAdded;
 };
 
 } // namespace Internal
index fead5de..c5f207c 100644 (file)
@@ -60,7 +60,6 @@ VectorRasterizeThread::VectorRasterizeThread( const std::string& url )
 : mUrl( url ),
   mVectorRenderer(),
   mConditionalWait(),
-  mResourceReadyTrigger(),
   mAnimationFinishedTrigger(),
   mPlayState( PlayState::STOPPED ),
   mStopBehavior( DevelImageVisual::StopBehavior::CURRENT_FRAME ),
@@ -93,9 +92,6 @@ VectorRasterizeThread::~VectorRasterizeThread()
     ConditionalWait::ScopedLock lock( mConditionalWait );
     mDestroyThread = true;
     mConditionalWait.Notify( lock );
-
-    // This should be called in the main thread to stop waiting for the dequeuable buffer.
-    mVectorRenderer.StopRender();
   }
 
   DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorRasterizeThread::~VectorRasterizeThread: Join [%p]\n", this );
@@ -193,12 +189,6 @@ void VectorRasterizeThread::RenderFrame()
   }
 }
 
-void VectorRasterizeThread::SetResourceReadyCallback( EventThreadCallback* callback )
-{
-  ConditionalWait::ScopedLock lock( mConditionalWait );
-  mResourceReadyTrigger = std::unique_ptr< EventThreadCallback >( callback );
-}
-
 void VectorRasterizeThread::SetAnimationFinishedCallback( EventThreadCallback* callback )
 {
   ConditionalWait::ScopedLock lock( mConditionalWait );
@@ -294,6 +284,12 @@ void VectorRasterizeThread::SetCurrentFrameNumber( uint32_t frameNumber )
 {
   ConditionalWait::ScopedLock lock( mConditionalWait );
 
+  if( mCurrentFrame == frameNumber )
+  {
+    DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorRasterizeThread::SetCurrentFrameNumber: Set same frame [%d] [%p]\n", frameNumber, this );
+    return;
+  }
+
   if( frameNumber >= mStartFrame && frameNumber <= mEndFrame )
   {
     mCurrentFrame = frameNumber;
@@ -340,6 +336,11 @@ void VectorRasterizeThread::SetLoopingMode( DevelImageVisual::LoopingMode::Type
   DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorRasterizeThread::SetLoopingMode: looping mode = %d [%p]\n", mLoopingMode, this );
 }
 
+VectorRasterizeThread::UploadCompletedSignalType& VectorRasterizeThread::UploadCompletedSignal()
+{
+  return mVectorRenderer.UploadCompletedSignal();
+}
+
 void VectorRasterizeThread::Initialize()
 {
   mVectorRenderer = VectorAnimationRenderer::New( mUrl );
@@ -361,7 +362,7 @@ void VectorRasterizeThread::Initialize()
 
 void VectorRasterizeThread::Rasterize()
 {
-  bool resourceReady, stopped = false;
+  bool stopped = false;
   uint32_t currentFrame, startFrame, endFrame;
   int32_t loopCount;
 
@@ -379,14 +380,13 @@ void VectorRasterizeThread::Rasterize()
       mCurrentFrame = mForward ? mCurrentFrame + 1 : mCurrentFrame - 1;
     }
 
-    resourceReady = mResourceReady;
     currentFrame = mCurrentFrame;
     startFrame = mStartFrame;
     endFrame = mEndFrame;
     loopCount = mLoopCount;
 
-    mNeedRender = false;
     mResourceReady = true;
+    mNeedRender = false;
     mCurrentFrameUpdated = false;
     mUpdateFrameNumber = true;
   }
@@ -455,13 +455,6 @@ void VectorRasterizeThread::Rasterize()
     mUpdateFrameNumber = false;
   }
 
-  if( !resourceReady )
-  {
-    DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorRasterizeThread::Rasterize: Resource ready trigger [%p]\n", this );
-
-    mResourceReadyTrigger->Trigger();
-  }
-
   if( stopped )
   {
     mPlayState = PlayState::STOPPED;
@@ -471,7 +464,7 @@ void VectorRasterizeThread::Rasterize()
     // Animation is finished
     mAnimationFinishedTrigger->Trigger();
 
-    DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorRasterizeThread::Rasterize: Animation is finished [%p]\n", this );
+    DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorRasterizeThread::Rasterize: Animation is finished [current = %d] [%p]\n", currentFrame, this );
   }
 
   auto timeToSleepUntil = currentFrameStartTime + std::chrono::nanoseconds( mFrameDurationNanoSeconds );
index ef262bd..0855f14 100644 (file)
@@ -46,6 +46,8 @@ class VectorRasterizeThread : public Thread
 {
 public:
 
+  using UploadCompletedSignalType = Dali::VectorAnimationRenderer::UploadCompletedSignalType;
+
   /**
    * @brief Constructor.
    *
@@ -94,12 +96,6 @@ public:
   void RenderFrame();
 
   /**
-   * @brief This callback is called after the first frame is ready.
-   * @param[in] callback The resource ready callback
-   */
-  void SetResourceReadyCallback( EventThreadCallback* callback );
-
-  /**
    * @brief This callback is called after the animation is finished.
    * @param[in] callback The animation finished callback
    */
@@ -168,6 +164,12 @@ public:
    */
   void SetLoopingMode( DevelImageVisual::LoopingMode::Type loopingMode );
 
+  /**
+   * @brief Connect to this signal to be notified when the texture upload is completed.
+   * @return The signal to connect to.
+   */
+  UploadCompletedSignalType& UploadCompletedSignal();
+
 protected:
 
   /**
@@ -212,7 +214,6 @@ private:
   std::string                 mUrl;
   VectorAnimationRenderer     mVectorRenderer;
   ConditionalWait             mConditionalWait;
-  std::unique_ptr< EventThreadCallback > mResourceReadyTrigger;
   std::unique_ptr< EventThreadCallback > mAnimationFinishedTrigger;
   Vector2                     mPlayRange;
   PlayState                   mPlayState;
index 3d2c4a8..6ccd0d5 100644 (file)
@@ -31,7 +31,7 @@ namespace Toolkit
 
 const unsigned int TOOLKIT_MAJOR_VERSION = 1;
 const unsigned int TOOLKIT_MINOR_VERSION = 4;
-const unsigned int TOOLKIT_MICRO_VERSION = 34;
+const unsigned int TOOLKIT_MICRO_VERSION = 35;
 const char * const TOOLKIT_BUILD_DATE    = __DATE__ " " __TIME__;
 
 #ifdef DEBUG_ENABLED
index 1f060d9..677d3b5 100644 (file)
@@ -1,6 +1,6 @@
 Name:       dali-toolkit
 Summary:    Dali 3D engine Toolkit
-Version:    1.4.34
+Version:    1.4.35
 Release:    1
 Group:      System/Libraries
 License:    Apache-2.0 and BSD-3-Clause and MIT