Chromium Code Reviews| Index: Source/core/animation/AnimationClock.cpp |
| diff --git a/Source/core/animation/AnimationClock.cpp b/Source/core/animation/AnimationClock.cpp |
| index d51c95e7aed188da489a296342619fdac98b2841..34693928d8f3947afc106f19cbaf920d6cb6dcad 100644 |
| --- a/Source/core/animation/AnimationClock.cpp |
| +++ b/Source/core/animation/AnimationClock.cpp |
| @@ -34,49 +34,52 @@ |
| #include "wtf/CurrentTime.h" |
| #include <math.h> |
| -namespace { |
| - |
| -// FIXME: This is an approximation of time between frames, used when |
| -// ticking the animation clock outside of animation frame callbacks. |
| -// Ideally this would be generated by the compositor. |
| -const double approximateFrameTime = 1 / 60.0; |
| - |
| -} |
| - |
| namespace WebCore { |
| unsigned AnimationClock::s_currentTask = 0; |
| -void AnimationClock::updateTime(double time) |
| +void AnimationClock::updateTime(blink::WebFrameTime frameTime) |
| { |
| - if (time > m_time) |
| - m_time = time; |
| + ASSERT(internalCurrentTime() <= frameTime.displayFrameTime); |
| + m_frameTime = frameTime; |
| m_currentTask = s_currentTask; |
| } |
| double AnimationClock::currentTime() |
| { |
| + ASSERT(m_frameTime.displayFrameTime >= 0); |
| + ASSERT(m_frameTime.predictedNextDisplayFrameTime >= 0); |
| + return internalCurrentTime(); |
| +} |
| + |
| +double AnimationClock::internalCurrentTime() |
| +{ |
| if (m_currentTask != s_currentTask) { |
| - const double currentTime = m_monotonicallyIncreasingTime(); |
| - if (m_time < currentTime) { |
| - // Advance to the first estimated frame after the current time. |
| - const double frameShift = fmod(currentTime - m_time, approximateFrameTime); |
| - const double newTime = currentTime + (approximateFrameTime - frameShift); |
| - ASSERT(newTime >= currentTime); |
| - ASSERT(newTime <= currentTime + approximateFrameTime); |
| - updateTime(newTime); |
| - } else { |
| - m_currentTask = s_currentTask; |
| - } |
| + return m_frameTime.predictedNextDisplayFrameTime; |
| } |
| - return m_time; |
| + return m_frameTime.displayFrameTime; |
| } |
| -void AnimationClock::resetTimeForTesting() |
| +void AnimationClock::clearTimeForTesting() |
| { |
| - m_time = 0; |
| + m_frameTime = blink::WebFrameTime(-1, -1, -1, -1); |
|
eseidel
2014/07/07 16:31:50
Either make it default with an .isEmpty() accessor
mithro-old
2014/07/07 17:47:15
I've attempted a isNull / createNull pair on the W
|
| m_currentTask = 0; |
| s_currentTask = 0; |
| } |
| +void AnimationClock::tickTimeForTesting() |
| +{ |
| + double nextTime = m_frameTime.predictedNextDisplayFrameTime; |
| + if (nextTime == -1.0) { |
| + nextTime = WTF::monotonicallyIncreasingTime(); |
| + } |
| + |
| + updateTime(blink::WebFrameTime(-1, -1, nextTime, nextTime + (1 / 60.0))); |
| +} |
| + |
| +void AnimationClock::resetTimeForTesting() |
| +{ |
| + clearTimeForTesting(); |
| + tickTimeForTesting(); |
| +} |
| } |