Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(275)

Unified Diff: Source/core/animation/AnimationStack.cpp

Issue 210703002: Web Animations: Sort Animations in the AnimationStack (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/animation/AnimationStack.h ('k') | Source/core/animation/AnimationStackTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « Source/core/animation/AnimationStack.h ('k') | Source/core/animation/AnimationStackTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698