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

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: fix compile? :| 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 b1959b31a11f08f86e669c36ef084811a3474cb6..0fc86c0045fbbff57291c0376acba8b978905619 100644
--- a/Source/core/animation/AnimationStack.cpp
+++ b/Source/core/animation/AnimationStack.cpp
@@ -30,8 +30,8 @@
#include "config.h"
#include "core/animation/AnimationStack.h"
-#include "core/animation/Interpolation.h"
+#include "core/animation/Interpolation.h"
#include "core/animation/css/CSSAnimations.h"
namespace WebCore {
@@ -47,6 +47,22 @@ void copyToActiveInterpolationMap(const WillBeHeapVector<RefPtrWillBeMember<WebC
}
}
+bool compareAnimations(Animation* animation1, Animation* animation2)
+{
+ ASSERT(animation1->player() && animation2->player());
+ return AnimationPlayer::hasLowerPriority(animation1->player(), animation2->player());
+}
+
+void copyNewAnimationsToActiveInterpolationMap(const Vector<InertAnimation*>& newAnimations, WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& result)
+{
+ for (size_t i = 0; i < newAnimations.size(); ++i) {
+ OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<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;
}
-WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > AnimationStack::activeInterpolations(const AnimationStack* animationStack, const Vector<InertAnimation*>* newAnimations, const HashSet<const AnimationPlayer*>* cancelledAnimationPlayers, Animation::Priority priority)
+WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<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.
+
WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<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) {
- OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<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