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