refactor dali-animation. 11/245511/11
authorsub.mohanty@samsung.com <sub.mohanty@samsung.com>
Sun, 11 Oct 2020 01:26:36 +0000 (10:26 +0900)
committerDavid Steele <david.steele@samsung.com>
Tue, 3 Nov 2020 12:00:16 +0000 (12:00 +0000)
- refactor keyframeChannel class.
- refactor KeyFrameBaseSpec to avoid heap allocation.
- keep a templated form of GetSpecialization.
- in the keyframeanimation functor keep a copy of keyframeChannel instead of heap allocated object.
- remove AnimatorFunctorBase class and replace it with std::function to avoid heap allocation when possible.
- structure packing of AnimatorBase

Change-Id: I416df4601116547c79f04b2cf8e0bc95e622b869

dali/internal/event/animation/animation-impl.cpp
dali/internal/event/animation/animator-connector-base.h
dali/internal/event/animation/animator-connector.h
dali/internal/event/animation/key-frame-channel.h
dali/internal/event/animation/key-frames-impl.cpp
dali/internal/event/animation/key-frames-impl.h
dali/internal/update/animation/scene-graph-animator.h
dali/public-api/animation/key-frames.cpp

index 0a05d70..0200fb0 100644 (file)
@@ -443,67 +443,67 @@ void Animation::AnimateBy(Property& target, Property::Value relativeValue, Alpha
   {
     case Property::BOOLEAN:
     {
-      AddAnimatorConnector( AnimatorConnector<bool>::New( object,
-                                                          target.propertyIndex,
-                                                          target.componentIndex,
-                                                          new AnimateByBoolean(relativeValue.Get<bool>()),
-                                                          alpha,
-                                                          period ) );
+      AddAnimatorConnector(AnimatorConnector<bool>::New(object,
+                                                        target.propertyIndex,
+                                                        target.componentIndex,
+                                                        AnimateByBoolean(relativeValue.Get<bool>()),
+                                                        alpha,
+                                                        period));
       break;
     }
 
     case Property::INTEGER:
     {
-      AddAnimatorConnector( AnimatorConnector<int32_t>::New( object,
-                                                             target.propertyIndex,
-                                                             target.componentIndex,
-                                                             new AnimateByInteger(relativeValue.Get<int32_t>()),
-                                                             alpha,
-                                                             period ) );
+      AddAnimatorConnector(AnimatorConnector<int32_t>::New(object,
+                                                           target.propertyIndex,
+                                                           target.componentIndex,
+                                                           AnimateByInteger(relativeValue.Get<int32_t>()),
+                                                           alpha,
+                                                           period));
       break;
     }
 
     case Property::FLOAT:
     {
-      AddAnimatorConnector( AnimatorConnector<float>::New( object,
-                                                           target.propertyIndex,
-                                                           target.componentIndex,
-                                                           new AnimateByFloat(relativeValue.Get<float>()),
-                                                           alpha,
-                                                           period ) );
+      AddAnimatorConnector(AnimatorConnector<float>::New(object,
+                                                         target.propertyIndex,
+                                                         target.componentIndex,
+                                                         AnimateByFloat(relativeValue.Get<float>()),
+                                                         alpha,
+                                                         period));
       break;
     }
 
     case Property::VECTOR2:
     {
-      AddAnimatorConnector( AnimatorConnector<Vector2>::New( object,
-                                                             target.propertyIndex,
-                                                             target.componentIndex,
-                                                             new AnimateByVector2(relativeValue.Get<Vector2>()),
-                                                             alpha,
-                                                             period ) );
+      AddAnimatorConnector(AnimatorConnector<Vector2>::New(object,
+                                                           target.propertyIndex,
+                                                           target.componentIndex,
+                                                           AnimateByVector2(relativeValue.Get<Vector2>()),
+                                                           alpha,
+                                                           period));
       break;
     }
 
     case Property::VECTOR3:
     {
-      AddAnimatorConnector( AnimatorConnector<Vector3>::New( object,
-                                                             target.propertyIndex,
-                                                             target.componentIndex,
-                                                             new AnimateByVector3(relativeValue.Get<Vector3>()),
-                                                             alpha,
-                                                             period ) );
+      AddAnimatorConnector(AnimatorConnector<Vector3>::New(object,
+                                                           target.propertyIndex,
+                                                           target.componentIndex,
+                                                           AnimateByVector3(relativeValue.Get<Vector3>()),
+                                                           alpha,
+                                                           period));
       break;
     }
 
     case Property::VECTOR4:
     {
-      AddAnimatorConnector( AnimatorConnector<Vector4>::New( object,
-                                                             target.propertyIndex,
-                                                             target.componentIndex,
-                                                             new AnimateByVector4(relativeValue.Get<Vector4>()),
-                                                             alpha,
-                                                             period ) );
+      AddAnimatorConnector(AnimatorConnector<Vector4>::New(object,
+                                                           target.propertyIndex,
+                                                           target.componentIndex,
+                                                           AnimateByVector4(relativeValue.Get<Vector4>()),
+                                                           alpha,
+                                                           period));
       break;
     }
 
@@ -511,12 +511,12 @@ void Animation::AnimateBy(Property& target, Property::Value relativeValue, Alpha
     {
       AngleAxis angleAxis = relativeValue.Get<AngleAxis>();
 
-      AddAnimatorConnector( AnimatorConnector<Quaternion>::New( object,
-                                                                target.propertyIndex,
-                                                                target.componentIndex,
-                                                                new RotateByAngleAxis(angleAxis.angle, angleAxis.axis),
-                                                                alpha,
-                                                                period ) );
+      AddAnimatorConnector(AnimatorConnector<Quaternion>::New(object,
+                                                              target.propertyIndex,
+                                                              target.componentIndex,
+                                                              RotateByAngleAxis(angleAxis.angle, angleAxis.axis),
+                                                              alpha,
+                                                              period));
       break;
     }
 
@@ -564,78 +564,78 @@ void Animation::AnimateTo(Property& target, Property::Value destinationValue, Al
   {
     case Property::BOOLEAN:
     {
-      AddAnimatorConnector( AnimatorConnector<bool>::New( object,
-                                                          target.propertyIndex,
-                                                          target.componentIndex,
-                                                          new AnimateToBoolean( destinationValue.Get<bool>() ),
-                                                          alpha,
-                                                          period ) );
+      AddAnimatorConnector(AnimatorConnector<bool>::New(object,
+                                                        target.propertyIndex,
+                                                        target.componentIndex,
+                                                        AnimateToBoolean(destinationValue.Get<bool>()),
+                                                        alpha,
+                                                        period));
       break;
     }
 
     case Property::INTEGER:
     {
-      AddAnimatorConnector( AnimatorConnector<int32_t>::New( object,
-                                                             target.propertyIndex,
-                                                             target.componentIndex,
-                                                             new AnimateToInteger( destinationValue.Get<int32_t>() ),
-                                                             alpha,
-                                                             period ) );
+      AddAnimatorConnector(AnimatorConnector<int32_t>::New(object,
+                                                           target.propertyIndex,
+                                                           target.componentIndex,
+                                                           AnimateToInteger(destinationValue.Get<int32_t>()),
+                                                           alpha,
+                                                           period));
       break;
     }
 
     case Property::FLOAT:
     {
-      AddAnimatorConnector( AnimatorConnector<float>::New( object,
-                                                           target.propertyIndex,
-                                                           target.componentIndex,
-                                                           new AnimateToFloat( destinationValue.Get<float>() ),
-                                                           alpha,
-                                                           period ) );
+      AddAnimatorConnector(AnimatorConnector<float>::New(object,
+                                                         target.propertyIndex,
+                                                         target.componentIndex,
+                                                         AnimateToFloat(destinationValue.Get<float>()),
+                                                         alpha,
+                                                         period));
       break;
     }
 
     case Property::VECTOR2:
     {
-      AddAnimatorConnector( AnimatorConnector<Vector2>::New( object,
-                                                             target.propertyIndex,
-                                                             target.componentIndex,
-                                                             new AnimateToVector2( destinationValue.Get<Vector2>() ),
-                                                             alpha,
-                                                             period ) );
+      AddAnimatorConnector(AnimatorConnector<Vector2>::New(object,
+                                                           target.propertyIndex,
+                                                           target.componentIndex,
+                                                           AnimateToVector2(destinationValue.Get<Vector2>()),
+                                                           alpha,
+                                                           period));
       break;
     }
 
     case Property::VECTOR3:
     {
-      AddAnimatorConnector( AnimatorConnector<Vector3>::New( object,
-                                                             target.propertyIndex,
-                                                             target.componentIndex,
-                                                             new AnimateToVector3( destinationValue.Get<Vector3>() ),
-                                                             alpha,
-                                                             period ) );
+      AddAnimatorConnector(AnimatorConnector<Vector3>::New(object,
+                                                           target.propertyIndex,
+                                                           target.componentIndex,
+                                                           AnimateToVector3(destinationValue.Get<Vector3>()),
+                                                           alpha,
+                                                           period));
       break;
     }
 
     case Property::VECTOR4:
     {
-      AddAnimatorConnector( AnimatorConnector<Vector4>::New( object,
-                                                             target.propertyIndex,
-                                                             target.componentIndex,
-                                                             new AnimateToVector4( destinationValue.Get<Vector4>() ),
-                                                             alpha,
-                                                             period ) );
+      AddAnimatorConnector(AnimatorConnector<Vector4>::New(object,
+                                                           target.propertyIndex,
+                                                           target.componentIndex,
+                                                           AnimateToVector4(destinationValue.Get<Vector4>()),
+                                                           alpha,
+                                                           period));
       break;
     }
 
     case Property::ROTATION:
     {
-      AddAnimatorConnector( AnimatorConnector<Quaternion>::New( object,
-                                                                target.propertyIndex,
-                                                                target.componentIndex,
-                                                                new RotateToQuaternion( destinationValue.Get<Quaternion>() ),
-                                                                alpha,
-                                                                period ) );
+      AddAnimatorConnector(AnimatorConnector<Quaternion>::New(object,
+                                                              target.propertyIndex,
+                                                              target.componentIndex,
+                                                              RotateToQuaternion(destinationValue.Get<Quaternion>()),
+                                                              alpha,
+                                                              period));
       break;
     }
 
@@ -703,99 +703,85 @@ void Animation::AnimateBetween( Property target, const KeyFrames& keyFrames, Alp
   {
     case Dali::Property::BOOLEAN:
     {
-      const KeyFrameBoolean* kf;
-      GetSpecialization(keyFrames, kf);
-      KeyFrameBooleanPtr kfCopy = KeyFrameBoolean::Clone(*kf);
-      AddAnimatorConnector( AnimatorConnector<bool>::New( object,
-                                                          target.propertyIndex,
-                                                          target.componentIndex,
-                                                          new KeyFrameBooleanFunctor(kfCopy),
-                                                          alpha,
-                                                          period ) );
+      auto kf = GetSpecialization<const KeyFrameBoolean*>(keyFrames);
+      AddAnimatorConnector(AnimatorConnector<bool>::New(object,
+                                                        target.propertyIndex,
+                                                        target.componentIndex,
+                                                        KeyFrameBooleanFunctor(*kf), // takes a copy of the keyframe
+                                                        alpha,
+                                                        period));
       break;
     }
 
     case Dali::Property::INTEGER:
     {
-      const KeyFrameInteger* kf;
-      GetSpecialization(keyFrames, kf);
-      KeyFrameIntegerPtr kfCopy = KeyFrameInteger::Clone(*kf);
-      AddAnimatorConnector( AnimatorConnector<int32_t>::New( object,
-                                                         target.propertyIndex,
-                                                         target.componentIndex,
-                                                         new KeyFrameIntegerFunctor(kfCopy,interpolation),
-                                                         alpha,
-                                                         period ) );
+      auto kf = GetSpecialization<const KeyFrameInteger*>(keyFrames);
+      AddAnimatorConnector(AnimatorConnector<int32_t>::New(object,
+                                                           target.propertyIndex,
+                                                           target.componentIndex,
+                                                           KeyFrameIntegerFunctor(*kf, interpolation), // takes a copy of the keyframe
+                                                           alpha,
+                                                           period));
       break;
     }
 
     case Dali::Property::FLOAT:
     {
-      const KeyFrameNumber* kf;
-      GetSpecialization(keyFrames, kf);
-      KeyFrameNumberPtr kfCopy = KeyFrameNumber::Clone(*kf);
-      AddAnimatorConnector( AnimatorConnector<float>::New( object,
-                                                           target.propertyIndex,
-                                                           target.componentIndex,
-                                                           new KeyFrameNumberFunctor(kfCopy,interpolation),
-                                                           alpha,
-                                                           period ) );
+      auto kf = GetSpecialization<const KeyFrameNumber*>(keyFrames);
+      AddAnimatorConnector(AnimatorConnector<float>::New(object,
+                                                         target.propertyIndex,
+                                                         target.componentIndex,
+                                                         KeyFrameNumberFunctor(*kf, interpolation), // takes a copy of the keyframe
+                                                         alpha,
+                                                         period));
       break;
     }
 
     case Dali::Property::VECTOR2:
     {
-      const KeyFrameVector2* kf;
-      GetSpecialization(keyFrames, kf);
-      KeyFrameVector2Ptr kfCopy = KeyFrameVector2::Clone(*kf);
-      AddAnimatorConnector( AnimatorConnector<Vector2>::New( object,
-                                                             target.propertyIndex,
-                                                             target.componentIndex,
-                                                             new KeyFrameVector2Functor(kfCopy,interpolation),
-                                                             alpha,
-                                                             period ) );
+      auto kf = GetSpecialization<const KeyFrameVector2*>(keyFrames);
+      AddAnimatorConnector(AnimatorConnector<Vector2>::New(object,
+                                                           target.propertyIndex,
+                                                           target.componentIndex,
+                                                           KeyFrameVector2Functor(*kf, interpolation), // takes a copy of the keyframe
+                                                           alpha,
+                                                           period));
       break;
     }
 
     case Dali::Property::VECTOR3:
     {
-      const KeyFrameVector3* kf;
-      GetSpecialization(keyFrames, kf);
-      KeyFrameVector3Ptr kfCopy = KeyFrameVector3::Clone(*kf);
-      AddAnimatorConnector( AnimatorConnector<Vector3>::New( object,
-                                                             target.propertyIndex,
-                                                             target.componentIndex,
-                                                             new KeyFrameVector3Functor(kfCopy,interpolation),
-                                                             alpha,
-                                                             period ) );
+      auto kf = GetSpecialization<const KeyFrameVector3*>(keyFrames);
+      AddAnimatorConnector(AnimatorConnector<Vector3>::New(object,
+                                                           target.propertyIndex,
+                                                           target.componentIndex,
+                                                           KeyFrameVector3Functor(*kf, interpolation), // takes a copy of the keyframe
+                                                           alpha,
+                                                           period));
       break;
     }
 
     case Dali::Property::VECTOR4:
     {
-      const KeyFrameVector4* kf;
-      GetSpecialization(keyFrames, kf);
-      KeyFrameVector4Ptr kfCopy = KeyFrameVector4::Clone(*kf);
-      AddAnimatorConnector( AnimatorConnector<Vector4>::New( object,
-                                                             target.propertyIndex,
-                                                             target.componentIndex,
-                                                             new KeyFrameVector4Functor(kfCopy,interpolation),
-                                                             alpha,
-                                                             period ) );
+      auto kf = GetSpecialization<const KeyFrameVector4*>(keyFrames);
+      AddAnimatorConnector(AnimatorConnector<Vector4>::New(object,
+                                                           target.propertyIndex,
+                                                           target.componentIndex,
+                                                           KeyFrameVector4Functor(*kf, interpolation), // takes a copy of the keyframe
+                                                           alpha,
+                                                           period));
       break;
     }
 
     case Dali::Property::ROTATION:
     {
-      const KeyFrameQuaternion* kf;
-      GetSpecialization(keyFrames, kf);
-      KeyFrameQuaternionPtr kfCopy = KeyFrameQuaternion::Clone(*kf);
-      AddAnimatorConnector( AnimatorConnector<Quaternion>::New( object,
-                                                                target.propertyIndex,
-                                                                target.componentIndex,
-                                                                new KeyFrameQuaternionFunctor(kfCopy),
-                                                                alpha,
-                                                                period ) );
+      auto kf = GetSpecialization<const KeyFrameQuaternion*>(keyFrames);
+      AddAnimatorConnector(AnimatorConnector<Quaternion>::New(object,
+                                                              target.propertyIndex,
+                                                              target.componentIndex,
+                                                              KeyFrameQuaternionFunctor(*kf), // takes a copy of the keyframe
+                                                              alpha,
+                                                              period));
       break;
     }
 
@@ -900,23 +886,23 @@ void Animation::Animate( Actor& actor, const Path& path, const Vector3& forward,
   PathPtr pathCopy = Path::Clone(path);
 
   //Position animation
-  AddAnimatorConnector( AnimatorConnector<Vector3>::New( actor,
-                                                         Dali::Actor::Property::POSITION,
-                                                         Property::INVALID_COMPONENT_INDEX,
-                                                         new PathPositionFunctor( pathCopy ),
-                                                         alpha,
-                                                         period ) );
+  AddAnimatorConnector(AnimatorConnector<Vector3>::New(actor,
+                                                       Dali::Actor::Property::POSITION,
+                                                       Property::INVALID_COMPONENT_INDEX,
+                                                       PathPositionFunctor(pathCopy),
+                                                       alpha,
+                                                       period));
 
   //If forward is zero, PathRotationFunctor will always return the unit quaternion
   if( forward != Vector3::ZERO )
   {
     //Rotation animation
-    AddAnimatorConnector( AnimatorConnector<Quaternion>::New( actor,
-                                                              Dali::Actor::Property::ORIENTATION,
-                                                              Property::INVALID_COMPONENT_INDEX,
-                                                              new PathRotationFunctor( pathCopy, forward ),
-                                                              alpha,
-                                                              period ) );
+    AddAnimatorConnector(AnimatorConnector<Quaternion>::New(actor,
+                                                            Dali::Actor::Property::ORIENTATION,
+                                                            Property::INVALID_COMPONENT_INDEX,
+                                                            PathRotationFunctor(pathCopy, forward),
+                                                            alpha,
+                                                            period));
   }
 }
 
@@ -924,24 +910,24 @@ void Animation::Show(Actor& actor, float delaySeconds)
 {
   ExtendDuration( TimePeriod(delaySeconds, 0) );
 
-  AddAnimatorConnector( AnimatorConnector<bool>::New( actor,
-                                                      Dali::Actor::Property::VISIBLE,
-                                                      Property::INVALID_COMPONENT_INDEX,
-                                                      new AnimateToBoolean(SHOW_VALUE),
-                                                      mDefaultAlpha,
-                                                      TimePeriod(delaySeconds, 0.0f/*immediate*/) ) );
+  AddAnimatorConnector(AnimatorConnector<bool>::New(actor,
+                                                    Dali::Actor::Property::VISIBLE,
+                                                    Property::INVALID_COMPONENT_INDEX,
+                                                    AnimateToBoolean(SHOW_VALUE),
+                                                    mDefaultAlpha,
+                                                    TimePeriod(delaySeconds, 0.0f /*immediate*/)));
 }
 
 void Animation::Hide(Actor& actor, float delaySeconds)
 {
   ExtendDuration( TimePeriod(delaySeconds, 0) );
 
-  AddAnimatorConnector( AnimatorConnector<bool>::New( actor,
-                                                      Dali::Actor::Property::VISIBLE,
-                                                      Property::INVALID_COMPONENT_INDEX,
-                                                      new AnimateToBoolean(HIDE_VALUE),
-                                                      mDefaultAlpha,
-                                                      TimePeriod(delaySeconds, 0.0f/*immediate*/) ) );
+  AddAnimatorConnector(AnimatorConnector<bool>::New(actor,
+                                                    Dali::Actor::Property::VISIBLE,
+                                                    Property::INVALID_COMPONENT_INDEX,
+                                                    AnimateToBoolean(HIDE_VALUE),
+                                                    mDefaultAlpha,
+                                                    TimePeriod(delaySeconds, 0.0f /*immediate*/)));
 }
 
 bool Animation::DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes )
index 8e839fb..8699012 100644 (file)
@@ -49,21 +49,16 @@ public:
   /**
    * Constructor.
    */
-  AnimatorConnectorBase(
-      Object& object,
-      Property::Index propertyIndex,
-      int32_t componentIndex,
-      Internal::AnimatorFunctionBase* animatorFunction,
-      AlphaFunction alpha,
-      const TimePeriod& period)
-  : mParent( nullptr ),
-    mObject( &object ),
-    mAnimator( nullptr ),
-    mAnimatorFunction( animatorFunction ),
+  AnimatorConnectorBase(Object&           object,
+                        Property::Index   propertyIndex,
+                        int32_t           componentIndex,
+                        AlphaFunction     alpha,
+                        const TimePeriod& period)
+  : mObject(&object),
     mAlphaFunction(alpha),
     mTimePeriod(period),
-    mPropertyIndex( propertyIndex ),
-    mComponentIndex( componentIndex )
+    mPropertyIndex(propertyIndex),
+    mComponentIndex(componentIndex)
   {
     object.AddObserver( *this );
   }
@@ -77,13 +72,6 @@ public:
     {
       mObject->RemoveObserver( *this );
     }
-
-    // If there is not a SceneGraph::Animator, the AnimatorConnector is responsible for deleting the mAnimatorFunction
-    // otherwise, the animator function ownership is transferred to the SceneGraph::Animator
-    if( !mAnimator )
-    {
-      delete mAnimatorFunction;
-    }
   }
 
   /**
@@ -96,7 +84,6 @@ public:
   void CreateAnimator()
   {
     DALI_ASSERT_DEBUG( mAnimator == nullptr );
-    DALI_ASSERT_DEBUG( mAnimatorFunction != nullptr );
     DALI_ASSERT_DEBUG( mParent != nullptr );
 
     //Get the PropertyOwner the animator is going to animate
@@ -206,18 +193,15 @@ private:
   }
 
 protected:
-
-  Animation* mParent; ///< The parent owns the connector.
-  Object* mObject; ///< Not owned by the animator connector. Valid until ObjectDestroyed() is called.
-  SceneGraph::AnimatorBase* mAnimator;
-  Internal::AnimatorFunctionBase* mAnimatorFunction;  ///< Owned by the animator connector until an Scenegraph::Animator is created
+  Animation*                mParent{nullptr}; ///< The parent owns the connector.
+  Object*                   mObject;          ///< Not owned by the animator connector. Valid until ObjectDestroyed() is called.
+  SceneGraph::AnimatorBase* mAnimator{nullptr};
 
   AlphaFunction mAlphaFunction;
-  TimePeriod mTimePeriod;
+  TimePeriod    mTimePeriod;
 
   Property::Index mPropertyIndex;
-  int32_t mComponentIndex;
-
+  int32_t         mComponentIndex;
 };
 
 } // namespace Internal
index 48bd693..434fdc9 100644 (file)
@@ -18,6 +18,9 @@
  *
  */
 
+//EXTERNAL INCLUDES
+#include <functional>
+
 // INTERNAL INCLUDES
 #include <dali/internal/event/animation/animator-connector-base.h>
 #include <dali/internal/event/animation/animation-impl.h>
@@ -41,6 +44,10 @@ namespace Internal
 template < typename PropertyType >
 class AnimatorConnector : public AnimatorConnectorBase
 {
+  using AnimatorFunction = std::function<PropertyType(float, const PropertyType&)>;
+
+  AnimatorFunction mAnimatorFunction;
+
 public:
 
   using AnimatorType = SceneGraph::Animator< PropertyType, PropertyAccessor<PropertyType> >;
@@ -56,19 +63,19 @@ public:
    * @param[in] period The time period of the animator.
    * @return A pointer to a newly allocated animator connector.
    */
-  static AnimatorConnectorBase* New( Object& object,
-                                     Property::Index propertyIndex,
-                                     int32_t componentIndex,
-                                     AnimatorFunctionBase* animatorFunction,
-                                     AlphaFunction alpha,
-                                     const TimePeriod& period )
+  static AnimatorConnectorBase* New(Object&           object,
+                                    Property::Index   propertyIndex,
+                                    int32_t           componentIndex,
+                                    AnimatorFunction  animatorFunction,
+                                    AlphaFunction     alpha,
+                                    const TimePeriod& period)
   {
-    return new AnimatorConnector( object,
-                                  propertyIndex,
-                                  componentIndex,
-                                  animatorFunction,
-                                  alpha,
-                                  period );
+    return new AnimatorConnector(object,
+                                 propertyIndex,
+                                 componentIndex,
+                                 std::move(animatorFunction),
+                                 alpha,
+                                 period);
   }
 
   /**
@@ -81,13 +88,14 @@ private:
   /**
    * Private constructor; see also AnimatorConnector::New().
    */
-  AnimatorConnector( Object& object,
-                     Property::Index propertyIndex,
-                     int32_t componentIndex,
-                     Internal::AnimatorFunctionBase* animatorFunction,
-                     AlphaFunction alpha,
-                     const TimePeriod& period )
-  : AnimatorConnectorBase( object, propertyIndex, componentIndex, animatorFunction, alpha, period )
+  AnimatorConnector(Object&           object,
+                    Property::Index   propertyIndex,
+                    int32_t           componentIndex,
+                    AnimatorFunction  animatorFunction,
+                    AlphaFunction     alpha,
+                    const TimePeriod& period)
+  : AnimatorConnectorBase(object, propertyIndex, componentIndex, alpha, period),
+    mAnimatorFunction(std::move(animatorFunction))
   {
   }
 
@@ -113,7 +121,11 @@ private:
     {
       if( baseProperty.IsTransformManagerProperty() )
       {
-        mAnimator = SceneGraph::AnimatorTransformProperty< PropertyType,TransformManagerPropertyAccessor<PropertyType> >::New( propertyOwner, baseProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod );
+        mAnimator = SceneGraph::AnimatorTransformProperty<PropertyType, TransformManagerPropertyAccessor<PropertyType> >::New(propertyOwner,
+                                                                                                                              baseProperty,
+                                                                                                                              std::move(mAnimatorFunction),
+                                                                                                                              mAlphaFunction,
+                                                                                                                              mTimePeriod);
         // Don't reset transform manager properties - TransformManager will do it more efficiently
       }
       else
@@ -124,8 +136,12 @@ private:
     else
     {
       // Create the animator and resetter
-      mAnimator = AnimatorType::New( propertyOwner, *animatableProperty, mAnimatorFunction,
-                                     mAlphaFunction, mTimePeriod );
+      mAnimator = AnimatorType::New(propertyOwner,
+                                    *animatableProperty,
+                                    std::move(mAnimatorFunction),
+                                    mAlphaFunction,
+                                    mTimePeriod);
+
       resetterRequired = true;
     }
     return resetterRequired;
@@ -138,6 +154,10 @@ private:
 template <>
 class AnimatorConnector< float > : public AnimatorConnectorBase
 {
+  using AnimatorFunction = std::function<float(float, const float&)>;
+
+  AnimatorFunction mAnimatorFunction;
+
 public:
 
   using AnimatorType = SceneGraph::Animator< float, PropertyAccessor<float> >;
@@ -153,19 +173,19 @@ public:
    * @param[in] period The time period of the animator.
    * @return A pointer to a newly allocated animator connector.
    */
-  static AnimatorConnectorBase* New( Object& object,
-                                     Property::Index propertyIndex,
-                                     int32_t componentIndex,
-                                     AnimatorFunctionBase* animatorFunction,
-                                     AlphaFunction alpha,
-                                     const TimePeriod& period )
+  static AnimatorConnectorBase* New(Object&           object,
+                                    Property::Index   propertyIndex,
+                                    int32_t           componentIndex,
+                                    AnimatorFunction  animatorFunction,
+                                    AlphaFunction     alpha,
+                                    const TimePeriod& period)
   {
-    return new AnimatorConnector( object,
-                                  propertyIndex,
-                                  componentIndex,
-                                  animatorFunction,
-                                  alpha,
-                                  period );
+    return new AnimatorConnector(object,
+                                 propertyIndex,
+                                 componentIndex,
+                                 std::move(animatorFunction),
+                                 alpha,
+                                 period);
   }
 
   /**
@@ -178,13 +198,14 @@ private:
   /**
    * Private constructor; see also AnimatorConnector::New().
    */
-  AnimatorConnector( Object& object,
-                     Property::Index propertyIndex,
-                     int32_t componentIndex,
-                     Internal::AnimatorFunctionBase* animatorFunction,
-                     AlphaFunction alpha,
-                     const TimePeriod& period )
-  : AnimatorConnectorBase( object, propertyIndex, componentIndex, animatorFunction, alpha, period )
+  AnimatorConnector(Object&           object,
+                    Property::Index   propertyIndex,
+                    int32_t           componentIndex,
+                    AnimatorFunction  animatorFunction,
+                    AlphaFunction     alpha,
+                    const TimePeriod& period)
+  : AnimatorConnectorBase(object, propertyIndex, componentIndex, alpha, period),
+    mAnimatorFunction(std::move(animatorFunction))
   {
   }
 
@@ -210,7 +231,11 @@ private:
       {
         if( baseProperty.IsTransformManagerProperty() )
         {
-          mAnimator = SceneGraph::AnimatorTransformProperty< float,TransformManagerPropertyAccessor<float> >::New( propertyOwner, baseProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod );
+          mAnimator = SceneGraph::AnimatorTransformProperty<float, TransformManagerPropertyAccessor<float> >::New(propertyOwner,
+                                                                                                                  baseProperty,
+                                                                                                                  std::move(mAnimatorFunction),
+                                                                                                                  mAlphaFunction,
+                                                                                                                  mTimePeriod);
           // Don't reset transform manager properties - TransformManager will do it more efficiently
         }
         else
@@ -221,8 +246,12 @@ private:
       else
       {
         // Create the animator and resetter
-        mAnimator = AnimatorType::New( propertyOwner, *animatableProperty, mAnimatorFunction,
-                                       mAlphaFunction, mTimePeriod );
+        mAnimator = AnimatorType::New(propertyOwner,
+                                      *animatableProperty,
+                                      std::move(mAnimatorFunction),
+                                      mAlphaFunction,
+                                      mTimePeriod);
+
         resetterRequired = true;
       }
     }
@@ -242,20 +271,20 @@ private:
           {
             case 0:
             {
-              mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorX<Vector2> >::New( propertyOwner,
-                                                                                                   *animatableProperty,
-                                                                                                   mAnimatorFunction,
-                                                                                                   mAlphaFunction,
-                                                                                                   mTimePeriod );
+              mAnimator = SceneGraph::Animator<float, PropertyComponentAccessorX<Vector2> >::New(propertyOwner,
+                                                                                                 *animatableProperty,
+                                                                                                 std::move(mAnimatorFunction),
+                                                                                                 mAlphaFunction,
+                                                                                                 mTimePeriod);
               break;
             }
             case 1:
             {
-              mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorY<Vector2> >::New( propertyOwner,
-                                                                                                   *animatableProperty,
-                                                                                                   mAnimatorFunction,
-                                                                                                   mAlphaFunction,
-                                                                                                   mTimePeriod );
+              mAnimator = SceneGraph::Animator<float, PropertyComponentAccessorY<Vector2> >::New(propertyOwner,
+                                                                                                 *animatableProperty,
+                                                                                                 std::move(mAnimatorFunction),
+                                                                                                 mAlphaFunction,
+                                                                                                 mTimePeriod);
               break;
             }
             default:
@@ -279,15 +308,27 @@ private:
             {
               if( mComponentIndex == 0 )
               {
-                mAnimator = SceneGraph::AnimatorTransformProperty< float,TransformManagerPropertyComponentAccessor<Vector3,0> >::New( propertyOwner, baseProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod );
+                mAnimator = SceneGraph::AnimatorTransformProperty<float, TransformManagerPropertyComponentAccessor<Vector3, 0> >::New(propertyOwner,
+                                                                                                                                      baseProperty,
+                                                                                                                                      std::move(mAnimatorFunction),
+                                                                                                                                      mAlphaFunction,
+                                                                                                                                      mTimePeriod);
               }
               else if( mComponentIndex == 1 )
               {
-                mAnimator = SceneGraph::AnimatorTransformProperty< float,TransformManagerPropertyComponentAccessor<Vector3,1> >::New( propertyOwner, baseProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod );
+                mAnimator = SceneGraph::AnimatorTransformProperty<float, TransformManagerPropertyComponentAccessor<Vector3, 1> >::New(propertyOwner,
+                                                                                                                                      baseProperty,
+                                                                                                                                      std::move(mAnimatorFunction),
+                                                                                                                                      mAlphaFunction,
+                                                                                                                                      mTimePeriod);
               }
               else if( mComponentIndex == 2 )
               {
-                mAnimator = SceneGraph::AnimatorTransformProperty< float,TransformManagerPropertyComponentAccessor<Vector3,2> >::New( propertyOwner, baseProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod );
+                mAnimator = SceneGraph::AnimatorTransformProperty<float, TransformManagerPropertyComponentAccessor<Vector3, 2> >::New(propertyOwner,
+                                                                                                                                      baseProperty,
+                                                                                                                                      std::move(mAnimatorFunction),
+                                                                                                                                      mAlphaFunction,
+                                                                                                                                      mTimePeriod);
               }
             }
             else
@@ -305,29 +346,29 @@ private:
             {
               case 0:
               {
-                mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorX<Vector3> >::New( propertyOwner,
-                                                                                                     *animatableProperty,
-                                                                                                     mAnimatorFunction,
-                                                                                                     mAlphaFunction,
-                                                                                                     mTimePeriod );
+                mAnimator = SceneGraph::Animator<float, PropertyComponentAccessorX<Vector3> >::New(propertyOwner,
+                                                                                                   *animatableProperty,
+                                                                                                   std::move(mAnimatorFunction),
+                                                                                                   mAlphaFunction,
+                                                                                                   mTimePeriod);
                 break;
               }
               case 1:
               {
-                mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorY<Vector3> >::New( propertyOwner,
-                                                                                                     *animatableProperty,
-                                                                                                     mAnimatorFunction,
-                                                                                                     mAlphaFunction,
-                                                                                                     mTimePeriod );
+                mAnimator = SceneGraph::Animator<float, PropertyComponentAccessorY<Vector3> >::New(propertyOwner,
+                                                                                                   *animatableProperty,
+                                                                                                   std::move(mAnimatorFunction),
+                                                                                                   mAlphaFunction,
+                                                                                                   mTimePeriod);
                 break;
               }
               case 2:
               {
-                mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorZ<Vector3> >::New( propertyOwner,
-                                                                                                     *animatableProperty,
-                                                                                                     mAnimatorFunction,
-                                                                                                     mAlphaFunction,
-                                                                                                     mTimePeriod );
+                mAnimator = SceneGraph::Animator<float, PropertyComponentAccessorZ<Vector3> >::New(propertyOwner,
+                                                                                                   *animatableProperty,
+                                                                                                   std::move(mAnimatorFunction),
+                                                                                                   mAlphaFunction,
+                                                                                                   mTimePeriod);
                 break;
               }
               default:
@@ -353,38 +394,38 @@ private:
           {
             case 0:
             {
-              mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorX<Vector4> >::New( propertyOwner,
-                                                                                                   *animatableProperty,
-                                                                                                   mAnimatorFunction,
-                                                                                                   mAlphaFunction,
-                                                                                                   mTimePeriod );
+              mAnimator = SceneGraph::Animator<float, PropertyComponentAccessorX<Vector4> >::New(propertyOwner,
+                                                                                                 *animatableProperty,
+                                                                                                 std::move(mAnimatorFunction),
+                                                                                                 mAlphaFunction,
+                                                                                                 mTimePeriod);
               break;
             }
             case 1:
             {
-              mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorY<Vector4> >::New( propertyOwner,
-                                                                                                   *animatableProperty,
-                                                                                                   mAnimatorFunction,
-                                                                                                   mAlphaFunction,
-                                                                                                   mTimePeriod );
+              mAnimator = SceneGraph::Animator<float, PropertyComponentAccessorY<Vector4> >::New(propertyOwner,
+                                                                                                 *animatableProperty,
+                                                                                                 std::move(mAnimatorFunction),
+                                                                                                 mAlphaFunction,
+                                                                                                 mTimePeriod);
               break;
             }
             case 2:
             {
-              mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorZ<Vector4> >::New( propertyOwner,
-                                                                                                   *animatableProperty,
-                                                                                                   mAnimatorFunction,
-                                                                                                   mAlphaFunction,
-                                                                                                   mTimePeriod );
+              mAnimator = SceneGraph::Animator<float, PropertyComponentAccessorZ<Vector4> >::New(propertyOwner,
+                                                                                                 *animatableProperty,
+                                                                                                 std::move(mAnimatorFunction),
+                                                                                                 mAlphaFunction,
+                                                                                                 mTimePeriod);
               break;
             }
             case 3:
             {
-              mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorW<Vector4> >::New( propertyOwner,
-                                                                                                   *animatableProperty,
-                                                                                                   mAnimatorFunction,
-                                                                                                   mAlphaFunction,
-                                                                                                   mTimePeriod );
+              mAnimator = SceneGraph::Animator<float, PropertyComponentAccessorW<Vector4> >::New(propertyOwner,
+                                                                                                 *animatableProperty,
+                                                                                                 std::move(mAnimatorFunction),
+                                                                                                 mAlphaFunction,
+                                                                                                 mTimePeriod);
               break;
             }
 
index 820340c..c7f0444 100644 (file)
@@ -18,6 +18,9 @@
  *
  */
 
+// EXTERNAL INCLUDES
+#include <algorithm>
+
 // INTERNAL INCLUDES
 #include <dali/internal/event/animation/progress-value.h>
 #include <dali/public-api/animation/animation.h>
@@ -27,171 +30,76 @@ namespace Dali
 {
 namespace Internal
 {
-
-class KeyFrameChannelBase
-{
-public:
-  enum KeyFrameChannelId
-  {
-    Translate, Rotate, Scale,
-  };
-
-  KeyFrameChannelBase(KeyFrameChannelId channel_id)
-  : mChannelId(channel_id)
-  {
-  }
-
-  virtual ~KeyFrameChannelBase() = default;
-
-  KeyFrameChannelId GetId() const
-  {
-    return mChannelId;
-  }
-
-  virtual bool IsActive(float progress) = 0;
-
-protected:
-  KeyFrameChannelId       mChannelId;
-};
-
-
-template <typename V>
-class KeyFrameChannel : public KeyFrameChannelBase
+template<typename V>
+struct KeyFrameChannel
 {
-public:
-  using ProgressValues = std::vector<ProgressValue<V> >;
-
-  KeyFrameChannel(KeyFrameChannelId channel_id, ProgressValues& values )
-  : KeyFrameChannelBase(channel_id),
-    mValues(values)
-  {
-  }
-
-  ~KeyFrameChannel() override = default;
-
-  bool IsActive (float progress) override;
+  using ProgressValues = std::vector<ProgressValue<V>>;
 
-  V GetValue(float progress, Dali::Animation::Interpolation interpolation) const;
-
-  bool FindInterval(typename ProgressValues::iterator& start,
-                    typename ProgressValues::iterator& end,
-                    float progress) const;
-
-  ProgressValues& mValues;
-};
-
-template <class V>
-bool KeyFrameChannel<V>::IsActive (float progress)
-{
-  bool active = false;
-  if(!mValues.empty())
+  bool IsActive(float progress) const
   {
-    ProgressValue<V>& first = mValues.front();
-
-    if( progress >= first.GetProgress() )
+    if(!mValues.empty() && (progress >= mValues[0].GetProgress()))
     {
-      active = true;
+      return true;
     }
+    return false;
   }
-  return active;
-}
 
-/**
- * Use a linear search to find the interval containing progress
- */
-template <class V>
-bool KeyFrameChannel<V>::FindInterval(
-  typename ProgressValues::iterator& start,
-  typename ProgressValues::iterator& end,
-  float progress) const
-{
-  bool found = false;
-  typename std::vector<ProgressValue<V> >::iterator iter = mValues.begin();
-  typename std::vector<ProgressValue<V> >::iterator prevIter = iter;
-
-  while(iter != mValues.end() && iter->GetProgress() <= progress)
-  {
-    prevIter = iter;
-    ++iter;
-  }
-
-  if(iter == mValues.end())
-  {
-    --prevIter;
-    --iter;
-  }
-
-  if(prevIter->GetProgress() <= progress
-     &&
-     iter->GetProgress() > progress)
+  V GetValue(float progress, Dali::Animation::Interpolation interpolation) const
   {
-    found = true;
-    start = prevIter;
-    end   = iter;
-  }
+    V interpolatedV{};
 
-  return found;
-}
-
-template <class V>
-V KeyFrameChannel<V>::GetValue (float progress, Dali::Animation::Interpolation interpolation) const
-{
-  ProgressValue<V>&  firstPV =  mValues.front();
-
-  typename std::vector<ProgressValue<V> >::iterator start;
-  typename std::vector<ProgressValue<V> >::iterator end;
-
-  V interpolatedV = firstPV.GetValue();
-  if(progress >= mValues.back().GetProgress() )
-  {
-    interpolatedV = mValues.back().GetValue(); // This should probably be last value...
-  }
-  else if(FindInterval(start, end, progress))
-  {
-    float frameProgress = (progress - start->GetProgress()) / (end->GetProgress() - start->GetProgress());
-
-    if( interpolation == Dali::Animation::LINEAR )
+    if(progress >= mValues.back().GetProgress())
     {
-      Interpolate(interpolatedV, start->GetValue(), end->GetValue(), frameProgress);
+      interpolatedV = mValues.back().GetValue();
     }
     else
     {
-      //Calculate prev and next values
-      V prev;
-      if( start != mValues.begin() )
-      {
-        prev = (start-1)->GetValue();
-      }
-      else
-      {
-        //Project next value through start point
-        prev = start->GetValue() + (start->GetValue()-(start+1)->GetValue());
-      }
+      auto end   = std::find_if(mValues.begin(), mValues.end(), [=](const auto& element) { return element.GetProgress() > progress; });
+      auto start = end - 1;
 
-      V next;
-      if( end != mValues.end()-1)
-      {
-        next = (end+1)->GetValue();
-      }
-      else
+      const bool validInterval = (end != mValues.end()) && (start->GetProgress() <= progress);
+
+      if(validInterval)
       {
-        //Project prev value through end point
-        next = end->GetValue() + (end->GetValue()-(end-1)->GetValue());
+        float frameProgress = (progress - start->GetProgress()) / (end->GetProgress() - start->GetProgress());
+        if(interpolation == Dali::Animation::LINEAR)
+        {
+          Interpolate(interpolatedV, start->GetValue(), end->GetValue(), frameProgress);
+        }
+        else
+        {
+          //Calculate prev and next values
+          V prev;
+          if(start != mValues.begin())
+          {
+            prev = (start - 1)->GetValue();
+          }
+          else
+          {
+            //Project next value through start point
+            prev = start->GetValue() + (start->GetValue() - (start + 1)->GetValue());
+          }
+
+          V next;
+          if(end != mValues.end() - 1)
+          {
+            next = (end + 1)->GetValue();
+          }
+          else
+          {
+            //Project prev value through end point
+            next = end->GetValue() + (end->GetValue() - (end - 1)->GetValue());
+          }
+
+          CubicInterpolate(interpolatedV, prev, start->GetValue(), end->GetValue(), next, frameProgress);
+        }
       }
-
-      CubicInterpolate(interpolatedV, prev, start->GetValue(), end->GetValue(), next, frameProgress);
     }
+    return interpolatedV;
   }
 
-  return interpolatedV;
-}
-
-using KeyFrameChannelNumber     = KeyFrameChannel<float>;
-using KeyFrameChannelVector2    = KeyFrameChannel<Vector2>;
-using KeyFrameChannelVector3    = KeyFrameChannel<Vector3>;
-using KeyFrameChannelVector4    = KeyFrameChannel<Vector4>;
-using KeyFrameChannelQuaternion = KeyFrameChannel<Quaternion>;
-using KeyFrameChannelAngleAxis  = KeyFrameChannel<AngleAxis>;
+  ProgressValues mValues;
+};
 
 } // Internal
 } // namespace Dali
index fa265cc..7ecfd6b 100644 (file)
@@ -28,14 +28,6 @@ KeyFrames* KeyFrames::New()
   return new KeyFrames();
 }
 
-KeyFrames::KeyFrames()
-  : mType(Property::NONE),
-    mKeyFrames(nullptr)
-{
-}
-
-KeyFrames::~KeyFrames() = default;
-
 void KeyFrames::CreateKeyFramesSpec(Property::Type type)
 {
   mType = type;
@@ -44,37 +36,37 @@ void KeyFrames::CreateKeyFramesSpec(Property::Type type)
   {
     case Property::BOOLEAN:
     {
-      mKeyFrames = Internal::KeyFrameBoolean::New();
+      mKeyFrames = std::make_unique<Internal::KeyFrameBoolean>();
       break;
     }
     case Property::INTEGER:
     {
-      mKeyFrames = Internal::KeyFrameInteger::New();
+      mKeyFrames = std::make_unique<Internal::KeyFrameInteger>();
       break;
     }
     case Property::FLOAT:
     {
-      mKeyFrames = Internal::KeyFrameNumber::New();
+      mKeyFrames = std::make_unique<Internal::KeyFrameNumber>();
       break;
     }
     case Property::VECTOR2:
     {
-      mKeyFrames = Internal::KeyFrameVector2::New();
+      mKeyFrames = std::make_unique<Internal::KeyFrameVector2>();
       break;
     }
     case Property::VECTOR3:
     {
-      mKeyFrames = Internal::KeyFrameVector3::New();
+      mKeyFrames = std::make_unique<Internal::KeyFrameVector3>();
       break;
     }
     case Property::VECTOR4:
     {
-      mKeyFrames = Internal::KeyFrameVector4::New();
+      mKeyFrames = std::make_unique<Internal::KeyFrameVector4>();
       break;
     }
     case Property::ROTATION:
     {
-      mKeyFrames = Internal::KeyFrameQuaternion::New();
+      mKeyFrames = std::make_unique<Internal::KeyFrameQuaternion>();
       break;
     }
     default:
@@ -90,7 +82,7 @@ Property::Type KeyFrames::GetType() const
   return mType;
 }
 
-void KeyFrames::Add(float time, Property::Value value, AlphaFunction alpha)
+void KeyFrames::Add(float time, const Property::Value& value, AlphaFunction alpha)
 {
   if(mType == Property::NONE)
   {
@@ -100,49 +92,51 @@ void KeyFrames::Add(float time, Property::Value value, AlphaFunction alpha)
   // Once we have created a type, can only add values of the same type
   DALI_ASSERT_ALWAYS( mType == value.GetType() && "Can only add values of the same type to a KeyFrame" );
 
-  DALI_ASSERT_DEBUG(mKeyFrames);
+  auto keyframes = mKeyFrames.get();
+
+  DALI_ASSERT_DEBUG(keyframes);
 
   switch(mType)
   {
     case Property::BOOLEAN:
     {
-      Internal::KeyFrameBoolean* kf = static_cast<Internal::KeyFrameBoolean*>(mKeyFrames.Get());
+      Internal::KeyFrameBoolean* kf = static_cast<Internal::KeyFrameBoolean*>(keyframes);
       kf->AddKeyFrame(time, value.Get<bool>(), alpha);
       break;
     }
     case Property::INTEGER:
     {
-      Internal::KeyFrameInteger* kf = static_cast<Internal::KeyFrameInteger*>(mKeyFrames.Get());
+      Internal::KeyFrameInteger* kf = static_cast<Internal::KeyFrameInteger*>(keyframes);
       kf->AddKeyFrame(time, value.Get<int>(), alpha);
       break;
     }
     case Property::FLOAT:
     {
-      Internal::KeyFrameNumber* kf = static_cast<Internal::KeyFrameNumber*>(mKeyFrames.Get());
+      Internal::KeyFrameNumber* kf = static_cast<Internal::KeyFrameNumber*>(keyframes);
       kf->AddKeyFrame(time, value.Get<float>(), alpha);
       break;
     }
     case Property::VECTOR2:
     {
-      Internal::KeyFrameVector2* kf = static_cast<Internal::KeyFrameVector2*>(mKeyFrames.Get());
+      Internal::KeyFrameVector2* kf = static_cast<Internal::KeyFrameVector2*>(keyframes);
       kf->AddKeyFrame(time, value.Get<Vector2>(), alpha);
       break;
     }
     case Property::VECTOR3:
     {
-      Internal::KeyFrameVector3* kf = static_cast<Internal::KeyFrameVector3*>(mKeyFrames.Get());
+      Internal::KeyFrameVector3* kf = static_cast<Internal::KeyFrameVector3*>(keyframes);
       kf->AddKeyFrame(time, value.Get<Vector3>(), alpha);
       break;
     }
     case Property::VECTOR4:
     {
-      Internal::KeyFrameVector4* kf = static_cast<Internal::KeyFrameVector4*>(mKeyFrames.Get());
+      Internal::KeyFrameVector4* kf = static_cast<Internal::KeyFrameVector4*>(keyframes);
       kf->AddKeyFrame(time, value.Get<Vector4>(), alpha);
       break;
     }
     case Property::ROTATION:
     {
-      Internal::KeyFrameQuaternion* kf = static_cast<Internal::KeyFrameQuaternion*>(mKeyFrames.Get());
+      Internal::KeyFrameQuaternion* kf = static_cast<Internal::KeyFrameQuaternion*>(keyframes);
       kf->AddKeyFrame(time, value.Get<Quaternion>(), alpha);
       break;
     }
@@ -154,7 +148,7 @@ void KeyFrames::Add(float time, Property::Value value, AlphaFunction alpha)
 
 KeyFrameSpec* KeyFrames::GetKeyFramesBase() const
 {
-  return mKeyFrames.Get();
+  return mKeyFrames.get();
 }
 
 Property::Value KeyFrames::GetLastKeyFrameValue() const
index 989e481..1f21625 100644 (file)
  *
  */
 
+// EXTERNAL INCLUDES
+#include <memory>
+
 // INTERNAL INCLUDES
 #include <dali/public-api/common/vector-wrapper.h>
 #include <dali/public-api/animation/key-frames.h>
 #include <dali/public-api/object/base-object.h>
 #include <dali/public-api/animation/alpha-function.h>
-#include <dali/internal/event/animation/progress-value.h>
 #include <dali/internal/event/animation/key-frame-channel.h>
 
 namespace Dali
@@ -32,7 +34,6 @@ namespace Internal
 {
 class KeyFrameSpec;
 class KeyFrames;
-using KeyFramesPtr = IntrusivePtr<KeyFrames>;
 
 /**
  * KeyFrames class is responsible for creating and building a specialized KeyFrame class
@@ -43,24 +44,7 @@ class KeyFrames : public BaseObject
 public:
   static KeyFrames* New();
 
-  /**
-   * Instantiate an empty KeyFrames object
-   */
-  KeyFrames();
-
-protected:
-  ~KeyFrames() override;
-
 private:
-  /**
-   * Don't allow copy constructor
-   */
-  KeyFrames(const KeyFrames& rhs);
-
-  /**
-   * Don't allow copy operator
-   */
-  KeyFrames& operator=(const KeyFrames& rhs);
 
   /**
    * Create a specialization from the given type, and store it to the mSpec
@@ -86,7 +70,7 @@ public:
    * @param[in] alpha An alpha function to blend between this key frame and the
    * next key frame.
    */
-  void Add(float time, Property::Value value, AlphaFunction alpha);
+  void Add(float time, const Property::Value& value, AlphaFunction alpha);
 
   /**
    * Return the key frames without specialization. The GetSpecialization methods
@@ -100,22 +84,18 @@ public:
   Dali::Property::Value GetLastKeyFrameValue() const;
 
 private:
-  Dali::Property::Type mType; // Type of the specialization
-  IntrusivePtr<KeyFrameSpec> mKeyFrames;   // Pointer to the specialized key frame object
+  Dali::Property::Type          mType{Property::NONE}; // Type of the specialization
+  std::unique_ptr<KeyFrameSpec> mKeyFrames;            // Pointer to the specialized key frame object
 };
 
-
 /**
  * This is the base class for the individual template specializations, allowing a ptr to be
- * stored in the handle object above. It inherits from RefObject to allow smart pointers
- * to be used for the specializations. Note that the derived template class below
- * allows for a copy constructor so that the specialization object can be cloned before
- * being passed to the scene-graph for animation.
+ * stored in the handle object above.
  */
-class KeyFrameSpec : public RefObject
+class KeyFrameSpec
 {
 public:
-  KeyFrameSpec() = default;
+  virtual ~KeyFrameSpec() = default;
 
   virtual std::size_t GetNumberOfKeyFrames() const = 0;
 
@@ -125,85 +105,19 @@ public:
    * @param[out] value The value of the given key frame
    */
   virtual void GetKeyFrameAsValue( std::size_t index, Property::Value& value ) = 0;
-
-protected:
-
-  /**
-   * A reference counted object may only be deleted by calling Unreference()
-   */
-  ~KeyFrameSpec() override = default;
 };
 
-
 /**
- * The base template class for each key frame specialization. It stores a vector of
- * ProgressValue pairs in mPVs, and uses the existing interface for KeyFrameChannel
- * to point at this vector.
+ * The base template class for each key frame specialization.
  */
 template<typename V>
 class KeyFrameBaseSpec : public KeyFrameSpec
 {
-private:
-  using PV          = ProgressValue<V>;
-  using PVContainer = std::vector<PV>;
-
-  PVContainer                    mPVs;       // The ProgressValue pairs
-  KeyFrameChannel<V>*            mKeyFrames; // The key frame interpolator
+  KeyFrameChannel<V> mChannel; // The key frame channel
 
 public:
-  static KeyFrameBaseSpec<V>* New()
-  {
-    return new KeyFrameBaseSpec<V>();
-  }
-
-  static KeyFrameBaseSpec<V>* Clone(const KeyFrameBaseSpec<V>& keyFrames)
-  {
-    return new KeyFrameBaseSpec<V>(keyFrames);
-  }
-
   /**
-   * Constructor
-   */
-  KeyFrameBaseSpec<V>()
-  {
-    mKeyFrames = new KeyFrameChannel<V>(KeyFrameChannelBase::Translate, mPVs);
-  }
-
-protected:
-  /**
-   * Copy Constructor
-   * Allow cloning of this object
-   */
-  KeyFrameBaseSpec<V>(const KeyFrameBaseSpec<V>& keyFrames)
-  : mPVs(keyFrames.mPVs)
-  {
-    mKeyFrames = new KeyFrameChannel<V>(KeyFrameChannelBase::Translate, mPVs);
-  }
-
-  KeyFrameBaseSpec<V>& operator=( const KeyFrameBaseSpec<V>& keyFrames )
-  {
-    if( this != &keyFrames )
-    {
-      mPVs.clear();
-      mPVs = keyFrames.mPVs;
-      delete mKeyFrames;
-      mKeyFrames = new KeyFrameChannel<V>(KeyFrameChannelBase::Translate, mPVs);
-    }
-    return *this;
-  }
-
-  /**
-   * Destructor. Ensure progress value pairs are cleared down
-   */
-  ~KeyFrameBaseSpec<V>() override
-  {
-    delete mKeyFrames;
-    mPVs.clear();
-  }
-
-public:
-  /**
-   * Add a key frame to the progress value vector. Key frames should be added
+   * Add a key frame to the channel. Key frames should be added
    * in time order (this method does not sort the vector by time)
    * @param[in] t - progress
    * @param[in] v - value
@@ -211,16 +125,16 @@ public:
    */
   void AddKeyFrame(float t, V v, AlphaFunction alpha)
   {
-    mPVs.push_back(PV(t, v));
+    mChannel.mValues.push_back({t, v});
   }
 
   /**
    * Get the number of key frames
-   * @return The size of the progress value vector
+   * @return Channel size
    */
   std::size_t GetNumberOfKeyFrames() const override
   {
-    return mPVs.size();
+    return mChannel.mValues.size();
   }
 
   /**
@@ -229,11 +143,12 @@ public:
    * @param[out] time The progress of the given key frame
    * @param[out] value The value of the given key frame
    */
-  virtual void GetKeyFrame(unsigned int index, float& time, V& value) const
+  void GetKeyFrame(unsigned int index, float& time, V& value) const
   {
-    DALI_ASSERT_ALWAYS( index < mPVs.size() && "KeyFrame index is out of bounds" );
-    time  = mPVs[index].mProgress;
-    value = mPVs[index].mValue;
+    DALI_ASSERT_ALWAYS(index < mChannel.mValues.size() && "KeyFrame index is out of bounds");
+    const auto& element = mChannel.mValues[index];
+    time                = element.mProgress;
+    value               = element.mValue;
   }
 
   /**
@@ -241,7 +156,7 @@ public:
    */
   void GetKeyFrameAsValue( std::size_t index, Property::Value& value ) override
   {
-    value = mPVs[index].mValue;
+    value = mChannel.mValues[index].mValue;
   }
 
   /**
@@ -252,7 +167,7 @@ public:
    */
   bool IsActive(float progress) const
   {
-    return mKeyFrames->IsActive(progress);
+    return mChannel.IsActive(progress);
   }
 
   /**
@@ -262,7 +177,7 @@ public:
    */
   V GetValue(float progress, Dali::Animation::Interpolation interpolation) const
   {
-    return mKeyFrames->GetValue(progress, interpolation);
+    return mChannel.GetValue(progress, interpolation);
   }
 };
 
@@ -274,82 +189,10 @@ using KeyFrameVector3    = KeyFrameBaseSpec<Vector3>;
 using KeyFrameVector4    = KeyFrameBaseSpec<Vector4>;
 using KeyFrameQuaternion = KeyFrameBaseSpec<Quaternion>;
 
-using KeyFrameBooleanPtr    = IntrusivePtr<KeyFrameBoolean>;
-using KeyFrameNumberPtr     = IntrusivePtr<KeyFrameNumber>;
-using KeyFrameIntegerPtr    = IntrusivePtr<KeyFrameInteger>;
-using KeyFrameVector2Ptr    = IntrusivePtr<KeyFrameVector2>;
-using KeyFrameVector3Ptr    = IntrusivePtr<KeyFrameVector3>;
-using KeyFrameVector4Ptr    = IntrusivePtr<KeyFrameVector4>;
-using KeyFrameQuaternionPtr = IntrusivePtr<KeyFrameQuaternion>;
-
-inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameBoolean*& keyFrameSpec)
-{
-  keyFrameSpec = static_cast<Internal::KeyFrameBoolean*>(keyFrames.GetKeyFramesBase());
-}
-
-inline void GetSpecialization(const Internal::KeyFrames& keyFrames, const Internal::KeyFrameBoolean*& keyFrameSpec)
-{
-  keyFrameSpec = static_cast<const Internal::KeyFrameBoolean*>(keyFrames.GetKeyFramesBase());
-}
-
-inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameNumber*& keyFrameSpec)
-{
-  keyFrameSpec = static_cast<Internal::KeyFrameNumber*>(keyFrames.GetKeyFramesBase());
-}
-
-inline void GetSpecialization(const Internal::KeyFrames& keyFrames, const Internal::KeyFrameNumber*& keyFrameSpec)
-{
-  keyFrameSpec = static_cast<const Internal::KeyFrameNumber*>(keyFrames.GetKeyFramesBase());
-}
-
-inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameInteger*& keyFrameSpec)
-{
-  keyFrameSpec = static_cast<Internal::KeyFrameInteger*>(keyFrames.GetKeyFramesBase());
-}
-
-inline void GetSpecialization(const Internal::KeyFrames& keyFrames, const Internal::KeyFrameInteger*& keyFrameSpec)
-{
-  keyFrameSpec = static_cast<const Internal::KeyFrameInteger*>(keyFrames.GetKeyFramesBase());
-}
-
-inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameVector2*& keyFrameSpec)
-{
-  keyFrameSpec = static_cast<Internal::KeyFrameVector2*>(keyFrames.GetKeyFramesBase());
-}
-
-inline void GetSpecialization(const Internal::KeyFrames& keyFrames, const Internal::KeyFrameVector2*& keyFrameSpec)
-{
-  keyFrameSpec = static_cast<const Internal::KeyFrameVector2*>(keyFrames.GetKeyFramesBase());
-}
-
-inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameVector3*& keyFrameSpec)
-{
-  keyFrameSpec = static_cast<Internal::KeyFrameVector3*>(keyFrames.GetKeyFramesBase());
-}
-
-inline void GetSpecialization(const Internal::KeyFrames& keyFrames, const Internal::KeyFrameVector3*& keyFrameSpec)
-{
-  keyFrameSpec = static_cast<const Internal::KeyFrameVector3*>(keyFrames.GetKeyFramesBase());
-}
-
-inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameVector4*& keyFrameSpec)
-{
-  keyFrameSpec = static_cast<Internal::KeyFrameVector4*>(keyFrames.GetKeyFramesBase());
-}
-
-inline void GetSpecialization(const Internal::KeyFrames& keyFrames, const Internal::KeyFrameVector4*& keyFrameSpec)
-{
-  keyFrameSpec = static_cast<const Internal::KeyFrameVector4*>(keyFrames.GetKeyFramesBase());
-}
-
-inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameQuaternion*& keyFrameSpec)
-{
-  keyFrameSpec = static_cast<Internal::KeyFrameQuaternion*>(keyFrames.GetKeyFramesBase());
-}
-
-inline void GetSpecialization(const Internal::KeyFrames& keyFrames, const Internal::KeyFrameQuaternion*& keyFrameSpec)
+template<typename DeriveClass>
+auto GetSpecialization(const Internal::KeyFrames& keyFrames)
 {
-  keyFrameSpec = static_cast<const Internal::KeyFrameQuaternion*>(keyFrames.GetKeyFramesBase());
+  return static_cast<DeriveClass>(keyFrames.GetKeyFramesBase());
 }
 
 } // Internal
index 56ed6c4..3ff3144 100644 (file)
@@ -20,6 +20,7 @@
 
 // EXTERNAL INCLUDES
 #include <cmath>
+#include <functional>
 
 // INTERNAL INCLUDES
 #include <dali/public-api/animation/alpha-function.h>
@@ -45,59 +46,6 @@ namespace Internal
 
 using Interpolation = Dali::Animation::Interpolation;
 
-/**
- * AnimatorFunction base class.
- * Needs to be declared first so AnimatorBase knows about it's destructor
- * All update functions must inherit from AnimatorFunctionBase and overload the appropiate "()" operator
- */
-struct AnimatorFunctionBase
-{
-  /**
-   * Constructor
-   */
-  AnimatorFunctionBase() = default;
-
-  /*
-   * Virtual destructor (Intended as base class)
-   */
-  virtual ~AnimatorFunctionBase() = default;
-
-  ///Stub "()" operators.
-  virtual bool operator()(float progress, const bool& property)
-  {
-    return property;
-  }
-
-  virtual float operator()(float progress, const int32_t& property)
-  {
-    return static_cast<float>( property );
-  }
-
-  virtual float operator()(float progress, const float& property)
-  {
-    return property;
-  }
-
-  virtual Vector2 operator()(float progress, const Vector2& property)
-  {
-    return property;
-  }
-
-  virtual Vector3 operator()(float progress, const Vector3& property)
-  {
-    return property;
-  }
-
-  virtual Vector4 operator()(float progress, const Vector4& property)
-  {
-    return property;
-  }
-
-  virtual Quaternion operator()(float progress, const Quaternion& property)
-  {
-    return property;
-  }
-};
 
 namespace SceneGraph
 {
@@ -135,17 +83,14 @@ public:
    * Constructor.
    */
   AnimatorBase( PropertyOwner* propertyOwner,
-                AnimatorFunctionBase* animatorFunction,
                 AlphaFunction alphaFunction,
                 const TimePeriod& timePeriod )
   : mLifecycleObserver( nullptr ),
     mPropertyOwner( propertyOwner ),
-    mAnimatorFunction( animatorFunction ),
     mDurationSeconds( timePeriod.durationSeconds ),
     mIntervalDelaySeconds( timePeriod.delaySeconds ),
     mSpeedFactor( 1.0f ),
     mCurrentProgress( 0.f ),
-    mLoopCount( 1 ),
     mAlphaFunction( alphaFunction ),
     mDisconnectAction( Dali::Animation::BAKE_FINAL ),
     mAnimationPlaying( false ),
@@ -160,7 +105,6 @@ public:
    */
   ~AnimatorBase() override
   {
-    delete mAnimatorFunction;
     if (mPropertyOwner && mConnectedToSceneGraph)
     {
       mPropertyOwner->RemoveObserver(*this);
@@ -560,16 +504,15 @@ protected:
 
   LifecycleObserver* mLifecycleObserver;
   PropertyOwner* mPropertyOwner;
-  AnimatorFunctionBase* mAnimatorFunction;
+
   float mDurationSeconds;
   float mIntervalDelaySeconds;
   float mSpeedFactor;
   float mCurrentProgress;
 
-  int32_t mLoopCount;
-
   AlphaFunction mAlphaFunction;
 
+  int32_t                    mLoopCount{1};
   Dali::Animation::EndAction mDisconnectAction;     ///< EndAction to apply when target object gets disconnected from the stage.
   bool mAnimationPlaying:1;                         ///< whether disconnect has been applied while it's running.
   bool mEnabled:1;                                  ///< Animator is "enabled" while its target object is valid and on the stage.
@@ -580,9 +523,13 @@ protected:
 /**
  * An animator for a specific property type PropertyType.
  */
-template < typename PropertyType, typename PropertyAccessorType >
-class Animator : public AnimatorBase
+template<typename PropertyType, typename PropertyAccessorType>
+class Animator final : public AnimatorBase
 {
+  using AnimatorFunction = std::function<PropertyType(float, const PropertyType&)>;
+
+  AnimatorFunction mAnimatorFunction;
+
 public:
 
   /**
@@ -593,26 +540,21 @@ public:
    * @param[in] timePeriod The time period of this animation.
    * @return A newly allocated animator.
    */
-  static AnimatorBase* New( const PropertyOwner& propertyOwner,
-                            const PropertyBase& property,
-                            AnimatorFunctionBase* animatorFunction,
-                            AlphaFunction alphaFunction,
-                            const TimePeriod& timePeriod )
+  static AnimatorBase* New(const PropertyOwner& propertyOwner,
+                           const PropertyBase&  property,
+                           AnimatorFunction     animatorFunction,
+                           AlphaFunction        alphaFunction,
+                           const TimePeriod&    timePeriod)
   {
     // The property was const in the actor-thread, but animators are used in the scene-graph thread.
-    return new Animator( const_cast<PropertyOwner*>( &propertyOwner ),
-                                  const_cast<PropertyBase*>( &property ),
-                                  animatorFunction,
-                                  alphaFunction,
-                                  timePeriod );
+    return new Animator(const_cast<PropertyOwner*>(&propertyOwner),
+                        const_cast<PropertyBase*>(&property),
+                        std::move(animatorFunction),
+                        alphaFunction,
+                        timePeriod);
   }
 
   /**
-   * Virtual destructor.
-   */
-  ~Animator() override = default;
-
-  /**
    * @copydoc AnimatorBase::DoUpdate( BufferIndex bufferIndex, bool bake, float alpha )
    */
   void DoUpdate( BufferIndex bufferIndex, bool bake, float alpha ) final
@@ -620,7 +562,7 @@ public:
     const PropertyType& current = mPropertyAccessor.Get( bufferIndex );
 
     // need to cast the return value in case property is integer
-    const PropertyType result = static_cast<PropertyType>( (*mAnimatorFunction)( alpha, current ) );
+    const PropertyType result = static_cast<PropertyType>(mAnimatorFunction(alpha, current));
 
     if ( bake )
     {
@@ -637,13 +579,14 @@ private:
   /**
    * Private constructor; see also Animator::New().
    */
-  Animator( PropertyOwner* propertyOwner,
-            PropertyBase* property,
-            AnimatorFunctionBase* animatorFunction,
-            AlphaFunction alphaFunction,
-            const TimePeriod& timePeriod )
-  : AnimatorBase( propertyOwner, animatorFunction, alphaFunction, timePeriod ),
-    mPropertyAccessor( property )
+  Animator(PropertyOwner*    propertyOwner,
+           PropertyBase*     property,
+           AnimatorFunction  animatorFunction,
+           AlphaFunction     alphaFunction,
+           const TimePeriod& timePeriod)
+  : AnimatorBase(propertyOwner, alphaFunction, timePeriod),
+    mAnimatorFunction(std::move(animatorFunction)),
+    mPropertyAccessor(property)
   {
     // WARNING - this object is created in the event-thread
     // The scene-graph mPropertyOwner object cannot be observed here
@@ -666,9 +609,13 @@ protected:
 /**
  * An animator for a specific property type PropertyType.
  */
-template <typename PropertyType, typename PropertyAccessorType>
-class AnimatorTransformProperty : public AnimatorBase
+template<typename PropertyType, typename PropertyAccessorType>
+class AnimatorTransformProperty final : public AnimatorBase
 {
+  using AnimatorFunction = std::function<PropertyType(float, const PropertyType&)>;
+
+  AnimatorFunction mAnimatorFunction;
+
 public:
 
   /**
@@ -679,27 +626,22 @@ public:
    * @param[in] timePeriod The time period of this animation.
    * @return A newly allocated animator.
    */
-  static AnimatorBase* New( const PropertyOwner& propertyOwner,
-                            const PropertyBase& property,
-                            AnimatorFunctionBase* animatorFunction,
-                            AlphaFunction alphaFunction,
-                            const TimePeriod& timePeriod )
+  static AnimatorBase* New(const PropertyOwner& propertyOwner,
+                           const PropertyBase&  property,
+                           AnimatorFunction     animatorFunction,
+                           AlphaFunction        alphaFunction,
+                           const TimePeriod&    timePeriod)
   {
 
     // The property was const in the actor-thread, but animators are used in the scene-graph thread.
-    return new AnimatorTransformProperty( const_cast<PropertyOwner*>( &propertyOwner ),
-                                                                         const_cast<PropertyBase*>( &property ),
-                                                                         animatorFunction,
-                                                                         alphaFunction,
-                                                                         timePeriod );
+    return new AnimatorTransformProperty(const_cast<PropertyOwner*>(&propertyOwner),
+                                         const_cast<PropertyBase*>(&property),
+                                         std::move(animatorFunction),
+                                         alphaFunction,
+                                         timePeriod);
   }
 
   /**
-   * Virtual destructor.
-   */
-  ~AnimatorTransformProperty() override = default;
-
-  /**
    * @copydoc AnimatorBase::DoUpdate( BufferIndex bufferIndex, bool bake, float alpha )
    */
   void DoUpdate( BufferIndex bufferIndex, bool bake, float alpha ) final
@@ -707,7 +649,7 @@ public:
     const PropertyType& current = mPropertyAccessor.Get( bufferIndex );
 
     // need to cast the return value in case property is integer
-    const PropertyType result = static_cast<PropertyType>( (*mAnimatorFunction)( alpha, current ) );
+    const PropertyType result = static_cast<PropertyType>(mAnimatorFunction(alpha, current));
 
     if ( bake )
     {
@@ -724,13 +666,14 @@ private:
   /**
    * Private constructor; see also Animator::New().
    */
-  AnimatorTransformProperty( PropertyOwner* propertyOwner,
-            PropertyBase* property,
-            AnimatorFunctionBase* animatorFunction,
-            AlphaFunction alphaFunction,
-            const TimePeriod& timePeriod )
-  : AnimatorBase( propertyOwner, animatorFunction, alphaFunction, timePeriod ),
-    mPropertyAccessor( property )
+  AnimatorTransformProperty(PropertyOwner*    propertyOwner,
+                            PropertyBase*     property,
+                            AnimatorFunction  animatorFunction,
+                            AlphaFunction     alphaFunction,
+                            const TimePeriod& timePeriod)
+  : AnimatorBase(propertyOwner, alphaFunction, timePeriod),
+    mAnimatorFunction(std::move(animatorFunction)),
+    mPropertyAccessor(property)
   {
     // WARNING - this object is created in the event-thread
     // The scene-graph mPropertyOwner object cannot be observed here
@@ -751,15 +694,14 @@ protected:
 
 // Update functions
 
-struct AnimateByInteger : public AnimatorFunctionBase
+struct AnimateByInteger
 {
   AnimateByInteger(const int& relativeValue)
   : mRelative(relativeValue)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  float operator()(float alpha, const int32_t& property) override
+  float operator()(float alpha, const int32_t& property)
   {
     // integers need to be correctly rounded
     return roundf(static_cast<float>( property ) + static_cast<float>( mRelative ) * alpha );
@@ -768,15 +710,14 @@ struct AnimateByInteger : public AnimatorFunctionBase
   int32_t mRelative;
 };
 
-struct AnimateToInteger : public AnimatorFunctionBase
+struct AnimateToInteger
 {
   AnimateToInteger(const int& targetValue)
   : mTarget(targetValue)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  float operator()(float alpha, const int32_t& property) override
+  float operator()(float alpha, const int32_t& property)
   {
     // integers need to be correctly rounded
     return roundf(static_cast<float>( property ) + (static_cast<float>(mTarget - property) * alpha) );
@@ -785,15 +726,14 @@ struct AnimateToInteger : public AnimatorFunctionBase
   int32_t mTarget;
 };
 
-struct AnimateByFloat : public AnimatorFunctionBase
+struct AnimateByFloat
 {
   AnimateByFloat(const float& relativeValue)
   : mRelative(relativeValue)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  float operator()(float alpha, const float& property) override
+  float operator()(float alpha, const float& property)
   {
     return float(property + mRelative * alpha);
   }
@@ -801,15 +741,14 @@ struct AnimateByFloat : public AnimatorFunctionBase
   float mRelative;
 };
 
-struct AnimateToFloat : public AnimatorFunctionBase
+struct AnimateToFloat
 {
   AnimateToFloat(const float& targetValue)
   : mTarget(targetValue)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  float operator()(float alpha, const float& property) override
+  float operator()(float alpha, const float& property)
   {
     return float(property + ((mTarget - property) * alpha));
   }
@@ -817,15 +756,14 @@ struct AnimateToFloat : public AnimatorFunctionBase
   float mTarget;
 };
 
-struct AnimateByVector2 : public AnimatorFunctionBase
+struct AnimateByVector2
 {
   AnimateByVector2(const Vector2& relativeValue)
   : mRelative(relativeValue)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  Vector2 operator()(float alpha, const Vector2& property) override
+  Vector2 operator()(float alpha, const Vector2& property)
   {
     return Vector2(property + mRelative * alpha);
   }
@@ -833,15 +771,14 @@ struct AnimateByVector2 : public AnimatorFunctionBase
   Vector2 mRelative;
 };
 
-struct AnimateToVector2 : public AnimatorFunctionBase
+struct AnimateToVector2
 {
   AnimateToVector2(const Vector2& targetValue)
   : mTarget(targetValue)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  Vector2 operator()(float alpha, const Vector2& property) override
+  Vector2 operator()(float alpha, const Vector2& property)
   {
     return Vector2(property + ((mTarget - property) * alpha));
   }
@@ -849,15 +786,14 @@ struct AnimateToVector2 : public AnimatorFunctionBase
   Vector2 mTarget;
 };
 
-struct AnimateByVector3 : public AnimatorFunctionBase
+struct AnimateByVector3
 {
   AnimateByVector3(const Vector3& relativeValue)
   : mRelative(relativeValue)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  Vector3 operator()(float alpha, const Vector3& property) override
+  Vector3 operator()(float alpha, const Vector3& property)
   {
     return Vector3(property + mRelative * alpha);
   }
@@ -865,15 +801,14 @@ struct AnimateByVector3 : public AnimatorFunctionBase
   Vector3 mRelative;
 };
 
-struct AnimateToVector3 : public AnimatorFunctionBase
+struct AnimateToVector3
 {
   AnimateToVector3(const Vector3& targetValue)
   : mTarget(targetValue)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  Vector3 operator()(float alpha, const Vector3& property) override
+  Vector3 operator()(float alpha, const Vector3& property)
   {
     return Vector3(property + ((mTarget - property) * alpha));
   }
@@ -881,15 +816,14 @@ struct AnimateToVector3 : public AnimatorFunctionBase
   Vector3 mTarget;
 };
 
-struct AnimateByVector4 : public AnimatorFunctionBase
+struct AnimateByVector4
 {
   AnimateByVector4(const Vector4& relativeValue)
   : mRelative(relativeValue)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  Vector4 operator()(float alpha, const Vector4& property) override
+  Vector4 operator()(float alpha, const Vector4& property)
   {
     return Vector4(property + mRelative * alpha);
   }
@@ -897,15 +831,14 @@ struct AnimateByVector4 : public AnimatorFunctionBase
   Vector4 mRelative;
 };
 
-struct AnimateToVector4 : public AnimatorFunctionBase
+struct AnimateToVector4
 {
   AnimateToVector4(const Vector4& targetValue)
   : mTarget(targetValue)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  Vector4 operator()(float alpha, const Vector4& property) override
+  Vector4 operator()(float alpha, const Vector4& property)
   {
     return Vector4(property + ((mTarget - property) * alpha));
   }
@@ -913,15 +846,14 @@ struct AnimateToVector4 : public AnimatorFunctionBase
   Vector4 mTarget;
 };
 
-struct AnimateByOpacity : public AnimatorFunctionBase
+struct AnimateByOpacity
 {
   AnimateByOpacity(const float& relativeValue)
   : mRelative(relativeValue)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  Vector4 operator()(float alpha, const Vector4& property) override
+  Vector4 operator()(float alpha, const Vector4& property)
   {
     Vector4 result(property);
     result.a += mRelative * alpha;
@@ -932,15 +864,14 @@ struct AnimateByOpacity : public AnimatorFunctionBase
   float mRelative;
 };
 
-struct AnimateToOpacity : public AnimatorFunctionBase
+struct AnimateToOpacity
 {
   AnimateToOpacity(const float& targetValue)
   : mTarget(targetValue)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  Vector4 operator()(float alpha, const Vector4& property) override
+  Vector4 operator()(float alpha, const Vector4& property)
   {
     Vector4 result(property);
     result.a = property.a + ((mTarget - property.a) * alpha);
@@ -951,15 +882,14 @@ struct AnimateToOpacity : public AnimatorFunctionBase
   float mTarget;
 };
 
-struct AnimateByBoolean : public AnimatorFunctionBase
+struct AnimateByBoolean
 {
   AnimateByBoolean(bool relativeValue)
   : mRelative(relativeValue)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  bool operator()(float alpha, const bool& property) override
+  bool operator()(float alpha, const bool& property)
   {
     // Alpha is not useful here, just keeping to the same template as other update functors
     return bool(alpha >= 1.0f ? (property || mRelative) : property);
@@ -968,15 +898,14 @@ struct AnimateByBoolean : public AnimatorFunctionBase
   bool mRelative;
 };
 
-struct AnimateToBoolean : public AnimatorFunctionBase
+struct AnimateToBoolean
 {
   AnimateToBoolean(bool targetValue)
   : mTarget(targetValue)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  bool operator()(float alpha, const bool& property) override
+  bool operator()(float alpha, const bool& property)
   {
     // Alpha is not useful here, just keeping to the same template as other update functors
     return bool(alpha >= 1.0f ? mTarget : property);
@@ -985,7 +914,7 @@ struct AnimateToBoolean : public AnimatorFunctionBase
   bool mTarget;
 };
 
-struct RotateByAngleAxis : public AnimatorFunctionBase
+struct RotateByAngleAxis
 {
   RotateByAngleAxis(const Radian& angleRadians, const Vector3& axis)
   : mAngleRadians( angleRadians ),
@@ -993,8 +922,7 @@ struct RotateByAngleAxis : public AnimatorFunctionBase
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  Quaternion operator()(float alpha, const Quaternion& rotation) override
+  Quaternion operator()(float alpha, const Quaternion& rotation)
   {
     if (alpha > 0.0f)
     {
@@ -1008,15 +936,14 @@ struct RotateByAngleAxis : public AnimatorFunctionBase
   Vector3 mAxis;
 };
 
-struct RotateToQuaternion : public AnimatorFunctionBase
+struct RotateToQuaternion
 {
   RotateToQuaternion(const Quaternion& targetValue)
   : mTarget(targetValue)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  Quaternion operator()(float alpha, const Quaternion& rotation) override
+  Quaternion operator()(float alpha, const Quaternion& rotation)
   {
     return Quaternion::Slerp(rotation, mTarget, alpha);
   }
@@ -1024,162 +951,157 @@ struct RotateToQuaternion : public AnimatorFunctionBase
   Quaternion mTarget;
 };
 
-
-struct KeyFrameBooleanFunctor : public AnimatorFunctionBase
+struct KeyFrameBooleanFunctor
 {
-  KeyFrameBooleanFunctor(KeyFrameBooleanPtr keyFrames)
-  : mKeyFrames(keyFrames)
+  KeyFrameBooleanFunctor(KeyFrameBoolean keyFrames)
+  : mKeyFrames(std::move(keyFrames))
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  bool operator()(float progress, const bool& property) override
+  bool operator()(float progress, const bool& property)
   {
-    if(mKeyFrames->IsActive(progress))
+    if(mKeyFrames.IsActive(progress))
     {
-      return mKeyFrames->GetValue(progress, Dali::Animation::LINEAR);
+      return mKeyFrames.GetValue(progress, Dali::Animation::LINEAR);
     }
     return property;
   }
 
-  KeyFrameBooleanPtr mKeyFrames;
+  KeyFrameBoolean mKeyFrames;
 };
 
-struct KeyFrameIntegerFunctor : public AnimatorFunctionBase
+struct KeyFrameIntegerFunctor
 {
-  KeyFrameIntegerFunctor(KeyFrameIntegerPtr keyFrames, Interpolation interpolation)
-  : mKeyFrames(keyFrames),mInterpolation(interpolation)
+  KeyFrameIntegerFunctor(KeyFrameInteger keyFrames, Interpolation interpolation)
+  : mKeyFrames(std::move(keyFrames)),
+    mInterpolation(interpolation)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  float operator()(float progress, const int32_t& property) override
+  float operator()(float progress, const int32_t& property)
   {
-    if(mKeyFrames->IsActive(progress))
+    if(mKeyFrames.IsActive(progress))
     {
-      return static_cast<float>( mKeyFrames->GetValue(progress, mInterpolation) );
+      return static_cast<float>(mKeyFrames.GetValue(progress, mInterpolation));
     }
     return static_cast<float>( property );
   }
 
-  KeyFrameIntegerPtr mKeyFrames;
+  KeyFrameInteger mKeyFrames;
   Interpolation mInterpolation;
 };
 
-struct KeyFrameNumberFunctor : public AnimatorFunctionBase
+struct KeyFrameNumberFunctor
 {
-  KeyFrameNumberFunctor(KeyFrameNumberPtr keyFrames, Interpolation interpolation)
-  : mKeyFrames(keyFrames),mInterpolation(interpolation)
+  KeyFrameNumberFunctor(KeyFrameNumber keyFrames, Interpolation interpolation)
+  : mKeyFrames(std::move(keyFrames)),
+    mInterpolation(interpolation)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  float operator()(float progress, const float& property) override
+  float operator()(float progress, const float& property)
   {
-    if(mKeyFrames->IsActive(progress))
+    if(mKeyFrames.IsActive(progress))
     {
-      return mKeyFrames->GetValue(progress, mInterpolation);
+      return mKeyFrames.GetValue(progress, mInterpolation);
     }
     return property;
   }
 
-  KeyFrameNumberPtr mKeyFrames;
+  KeyFrameNumber mKeyFrames;
   Interpolation mInterpolation;
 };
 
-struct KeyFrameVector2Functor : public AnimatorFunctionBase
+struct KeyFrameVector2Functor
 {
-  KeyFrameVector2Functor(KeyFrameVector2Ptr keyFrames, Interpolation interpolation)
-  : mKeyFrames(keyFrames),mInterpolation(interpolation)
+  KeyFrameVector2Functor(KeyFrameVector2 keyFrames, Interpolation interpolation)
+  : mKeyFrames(std::move(keyFrames)),
+    mInterpolation(interpolation)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  Vector2 operator()(float progress, const Vector2& property) override
+  Vector2 operator()(float progress, const Vector2& property)
   {
-    if(mKeyFrames->IsActive(progress))
+    if(mKeyFrames.IsActive(progress))
     {
-      return mKeyFrames->GetValue(progress, mInterpolation);
+      return mKeyFrames.GetValue(progress, mInterpolation);
     }
     return property;
   }
 
-  KeyFrameVector2Ptr mKeyFrames;
+  KeyFrameVector2 mKeyFrames;
   Interpolation mInterpolation;
 };
 
-
-struct KeyFrameVector3Functor : public AnimatorFunctionBase
+struct KeyFrameVector3Functor
 {
-  KeyFrameVector3Functor(KeyFrameVector3Ptr keyFrames, Interpolation interpolation)
-  : mKeyFrames(keyFrames),mInterpolation(interpolation)
+  KeyFrameVector3Functor(KeyFrameVector3 keyFrames, Interpolation interpolation)
+  : mKeyFrames(std::move(keyFrames)),
+    mInterpolation(interpolation)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  Vector3 operator()(float progress, const Vector3& property) override
+  Vector3 operator()(float progress, const Vector3& property)
   {
-    if(mKeyFrames->IsActive(progress))
+    if(mKeyFrames.IsActive(progress))
     {
-      return mKeyFrames->GetValue(progress, mInterpolation);
+      return mKeyFrames.GetValue(progress, mInterpolation);
     }
     return property;
   }
 
-  KeyFrameVector3Ptr mKeyFrames;
+  KeyFrameVector3 mKeyFrames;
   Interpolation mInterpolation;
 };
 
-struct KeyFrameVector4Functor : public AnimatorFunctionBase
+struct KeyFrameVector4Functor
 {
-  KeyFrameVector4Functor(KeyFrameVector4Ptr keyFrames, Interpolation interpolation)
-  : mKeyFrames(keyFrames),mInterpolation(interpolation)
+  KeyFrameVector4Functor(KeyFrameVector4 keyFrames, Interpolation interpolation)
+  : mKeyFrames(std::move(keyFrames)),
+    mInterpolation(interpolation)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  Vector4 operator()(float progress, const Vector4& property) override
+  Vector4 operator()(float progress, const Vector4& property)
   {
-    if(mKeyFrames->IsActive(progress))
+    if(mKeyFrames.IsActive(progress))
     {
-      return mKeyFrames->GetValue(progress, mInterpolation);
+      return mKeyFrames.GetValue(progress, mInterpolation);
     }
     return property;
   }
 
-  KeyFrameVector4Ptr mKeyFrames;
+  KeyFrameVector4 mKeyFrames;
   Interpolation mInterpolation;
 };
 
-struct KeyFrameQuaternionFunctor : public AnimatorFunctionBase
+struct KeyFrameQuaternionFunctor
 {
-  KeyFrameQuaternionFunctor(KeyFrameQuaternionPtr keyFrames)
-  : mKeyFrames(keyFrames)
+  KeyFrameQuaternionFunctor(KeyFrameQuaternion keyFrames)
+  : mKeyFrames(std::move(keyFrames))
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  Quaternion operator()(float progress, const Quaternion& property) override
+  Quaternion operator()(float progress, const Quaternion& property)
   {
-    if(mKeyFrames->IsActive(progress))
+    if(mKeyFrames.IsActive(progress))
     {
-      return mKeyFrames->GetValue(progress, Dali::Animation::LINEAR);
+      return mKeyFrames.GetValue(progress, Dali::Animation::LINEAR);
     }
     return property;
   }
 
-  KeyFrameQuaternionPtr mKeyFrames;
+  KeyFrameQuaternion mKeyFrames;
 };
 
-struct PathPositionFunctor : public AnimatorFunctionBase
+struct PathPositionFunctor
 {
   PathPositionFunctor( PathPtr path )
   : mPath(path)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  Vector3 operator()(float progress, const Vector3& property) override
+  Vector3 operator()(float progress, const Vector3& property)
   {
     Vector3 position(property);
     static_cast<void>( mPath->SamplePosition(progress, position) );
@@ -1189,7 +1111,7 @@ struct PathPositionFunctor : public AnimatorFunctionBase
   PathPtr mPath;
 };
 
-struct PathRotationFunctor : public AnimatorFunctionBase
+struct PathRotationFunctor
 {
   PathRotationFunctor( PathPtr path, const Vector3& forward )
   : mPath(path),
@@ -1198,8 +1120,7 @@ struct PathRotationFunctor : public AnimatorFunctionBase
     mForward.Normalize();
   }
 
-  using AnimatorFunctionBase::operator();
-  Quaternion operator()(float progress, const Quaternion& property) override
+  Quaternion operator()(float progress, const Quaternion& property)
   {
     Vector3 tangent;
     if( mPath->SampleTangent(progress, tangent) )
index dbf21e1..bff6040 100644 (file)
@@ -56,7 +56,7 @@ Property::Type KeyFrames::GetType() const
 
 void KeyFrames::Add(float time, Property::Value value)
 {
-  Add(time, value, AlphaFunction::DEFAULT);
+  Add(time, std::move(value), AlphaFunction::DEFAULT);
 }
 
 void KeyFrames::Add(float time, Property::Value value, AlphaFunction alpha)