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

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: Rebase. 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
« no previous file with comments | « Source/core/animation/css/CSSPendingAnimations.h ('k') | Source/core/core.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // 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 }
59
60 // Otherwise we can start all animations immediately.
61 for (size_t i = 0; i < m_pending.size(); ++i) {
62 m_pending[i].first->setStartTime(m_pending[i].second);
63 }
64 m_pending.clear();
65 }
66
67 void CSSPendingAnimations::startPendingAnimationsAfterCompositingUpdate()
68 {
69 bool startedOnCompositor = false;
70 for (size_t i = 0; i < m_pending.size(); ++i) {
71 if (m_pending[i].first->maybeStartAnimationOnCompositor())
72 startedOnCompositor = true;
46 } 73 }
47 74
48 // If any animations were started on the compositor, all remaining 75 // If any animations were started on the compositor, all remaining
49 // need to wait for a start time. 76 // need to wait for a synchronized start time. Otherwise they may
50 if (unstarted.size() < m_pending.size()) { 77 // start immediately.
51 // FIXME: handle case where timeline has not yet started 78 if (startedOnCompositor) {
52 m_waitingForCompositorAnimationStart.append(unstarted); 79 for (size_t i = 0; i < m_pending.size(); ++i)
80 m_waitingForCompositorAnimationStart.append(m_pending[i].first);
53 } else { 81 } else {
54 // Otherwise, all players can start immediately. 82 for (size_t i = 0; i < m_pending.size(); ++i)
55 for (size_t i = 0; i < unstarted.size(); i++) { 83 m_pending[i].first->setStartTime(m_pending[i].second);
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 } 84 }
61 m_pending.clear(); 85 m_pending.clear();
62 } 86 }
63 87
64 void CSSPendingAnimations::notifyCompositorAnimationStarted(double monotonicAnim ationStartTime) 88 void CSSPendingAnimations::notifyCompositorAnimationStarted(double monotonicAnim ationStartTime)
65 { 89 {
66 for (size_t i = 0; i < m_waitingForCompositorAnimationStart.size(); i++) { 90 for (size_t i = 0; i < m_waitingForCompositorAnimationStart.size(); ++i) {
67 Player* player = m_waitingForCompositorAnimationStart[i].get(); 91 Player* player = m_waitingForCompositorAnimationStart[i].get();
68 player->setStartTime(monotonicAnimationStartTime - player->timeline().ze roTime()); 92 player->setStartTime(monotonicAnimationStartTime - player->timeline().ze roTime());
69 } 93 }
70 94
71 m_waitingForCompositorAnimationStart.clear(); 95 m_waitingForCompositorAnimationStart.clear();
72 } 96 }
73 97
74 } // namespace 98 } // namespace
OLDNEW
« no previous file with comments | « Source/core/animation/css/CSSPendingAnimations.h ('k') | Source/core/core.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698