Append Stopped animation notify list at Update Animation time
[platform/core/uifw/dali-core.git] / dali / internal / update / animation / scene-graph-animation.h
index cebcb2e..869fe2f 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_SCENE_GRAPH_ANIMATION_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@
 #include <dali/internal/common/buffer-index.h>
 #include <dali/internal/common/message.h>
 #include <dali/internal/event/common/event-thread-services.h>
+#include <dali/internal/event/common/notifier-interface.h>
 #include <dali/internal/update/animation/scene-graph-animator.h>
 
 namespace Dali
@@ -37,7 +38,7 @@ namespace SceneGraph
  * managers "update" phase. An animation is a container of Animator objects; the actual setting
  * of object values is done by the animators.
  */
-class Animation
+class Animation : public NotifierInterface
 {
 public:
   using EndAction = Dali::Animation::EndAction;
@@ -193,6 +194,15 @@ public:
   void SetPlayRange(const Vector2& range);
 
   /**
+   * @brief Sets the blend point to interpolate animate property
+   *
+   * @param[in] blendPoint A value between [0,1], If the value of the keyframe whose progress is 0 is different from the current value,
+   * the property is animated as it smoothly blends until the progress reaches the blendPoint.
+   * @note The blendPoint only affects animation registered with AnimateBetween. Other animations operate the same as when Play() is called.
+   */
+  void SetBlendPoint(float blendPoint);
+
+  /**
    * Play the animation.
    */
   void Play();
@@ -222,6 +232,12 @@ public:
   bool Stop(BufferIndex bufferIndex);
 
   /**
+   * Clear the animator. It will stop animation, clear all animators, and make this animation never played before.
+   * @param[in] bufferIndex The buffer to update when mEndAction == Bake.
+   */
+  void ClearAnimator(BufferIndex bufferIndex);
+
+  /**
    * Called shortly before the animation is destroyed.
    * @param[in] bufferIndex The buffer to update when mEndAction == Bake.
    */
@@ -286,11 +302,13 @@ public:
    * @pre The animation is playing or paused.
    * @param[in] bufferIndex The buffer to update.
    * @param[in] elapsedSeconds The time elapsed since the previous frame.
-   * @param[out] looped True if the animation looped
+   * @param[out] stopped True if the animation stopped this loop
    * @param[out] finished True if the animation has finished.
    * @param[out] progressReached True if progress marker reached
    */
-  void Update(BufferIndex bufferIndex, float elapsedSeconds, bool& looped, bool& finished, bool& progressReached);
+  void Update(BufferIndex bufferIndex, float elapsedSeconds, bool& stopped, bool& finished, bool& progressReached);
+
+  static uint32_t GetMemoryPoolCapacity();
 
 protected:
   /**
@@ -337,6 +355,7 @@ protected:
   float mElapsedSeconds;
   float mSpeedFactor;
   float mProgressMarker; // Progress marker to trigger a notification
+  float mBlendPoint;
 
   int32_t mPlayedCount; // Incremented at end of animation or completion of all loops
                         // Never incremented when looping forever. Event thread tracks to signal end.
@@ -350,10 +369,13 @@ protected:
 
   bool mProgressReachedSignalRequired; // Flag to indicate the progress marker was hit
   bool mAutoReverseEnabled;            // Flag to identify that the looping mode is auto reverse.
+  bool mAnimatorSortRequired;          // Flag to whether we need to sort animator or not.
   bool mIsActive[2];                   // Flag to indicate whether the animation is active in the current frame (which is double buffered)
+  bool mIsFirstLoop;
+  bool mIsStopped; // Flag to whether this animation call stoped by user at this frame.
 };
 
-}; //namespace SceneGraph
+}; // namespace SceneGraph
 
 // value types used by messages
 template<>
@@ -453,6 +475,17 @@ inline void SetPlayRangeMessage(EventThreadServices& eventThreadServices, const
   new(slot) LocalType(&animation, &Animation::SetPlayRange, range);
 }
 
+inline void SetBlendPointMessage(EventThreadServices& eventThreadServices, const Animation& animation, float blendPoint)
+{
+  using LocalType = MessageValue1<Animation, float>;
+
+  // Reserve some memory inside the message queue
+  uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
+
+  // Construct message in the message queue memory; note that delete should not be called on the return value
+  new(slot) LocalType(&animation, &Animation::SetBlendPoint, blendPoint);
+}
+
 inline void PlayAnimationMessage(EventThreadServices& eventThreadServices, const Animation& animation)
 {
   using LocalType = Message<Animation>;