Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "core/animation/css/CSSPendingAnimations.h" | 32 #include "core/animation/css/CSSPendingAnimations.h" |
| 33 | 33 |
| 34 #include "core/animation/Animation.h" | |
| 34 #include "core/animation/DocumentTimeline.h" | 35 #include "core/animation/DocumentTimeline.h" |
| 36 #include "core/frame/FrameView.h" | |
| 35 | 37 |
| 36 namespace WebCore { | 38 namespace WebCore { |
| 37 | 39 |
| 38 void CSSPendingAnimations::startPendingAnimations() | 40 void CSSPendingAnimations::add(Player* player) |
| 39 { | 41 { |
| 40 Vector<RefPtr<Player> > unstarted; | 42 ASSERT(player->source()->isAnimation()); |
| 41 for (size_t i = 0; i < m_pending.size(); i++) { | 43 // The actual start time is either this value, or the time that |
| 42 if (m_pending[i]->maybeStartAnimationOnCompositor()) | 44 // this animation, or an animation that it is synchronized with |
| 43 m_waitingForCompositorAnimationStart.append(m_pending[i]); | 45 // is started on the compositor. |
| 44 else | 46 const double defaultStartTime = player->timeline().currentTime(); |
| 45 unstarted.append(m_pending[i]); | 47 m_pending.append(std::make_pair(player, defaultStartTime)); |
| 48 }; | |
| 49 | |
| 50 void CSSPendingAnimations::startPendingAnimationsAfterStyleRecalc() | |
| 51 { | |
| 52 // If there's a candidate for animation on compositor wait for compositing u pdate. | |
| 53 for (size_t i = 0; i < m_pending.size(); ++i) { | |
| 54 Player* player = m_pending[i].first.get(); | |
| 55 // Note: The player may have been cancelled while waiting to start. | |
| 56 if (player->source() && toAnimation(player->source())->isCandidateForAni mationOnCompositor()) { | |
| 57 return; | |
| 58 } | |
|
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
| |
| 46 } | 59 } |
| 47 | 60 |
| 61 for (size_t i = 0; i < m_pending.size(); ++i) { | |
| 62 Player* player = m_pending[i].first.get(); | |
| 63 // FIXME: ASSERT that the clock backing the timeline is frozen. | |
| 64 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.
| |
| 65 } | |
| 66 m_pending.clear(); | |
| 67 } | |
| 68 | |
| 69 void CSSPendingAnimations::startPendingAnimationsAfterCompositingUpdate() | |
| 70 { | |
| 71 bool startedOnCompositor = false; | |
| 72 for (size_t i = 0; i < m_pending.size(); ++i) { | |
| 73 if (m_pending[i].first->maybeStartAnimationOnCompositor()) | |
| 74 startedOnCompositor = true; | |
| 75 } | |
| 48 // If any animations were started on the compositor, all remaining | 76 // If any animations were started on the compositor, all remaining |
| 49 // need to wait for a start time. | 77 // need to wait for a start time. Otherwise they may start immediately. |
| 50 if (unstarted.size() < m_pending.size()) { | 78 for (size_t i = 0; i < m_pending.size(); ++i) { |
| 51 // FIXME: handle case where timeline has not yet started | 79 if (startedOnCompositor) |
| 52 m_waitingForCompositorAnimationStart.append(unstarted); | 80 m_waitingForCompositorAnimationStart.append(m_pending[i].first); |
| 53 } else { | 81 else |
| 54 // Otherwise, all players can start immediately. | 82 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.
| |
| 55 for (size_t i = 0; i < unstarted.size(); i++) { | |
| 56 Player* player = unstarted[i].get(); | |
| 57 // FIXME: ASSERT that the clock backing the timeline is frozen. | |
| 58 player->setStartTime(player->timeline().currentTime()); | |
| 59 } | |
| 60 } | 83 } |
| 61 m_pending.clear(); | 84 m_pending.clear(); |
| 62 } | 85 } |
| 63 | 86 |
| 64 void CSSPendingAnimations::notifyCompositorAnimationStarted(double monotonicAnim ationStartTime) | 87 void CSSPendingAnimations::notifyCompositorAnimationStarted(double monotonicAnim ationStartTime) |
| 65 { | 88 { |
| 66 for (size_t i = 0; i < m_waitingForCompositorAnimationStart.size(); i++) { | 89 for (size_t i = 0; i < m_waitingForCompositorAnimationStart.size(); ++i) { |
| 67 Player* player = m_waitingForCompositorAnimationStart[i].get(); | 90 Player* player = m_waitingForCompositorAnimationStart[i].get(); |
| 68 player->setStartTime(monotonicAnimationStartTime - player->timeline().ze roTime()); | 91 player->setStartTime(monotonicAnimationStartTime - player->timeline().ze roTime()); |
| 69 } | 92 } |
| 70 | 93 |
| 71 m_waitingForCompositorAnimationStart.clear(); | 94 m_waitingForCompositorAnimationStart.clear(); |
| 72 } | 95 } |
| 73 | 96 |
| 74 } // namespace | 97 } // namespace |
| OLD | NEW |