[Tizen] Do not call NotifyObjects in case of finished animations
[platform/core/uifw/dali-core.git] / dali / internal / event / animation / animation-impl.cpp
index 92791da..f1f981f 100644 (file)
@@ -137,7 +137,6 @@ void ValidateParameters( Property::Type propertyType, Property::Type destination
 
 } // anonymous namespace
 
-
 AnimationPtr Animation::New(float durationSeconds)
 {
   if( durationSeconds < 0.0f )
@@ -155,26 +154,13 @@ AnimationPtr Animation::New(float durationSeconds)
   return animation;
 }
 
-Animation::Animation( EventThreadServices& eventThreadServices, AnimationPlaylist& playlist, float durationSeconds, EndAction endAction, EndAction disconnectAction, AlphaFunction defaultAlpha )
-: mAnimation( nullptr ),
-  mEventThreadServices( eventThreadServices ),
-  mPlaylist( playlist ),
-  mFinishedSignal(),
-  mConnectors(),
-  mConnectorTargetValues(),
-  mPlayRange( Vector2(0.0f,1.0f)),
-  mDurationSeconds( durationSeconds ),
-  mSpeedFactor(1.0f),
-  mNotificationCount( 0 ),
-  mLoopCount(1),
-  mCurrentLoop(0),
-  mEndAction( endAction ),
-  mDisconnectAction( disconnectAction ),
-  mDefaultAlpha( defaultAlpha ),
-  mState(Dali::Animation::STOPPED),
-  mProgressReachedMarker( 0.0f ),
-  mDelaySeconds( 0.0f ),
-  mAutoReverseEnabled( false )
+Animation::Animation(EventThreadServices& eventThreadServices, AnimationPlaylist& playlist, float durationSeconds, EndAction endAction, EndAction disconnectAction, AlphaFunction defaultAlpha)
+: mEventThreadServices(eventThreadServices),
+  mPlaylist(playlist),
+  mDefaultAlpha(defaultAlpha),
+  mDurationSeconds(durationSeconds),
+  mEndAction(endAction),
+  mDisconnectAction(disconnectAction)
 {
 }
 
@@ -400,7 +386,7 @@ void Animation::Clear()
   DALI_ASSERT_DEBUG(mAnimation);
 
   // Only notify the objects with the current values if the end action is set to BAKE
-  if( mEndAction == EndAction::BAKE )
+  if(mEndAction == EndAction::BAKE && mState != Dali::Animation::STOPPED)
   {
     NotifyObjects( Notify::USE_CURRENT_VALUE );
   }
@@ -422,22 +408,22 @@ void Animation::Clear()
   mPlaylist.OnClear( *this );
 }
 
-void Animation::AnimateBy( Property& target, Property::Value& relativeValue )
+void Animation::AnimateBy(Property& target, Property::Value relativeValue)
 {
-  AnimateBy( target, relativeValue, mDefaultAlpha, TimePeriod(mDurationSeconds) );
+  AnimateBy(target, std::move(relativeValue), mDefaultAlpha, TimePeriod(mDurationSeconds));
 }
 
-void Animation::AnimateBy( Property& target, Property::Value& relativeValue, AlphaFunction alpha )
+void Animation::AnimateBy(Property& target, Property::Value relativeValue, AlphaFunction alpha)
 {
-  AnimateBy( target, relativeValue, alpha, TimePeriod(mDurationSeconds) );
+  AnimateBy(target, std::move(relativeValue), alpha, TimePeriod(mDurationSeconds));
 }
 
-void Animation::AnimateBy( Property& target, Property::Value& relativeValue, TimePeriod period )
+void Animation::AnimateBy(Property& target, Property::Value relativeValue, TimePeriod period)
 {
-  AnimateBy( target, relativeValue, mDefaultAlpha, period );
+  AnimateBy(target, std::move(relativeValue), mDefaultAlpha, period);
 }
 
