From 08df5d19190794835a5e71e499ced1a9f8e62843 Mon Sep 17 00:00:00 2001 From: "sub.mohanty@samsung.com" Date: Sun, 11 Oct 2020 10:26:36 +0900 Subject: [PATCH] refactor dali-animation. - 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 | 328 +++++++++--------- .../event/animation/animator-connector-base.h | 42 +-- dali/internal/event/animation/animator-connector.h | 225 +++++++------ dali/internal/event/animation/key-frame-channel.h | 200 +++-------- dali/internal/event/animation/key-frames-impl.cpp | 44 ++- dali/internal/event/animation/key-frames-impl.h | 209 ++---------- .../update/animation/scene-graph-animator.h | 365 ++++++++------------- dali/public-api/animation/key-frames.cpp | 2 +- 8 files changed, 546 insertions(+), 869 deletions(-) diff --git a/dali/internal/event/animation/animation-impl.cpp b/dali/internal/event/animation/animation-impl.cpp index 0a05d70..0200fb0 100644 --- a/dali/internal/event/animation/animation-impl.cpp +++ b/dali/internal/event/animation/animation-impl.cpp @@ -443,67 +443,67 @@ void Animation::AnimateBy(Property& target, Property::Value relativeValue, Alpha { case Property::BOOLEAN: { - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new AnimateByBoolean(relativeValue.Get()), - alpha, - period ) ); + AddAnimatorConnector(AnimatorConnector::New(object, + target.propertyIndex, + target.componentIndex, + AnimateByBoolean(relativeValue.Get()), + alpha, + period)); break; } case Property::INTEGER: { - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new AnimateByInteger(relativeValue.Get()), - alpha, - period ) ); + AddAnimatorConnector(AnimatorConnector::New(object, + target.propertyIndex, + target.componentIndex, + AnimateByInteger(relativeValue.Get()), + alpha, + period)); break; } case Property::FLOAT: { - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new AnimateByFloat(relativeValue.Get()), - alpha, - period ) ); + AddAnimatorConnector(AnimatorConnector::New(object, + target.propertyIndex, + target.componentIndex, + AnimateByFloat(relativeValue.Get()), + alpha, + period)); break; } case Property::VECTOR2: { - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new AnimateByVector2(relativeValue.Get()), - alpha, - period ) ); + AddAnimatorConnector(AnimatorConnector::New(object, + target.propertyIndex, + target.componentIndex, + AnimateByVector2(relativeValue.Get()), + alpha, + period)); break; } case Property::VECTOR3: { - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new AnimateByVector3(relativeValue.Get()), - alpha, - period ) ); + AddAnimatorConnector(AnimatorConnector::New(object, + target.propertyIndex, + target.componentIndex, + AnimateByVector3(relativeValue.Get()), + alpha, + period)); break; } case Property::VECTOR4: { - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new AnimateByVector4(relativeValue.Get()), - alpha, - period ) ); + AddAnimatorConnector(AnimatorConnector::New(object, + target.propertyIndex, + target.componentIndex, + AnimateByVector4(relativeValue.Get()), + alpha, + period)); break; } @@ -511,12 +511,12 @@ void Animation::AnimateBy(Property& target, Property::Value relativeValue, Alpha { AngleAxis angleAxis = relativeValue.Get(); - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new RotateByAngleAxis(angleAxis.angle, angleAxis.axis), - alpha, - period ) ); + AddAnimatorConnector(AnimatorConnector::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::New( object, - target.propertyIndex, - target.componentIndex, - new AnimateToBoolean( destinationValue.Get() ), - alpha, - period ) ); + AddAnimatorConnector(AnimatorConnector::New(object, + target.propertyIndex, + target.componentIndex, + AnimateToBoolean(destinationValue.Get()), + alpha, + period)); break; } case Property::INTEGER: { - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new AnimateToInteger( destinationValue.Get() ), - alpha, - period ) ); + AddAnimatorConnector(AnimatorConnector::New(object, + target.propertyIndex, + target.componentIndex, + AnimateToInteger(destinationValue.Get()), + alpha, + period)); break; } case Property::FLOAT: { - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new AnimateToFloat( destinationValue.Get() ), - alpha, - period ) ); + AddAnimatorConnector(AnimatorConnector::New(object, + target.propertyIndex, + target.componentIndex, + AnimateToFloat(destinationValue.Get()), + alpha, + period)); break; } case Property::VECTOR2: { - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new AnimateToVector2( destinationValue.Get() ), - alpha, - period ) ); + AddAnimatorConnector(AnimatorConnector::New(object, + target.propertyIndex, + target.componentIndex, + AnimateToVector2(destinationValue.Get()), + alpha, + period)); break; } case Property::VECTOR3: { - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new AnimateToVector3( destinationValue.Get() ), - alpha, - period ) ); + AddAnimatorConnector(AnimatorConnector::New(object, + target.propertyIndex, + target.componentIndex, + AnimateToVector3(destinationValue.Get()), + alpha, + period)); break; } case Property::VECTOR4: { - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new AnimateToVector4( destinationValue.Get() ), - alpha, - period ) ); + AddAnimatorConnector(AnimatorConnector::New(object, + target.propertyIndex, + target.componentIndex, + AnimateToVector4(destinationValue.Get()), + alpha, + period)); break; } case Property::ROTATION: { - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new RotateToQuaternion( destinationValue.Get() ), - alpha, - period ) ); + AddAnimatorConnector(AnimatorConnector::New(object, + target.propertyIndex, + target.componentIndex, + RotateToQuaternion(destinationValue.Get()), + 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::New( object, - target.propertyIndex, - target.componentIndex, - new KeyFrameBooleanFunctor(kfCopy), - alpha, - period ) ); + auto kf = GetSpecialization(keyFrames); + AddAnimatorConnector(AnimatorConnector::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::New( object, - target.propertyIndex, - target.componentIndex, - new KeyFrameIntegerFunctor(kfCopy,interpolation), - alpha, - period ) ); + auto kf = GetSpecialization(keyFrames); + AddAnimatorConnector(AnimatorConnector::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::New( object, - target.propertyIndex, - target.componentIndex, - new KeyFrameNumberFunctor(kfCopy,interpolation), - alpha, - period ) ); + auto kf = GetSpecialization(keyFrames); + AddAnimatorConnector(AnimatorConnector::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::New( object, - target.propertyIndex, - target.componentIndex, - new KeyFrameVector2Functor(kfCopy,interpolation), - alpha, - period ) ); + auto kf = GetSpecialization(keyFrames); + AddAnimatorConnector(AnimatorConnector::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::New( object, - target.propertyIndex, - target.componentIndex, - new KeyFrameVector3Functor(kfCopy,interpolation), - alpha, - period ) ); + auto kf = GetSpecialization(keyFrames); + AddAnimatorConnector(AnimatorConnector::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::New( object, - target.propertyIndex, - target.componentIndex, - new KeyFrameVector4Functor(kfCopy,interpolation), - alpha, - period ) ); + auto kf = GetSpecialization(keyFrames); + AddAnimatorConnector(AnimatorConnector::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::New( object, - target.propertyIndex, - target.componentIndex, - new KeyFrameQuaternionFunctor(kfCopy), - alpha, - period ) ); + auto kf = GetSpecialization(keyFrames); + AddAnimatorConnector(AnimatorConnector::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::New( actor, - Dali::Actor::Property::POSITION, - Property::INVALID_COMPONENT_INDEX, - new PathPositionFunctor( pathCopy ), - alpha, - period ) ); + AddAnimatorConnector(AnimatorConnector::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::New( actor, - Dali::Actor::Property::ORIENTATION, - Property::INVALID_COMPONENT_INDEX, - new PathRotationFunctor( pathCopy, forward ), - alpha, - period ) ); + AddAnimatorConnector(AnimatorConnector::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::New( actor, - Dali::Actor::Property::VISIBLE, - Property::INVALID_COMPONENT_INDEX, - new AnimateToBoolean(SHOW_VALUE), - mDefaultAlpha, - TimePeriod(delaySeconds, 0.0f/*immediate*/) ) ); + AddAnimatorConnector(AnimatorConnector::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::New( actor, - Dali::Actor::Property::VISIBLE, - Property::INVALID_COMPONENT_INDEX, - new AnimateToBoolean(HIDE_VALUE), - mDefaultAlpha, - TimePeriod(delaySeconds, 0.0f/*immediate*/) ) ); + AddAnimatorConnector(AnimatorConnector::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 ) diff --git a/dali/internal/event/animation/animator-connector-base.h b/dali/internal/event/animation/animator-connector-base.h index 8e839fb..8699012 100644 --- a/dali/internal/event/animation/animator-connector-base.h +++ b/dali/internal/event/animation/animator-connector-base.h @@ -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 diff --git a/dali/internal/event/animation/animator-connector.h b/dali/internal/event/animation/animator-connector.h index 48bd693..434fdc9 100644 --- a/dali/internal/event/animation/animator-connector.h +++ b/dali/internal/event/animation/animator-connector.h @@ -18,6 +18,9 @@ * */ +//EXTERNAL INCLUDES +#include + // INTERNAL INCLUDES #include #include @@ -41,6 +44,10 @@ namespace Internal template < typename PropertyType > class AnimatorConnector : public AnimatorConnectorBase { + using AnimatorFunction = std::function; + + AnimatorFunction mAnimatorFunction; + public: using AnimatorType = SceneGraph::Animator< PropertyType, PropertyAccessor >; @@ -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 >::New( propertyOwner, baseProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod ); + mAnimator = SceneGraph::AnimatorTransformProperty >::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; + + AnimatorFunction mAnimatorFunction; + public: using AnimatorType = SceneGraph::Animator< float, PropertyAccessor >; @@ -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 >::New( propertyOwner, baseProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod ); + mAnimator = SceneGraph::AnimatorTransformProperty >::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 >::New( propertyOwner, - *animatableProperty, - mAnimatorFunction, - mAlphaFunction, - mTimePeriod ); + mAnimator = SceneGraph::Animator >::New(propertyOwner, + *animatableProperty, + std::move(mAnimatorFunction), + mAlphaFunction, + mTimePeriod); break; } case 1: { - mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorY >::New( propertyOwner, - *animatableProperty, - mAnimatorFunction, - mAlphaFunction, - mTimePeriod ); + mAnimator = SceneGraph::Animator >::New(propertyOwner, + *animatableProperty, + std::move(mAnimatorFunction), + mAlphaFunction, + mTimePeriod); break; } default: @@ -279,15 +308,27 @@ private: { if( mComponentIndex == 0 ) { - mAnimator = SceneGraph::AnimatorTransformProperty< float,TransformManagerPropertyComponentAccessor >::New( propertyOwner, baseProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod ); + mAnimator = SceneGraph::AnimatorTransformProperty >::New(propertyOwner, + baseProperty, + std::move(mAnimatorFunction), + mAlphaFunction, + mTimePeriod); } else if( mComponentIndex == 1 ) { - mAnimator = SceneGraph::AnimatorTransformProperty< float,TransformManagerPropertyComponentAccessor >::New( propertyOwner, baseProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod ); + mAnimator = SceneGraph::AnimatorTransformProperty >::New(propertyOwner, + baseProperty, + std::move(mAnimatorFunction), + mAlphaFunction, + mTimePeriod); } else if( mComponentIndex == 2 ) { - mAnimator = SceneGraph::AnimatorTransformProperty< float,TransformManagerPropertyComponentAccessor >::New( propertyOwner, baseProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod ); + mAnimator = SceneGraph::AnimatorTransformProperty >::New(propertyOwner, + baseProperty, + std::move(mAnimatorFunction), + mAlphaFunction, + mTimePeriod); } } else @@ -305,29 +346,29 @@ private: { case 0: { - mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorX >::New( propertyOwner, - *animatableProperty, - mAnimatorFunction, - mAlphaFunction, - mTimePeriod ); + mAnimator = SceneGraph::Animator >::New(propertyOwner, + *animatableProperty, + std::move(mAnimatorFunction), + mAlphaFunction, + mTimePeriod); break; } case 1: { - mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorY >::New( propertyOwner, - *animatableProperty, - mAnimatorFunction, - mAlphaFunction, - mTimePeriod ); + mAnimator = SceneGraph::Animator >::New(propertyOwner, + *animatableProperty, + std::move(mAnimatorFunction), + mAlphaFunction, + mTimePeriod); break; } case 2: { - mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorZ >::New( propertyOwner, - *animatableProperty, - mAnimatorFunction, - mAlphaFunction, - mTimePeriod ); + mAnimator = SceneGraph::Animator >::New(propertyOwner, + *animatableProperty, + std::move(mAnimatorFunction), + mAlphaFunction, + mTimePeriod); break; } default: @@ -353,38 +394,38 @@ private: { case 0: { - mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorX >::New( propertyOwner, - *animatableProperty, - mAnimatorFunction, - mAlphaFunction, - mTimePeriod ); + mAnimator = SceneGraph::Animator >::New(propertyOwner, + *animatableProperty, + std::move(mAnimatorFunction), + mAlphaFunction, + mTimePeriod); break; } case 1: { - mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorY >::New( propertyOwner, - *animatableProperty, - mAnimatorFunction, - mAlphaFunction, - mTimePeriod ); + mAnimator = SceneGraph::Animator >::New(propertyOwner, + *animatableProperty, + std::move(mAnimatorFunction), + mAlphaFunction, + mTimePeriod); break; } case 2: { - mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorZ >::New( propertyOwner, - *animatableProperty, - mAnimatorFunction, - mAlphaFunction, - mTimePeriod ); + mAnimator = SceneGraph::Animator >::New(propertyOwner, + *animatableProperty, + std::move(mAnimatorFunction), + mAlphaFunction, + mTimePeriod); break; } case 3: { - mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorW >::New( propertyOwner, - *animatableProperty, - mAnimatorFunction, - mAlphaFunction, - mTimePeriod ); + mAnimator = SceneGraph::Animator >::New(propertyOwner, + *animatableProperty, + std::move(mAnimatorFunction), + mAlphaFunction, + mTimePeriod); break; } diff --git a/dali/internal/event/animation/key-frame-channel.h b/dali/internal/event/animation/key-frame-channel.h index 820340c..c7f0444 100644 --- a/dali/internal/event/animation/key-frame-channel.h +++ b/dali/internal/event/animation/key-frame-channel.h @@ -18,6 +18,9 @@ * */ +// EXTERNAL INCLUDES +#include + // INTERNAL INCLUDES #include #include @@ -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 -class KeyFrameChannel : public KeyFrameChannelBase +template +struct KeyFrameChannel { -public: - using ProgressValues = std::vector >; - - KeyFrameChannel(KeyFrameChannelId channel_id, ProgressValues& values ) - : KeyFrameChannelBase(channel_id), - mValues(values) - { - } - - ~KeyFrameChannel() override = default; - - bool IsActive (float progress) override; + using ProgressValues = std::vector>; - 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 -bool KeyFrameChannel::IsActive (float progress) -{ - bool active = false; - if(!mValues.empty()) + bool IsActive(float progress) const { - ProgressValue& 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 -bool KeyFrameChannel::FindInterval( - typename ProgressValues::iterator& start, - typename ProgressValues::iterator& end, - float progress) const -{ - bool found = false; - typename std::vector >::iterator iter = mValues.begin(); - typename std::vector >::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 -V KeyFrameChannel::GetValue (float progress, Dali::Animation::Interpolation interpolation) const -{ - ProgressValue& firstPV = mValues.front(); - - typename std::vector >::iterator start; - typename std::vector >::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; -using KeyFrameChannelVector2 = KeyFrameChannel; -using KeyFrameChannelVector3 = KeyFrameChannel; -using KeyFrameChannelVector4 = KeyFrameChannel; -using KeyFrameChannelQuaternion = KeyFrameChannel; -using KeyFrameChannelAngleAxis = KeyFrameChannel; + ProgressValues mValues; +}; } // Internal } // namespace Dali diff --git a/dali/internal/event/animation/key-frames-impl.cpp b/dali/internal/event/animation/key-frames-impl.cpp index fa265cc..7ecfd6b 100644 --- a/dali/internal/event/animation/key-frames-impl.cpp +++ b/dali/internal/event/animation/key-frames-impl.cpp @@ -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(); break; } case Property::INTEGER: { - mKeyFrames = Internal::KeyFrameInteger::New(); + mKeyFrames = std::make_unique(); break; } case Property::FLOAT: { - mKeyFrames = Internal::KeyFrameNumber::New(); + mKeyFrames = std::make_unique(); break; } case Property::VECTOR2: { - mKeyFrames = Internal::KeyFrameVector2::New(); + mKeyFrames = std::make_unique(); break; } case Property::VECTOR3: { - mKeyFrames = Internal::KeyFrameVector3::New(); + mKeyFrames = std::make_unique(); break; } case Property::VECTOR4: { - mKeyFrames = Internal::KeyFrameVector4::New(); + mKeyFrames = std::make_unique(); break; } case Property::ROTATION: { - mKeyFrames = Internal::KeyFrameQuaternion::New(); + mKeyFrames = std::make_unique(); 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(mKeyFrames.Get()); + Internal::KeyFrameBoolean* kf = static_cast(keyframes); kf->AddKeyFrame(time, value.Get(), alpha); break; } case Property::INTEGER: { - Internal::KeyFrameInteger* kf = static_cast(mKeyFrames.Get()); + Internal::KeyFrameInteger* kf = static_cast(keyframes); kf->AddKeyFrame(time, value.Get(), alpha); break; } case Property::FLOAT: { - Internal::KeyFrameNumber* kf = static_cast(mKeyFrames.Get()); + Internal::KeyFrameNumber* kf = static_cast(keyframes); kf->AddKeyFrame(time, value.Get(), alpha); break; } case Property::VECTOR2: { - Internal::KeyFrameVector2* kf = static_cast(mKeyFrames.Get()); + Internal::KeyFrameVector2* kf = static_cast(keyframes); kf->AddKeyFrame(time, value.Get(), alpha); break; } case Property::VECTOR3: { - Internal::KeyFrameVector3* kf = static_cast(mKeyFrames.Get()); + Internal::KeyFrameVector3* kf = static_cast(keyframes); kf->AddKeyFrame(time, value.Get(), alpha); break; } case Property::VECTOR4: { - Internal::KeyFrameVector4* kf = static_cast(mKeyFrames.Get()); + Internal::KeyFrameVector4* kf = static_cast(keyframes); kf->AddKeyFrame(time, value.Get(), alpha); break; } case Property::ROTATION: { - Internal::KeyFrameQuaternion* kf = static_cast(mKeyFrames.Get()); + Internal::KeyFrameQuaternion* kf = static_cast(keyframes); kf->AddKeyFrame(time, value.Get(), 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 diff --git a/dali/internal/event/animation/key-frames-impl.h b/dali/internal/event/animation/key-frames-impl.h index 989e481..1f21625 100644 --- a/dali/internal/event/animation/key-frames-impl.h +++ b/dali/internal/event/animation/key-frames-impl.h @@ -18,12 +18,14 @@ * */ +// EXTERNAL INCLUDES +#include + // INTERNAL INCLUDES #include #include #include #include -#include #include namespace Dali @@ -32,7 +34,6 @@ namespace Internal { class KeyFrameSpec; class KeyFrames; -using KeyFramesPtr = IntrusivePtr; /** * 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 mKeyFrames; // Pointer to the specialized key frame object + Dali::Property::Type mType{Property::NONE}; // Type of the specialization + std::unique_ptr 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 class KeyFrameBaseSpec : public KeyFrameSpec { -private: - using PV = ProgressValue; - using PVContainer = std::vector; - - PVContainer mPVs; // The ProgressValue pairs - KeyFrameChannel* mKeyFrames; // The key frame interpolator + KeyFrameChannel mChannel; // The key frame channel public: - static KeyFrameBaseSpec* New() - { - return new KeyFrameBaseSpec(); - } - - static KeyFrameBaseSpec* Clone(const KeyFrameBaseSpec& keyFrames) - { - return new KeyFrameBaseSpec(keyFrames); - } - /** - * Constructor - */ - KeyFrameBaseSpec() - { - mKeyFrames = new KeyFrameChannel(KeyFrameChannelBase::Translate, mPVs); - } - -protected: - /** - * Copy Constructor - * Allow cloning of this object - */ - KeyFrameBaseSpec(const KeyFrameBaseSpec& keyFrames) - : mPVs(keyFrames.mPVs) - { - mKeyFrames = new KeyFrameChannel(KeyFrameChannelBase::Translate, mPVs); - } - - KeyFrameBaseSpec& operator=( const KeyFrameBaseSpec& keyFrames ) - { - if( this != &keyFrames ) - { - mPVs.clear(); - mPVs = keyFrames.mPVs; - delete mKeyFrames; - mKeyFrames = new KeyFrameChannel(KeyFrameChannelBase::Translate, mPVs); - } - return *this; - } - - /** - * Destructor. Ensure progress value pairs are cleared down - */ - ~KeyFrameBaseSpec() 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; using KeyFrameVector4 = KeyFrameBaseSpec; using KeyFrameQuaternion = KeyFrameBaseSpec; -using KeyFrameBooleanPtr = IntrusivePtr; -using KeyFrameNumberPtr = IntrusivePtr; -using KeyFrameIntegerPtr = IntrusivePtr; -using KeyFrameVector2Ptr = IntrusivePtr; -using KeyFrameVector3Ptr = IntrusivePtr; -using KeyFrameVector4Ptr = IntrusivePtr; -using KeyFrameQuaternionPtr = IntrusivePtr; - -inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameBoolean*& keyFrameSpec) -{ - keyFrameSpec = static_cast(keyFrames.GetKeyFramesBase()); -} - -inline void GetSpecialization(const Internal::KeyFrames& keyFrames, const Internal::KeyFrameBoolean*& keyFrameSpec) -{ - keyFrameSpec = static_cast(keyFrames.GetKeyFramesBase()); -} - -inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameNumber*& keyFrameSpec) -{ - keyFrameSpec = static_cast(keyFrames.GetKeyFramesBase()); -} - -inline void GetSpecialization(const Internal::KeyFrames& keyFrames, const Internal::KeyFrameNumber*& keyFrameSpec) -{ - keyFrameSpec = static_cast(keyFrames.GetKeyFramesBase()); -} - -inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameInteger*& keyFrameSpec) -{ - keyFrameSpec = static_cast(keyFrames.GetKeyFramesBase()); -} - -inline void GetSpecialization(const Internal::KeyFrames& keyFrames, const Internal::KeyFrameInteger*& keyFrameSpec) -{ - keyFrameSpec = static_cast(keyFrames.GetKeyFramesBase()); -} - -inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameVector2*& keyFrameSpec) -{ - keyFrameSpec = static_cast(keyFrames.GetKeyFramesBase()); -} - -inline void GetSpecialization(const Internal::KeyFrames& keyFrames, const Internal::KeyFrameVector2*& keyFrameSpec) -{ - keyFrameSpec = static_cast(keyFrames.GetKeyFramesBase()); -} - -inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameVector3*& keyFrameSpec) -{ - keyFrameSpec = static_cast(keyFrames.GetKeyFramesBase()); -} - -inline void GetSpecialization(const Internal::KeyFrames& keyFrames, const Internal::KeyFrameVector3*& keyFrameSpec) -{ - keyFrameSpec = static_cast(keyFrames.GetKeyFramesBase()); -} - -inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameVector4*& keyFrameSpec) -{ - keyFrameSpec = static_cast(keyFrames.GetKeyFramesBase()); -} - -inline void GetSpecialization(const Internal::KeyFrames& keyFrames, const Internal::KeyFrameVector4*& keyFrameSpec) -{ - keyFrameSpec = static_cast(keyFrames.GetKeyFramesBase()); -} - -inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameQuaternion*& keyFrameSpec) -{ - keyFrameSpec = static_cast(keyFrames.GetKeyFramesBase()); -} - -inline void GetSpecialization(const Internal::KeyFrames& keyFrames, const Internal::KeyFrameQuaternion*& keyFrameSpec) +template +auto GetSpecialization(const Internal::KeyFrames& keyFrames) { - keyFrameSpec = static_cast(keyFrames.GetKeyFramesBase()); + return static_cast(keyFrames.GetKeyFramesBase()); } } // Internal diff --git a/dali/internal/update/animation/scene-graph-animator.h b/dali/internal/update/animation/scene-graph-animator.h index 56ed6c4..3ff3144 100644 --- a/dali/internal/update/animation/scene-graph-animator.h +++ b/dali/internal/update/animation/scene-graph-animator.h @@ -20,6 +20,7 @@ // EXTERNAL INCLUDES #include +#include // INTERNAL INCLUDES #include @@ -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( 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 +class Animator final : public AnimatorBase { + using AnimatorFunction = std::function; + + 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 ), - const_cast( &property ), - animatorFunction, - alphaFunction, - timePeriod ); + return new Animator(const_cast(&propertyOwner), + const_cast(&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( (*mAnimatorFunction)( alpha, current ) ); + const PropertyType result = static_cast(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 -class AnimatorTransformProperty : public AnimatorBase +template +class AnimatorTransformProperty final : public AnimatorBase { + using AnimatorFunction = std::function; + + 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 ), - const_cast( &property ), - animatorFunction, - alphaFunction, - timePeriod ); + return new AnimatorTransformProperty(const_cast(&propertyOwner), + const_cast(&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( (*mAnimatorFunction)( alpha, current ) ); + const PropertyType result = static_cast(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( property ) + static_cast( 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( property ) + (static_cast(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( mKeyFrames->GetValue(progress, mInterpolation) ); + return static_cast(mKeyFrames.GetValue(progress, mInterpolation)); } return static_cast( 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( 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) ) diff --git a/dali/public-api/animation/key-frames.cpp b/dali/public-api/animation/key-frames.cpp index dbf21e1..bff6040 100644 --- a/dali/public-api/animation/key-frames.cpp +++ b/dali/public-api/animation/key-frames.cpp @@ -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) -- 2.7.4