Chromium Code Reviews| Index: Source/core/animation/css/CSSPendingAnimations.cpp |
| diff --git a/Source/core/animation/css/CSSPendingAnimations.cpp b/Source/core/animation/css/CSSPendingAnimations.cpp |
| index 86cd0a76ea364cb92e19324a9ef88a937729d142..18893389ff0c178f58ffb7881399fe7d49503ba2 100644 |
| --- a/Source/core/animation/css/CSSPendingAnimations.cpp |
| +++ b/Source/core/animation/css/CSSPendingAnimations.cpp |
| @@ -31,39 +31,62 @@ |
| #include "config.h" |
| #include "core/animation/css/CSSPendingAnimations.h" |
| +#include "core/animation/Animation.h" |
| #include "core/animation/DocumentTimeline.h" |
| +#include "core/frame/FrameView.h" |
| namespace WebCore { |
| -void CSSPendingAnimations::startPendingAnimations() |
| +void CSSPendingAnimations::add(Player* player) |
| { |
| - Vector<RefPtr<Player> > unstarted; |
| - for (size_t i = 0; i < m_pending.size(); i++) { |
| - if (m_pending[i]->maybeStartAnimationOnCompositor()) |
| - m_waitingForCompositorAnimationStart.append(m_pending[i]); |
| - else |
| - unstarted.append(m_pending[i]); |
| + ASSERT(player->source()->isAnimation()); |
| + // The actual start time is either this value, or the time that |
| + // this animation, or an animation that it is synchronized with |
| + // is started on the compositor. |
| + const double defaultStartTime = player->timeline().currentTime(); |
| + m_pending.append(std::make_pair(player, defaultStartTime)); |
| +}; |
| + |
| +void CSSPendingAnimations::startPendingAnimationsAfterStyleRecalc() |
| +{ |
| + // If there's a candidate for animation on compositor wait for compositing update. |
| + for (size_t i = 0; i < m_pending.size(); ++i) { |
| + Player* player = m_pending[i].first.get(); |
| + // Note: The player may have been cancelled while waiting to start. |
| + if (player->source() && toAnimation(player->source())->isCandidateForAnimationOnCompositor()) { |
| + return; |
| + } |
|
Steve Block
2013/11/20 04:42:52
No need for braces
dstockwell
2013/11/20 04:47:08
Someone must have made this optional, lint no long
|
| + } |
| + |
| + for (size_t i = 0; i < m_pending.size(); ++i) { |
| + Player* player = m_pending[i].first.get(); |
| + // FIXME: ASSERT that the clock backing the timeline is frozen. |
| + player->setStartTime(player->timeline().currentTime()); |
|
shans
2013/11/20 03:51:31
setStartTime(m_pending[i].second);
dstockwell
2013/11/20 04:42:31
Done.
|
| } |
| + m_pending.clear(); |
| +} |
| +void CSSPendingAnimations::startPendingAnimationsAfterCompositingUpdate() |
| +{ |
| + bool startedOnCompositor = false; |
| + for (size_t i = 0; i < m_pending.size(); ++i) { |
| + if (m_pending[i].first->maybeStartAnimationOnCompositor()) |
| + startedOnCompositor = true; |
| + } |
| // If any animations were started on the compositor, all remaining |
| - // need to wait for a start time. |
| - if (unstarted.size() < m_pending.size()) { |
| - // FIXME: handle case where timeline has not yet started |
| - m_waitingForCompositorAnimationStart.append(unstarted); |
| - } else { |
| - // Otherwise, all players can start immediately. |
| - for (size_t i = 0; i < unstarted.size(); i++) { |
| - Player* player = unstarted[i].get(); |
| - // FIXME: ASSERT that the clock backing the timeline is frozen. |
| - player->setStartTime(player->timeline().currentTime()); |
| - } |
| + // need to wait for a start time. Otherwise they may start immediately. |
| + for (size_t i = 0; i < m_pending.size(); ++i) { |
| + if (startedOnCompositor) |
| + m_waitingForCompositorAnimationStart.append(m_pending[i].first); |
| + else |
| + m_pending[i].first->setStartTime(m_pending[i].second); |
|
shans
2013/11/20 03:51:31
Nit: condition outside loop
dstockwell
2013/11/20 04:42:31
Done.
|
| } |
| m_pending.clear(); |
| } |
| void CSSPendingAnimations::notifyCompositorAnimationStarted(double monotonicAnimationStartTime) |
| { |
| - for (size_t i = 0; i < m_waitingForCompositorAnimationStart.size(); i++) { |
| + for (size_t i = 0; i < m_waitingForCompositorAnimationStart.size(); ++i) { |
| Player* player = m_waitingForCompositorAnimationStart[i].get(); |
| player->setStartTime(monotonicAnimationStartTime - player->timeline().zeroTime()); |
| } |