-void Animation::AnimateBy( Property& target, Property::Value& relativeValue, AlphaFunction alpha, TimePeriod period )
+void Animation::AnimateBy(Property& target, Property::Value relativeValue, AlphaFunction alpha, TimePeriod period)
 {
   Object& object = GetImplementation(target.object);
   const Property::Type propertyType = object.GetPropertyType( target.propertyIndex );
@@ -449,13 +435,8 @@ void Animation::AnimateBy( Property& target, Property::Value& relativeValue, Alp
 
   ExtendDuration(period);
 
-  // Store data to later notify the object that its property is being animated
-  ConnectorTargetValues connectorPair;
-  connectorPair.targetValue = relativeValue;
-  connectorPair.connectorIndex = mConnectors.Count();
-  connectorPair.timePeriod = period;
-  connectorPair.animatorType = Animation::BY;
-  mConnectorTargetValues.push_back( connectorPair );
+  // keep the current count.
+  auto connectorIndex = mConnectors.Count();
 
   // using destination type so component animation gets correct type
   switch ( destinationType )
@@ -541,27 +522,29 @@ void Animation::AnimateBy( Property& target, Property::Value& relativeValue, Alp
 
     default:
     {
-      // non animatable types handled already
+      DALI_ASSERT_DEBUG(false && "Property  not supported");
     }
   }
+  // Store data to later notify the object that its property is being animated
+  mConnectorTargetValues.push_back({std::move(relativeValue), period, connectorIndex, Animation::BY});
 }
 
-void Animation::AnimateTo( Property& target, Property::Value& destinationValue )
+void Animation::AnimateTo(Property& target, Property::Value destinationValue)
 {
-  AnimateTo( target, destinationValue, mDefaultAlpha, TimePeriod(mDurationSeconds) );
+  AnimateTo(target, std::move(destinationValue), mDefaultAlpha, TimePeriod(mDurationSeconds));
 }
 
-void Animation::AnimateTo( Property& target, Property::Value& destinationValue, AlphaFunction alpha )
+void Animation::AnimateTo(Property& target, Property::Value destinationValue, AlphaFunction alpha)
 {
-  AnimateTo( target, destinationValue, alpha, TimePeriod(mDurationSeconds));
+  AnimateTo(target, std::move(destinationValue), alpha, TimePeriod(mDurationSeconds));
 }
 
-void Animation::AnimateTo( Property& target, Property::Value& destinationValue, TimePeriod period )
+void Animation::AnimateTo(Property& target, Property::Value destinationValue, TimePeriod period)
 {
-  AnimateTo( target, destinationValue, mDefaultAlpha, period );
+  AnimateTo(target, std::move(destinationValue), mDefaultAlpha, period);
 }
 
-void Animation::AnimateTo( Property& target, Property::Value& destinationValue, AlphaFunction alpha, TimePeriod period )
+void Animation::AnimateTo(Property& target, Property::Value destinationValue, AlphaFunction alpha, TimePeriod period)
 {
   Object& object = GetImplementation( target.object );
   const Property::Type propertyType = object.GetPropertyType( target.propertyIndex );
@@ -573,13 +556,8 @@ void Animation::AnimateTo( Property& target, Property::Value& destinationValue,
 
   ExtendDuration( period );
 
-  // Store data to later notify the object that its property is being animated
-  ConnectorTargetValues connectorPair;
-  connectorPair.targetValue = destinationValue;
-  connectorPair.connectorIndex = mConnectors.Count();
-  connectorPair.timePeriod = period;
-  connectorPair.animatorType = Animation::TO;
-  mConnectorTargetValues.push_back( connectorPair );
+  // keep the current count.
+  auto connectorIndex = mConnectors.Count();
 
   // using destination type so component animation gets correct type
   switch ( destinationType )
@@ -663,9 +641,11 @@ void Animation::AnimateTo( Property& target, Property::Value& destinationValue,
 
     default:
     {
-      // non animatable types handled already
+      DALI_ASSERT_DEBUG(false && "Property  not supported");
     }
   }
+  // Store data to later notify the object that its property is being animated
+  mConnectorTargetValues.push_back({std::move(destinationValue), period, connectorIndex, Animation::TO});
 }
 
 void Animation::AnimateBetween( Property target, const KeyFrames& keyFrames )
@@ -716,12 +696,7 @@ void Animation::AnimateBetween( Property target, const KeyFrames& keyFrames, Alp
   ExtendDuration( period );
 
   // Store data to later notify the object that its property is being animated
-  ConnectorTargetValues connectorPair;
-  connectorPair.targetValue = keyFrames.GetLastKeyFrameValue();
-  connectorPair.connectorIndex = mConnectors.Count();
-  connectorPair.timePeriod = period;
-  connectorPair.animatorType = BETWEEN;
-  mConnectorTargetValues.push_back( connectorPair );
+  mConnectorTargetValues.push_back({keyFrames.GetLastKeyFrameValue(), period, mConnectors.Count(), BETWEEN});
 
   // using destination type so component animation gets correct type
   switch( destinationType )
@@ -826,7 +801,7 @@ void Animation::AnimateBetween( Property target, const KeyFrames& keyFrames, Alp
 
     default:
     {
-      // non animatable types handled by keyframes
+      DALI_ASSERT_DEBUG(false && "Property  not supported");
     }
   }
 }
@@ -1108,7 +1083,7 @@ void Animation::NotifyObjects( Animation::Notify notifyValueType )
       AnimatorConnectorBase* connector = mConnectors[ iter->connectorIndex ];
 
       Object* object = connector->GetObject();
-      if( object )
+      if(object && object->IsAnimationPossible())
       {
         const auto propertyIndex = connector->GetPropertyIndex();
         object->NotifyPropertyAnimation(