| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions are | |
| 6 * met: | |
| 7 * | |
| 8 * * Redistributions of source code must retain the above copyright | |
| 9 * notice, this list of conditions and the following disclaimer. | |
| 10 * * Redistributions in binary form must reproduce the above | |
| 11 * copyright notice, this list of conditions and the following disclaimer | |
| 12 * in the documentation and/or other materials provided with the | |
| 13 * distribution. | |
| 14 * * Neither the name of Google Inc. nor the names of its | |
| 15 * contributors may be used to endorse or promote products derived from | |
| 16 * this software without specific prior written permission. | |
| 17 * | |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 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. | |
| 29 */ | |
| 30 | |
| 31 #include "sky/engine/core/animation/PendingAnimations.h" | |
| 32 | |
| 33 #include "sky/engine/core/animation/Animation.h" | |
| 34 #include "sky/engine/core/animation/AnimationTimeline.h" | |
| 35 #include "sky/engine/core/frame/FrameView.h" | |
| 36 #include "sky/engine/core/page/Page.h" | |
| 37 #include "sky/engine/core/rendering/RenderLayer.h" | |
| 38 | |
| 39 namespace blink { | |
| 40 | |
| 41 void PendingAnimations::add(AnimationPlayer* player) | |
| 42 { | |
| 43 ASSERT(player); | |
| 44 ASSERT(m_pending.find(player) == kNotFound); | |
| 45 m_pending.append(player); | |
| 46 | |
| 47 Document* document = player->timeline()->document(); | |
| 48 document->scheduleVisualUpdate(); | |
| 49 | |
| 50 bool visible = document->page() && document->page()->visibilityState() == Pa
geVisibilityStateVisible; | |
| 51 if (!visible && !m_timer.isActive()) { | |
| 52 m_timer.startOneShot(0, FROM_HERE); | |
| 53 } | |
| 54 } | |
| 55 | |
| 56 bool PendingAnimations::update() | |
| 57 { | |
| 58 Vector<AnimationPlayer*> waitingForStartTime; | |
| 59 Vector<RefPtr<AnimationPlayer> > players; | |
| 60 players.swap(m_pending); | |
| 61 | |
| 62 for (size_t i = 0; i < players.size(); ++i) { | |
| 63 AnimationPlayer& player = *players[i].get(); | |
| 64 player.preCommit(); | |
| 65 if (player.playing() && !player.hasStartTime()) { | |
| 66 waitingForStartTime.append(&player); | |
| 67 } | |
| 68 } | |
| 69 | |
| 70 for (size_t i = 0; i < waitingForStartTime.size(); ++i) { | |
| 71 if (!waitingForStartTime[i]->hasStartTime()) { | |
| 72 waitingForStartTime[i]->notifyCompositorStartTime(waitingForStartTim
e[i]->timeline()->currentTimeInternal()); | |
| 73 } | |
| 74 } | |
| 75 | |
| 76 // FIXME: The postCommit should happen *after* the commit, not before. | |
| 77 for (size_t i = 0; i < players.size(); ++i) { | |
| 78 AnimationPlayer& player = *players[i].get(); | |
| 79 player.postCommit(player.timeline()->currentTimeInternal()); | |
| 80 } | |
| 81 | |
| 82 ASSERT(m_pending.isEmpty()); | |
| 83 return false; | |
| 84 } | |
| 85 | |
| 86 } // namespace | |
| OLD | NEW |