X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fupdate%2Fanimation%2Fscene-graph-animation.cpp;h=ec264354f1677e7e32dc413556113329f7ca9212;hb=10bd6b9d6d1df8d530de4173d48c4182492495b0;hp=659547f643441302c82218a659310fc3217baa6e;hpb=e4d22de85c81987aa749fb21dca87e88ed170509;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/update/animation/scene-graph-animation.cpp b/dali/internal/update/animation/scene-graph-animation.cpp index 659547f..ec26435 100644 --- a/dali/internal/update/animation/scene-graph-animation.cpp +++ b/dali/internal/update/animation/scene-graph-animation.cpp @@ -80,6 +80,7 @@ Animation::Animation(float durationSeconds, float speedFactor, const Vector2& pl mState(Stopped), mProgressReachedSignalRequired(false), mAutoReverseEnabled(false), + mAnimatorSortRequired(false), mIsActive{false} { } @@ -151,8 +152,12 @@ void Animation::SetPlayRange(const Vector2& range) void Animation::Play() { - // Sort according to end time with earlier end times coming first, if the end time is the same, then the animators are not moved - std::stable_sort(mAnimators.Begin(), mAnimators.End(), CompareAnimatorEndTimes); + if(mAnimatorSortRequired) + { + // Sort according to end time with earlier end times coming first, if the end time is the same, then the animators are not moved + std::stable_sort(mAnimators.Begin(), mAnimators.End(), CompareAnimatorEndTimes); + mAnimatorSortRequired = false; + } mState = Playing; @@ -299,6 +304,16 @@ void Animation::AddAnimator(OwnerPointer& animator) animator->ConnectToSceneGraph(); animator->SetDisconnectAction(mDisconnectAction); + // Check whether we need to sort mAnimators or not. + // Sort will be required only if new item is smaller than last value of container. + if(!mAnimatorSortRequired && !mAnimators.Empty()) + { + if(CompareAnimatorEndTimes(animator.Get(), *(mAnimators.End() - 1u))) + { + mAnimatorSortRequired = true; + } + } + mAnimators.PushBack(animator.Release()); } @@ -485,6 +500,10 @@ void Animation::UpdateAnimators(BufferIndex bufferIndex, bool bake, bool animati { //Remove animators whose PropertyOwner has been destroyed mAnimators.EraseIf([](auto& animator) { return animator->Orphan(); }); + + // Need to be re-sort if remained animators size is bigger than one. + // Note that if animator contains only zero or one items, It is already sorted case. + mAnimatorSortRequired = (mAnimators.Count() >= 2); } }