Refactor SceneGraphProperty handling code in event side to make RegisterProperty...
[platform/core/uifw/dali-core.git] / dali / internal / update / animation / scene-graph-animator.h
index 9997d9d..ae18f06 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_INTERNAL_SCENE_GRAPH_ANIMATOR_H__
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  */
 
 // INTERNAL INCLUDES
-#include <dali/internal/common/owner-container.h>
-#include <dali/internal/event/animation/key-frames-impl.h>
-#include <dali/internal/event/animation/path-impl.h>
-#include <dali/internal/update/nodes/node.h>
-#include <dali/internal/update/common/property-base.h>
-#include <dali/public-api/animation/alpha-functions.h>
+#include <dali/public-api/animation/alpha-function.h>
 #include <dali/public-api/animation/animation.h>
 #include <dali/public-api/animation/time-period.h>
+#include <dali/public-api/common/constants.h>
 #include <dali/public-api/common/dali-common.h>
 #include <dali/public-api/math/quaternion.h>
 #include <dali/public-api/math/radian.h>
+#include <dali/devel-api/common/owner-container.h>
+#include <dali/internal/event/animation/key-frames-impl.h>
+#include <dali/internal/event/animation/path-impl.h>
+#include <dali/internal/update/nodes/node.h>
+#include <dali/internal/update/common/property-base.h>
+#include <dali/internal/update/animation/property-accessor.h>
+#include <dali/integration-api/debug.h>
 
 namespace Dali
 {
@@ -62,15 +65,39 @@ public:
   typedef float (*AlphaFunc)(float progress); ///< Definition of an alpha function
 
   /**
+   * Observer to determine when the animator is no longer present
+   */
+  class LifecycleObserver
+  {
+  public:
+    /**
+     * Called shortly before the animator is destroyed.
+     */
+    virtual void ObjectDestroyed() = 0;
+
+  protected:
+    /**
+     * Virtual destructor, no deletion through this interface
+     */
+    virtual ~LifecycleObserver() = default;
+  };
+
+
+  /**
    * Constructor.
    */
   AnimatorBase()
-  : mDurationSeconds(1.0f),
-    mInitialDelaySeconds(0.0f),
-    mAlphaFunc(AlphaFunctions::Linear),
+  : mLifecycleObserver(nullptr),
+    mDurationSeconds(1.0f),
+    mIntervalDelaySeconds(0.0f),
+    mSpeedFactor(1.0f),
+    mLoopCount(1),
+    mAlphaFunction(AlphaFunction::DEFAULT),
     mDisconnectAction(Dali::Animation::BakeFinal),
-    mActive(false),
-    mEnabled(true)
+    mAnimationPlaying(false),
+    mEnabled(true),
+    mConnectedToSceneGraph(false),
+    mAutoReverseEnabled( false )
   {
   }
 
@@ -79,9 +106,28 @@ public:
    */
   virtual ~AnimatorBase()
   {
+    if( mLifecycleObserver != nullptr )
+    {
+      mLifecycleObserver->ObjectDestroyed();
+    }
+  }
+
+  void AddLifecycleObserver( LifecycleObserver& observer )
+  {
+    mLifecycleObserver = &observer;
+  }
+
+  void RemoveLifecycleObserver( LifecycleObserver& observer )
+  {
+    mLifecycleObserver = nullptr;
   }
 
   /**
+   * Called when Animator is added to the scene-graph in update-thread.
+   */
+  virtual void ConnectToSceneGraph() = 0;
+
+  /**
    * Set the duration of the animator.
    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
    * @param [in] seconds Duration in seconds.
@@ -97,46 +143,210 @@ public:
    * Retrieve the duration of the animator.
    * @return The duration in seconds.
    */
-  float GetDuration()
+  float GetDuration() const
   {
     return mDurationSeconds;
   }
 
+  void SetSpeedFactor( float factor )
+  {
+    mSpeedFactor = factor;
+  }
+
+  void SetLoopCount(int32_t loopCount)
+  {
+    mLoopCount = loopCount;
+  }
+
+  float SetProgress( float progress )
+  {
+    float value = 0.0f;
+
+    if( mAutoReverseEnabled )
+    {
+      if( mSpeedFactor > 0.0f )
+      {
+        value = 1.0f - 2.0f * std::abs( progress - 0.5f );
+      }
+      // Reverse mode
+      else if( mSpeedFactor < 0.0f )
+      {
+        value = 2.0f * std::abs( progress - 0.5f );
+      }
+    }
+    else
+    {
+      value = progress;
+    }
+
+    return value;
+  }
+
   /**
    * Set the delay before the animator should take effect.
    * The default is zero i.e. no delay.
    * @param [in] seconds The delay in seconds.
    */
-  void SetInitialDelay(float seconds)
+  void SetIntervalDelay(float seconds)
   {
-    mInitialDelaySeconds = seconds;
+    mIntervalDelaySeconds = seconds;
   }
 
   /**
-   * Retrieve the initial delay of the animator.
+   * Retrieve the delay before the animator should take effect.
    * @return The delay in seconds.
    */
-  float GetInitialDelay()
+  float GetIntervalDelay() const
   {
-    return mInitialDelaySeconds;
+    return mIntervalDelaySeconds;
   }
 
   /**
    * Set the alpha function for an animator.
    * @param [in] alphaFunc The alpha function to apply to the animation progress.
    */
-  void SetAlphaFunc(AlphaFunc alphaFunc)
+  void SetAlphaFunction(const AlphaFunction& alphaFunction)
   {
-    mAlphaFunc = alphaFunc;
+    mAlphaFunction = alphaFunction;
   }
 
   /**
    * Retrieve the alpha function of an animator.
    * @return The function.
    */
-  AlphaFunc GetAlphaFunc() const
+  AlphaFunction GetAlphaFunction() const
   {
-    return mAlphaFunc;
+    return mAlphaFunction;
+  }
+
+  /**
+   * Applies the alpha function to the specified progress
+   * @param[in] Current progress
+   * @return The progress after the alpha function has been aplied
+   */
+  float ApplyAlphaFunction( float progress ) const
+  {
+    float result = progress;
+
+    AlphaFunction::Mode alphaFunctionMode( mAlphaFunction.GetMode() );
+    if( alphaFunctionMode == AlphaFunction::BUILTIN_FUNCTION )
+    {
+      switch(mAlphaFunction.GetBuiltinFunction())
+      {
+        case AlphaFunction::DEFAULT:
+        case AlphaFunction::LINEAR:
+        {
+          break;
+        }
+        case AlphaFunction::REVERSE:
+        {
+          result = 1.0f-progress;
+          break;
+        }
+        case AlphaFunction::EASE_IN_SQUARE:
+        {
+          result = progress * progress;
+          break;
+        }
+        case AlphaFunction::EASE_OUT_SQUARE:
+        {
+          result = 1.0f - (1.0f-progress) * (1.0f-progress);
+          break;
+        }
+        case AlphaFunction::EASE_IN:
+        {
+          result = progress * progress * progress;
+          break;
+        }
+        case AlphaFunction::EASE_OUT:
+        {
+          result = (progress-1.0f) * (progress-1.0f) * (progress-1.0f) + 1.0f;
+          break;
+        }
+        case AlphaFunction::EASE_IN_OUT:
+        {
+          result = progress*progress*(3.0f-2.0f*progress);
+          break;
+        }
+        case AlphaFunction::EASE_IN_SINE:
+        {
+          result = -1.0f * cosf(progress * Math::PI_2) + 1.0f;
+          break;
+        }
+        case AlphaFunction::EASE_OUT_SINE:
+        {
+          result = sinf(progress * Math::PI_2);
+          break;
+        }
+        case AlphaFunction::EASE_IN_OUT_SINE:
+        {
+          result = -0.5f * (cosf(Math::PI * progress) - 1.0f);
+          break;
+        }
+        case AlphaFunction::BOUNCE:
+        {
+          result = sinf(progress * Math::PI);
+          break;
+        }
+        case AlphaFunction::SIN:
+        {
+          result = 0.5f - cosf(progress * 2.0f * Math::PI) * 0.5f;
+          break;
+        }
+        case AlphaFunction::EASE_OUT_BACK:
+        {
+          const float sqrt2 = 1.70158f;
+          progress -= 1.0f;
+          result = 1.0f + progress * progress * ( ( sqrt2 + 1.0f ) * progress + sqrt2 );
+          break;
+        }
+        case AlphaFunction::COUNT:
+        {
+          break;
+        }
+      }
+    }
+    else if(  alphaFunctionMode == AlphaFunction::CUSTOM_FUNCTION )
+    {
+      AlphaFunctionPrototype customFunction = mAlphaFunction.GetCustomFunction();
+      if( customFunction )
+      {
+        result = customFunction(progress);
+      }
+    }
+    else
+    {
+      //If progress is very close to 0 or very close to 1 we don't need to evaluate the curve as the result will
+      //be almost 0 or almost 1 respectively
+      if( ( progress > Math::MACHINE_EPSILON_1 ) && ((1.0f - progress) > Math::MACHINE_EPSILON_1) )
+      {
+        Dali::Vector4 controlPoints = mAlphaFunction.GetBezierControlPoints();
+
+        static const float tolerance = 0.001f;  //10 iteration max
+
+        //Perform a binary search on the curve
+        float lowerBound(0.0f);
+        float upperBound(1.0f);
+        float currentT(0.5f);
+        float currentX = EvaluateCubicBezier( controlPoints.x, controlPoints.z, currentT);
+        while( fabsf( progress - currentX ) > tolerance )
+        {
+          if( progress > currentX )
+          {
+            lowerBound = currentT;
+          }
+          else
+          {
+            upperBound = currentT;
+          }
+          currentT = (upperBound+lowerBound)*0.5f;
+          currentX = EvaluateCubicBezier( controlPoints.x, controlPoints.z, currentT);
+        }
+        result = EvaluateCubicBezier( controlPoints.y, controlPoints.w, currentT);
+      }
+    }
+
+    return result;
   }
 
   /**
@@ -166,19 +376,10 @@ public:
    */
   void SetActive( bool active )
   {
-    mActive = active;
+    mAnimationPlaying = active;
   }
 
   /**
-   * Retrieve whether the animator has been set to active or not.
-   * @return The active state.
-   */
-  bool GetActive() const
-  {
-    return mActive;
-  }
-
-  /*
    * Retrive wheter the animator's target object is valid and on the stage.
    * @return The enabled state.
    */
@@ -186,6 +387,16 @@ public:
   {
     return mEnabled;
   }
+
+  /**
+   * @brief Sets the looping mode.
+   * @param[in] loopingMode True when the looping mode is AUTO_REVERSE
+   */
+  void SetLoopingMode( bool loopingMode )
+  {
+    mAutoReverseEnabled = loopingMode;
+  }
+
   /**
    * Returns wheter the target object of the animator is still valid
    * or has been destroyed.
@@ -204,14 +415,33 @@ public:
 
 protected:
 
+  /**
+   * Helper function to evaluate a cubic bezier curve assuming first point is at 0.0 and last point is at 1.0
+   * @param[in] p0 First control point of the bezier curve
+   * @param[in] p1 Second control point of the bezier curve
+   * @param[in] t A floating point value between 0.0 and 1.0
+   * @return Value of the curve at progress t
+   */
+  inline float EvaluateCubicBezier( float p0, float p1, float t ) const
+  {
+    float tSquare = t*t;
+    return 3.0f*(1.0f-t)*(1.0f-t)*t*p0 + 3.0f*(1.0f-t)*tSquare*p1 + tSquare*t;
+  }
+
+  LifecycleObserver* mLifecycleObserver;
   float mDurationSeconds;
-  float mInitialDelaySeconds;
+  float mIntervalDelaySeconds;
+  float mSpeedFactor;
+
+  int32_t mLoopCount;
 
-  AlphaFunc mAlphaFunc;
+  AlphaFunction mAlphaFunction;
 
   Dali::Animation::EndAction mDisconnectAction;     ///< EndAction to apply when target object gets disconnected from the stage.
-  bool mActive:1;                                   ///< Animator is "active" while it's running.
+  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.
+  bool mConnectedToSceneGraph:1;                    ///< True if ConnectToSceneGraph() has been called in update-thread.
+  bool mAutoReverseEnabled:1;
 };
 
 /**
@@ -243,8 +473,8 @@ public:
                                                const_cast<PropertyBase*>( &property ),
                                                animatorFunction );
 
-    animator->SetAlphaFunc( alphaFunction );
-    animator->SetInitialDelay( timePeriod.delaySeconds );
+    animator->SetAlphaFunction( alphaFunction );
+    animator->SetIntervalDelay( timePeriod.delaySeconds );
     animator->SetDuration( timePeriod.durationSeconds );
 
     return animator;
@@ -255,15 +485,21 @@ public:
    */
   virtual ~Animator()
   {
-    if (mPropertyOwner)
+    if (mPropertyOwner && mConnectedToSceneGraph)
     {
       mPropertyOwner->RemoveObserver(*this);
     }
 
-    if( mAnimatorFunction )
-    {
-      delete mAnimatorFunction;
-    }
+    delete mAnimatorFunction;
+  }
+
+  /**
+   * Called when Animator is added to the scene-graph in update-thread.
+   */
+  virtual void ConnectToSceneGraph()
+  {
+    mConnectedToSceneGraph = true;
+    mPropertyOwner->AddObserver(*this);
   }
 
   /**
@@ -280,13 +516,12 @@ public:
   virtual void PropertyOwnerDisconnected( BufferIndex bufferIndex, PropertyOwner& owner )
   {
     // If we are active, then bake the value if required
-    if ( mActive && mDisconnectAction != Dali::Animation::Discard )
+    if ( mAnimationPlaying && mDisconnectAction != Dali::Animation::Discard )
     {
       // Bake to target-value if BakeFinal, otherwise bake current value
       Update( bufferIndex, ( mDisconnectAction == Dali::Animation::Bake ? mCurrentProgress : 1.0f ), true );
     }
 
-    mActive = false;
     mEnabled = false;
   }
 
@@ -296,8 +531,6 @@ public:
   virtual void PropertyOwnerDestroyed( PropertyOwner& owner )
   {
     mPropertyOwner = NULL;
-    mPropertyAccessor.Reset();
-    mEnabled = false;
   }
 
   /**
@@ -305,10 +538,18 @@ public:
    */
   virtual void Update( BufferIndex bufferIndex, float progress, bool bake )
   {
-    float alpha = mAlphaFunc( progress );
+    if( mLoopCount >= 0 )
+    {
+      // Update the progress value
+      progress = SetProgress( progress );
+    }
+
+    float alpha = ApplyAlphaFunction( progress );
+
     const PropertyType& current = mPropertyAccessor.Get( bufferIndex );
 
-    const PropertyType result = (*mAnimatorFunction)( alpha, current );
+    // need to cast the return value in case property is integer
+    const PropertyType result = static_cast<PropertyType>( (*mAnimatorFunction)( alpha, current ) );
     if ( bake )
     {
       mPropertyAccessor.Bake( bufferIndex, result );
@@ -342,7 +583,8 @@ private:
     mAnimatorFunction( animatorFunction ),
     mCurrentProgress( 0.0f )
   {
-    mPropertyOwner->AddObserver(*this);
+    // WARNING - this object is created in the event-thread
+    // The scene-graph mPropertyOwner object cannot be observed here
   }
 
   // Undefined
@@ -360,6 +602,166 @@ protected:
   float mCurrentProgress;
 };
 
+
+
+/**
+ * An animator for a specific property type PropertyType.
+ */
+template <typename T, typename PropertyAccessorType>
+class AnimatorTransformProperty : public AnimatorBase, public PropertyOwner::Observer
+{
+public:
+
+  /**
+   * Construct a new property animator.
+   * @param[in] property The animatable property; only valid while the Animator is attached.
+   * @param[in] animatorFunction The function used to animate the property.
+   * @param[in] alphaFunction The alpha function to apply.
+   * @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 )
+  {
+
+    // The property was const in the actor-thread, but animators are used in the scene-graph thread.
+    AnimatorTransformProperty* animator = new AnimatorTransformProperty( const_cast<PropertyOwner*>( &propertyOwner ),
+                                               const_cast<PropertyBase*>( &property ),
+                                               animatorFunction );
+
+    animator->SetAlphaFunction( alphaFunction );
+    animator->SetIntervalDelay( timePeriod.delaySeconds );
+    animator->SetDuration( timePeriod.durationSeconds );
+
+    return animator;
+  }
+
+  /**
+   * Virtual destructor.
+   */
+  virtual ~AnimatorTransformProperty()
+  {
+    if (mPropertyOwner && mConnectedToSceneGraph)
+    {
+      mPropertyOwner->RemoveObserver(*this);
+    }
+
+    delete mAnimatorFunction;
+  }
+
+  /**
+   * Called when Animator is added to the scene-graph in update-thread.
+   */
+  virtual void ConnectToSceneGraph()
+  {
+    mConnectedToSceneGraph = true;
+    mPropertyOwner->AddObserver(*this);
+  }
+
+  /**
+   * Called when mPropertyOwner is connected to the scene graph.
+   */
+  virtual void PropertyOwnerConnected( PropertyOwner& owner )
+  {
+    mEnabled = true;
+  }
+
+  /**
+   * Called when mPropertyOwner is disconnected from the scene graph.
+   */
+  virtual void PropertyOwnerDisconnected( BufferIndex bufferIndex, PropertyOwner& owner )
+  {
+    // If we are active, then bake the value if required
+    if ( mAnimationPlaying && mDisconnectAction != Dali::Animation::Discard )
+    {
+      // Bake to target-value if BakeFinal, otherwise bake current value
+      Update( bufferIndex, ( mDisconnectAction == Dali::Animation::Bake ? mCurrentProgress : 1.0f ), true );
+    }
+
+    mEnabled = false;
+  }
+
+  /**
+   * Called shortly before mPropertyOwner is destroyed
+   */
+  virtual void PropertyOwnerDestroyed( PropertyOwner& owner )
+  {
+    mPropertyOwner = NULL;
+  }
+
+  /**
+   * From AnimatorBase.
+   */
+  virtual void Update( BufferIndex bufferIndex, float progress, bool bake )
+  {
+    if( mLoopCount >= 0 )
+    {
+      // Update the progress value
+      progress = SetProgress( progress );
+    }
+
+    float alpha = ApplyAlphaFunction( progress );
+
+    const T& current = mPropertyAccessor.Get( bufferIndex );
+
+    // need to cast the return value in case property is integer
+    T result = static_cast<T>( (*mAnimatorFunction)( alpha, current ) );
+
+    if ( bake )
+    {
+      mPropertyAccessor.Bake( bufferIndex, result );
+    }
+    else
+    {
+      mPropertyAccessor.Set( bufferIndex, result );
+    }
+
+    mCurrentProgress = progress;
+  }
+
+  /**
+   * From AnimatorBase.
+   */
+  virtual bool Orphan()
+  {
+    return (mPropertyOwner == NULL);
+  }
+
+private:
+
+  /**
+   * Private constructor; see also Animator::New().
+   */
+  AnimatorTransformProperty( PropertyOwner* propertyOwner,
+            PropertyBase* property,
+            AnimatorFunctionBase* animatorFunction )
+  : mPropertyOwner( propertyOwner ),
+    mPropertyAccessor( property ),
+    mAnimatorFunction( animatorFunction ),
+    mCurrentProgress( 0.0f )
+  {
+    // WARNING - this object is created in the event-thread
+    // The scene-graph mPropertyOwner object cannot be observed here
+  }
+
+  // Undefined
+  AnimatorTransformProperty( const AnimatorTransformProperty& );
+
+  // Undefined
+  AnimatorTransformProperty& operator=( const AnimatorTransformProperty& );
+
+protected:
+
+  PropertyOwner* mPropertyOwner;
+  PropertyAccessorType mPropertyAccessor;
+
+  AnimatorFunctionBase* mAnimatorFunction;
+  float mCurrentProgress;
+};
+
 } // namespace SceneGraph
 
 /*
@@ -384,14 +786,9 @@ struct AnimatorFunctionBase
     return property;
   }
 
-  virtual float operator()(float progress, const int& property)
+  virtual float operator()(float progress, const int32_t& property)
   {
-    return property;
-  }
-
-  virtual float operator()(float progress, const unsigned int& property)
-  {
-    return property;
+    return static_cast<float>( property );
   }
 
   virtual float operator()(float progress, const float& property)
@@ -429,12 +826,14 @@ struct AnimateByInteger : public AnimatorFunctionBase
   {
   }
 
-  float operator()(float alpha, const int& property)
+  using AnimatorFunctionBase::operator();
+  float operator()(float alpha, const int32_t& property)
   {
-    return int(property + mRelative * alpha + 0.5f );
+    // integers need to be correctly rounded
+    return roundf(static_cast<float>( property ) + static_cast<float>( mRelative ) * alpha );
   }
 
-  int mRelative;
+  int32_t mRelative;
 };
 
 struct AnimateToInteger : public AnimatorFunctionBase
@@ -444,42 +843,14 @@ struct AnimateToInteger : public AnimatorFunctionBase
   {
   }
 
-  float operator()(float alpha, const int& property)
-  {
-    return int(property + ((mTarget - property) * alpha) + 0.5f);
-  }
-
-  int mTarget;
-};
-
-struct AnimateByUnsignedInteger : public AnimatorFunctionBase
-{
-  AnimateByUnsignedInteger(const unsigned int& relativeValue)
-  : mRelative(relativeValue)
-  {
-  }
-
-  float operator()(float alpha, const unsigned int& property)
-  {
-    return static_cast<unsigned int>(property + mRelative * alpha + 0.5f );
-  }
-
-  unsigned int mRelative;
-};
-
-struct AnimateToUnsignedInteger : public AnimatorFunctionBase
-{
-  AnimateToUnsignedInteger(const unsigned int& targetValue)
-  : mTarget(targetValue)
-  {
-  }
-
-  float operator()(float alpha, const unsigned int& property)
+  using AnimatorFunctionBase::operator();
+  float operator()(float alpha, const int32_t& property)
   {
-    return static_cast<unsigned int>(property + ((mTarget - property) * alpha) + 0.5f);
+    // integers need to be correctly rounded
+    return roundf(static_cast<float>( property ) + (static_cast<float>(mTarget - property) * alpha) );
   }
 
-  unsigned int mTarget;
+  int32_t mTarget;
 };
 
 struct AnimateByFloat : public AnimatorFunctionBase
@@ -489,6 +860,7 @@ struct AnimateByFloat : public AnimatorFunctionBase
   {
   }
 
+  using AnimatorFunctionBase::operator();
   float operator()(float alpha, const float& property)
   {
     return float(property + mRelative * alpha);
@@ -504,6 +876,7 @@ struct AnimateToFloat : public AnimatorFunctionBase
   {
   }
 
+  using AnimatorFunctionBase::operator();
   float operator()(float alpha, const float& property)
   {
     return float(property + ((mTarget - property) * alpha));
@@ -519,6 +892,7 @@ struct AnimateByVector2 : public AnimatorFunctionBase
   {
   }
 
+  using AnimatorFunctionBase::operator();
   Vector2 operator()(float alpha, const Vector2& property)
   {
     return Vector2(property + mRelative * alpha);
@@ -534,6 +908,7 @@ struct AnimateToVector2 : public AnimatorFunctionBase
   {
   }
 
+  using AnimatorFunctionBase::operator();
   Vector2 operator()(float alpha, const Vector2& property)
   {
     return Vector2(property + ((mTarget - property) * alpha));
@@ -549,6 +924,7 @@ struct AnimateByVector3 : public AnimatorFunctionBase
   {
   }
 
+  using AnimatorFunctionBase::operator();
   Vector3 operator()(float alpha, const Vector3& property)
   {
     return Vector3(property + mRelative * alpha);
@@ -564,6 +940,7 @@ struct AnimateToVector3 : public AnimatorFunctionBase
   {
   }
 
+  using AnimatorFunctionBase::operator();
   Vector3 operator()(float alpha, const Vector3& property)
   {
     return Vector3(property + ((mTarget - property) * alpha));
@@ -579,6 +956,7 @@ struct AnimateByVector4 : public AnimatorFunctionBase
   {
   }
 
+  using AnimatorFunctionBase::operator();
   Vector4 operator()(float alpha, const Vector4& property)
   {
     return Vector4(property + mRelative * alpha);
@@ -594,6 +972,7 @@ struct AnimateToVector4 : public AnimatorFunctionBase
   {
   }
 
+  using AnimatorFunctionBase::operator();
   Vector4 operator()(float alpha, const Vector4& property)
   {
     return Vector4(property + ((mTarget - property) * alpha));
@@ -609,6 +988,7 @@ struct AnimateByOpacity : public AnimatorFunctionBase
   {
   }
 
+  using AnimatorFunctionBase::operator();
   Vector4 operator()(float alpha, const Vector4& property)
   {
     Vector4 result(property);
@@ -627,6 +1007,7 @@ struct AnimateToOpacity : public AnimatorFunctionBase
   {
   }
 
+  using AnimatorFunctionBase::operator();
   Vector4 operator()(float alpha, const Vector4& property)
   {
     Vector4 result(property);
@@ -645,6 +1026,7 @@ struct AnimateByBoolean : public AnimatorFunctionBase
   {
   }
 
+  using AnimatorFunctionBase::operator();
   bool operator()(float alpha, const bool& property)
   {
     // Alpha is not useful here, just keeping to the same template as other update functors
@@ -661,6 +1043,7 @@ struct AnimateToBoolean : public AnimatorFunctionBase
   {
   }
 
+  using AnimatorFunctionBase::operator();
   bool operator()(float alpha, const bool& property)
   {
     // Alpha is not useful here, just keeping to the same template as other update functors
@@ -678,6 +1061,7 @@ struct RotateByAngleAxis : public AnimatorFunctionBase
   {
   }
 
+  using AnimatorFunctionBase::operator();
   Quaternion operator()(float alpha, const Quaternion& rotation)
   {
     if (alpha > 0.0f)
@@ -699,6 +1083,7 @@ struct RotateToQuaternion : public AnimatorFunctionBase
   {
   }
 
+  using AnimatorFunctionBase::operator();
   Quaternion operator()(float alpha, const Quaternion& rotation)
   {
     return Quaternion::Slerp(rotation, mTarget, alpha);
@@ -715,6 +1100,7 @@ struct KeyFrameBooleanFunctor : public AnimatorFunctionBase
   {
   }
 
+  using AnimatorFunctionBase::operator();
   bool operator()(float progress, const bool& property)
   {
     if(mKeyFrames->IsActive(progress))
@@ -734,39 +1120,20 @@ struct KeyFrameIntegerFunctor : public AnimatorFunctionBase
   {
   }
 
-  float operator()(float progress, const int& property)
+  using AnimatorFunctionBase::operator();
+  float operator()(float progress, const int32_t& property)
   {
     if(mKeyFrames->IsActive(progress))
     {
-      return mKeyFrames->GetValue(progress, mInterpolation);
+      return static_cast<float>( mKeyFrames->GetValue(progress, mInterpolation) );
     }
-    return property;
+    return static_cast<float>( property );
   }
 
   KeyFrameIntegerPtr mKeyFrames;
   Interpolation mInterpolation;
 };
 
-struct KeyFrameUnsignedIntegerFunctor : public AnimatorFunctionBase
-{
-  KeyFrameUnsignedIntegerFunctor(KeyFrameUnsignedIntegerPtr keyFrames, Interpolation interpolation)
-  : mKeyFrames(keyFrames),mInterpolation(interpolation)
-  {
-  }
-
-  float operator()(float progress, const unsigned int& property)
-  {
-    if(mKeyFrames->IsActive(progress))
-    {
-      return mKeyFrames->GetValue(progress, mInterpolation);
-    }
-    return property;
-  }
-
-  KeyFrameUnsignedIntegerPtr mKeyFrames;
-  Interpolation mInterpolation;
-};
-
 struct KeyFrameNumberFunctor : public AnimatorFunctionBase
 {
   KeyFrameNumberFunctor(KeyFrameNumberPtr keyFrames, Interpolation interpolation)
@@ -774,6 +1141,7 @@ struct KeyFrameNumberFunctor : public AnimatorFunctionBase
   {
   }
 
+  using AnimatorFunctionBase::operator();
   float operator()(float progress, const float& property)
   {
     if(mKeyFrames->IsActive(progress))
@@ -794,6 +1162,7 @@ struct KeyFrameVector2Functor : public AnimatorFunctionBase
   {
   }
 
+  using AnimatorFunctionBase::operator();
   Vector2 operator()(float progress, const Vector2& property)
   {
     if(mKeyFrames->IsActive(progress))
@@ -815,6 +1184,7 @@ struct KeyFrameVector3Functor : public AnimatorFunctionBase
   {
   }
 
+  using AnimatorFunctionBase::operator();
   Vector3 operator()(float progress, const Vector3& property)
   {
     if(mKeyFrames->IsActive(progress))
@@ -835,6 +1205,7 @@ struct KeyFrameVector4Functor : public AnimatorFunctionBase
   {
   }
 
+  using AnimatorFunctionBase::operator();
   Vector4 operator()(float progress, const Vector4& property)
   {
     if(mKeyFrames->IsActive(progress))
@@ -855,6 +1226,7 @@ struct KeyFrameQuaternionFunctor : public AnimatorFunctionBase
   {
   }
 
+  using AnimatorFunctionBase::operator();
   Quaternion operator()(float progress, const Quaternion& property)
   {
     if(mKeyFrames->IsActive(progress))
@@ -874,9 +1246,12 @@ struct PathPositionFunctor : public AnimatorFunctionBase
   {
   }
 
+  using AnimatorFunctionBase::operator();
   Vector3 operator()(float progress, const Vector3& property)
   {
-    return mPath->SamplePosition(progress );
+    Vector3 position(property);
+    static_cast<void>( mPath->SamplePosition(progress, position) );
+    return position;
   }
 
   PathPtr mPath;
@@ -891,17 +1266,24 @@ struct PathRotationFunctor : public AnimatorFunctionBase
     mForward.Normalize();
   }
 
+  using AnimatorFunctionBase::operator();
   Quaternion operator()(float progress, const Quaternion& property)
   {
-    Vector3 tangent( mPath->SampleTangent(progress) );
-    return Quaternion( mForward, tangent );
+    Vector3 tangent;
+    if( mPath->SampleTangent(progress, tangent) )
+    {
+      return Quaternion( mForward, tangent );
+    }
+    else
+    {
+      return property;
+    }
   }
 
   PathPtr mPath;
   Vector3 mForward;
 };
 
-
 } // namespace Internal
 
 } // namespace Dali