Chromium Code Reviews| Index: Source/core/animation/AnimationStack.cpp |
| diff --git a/Source/core/animation/AnimationStack.cpp b/Source/core/animation/AnimationStack.cpp |
| index 6c83afb3bf987bcd7f106d393122b5df7ef1cd57..79c26230ea5d68a0fd861ce7dfde3673214e1010 100644 |
| --- a/Source/core/animation/AnimationStack.cpp |
| +++ b/Source/core/animation/AnimationStack.cpp |
| @@ -47,6 +47,22 @@ void copyToActiveInterpolationMap(const Vector<RefPtr<WebCore::Interpolation> >& |
| } |
| } |
| +bool compareAnimations(Animation* animation1, Animation* animation2) |
| +{ |
| + ASSERT(animation1->player() && animation2->player()); |
| + return AnimationPlayer::hasLowerPriority(animation1->player(), animation2->player()); |
| +} |
| + |
| +void copyNewAnimationsToActiveInterpolationMap(const Vector<InertAnimation*>& newAnimations, HashMap<CSSPropertyID, RefPtr<Interpolation> >& result) |
| +{ |
| + for (size_t i = 0; i < newAnimations.size(); ++i) { |
| + OwnPtr<Vector<RefPtr<Interpolation> > > sample = newAnimations[i]->sample(); |
| + if (sample) { |
| + copyToActiveInterpolationMap(*sample, result); |
| + } |
| + } |
| +} |
| + |
| } // namespace |
| bool AnimationStack::affects(CSSPropertyID property) const |
| @@ -67,30 +83,31 @@ bool AnimationStack::hasActiveAnimationsOnCompositor(CSSPropertyID property) con |
| return false; |
| } |
| -HashMap<CSSPropertyID, RefPtr<Interpolation> > AnimationStack::activeInterpolations(const AnimationStack* animationStack, const Vector<InertAnimation*>* newAnimations, const HashSet<const AnimationPlayer*>* cancelledAnimationPlayers, Animation::Priority priority) |
| +HashMap<CSSPropertyID, RefPtr<Interpolation> > AnimationStack::activeInterpolations(AnimationStack* animationStack, const Vector<InertAnimation*>* newAnimations, const HashSet<const AnimationPlayer*>* cancelledAnimationPlayers, Animation::Priority priority, double timelineCurrentTime) |
| { |
| + // We don't exactly know when new animations will start, but timelineCurrentTime is a good estimate. |
|
dstockwell
2014/03/26 01:32:21
We should probably track the start time for the pu
Timothy Loh
2014/03/26 03:00:43
Done.
|
| + |
| HashMap<CSSPropertyID, RefPtr<Interpolation> > result; |
| if (animationStack) { |
| - const Vector<Animation*>& animations = animationStack->m_activeAnimations; |
| + Vector<Animation*>& animations = animationStack->m_activeAnimations; |
| + std::sort(animations.begin(), animations.end(), compareAnimations); |
| for (size_t i = 0; i < animations.size(); ++i) { |
| Animation* animation = animations[i]; |
| if (animation->priority() != priority) |
| continue; |
| if (cancelledAnimationPlayers && cancelledAnimationPlayers->contains(animation->player())) |
| continue; |
| + if (animation->player()->startTime() > timelineCurrentTime && newAnimations) { |
| + copyNewAnimationsToActiveInterpolationMap(*newAnimations, result); |
| + newAnimations = 0; |
| + } |
| copyToActiveInterpolationMap(animation->activeInterpolations(), result); |
| } |
| } |
| - if (newAnimations) { |
| - for (size_t i = 0; i < newAnimations->size(); ++i) { |
| - OwnPtr<Vector<RefPtr<Interpolation> > > sample = newAnimations->at(i)->sample(); |
| - if (sample) { |
| - copyToActiveInterpolationMap(*sample, result); |
| - } |
| - } |
| - } |
| + if (newAnimations) |
| + copyNewAnimationsToActiveInterpolationMap(*newAnimations, result); |
| return result; |
| } |