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..db25f943a854cec49df6dc50de260b7473a27fb9 100644 |
| --- a/Source/core/animation/css/CSSPendingAnimations.cpp |
| +++ b/Source/core/animation/css/CSSPendingAnimations.cpp |
| @@ -31,39 +31,64 @@ |
| #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()); |
| + m_pendingTime = monotonicallyIncreasingTime(); |
|
Steve Block
2013/11/20 00:36:16
This doesn't seem to be used?
dstockwell
2013/11/20 00:49:16
Will remove this.
|
| + const double defaultStartTime = player->timeline().currentTime(); |
|
Steve Block
2013/11/20 00:36:16
Why 'default'? Is there a case where a different s
dstockwell
2013/11/20 00:49:16
When the animation waits for a synchronized start
|
| + 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()) { |
| + Element* element = toAnimation(player->source())->target(); |
| + // FIXME: This isn't sufficient to cause a compositing update? |
| + if (element->document().view()) |
| + element->document().view()->scheduleAnimation(); |
| + return; |
| + } |
| + } |
| + |
| + 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()); |
| } |
| + 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; |
|
Steve Block
2013/11/20 00:36:16
break; ?
dstockwell
2013/11/20 00:49:16
We want to start all that we can on the compositor
|
| + } |
| // 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); |
| } |
| 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()); |
| } |