[dali_1.9.15] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / animated-vector-image / animated-vector-image-visual.cpp
1 /*
2  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.h>
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/common/stage.h>
23 #include <dali/devel-api/rendering/renderer-devel.h>
24 #include <dali/devel-api/adaptor-framework/window-devel.h>
25 #include <dali/integration-api/debug.h>
26
27 // INTERNAL INCLUDES
28 #include <dali-toolkit/public-api/visuals/image-visual-properties.h>
29 #include <dali-toolkit/public-api/visuals/visual-properties.h>
30 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
31 #include <dali-toolkit/devel-api/visuals/animated-vector-image-visual-signals-devel.h>
32 #include <dali-toolkit/internal/visuals/image-visual-shader-factory.h>
33 #include <dali-toolkit/internal/visuals/visual-factory-cache.h>
34 #include <dali-toolkit/internal/visuals/visual-string-constants.h>
35 #include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
36
37 namespace Dali
38 {
39
40 namespace Toolkit
41 {
42
43 namespace Internal
44 {
45
46 namespace
47 {
48
49 constexpr auto LOOP_FOREVER = -1;
50
51 const Dali::Vector4 FULL_TEXTURE_RECT( 0.f, 0.f, 1.f, 1.f );
52
53 // Flags for re-sending data to the rasterize thread
54 enum Flags
55 {
56   RESEND_PLAY_RANGE    = 1 << 0,
57   RESEND_LOOP_COUNT    = 1 << 1,
58   RESEND_STOP_BEHAVIOR = 1 << 2,
59   RESEND_LOOPING_MODE  = 1 << 3
60 };
61
62 // stop behavior
63 DALI_ENUM_TO_STRING_TABLE_BEGIN( STOP_BEHAVIOR )
64 DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::Toolkit::DevelImageVisual::StopBehavior, CURRENT_FRAME )
65 DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::Toolkit::DevelImageVisual::StopBehavior, FIRST_FRAME )
66 DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::Toolkit::DevelImageVisual::StopBehavior, LAST_FRAME )
67 DALI_ENUM_TO_STRING_TABLE_END( STOP_BEHAVIOR )
68
69 // looping mode
70 DALI_ENUM_TO_STRING_TABLE_BEGIN( LOOPING_MODE )
71 DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::Toolkit::DevelImageVisual::LoopingMode, RESTART )
72 DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::Toolkit::DevelImageVisual::LoopingMode, AUTO_REVERSE )
73 DALI_ENUM_TO_STRING_TABLE_END( LOOPING_MODE )
74
75 #if defined(DEBUG_ENABLED)
76 Debug::Filter* gVectorAnimationLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_VECTOR_ANIMATION" );
77 #endif
78
79 } // unnamed namespace
80
81 AnimatedVectorImageVisualPtr AnimatedVectorImageVisual::New( VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl, const Property::Map& properties )
82 {
83   AnimatedVectorImageVisualPtr visual( new AnimatedVectorImageVisual( factoryCache, shaderFactory, imageUrl ) );
84   visual->SetProperties( properties );
85
86   return visual;
87 }
88
89 AnimatedVectorImageVisualPtr AnimatedVectorImageVisual::New( VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl )
90 {
91   AnimatedVectorImageVisualPtr visual( new AnimatedVectorImageVisual( factoryCache, shaderFactory, imageUrl ) );
92
93   return visual;
94 }
95
96 AnimatedVectorImageVisual::AnimatedVectorImageVisual( VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl )
97 : Visual::Base( factoryCache, Visual::FittingMode::FILL ),
98   mUrl( imageUrl ),
99   mVectorAnimationTask( new VectorAnimationTask( factoryCache, imageUrl.GetUrl() ) ),
100   mImageVisualShaderFactory( shaderFactory ),
101   mVisualSize(),
102   mVisualScale( Vector2::ONE ),
103   mPlayRange(),
104   mPlacementActor(),
105   mLoopCount( LOOP_FOREVER ),
106   mResendFlag( 0 ),
107   mActionStatus( DevelAnimatedVectorImageVisual::Action::STOP ),
108   mStopBehavior( DevelImageVisual::StopBehavior::CURRENT_FRAME ),
109   mLoopingMode( DevelImageVisual::LoopingMode::RESTART ),
110   mRendererAdded( false )
111 {
112   // the rasterized image is with pre-multiplied alpha format
113   mImpl->mFlags |= Impl::IS_PREMULTIPLIED_ALPHA;
114
115   mVectorAnimationTask->UploadCompletedSignal().Connect( this, &AnimatedVectorImageVisual::OnUploadCompleted );
116   mVectorAnimationTask->SetAnimationFinishedCallback( new EventThreadCallback( MakeCallback( this, &AnimatedVectorImageVisual::OnAnimationFinished ) ) );
117 }
118
119 AnimatedVectorImageVisual::~AnimatedVectorImageVisual()
120 {
121   // Finalize animation task and disconnect the signal in the main thread
122   mVectorAnimationTask->UploadCompletedSignal().Disconnect( this, &AnimatedVectorImageVisual::OnUploadCompleted );
123   mVectorAnimationTask->Finalize();
124 }
125
126 void AnimatedVectorImageVisual::GetNaturalSize( Vector2& naturalSize )
127 {
128   if( mVisualSize != Vector2::ZERO )
129   {
130     naturalSize = mVisualSize;
131   }
132   else
133   {
134     uint32_t width, height;
135     mVectorAnimationTask->GetDefaultSize( width, height );
136     naturalSize.x = width;
137     naturalSize.y = height;
138   }
139
140   DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::GetNaturalSize: w = %f, h = %f [%p]\n", naturalSize.width, naturalSize.height, this );
141 }
142
143 void AnimatedVectorImageVisual::DoCreatePropertyMap( Property::Map& map ) const
144 {
145   map.Clear();
146   map.Insert( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::ANIMATED_VECTOR_IMAGE );
147   if( mUrl.IsValid() )
148   {
149     map.Insert( Toolkit::ImageVisual::Property::URL, mUrl.GetUrl() );
150   }
151   map.Insert( Toolkit::DevelImageVisual::Property::LOOP_COUNT, mLoopCount );
152
153   uint32_t startFrame, endFrame;
154   mVectorAnimationTask->GetPlayRange( startFrame, endFrame );
155
156   Property::Array playRange;
157   playRange.PushBack( static_cast< int32_t >( startFrame ) );
158   playRange.PushBack( static_cast< int32_t >( endFrame ) );
159   map.Insert( Toolkit::DevelImageVisual::Property::PLAY_RANGE, playRange );
160
161   map.Insert( Toolkit::DevelImageVisual::Property::PLAY_STATE, static_cast< int32_t >( mVectorAnimationTask->GetPlayState() ) );
162   map.Insert( Toolkit::DevelImageVisual::Property::CURRENT_FRAME_NUMBER, static_cast< int32_t >( mVectorAnimationTask->GetCurrentFrameNumber() ) );
163   map.Insert( Toolkit::DevelImageVisual::Property::TOTAL_FRAME_NUMBER, static_cast< int32_t >( mVectorAnimationTask->GetTotalFrameNumber() ) );
164
165   map.Insert( Toolkit::DevelImageVisual::Property::STOP_BEHAVIOR, mStopBehavior );
166   map.Insert( Toolkit::DevelImageVisual::Property::LOOPING_MODE, mLoopingMode );
167
168   Property::Map layerInfo;
169   mVectorAnimationTask->GetLayerInfo( layerInfo );
170   map.Insert( Toolkit::DevelImageVisual::Property::CONTENT_INFO, layerInfo );
171 }
172
173 void AnimatedVectorImageVisual::DoCreateInstancePropertyMap( Property::Map& map ) const
174 {
175   // Do nothing
176 }
177
178 void AnimatedVectorImageVisual::DoSetProperties( const Property::Map& propertyMap )
179 {
180   // url already passed in from constructor
181   for( Property::Map::SizeType iter = 0; iter < propertyMap.Count(); ++iter )
182   {
183     KeyValuePair keyValue = propertyMap.GetKeyValue( iter );
184     if( keyValue.first.type == Property::Key::INDEX )
185     {
186       DoSetProperty( keyValue.first.indexKey, keyValue.second );
187     }
188     else
189     {
190        if( keyValue.first == LOOP_COUNT_NAME )
191        {
192           DoSetProperty( Toolkit::DevelImageVisual::Property::LOOP_COUNT, keyValue.second );
193        }
194        else if( keyValue.first == PLAY_RANGE_NAME )
195        {
196           DoSetProperty( Toolkit::DevelImageVisual::Property::PLAY_RANGE, keyValue.second );
197        }
198        else if( keyValue.first == STOP_BEHAVIOR_NAME )
199        {
200           DoSetProperty( Toolkit::DevelImageVisual::Property::STOP_BEHAVIOR, keyValue.second );
201        }
202        else if( keyValue.first == LOOPING_MODE_NAME )
203        {
204           DoSetProperty( Toolkit::DevelImageVisual::Property::LOOPING_MODE, keyValue.second );
205        }
206     }
207   }
208 }
209
210 void AnimatedVectorImageVisual::DoSetProperty( Property::Index index, const Property::Value& value )
211 {
212   switch(index)
213   {
214     case Toolkit::DevelImageVisual::Property::LOOP_COUNT:
215     {
216       int32_t loopCount;
217       if( value.Get( loopCount ) )
218       {
219         mLoopCount = loopCount;
220         mResendFlag |= RESEND_LOOP_COUNT;
221       }
222       break;
223     }
224     case Toolkit::DevelImageVisual::Property::PLAY_RANGE:
225     {
226       Property::Array* array = value.GetArray();
227       if( array )
228       {
229         mPlayRange = *array;
230         mResendFlag |= RESEND_PLAY_RANGE;
231       }
232       break;
233     }
234     case Toolkit::DevelImageVisual::Property::STOP_BEHAVIOR:
235     {
236       int32_t stopBehavior = mStopBehavior;
237       if( Scripting::GetEnumerationProperty( value, STOP_BEHAVIOR_TABLE, STOP_BEHAVIOR_TABLE_COUNT, stopBehavior ) )
238       {
239         mStopBehavior = DevelImageVisual::StopBehavior::Type( stopBehavior );
240         mResendFlag |= RESEND_STOP_BEHAVIOR;
241       }
242       break;
243     }
244     case Toolkit::DevelImageVisual::Property::LOOPING_MODE:
245     {
246       int32_t loopingMode = mLoopingMode;
247       if( Scripting::GetEnumerationProperty( value, LOOPING_MODE_TABLE, LOOPING_MODE_TABLE_COUNT, loopingMode ) )
248       {
249         mLoopingMode = DevelImageVisual::LoopingMode::Type( loopingMode );
250         mResendFlag |= RESEND_LOOPING_MODE;
251       }
252       break;
253     }
254   }
255 }
256
257 void AnimatedVectorImageVisual::DoSetOnStage( Actor& actor )
258 {
259   Shader shader;
260
261   if( mImpl->mCustomShader )
262   {
263     shader = Shader::New( mImpl->mCustomShader->mVertexShader.empty() ? mImageVisualShaderFactory.GetVertexShaderSource() : mImpl->mCustomShader->mVertexShader,
264                           mImpl->mCustomShader->mFragmentShader.empty() ? mImageVisualShaderFactory.GetFragmentShaderSource() : mImpl->mCustomShader->mFragmentShader,
265                           mImpl->mCustomShader->mHints );
266
267     shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
268   }
269   else
270   {
271     shader = mImageVisualShaderFactory.GetShader( mFactoryCache, false, true, false );
272   }
273
274   Geometry geometry = mFactoryCache.GetGeometry( VisualFactoryCache::QUAD_GEOMETRY );
275
276   mImpl->mRenderer = Renderer::New( geometry, shader );
277
278   TextureSet textureSet = TextureSet::New();
279   mImpl->mRenderer.SetTextures( textureSet );
280
281   // Register transform properties
282   mImpl->mTransform.RegisterUniforms( mImpl->mRenderer, Direction::LEFT_TO_RIGHT );
283
284   // Defer the rasterisation task until we get given a size (by Size Negotiation algorithm)
285
286   // Hold the weak handle of the placement actor and delay the adding of renderer until the rasterization is finished.
287   mPlacementActor = actor;
288
289   mVectorAnimationTask->SetRenderer( mImpl->mRenderer );
290
291   // Add property notification for scaling & size
292   mScaleNotification = actor.AddPropertyNotification( Actor::Property::WORLD_SCALE, StepCondition( 0.1f, 1.0f ) );
293   mScaleNotification.NotifySignal().Connect( this, &AnimatedVectorImageVisual::OnScaleNotification );
294
295   mSizeNotification = actor.AddPropertyNotification( Actor::Property::SIZE, StepCondition( 3.0f ) );
296   mSizeNotification.NotifySignal().Connect( this, &AnimatedVectorImageVisual::OnSizeNotification );
297
298   DevelActor::VisibilityChangedSignal( actor ).Connect( this, &AnimatedVectorImageVisual::OnControlVisibilityChanged );
299
300   Window window = DevelWindow::Get( actor );
301   if( window )
302   {
303     DevelWindow::VisibilityChangedSignal( window ).Connect( this, &AnimatedVectorImageVisual::OnWindowVisibilityChanged );
304   }
305
306   DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::DoSetOnStage [%p]\n", this );
307 }
308
309 void AnimatedVectorImageVisual::DoSetOffStage( Actor& actor )
310 {
311   StopAnimation();
312
313   if( mImpl->mRenderer )
314   {
315     actor.RemoveRenderer( mImpl->mRenderer );
316     mImpl->mRenderer.Reset();
317
318     mRendererAdded = false;
319   }
320
321   // Remove property notification
322   actor.RemovePropertyNotification( mScaleNotification );
323   actor.RemovePropertyNotification( mSizeNotification );
324
325   DevelActor::VisibilityChangedSignal( actor ).Disconnect( this, &AnimatedVectorImageVisual::OnControlVisibilityChanged );
326
327   Window window = DevelWindow::Get( actor );
328   if( window )
329   {
330     DevelWindow::VisibilityChangedSignal( window ).Disconnect( this, &AnimatedVectorImageVisual::OnWindowVisibilityChanged );
331   }
332
333   mPlacementActor.Reset();
334
335   // Reset the visual size to zero so that when adding the actor back to stage the rasterization is forced
336   mVisualSize = Vector2::ZERO;
337   mVisualScale = Vector2::ONE;
338
339   DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::DoSetOffStage [%p]\n", this );
340 }
341
342 void AnimatedVectorImageVisual::OnSetTransform()
343 {
344   Vector2 visualSize = mImpl->mTransform.GetVisualSize( mImpl->mControlSize );
345
346   if( IsOnStage() && visualSize != mVisualSize )
347   {
348     DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::OnSetTransform: width = %f, height = %f [%p]\n", visualSize.width, visualSize.height, this );
349
350     mVisualSize = visualSize;
351
352     SetVectorImageSize();
353
354     SendAnimationData();
355
356     if( mActionStatus == DevelAnimatedVectorImageVisual::Action::PLAY )
357     {
358       mVectorAnimationTask->PlayAnimation();
359
360       mImpl->mRenderer.SetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::CONTINUOUSLY );
361     }
362     else
363     {
364       // Render one frame
365       mVectorAnimationTask->RenderFrame();
366     }
367   }
368 }
369
370 void AnimatedVectorImageVisual::OnDoAction( const Property::Index actionId, const Property::Value& attributes )
371 {
372   // Check if action is valid for this visual type and perform action if possible
373   switch( actionId )
374   {
375     case DevelAnimatedVectorImageVisual::Action::PLAY:
376     {
377       if( IsOnStage() && mVisualSize != Vector2::ZERO )
378       {
379         mVectorAnimationTask->PlayAnimation();
380
381         mImpl->mRenderer.SetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::CONTINUOUSLY );
382       }
383       mActionStatus = DevelAnimatedVectorImageVisual::Action::PLAY;
384       break;
385     }
386     case DevelAnimatedVectorImageVisual::Action::PAUSE:
387     {
388       mVectorAnimationTask->PauseAnimation();
389
390       if( mImpl->mRenderer )
391       {
392         mImpl->mRenderer.SetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::IF_REQUIRED );
393       }
394
395       mActionStatus = DevelAnimatedVectorImageVisual::Action::PAUSE;
396       break;
397     }
398     case DevelAnimatedVectorImageVisual::Action::STOP:
399     {
400       if( mVectorAnimationTask->GetPlayState() != DevelImageVisual::PlayState::STOPPED )
401       {
402         mVectorAnimationTask->StopAnimation();
403       }
404
405       if( mImpl->mRenderer )
406       {
407         mImpl->mRenderer.SetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::IF_REQUIRED );
408       }
409
410       mActionStatus = DevelAnimatedVectorImageVisual::Action::STOP;
411       break;
412     }
413     case DevelAnimatedVectorImageVisual::Action::JUMP_TO:
414     {
415       int32_t frameNumber;
416       if( attributes.Get( frameNumber ) )
417       {
418         mVectorAnimationTask->SetCurrentFrameNumber( frameNumber );
419
420         if( IsOnStage() && mVectorAnimationTask->GetPlayState() != DevelImageVisual::PlayState::PLAYING )
421         {
422           mVectorAnimationTask->RenderFrame();
423           Stage::GetCurrent().KeepRendering( 0.0f );    // Trigger rendering
424         }
425       }
426       break;
427     }
428     case DevelAnimatedVectorImageVisual::Action::UPDATE_PROPERTY:
429     {
430       Property::Map* map = attributes.GetMap();
431       if( map )
432       {
433         DoSetProperties( *map );
434
435         SendAnimationData();
436       }
437       break;
438     }
439   }
440 }
441
442 void AnimatedVectorImageVisual::OnUploadCompleted()
443 {
444   // If weak handle is holding a placement actor, it is the time to add the renderer to actor.
445   Actor actor = mPlacementActor.GetHandle();
446   if( actor && !mRendererAdded )
447   {
448     actor.AddRenderer( mImpl->mRenderer );
449     mRendererAdded = true;
450
451     ResourceReady( Toolkit::Visual::ResourceStatus::READY );
452
453     DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::OnUploadCompleted: Renderer is added [%p]\n", this );
454   }
455 }
456
457 void AnimatedVectorImageVisual::OnAnimationFinished()
458 {
459   DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::OnAnimationFinished: action state = %d [%p]\n", mActionStatus, this );
460
461   if( mActionStatus != DevelAnimatedVectorImageVisual::Action::STOP )
462   {
463     mActionStatus = DevelAnimatedVectorImageVisual::Action::STOP;
464
465     if( mImpl->mEventObserver )
466     {
467       mImpl->mEventObserver->NotifyVisualEvent( *this, DevelAnimatedVectorImageVisual::Signal::ANIMATION_FINISHED );
468     }
469   }
470
471   if( mImpl->mRenderer )
472   {
473     mImpl->mRenderer.SetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::IF_REQUIRED );
474   }
475 }
476
477 void AnimatedVectorImageVisual::SendAnimationData()
478 {
479   if( mResendFlag )
480   {
481     bool isPlaying = false;
482     if( mVectorAnimationTask->GetPlayState() == DevelImageVisual::PlayState::PLAYING )
483     {
484       mVectorAnimationTask->PauseAnimation();
485       isPlaying = true;
486     }
487
488     if( mResendFlag & RESEND_LOOP_COUNT )
489     {
490       mVectorAnimationTask->SetLoopCount( mLoopCount );
491     }
492
493     if( mResendFlag & RESEND_PLAY_RANGE )
494     {
495       mVectorAnimationTask->SetPlayRange( mPlayRange );
496     }
497
498     if( mResendFlag & RESEND_STOP_BEHAVIOR )
499     {
500       mVectorAnimationTask->SetStopBehavior( mStopBehavior );
501     }
502
503     if( mResendFlag & RESEND_LOOPING_MODE )
504     {
505       mVectorAnimationTask->SetLoopingMode( mLoopingMode );
506     }
507
508     if( IsOnStage() )
509     {
510       if( isPlaying )
511       {
512         mVectorAnimationTask->PlayAnimation();
513       }
514       else
515       {
516         mVectorAnimationTask->RenderFrame();
517         Stage::GetCurrent().KeepRendering( 0.0f );
518       }
519     }
520
521     mResendFlag = 0;
522   }
523 }
524
525 void AnimatedVectorImageVisual::SetVectorImageSize()
526 {
527   uint32_t width = static_cast< uint32_t >( mVisualSize.width * mVisualScale.width );
528   uint32_t height = static_cast< uint32_t >( mVisualSize.height * mVisualScale.height );
529
530   mVectorAnimationTask->SetSize( width, height );
531
532   if( IsOnStage() && mVectorAnimationTask->GetPlayState() != DevelImageVisual::PlayState::PLAYING )
533   {
534     mVectorAnimationTask->RenderFrame();
535     Stage::GetCurrent().KeepRendering( 0.0f );    // Trigger rendering
536   }
537 }
538
539 void AnimatedVectorImageVisual::StopAnimation()
540 {
541   if( mActionStatus != DevelAnimatedVectorImageVisual::Action::STOP )
542   {
543     mVectorAnimationTask->StopAnimation();
544
545     mActionStatus = DevelAnimatedVectorImageVisual::Action::STOP;
546
547     if( mImpl->mRenderer )
548     {
549       mImpl->mRenderer.SetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::IF_REQUIRED );
550     }
551   }
552 }
553
554 void AnimatedVectorImageVisual::OnScaleNotification( PropertyNotification& source )
555 {
556   Actor actor = mPlacementActor.GetHandle();
557   if( actor )
558   {
559     Vector3 scale = actor.GetProperty< Vector3 >( Actor::Property::WORLD_SCALE );
560     mVisualScale.width = scale.width;
561     mVisualScale.height = scale.height;
562
563     DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::OnScaleNotification: scale = %f, %f [%p]\n", mVisualScale.width, mVisualScale.height, this );
564
565     SetVectorImageSize();
566   }
567 }
568
569 void AnimatedVectorImageVisual::OnSizeNotification( PropertyNotification& source )
570 {
571   Actor actor = mPlacementActor.GetHandle();
572   if( actor )
573   {
574     Vector3 size = actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE );
575     mVisualSize.width = size.width;
576     mVisualSize.height = size.height;
577
578     DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::OnSizeNotification: size = %f, %f [%p]\n", mVisualSize.width, mVisualSize.height, this );
579
580     SetVectorImageSize();
581   }
582 }
583
584 void AnimatedVectorImageVisual::OnControlVisibilityChanged( Actor actor, bool visible, DevelActor::VisibilityChange::Type type )
585 {
586   if( !visible )
587   {
588     StopAnimation();
589
590     DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::OnControlVisibilityChanged: invisibile. Pause animation [%p]\n", this );
591   }
592 }
593
594 void AnimatedVectorImageVisual::OnWindowVisibilityChanged( Window window, bool visible )
595 {
596   if( !visible )
597   {
598     StopAnimation();
599
600     DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::OnWindowVisibilityChanged: invisibile. Pause animation [%p]\n", this );
601   }
602 }
603
604 } // namespace Internal
605
606 } // namespace Toolkit
607
608 } // namespace Dali