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