Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: Source/core/animation/css/CSSPendingAnimations.cpp

Issue 73643004: Web Animations: Extract an API for servicing animations (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Switch to references for non-null params. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 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.
42 if (m_pending[i]->maybeStartAnimationOnCompositor()) 44 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
43 m_waitingForCompositorAnimationStart.append(m_pending[i]); 45 m_pending.append(std::make_pair(player, defaultStartTime));
44 else 46 };
45 unstarted.append(m_pending[i]); 47
48 void CSSPendingAnimations::startPendingAnimationsAfterStyleRecalc()
49 {
50 // If there's a candidate for animation on compositor wait for compositing u pdate.
51 for (size_t i = 0; i < m_pending.size(); ++i) {
52 Player* player = m_pending[i].first.get();
53 // Note: The player may have been cancelled while waiting to start.
54 if (player->source() && toAnimation(player->source())->isCandidateForAni mationOnCompositor()) {
55 Element* element = toAnimation(player->source())->target();
56 // FIXME: This isn't sufficient to cause a compositing update?
57 if (element->document().view())
58 element->document().view()->scheduleAnimation();
59 return;
60 }
46 } 61 }
47 62
63 for (size_t i = 0; i < m_pending.size(); ++i) {
64 Player* player = m_pending[i].first.get();
65 // FIXME: ASSERT that the clock backing the timeline is frozen.
66 player->setStartTime(player->timeline().currentTime());
67 }
68 m_pending.clear();
69 }
70
71 void CSSPendingAnimations::startPendingAnimationsAfterCompositingUpdate()
72 {
73 bool startedOnCompositor = false;
74 for (size_t i = 0; i < m_pending.size(); ++i) {
75 if (m_pending[i].first->maybeStartAnimationOnCompositor())
76 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
77 }
48 // If any animations were started on the compositor, all remaining 78 // If any animations were started on the compositor, all remaining
49 // need to wait for a start time. 79 // need to wait for a start time. Otherwise they may start immediately.
50 if (unstarted.size() < m_pending.size()) { 80 for (size_t i = 0; i < m_pending.size(); ++i) {
51 // FIXME: handle case where timeline has not yet started 81 if (startedOnCompositor)
52 m_waitingForCompositorAnimationStart.append(unstarted); 82 m_waitingForCompositorAnimationStart.append(m_pending[i].first);
53 } else { 83 else
54 // Otherwise, all players can start immediately. 84 m_pending[i].first->setStartTime(m_pending[i].second);
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 } 85 }
61 m_pending.clear(); 86 m_pending.clear();
62 } 87 }
63 88
64 void CSSPendingAnimations::notifyCompositorAnimationStarted(double monotonicAnim ationStartTime) 89 void CSSPendingAnimations::notifyCompositorAnimationStarted(double monotonicAnim ationStartTime)
65 { 90 {
66 for (size_t i = 0; i < m_waitingForCompositorAnimationStart.size(); i++) { 91 for (size_t i = 0; i < m_waitingForCompositorAnimationStart.size(); ++i) {
67 Player* player = m_waitingForCompositorAnimationStart[i].get(); 92 Player* player = m_waitingForCompositorAnimationStart[i].get();
68 player->setStartTime(monotonicAnimationStartTime - player->timeline().ze roTime()); 93 player->setStartTime(monotonicAnimationStartTime - player->timeline().ze roTime());
69 } 94 }
70 95
71 m_waitingForCompositorAnimationStart.clear(); 96 m_waitingForCompositorAnimationStart.clear();
72 } 97 }
73 98
74 } // namespace 99 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698