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

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

Issue 1196023003: Web Animations: Avoid iteration when checking for outdated animations on timeline (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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/AnimationTimeline.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/animation/AnimationTimeline.cpp
diff --git a/Source/core/animation/AnimationTimeline.cpp b/Source/core/animation/AnimationTimeline.cpp
index 82af9a72ebc204cedf0ef3100ce996c89446b864..7827a075bfe9dffa5435b517aa07110ae10f5cc1 100644
--- a/Source/core/animation/AnimationTimeline.cpp
+++ b/Source/core/animation/AnimationTimeline.cpp
@@ -68,6 +68,7 @@ AnimationTimeline::AnimationTimeline(Document* document, PassOwnPtrWillBeRawPtr<
: m_document(document)
, m_zeroTime(0) // 0 is used by unit tests which cannot initialize from the loader
, m_zeroTimeInitialized(false)
+ , m_outdatedAnimationCount(0)
, m_playbackRate(1)
, m_lastCurrentTimeInternal(0)
{
@@ -147,12 +148,17 @@ void AnimationTimeline::serviceAnimations(TimingUpdateReason reason)
m_animationsNeedingUpdate.remove(animation);
}
- ASSERT(!hasOutdatedAnimation());
+ ASSERT(m_outdatedAnimationCount == 0);
+
+#if ENABLE(ASSERT)
+ for (const auto& animation : m_animationsNeedingUpdate)
+ ASSERT(!animation->outdated());
+#endif
}
void AnimationTimeline::scheduleNextService()
{
- ASSERT(!hasOutdatedAnimation());
+ ASSERT(m_outdatedAnimationCount == 0);
double timeToNextEffect = std::numeric_limits<double>::infinity();
for (const auto& animation : m_animationsNeedingUpdate) {
@@ -262,23 +268,21 @@ void AnimationTimeline::pauseAnimationsForTesting(double pauseTime)
serviceAnimations(TimingUpdateOnDemand);
}
-bool AnimationTimeline::hasOutdatedAnimation() const
+bool AnimationTimeline::needsAnimationTimingUpdate()
{
- for (const auto& animation : m_animationsNeedingUpdate) {
- if (animation->outdated())
- return true;
- }
- return false;
+ return m_animationsNeedingUpdate.size() && currentTimeInternal() != m_lastCurrentTimeInternal;
}
-bool AnimationTimeline::needsAnimationTimingUpdate()
+void AnimationTimeline::clearOutdatedAnimation(Animation* animation)
{
- return m_animationsNeedingUpdate.size() && currentTimeInternal() != m_lastCurrentTimeInternal;
+ ASSERT(!animation->outdated());
+ m_outdatedAnimationCount--;
}
void AnimationTimeline::setOutdatedAnimation(Animation* animation)
{
ASSERT(animation->outdated());
+ m_outdatedAnimationCount++;
m_animationsNeedingUpdate.add(animation);
if (m_document && m_document->page() && !m_document->page()->animator().isServicingAnimations())
m_timing->serviceOnNextFrame();
« no previous file with comments | « Source/core/animation/AnimationTimeline.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698