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