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

Side by Side Diff: Source/core/animation/Player.cpp

Issue 23874019: Web Animations CSS: Start running animations on the compositor (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 14 matching lines...) Expand all
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 31
32 #include "config.h" 32 #include "config.h"
33 #include "core/animation/Player.h" 33 #include "core/animation/Player.h"
34 34
35 #include "core/animation/Animation.h"
35 #include "core/animation/DocumentTimeline.h" 36 #include "core/animation/DocumentTimeline.h"
36 #include "core/animation/TimedItem.h" 37 #include "core/animation/TimedItem.h"
37 38
38 namespace WebCore { 39 namespace WebCore {
39 40
40 namespace {
41
42 double effectiveTime(double time) { return isNull(time) ? 0 : time; }
43
44 } // namespace
45
46 PassRefPtr<Player> Player::create(DocumentTimeline& timeline, TimedItem* content ) 41 PassRefPtr<Player> Player::create(DocumentTimeline& timeline, TimedItem* content )
47 { 42 {
48 return adoptRef(new Player(timeline, content)); 43 return adoptRef(new Player(timeline, content));
49 } 44 }
50 45
51 Player::Player(DocumentTimeline& timeline, TimedItem* content) 46 Player::Player(DocumentTimeline& timeline, TimedItem* content)
52 : m_pauseStartTime(nullValue()) 47 : m_pauseStartTime(nullValue())
53 , m_playbackRate(1) 48 , m_playbackRate(1)
54 , m_timeDrift(0) 49 , m_timeDrift(0)
55 , m_startTime(nullValue()) 50 , m_startTime(nullValue())
(...skipping 19 matching lines...) Expand all
75 update(); 70 update();
76 } 71 }
77 72
78 double Player::currentTimeBeforeDrift() const 73 double Player::currentTimeBeforeDrift() const
79 { 74 {
80 if (isNull(m_startTime)) 75 if (isNull(m_startTime))
81 return 0; 76 return 0;
82 return (effectiveTime(m_timeline.currentTime()) - startTime()) * m_playbackR ate; 77 return (effectiveTime(m_timeline.currentTime()) - startTime()) * m_playbackR ate;
83 } 78 }
84 79
80 bool Player::isCandidateForCompositorAnimation() const
81 {
82 if (!m_content || !m_content->isAnimation())
83 return false;
84
85 const Animation* animation = toAnimation(m_content.get());
86 if (hasStartTime()) {
87 // FIXME: Support starting compositor animations that have a fixed
88 // start time.
89 return animation->isRunningCompositorAnimation();
shans 2013/11/18 01:02:06 This is confusing. Why doesn't this method map cle
dstockwell 2013/11/18 05:30:34 This method no longer exists.
90 }
91
92 return animation->isCandidateForCompositorAnimation();
93 }
94
95 bool Player::startCompositorAnimations()
96 {
97 // FIXME: Support starting compositor animations that have a fixed
98 // start time.
99 ASSERT(!hasStartTime());
100 if (!m_content || !m_content->isAnimation())
101 return false;
102
103 return toAnimation(m_content.get())->startCompositorAnimations();
104 }
105
106 bool Player::isRunningCompositorAnimation(const Element* element, CSSPropertyID property)
107 {
108 if (!m_content || !m_content->isAnimation())
109 return false;
110 return toAnimation(m_content.get())->isRunningCompositorAnimation(element, p roperty);
111 }
112
113 void Player::cancelCompositorAnimations()
114 {
115 if (isRunningCompositorAnimation())
116 toAnimation(m_content.get())->cancelCompositorAnimations();
117 }
118
85 double Player::pausedTimeDrift() const 119 double Player::pausedTimeDrift() const
86 { 120 {
87 ASSERT(pausedInternal()); 121 ASSERT(pausedInternal());
88 return currentTimeBeforeDrift() - m_pauseStartTime; 122 return currentTimeBeforeDrift() - m_pauseStartTime;
89 } 123 }
90 124
91 double Player::timeDrift() const 125 double Player::timeDrift() const
92 { 126 {
93 return pausedInternal() ? pausedTimeDrift() : m_timeDrift; 127 return pausedInternal() ? pausedTimeDrift() : m_timeDrift;
94 } 128 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 if (pausedInternal()) 166 if (pausedInternal())
133 m_pauseStartTime = seekTime; 167 m_pauseStartTime = seekTime;
134 else 168 else
135 m_timeDrift = currentTimeBeforeDrift() - seekTime; 169 m_timeDrift = currentTimeBeforeDrift() - seekTime;
136 170
137 update(); 171 update();
138 } 172 }
139 173
140 void Player::pauseForTesting() 174 void Player::pauseForTesting()
141 { 175 {
142 ASSERT(!paused()); 176 RELEASE_ASSERT(!isRunningCompositorAnimation());
177 RELEASE_ASSERT(!paused());
143 m_isPausedForTesting = true; 178 m_isPausedForTesting = true;
144 setPausedImpl(true); 179 setPausedImpl(true);
145 } 180 }
146 181
147 void Player::setPaused(bool newValue) 182 void Player::setPaused(bool newValue)
148 { 183 {
149 ASSERT(!m_isPausedForTesting); 184 ASSERT(!m_isPausedForTesting);
150 setPausedImpl(newValue); 185 setPausedImpl(newValue);
151 } 186 }
152 187
153 void Player::setPausedImpl(bool newValue) 188 void Player::setPausedImpl(bool newValue)
154 { 189 {
155 if (pausedInternal() == newValue) 190 if (pausedInternal() == newValue)
156 return; 191 return;
157 192
158 if (newValue) 193 if (newValue) {
194 cancelCompositorAnimations();
159 m_pauseStartTime = currentTime(); 195 m_pauseStartTime = currentTime();
160 else { 196 } else {
161 m_timeDrift = pausedTimeDrift(); 197 m_timeDrift = pausedTimeDrift();
162 m_pauseStartTime = nullValue(); 198 m_pauseStartTime = nullValue();
163 } 199 }
164 } 200 }
165 201
166 void Player::setPlaybackRate(double newRate) 202 void Player::setPlaybackRate(double newRate)
167 { 203 {
168 double previousTime = currentTime(); 204 double previousTime = currentTime();
169 m_playbackRate = newRate; 205 m_playbackRate = newRate;
170 setCurrentTime(previousTime); 206 setCurrentTime(previousTime);
171 } 207 }
172 208
173 } // namespace 209 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698