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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
85 return (timelineTime - m_startTime) * m_playbackRate; | 85 return (timelineTime - m_startTime) * m_playbackRate; |
86 } | 86 } |
87 | 87 |
88 double Player::currentTimeWithLag() const | 88 double Player::currentTimeWithLag() const |
89 { | 89 { |
90 ASSERT(!m_held); | 90 ASSERT(!m_held); |
91 double time = currentTimeWithoutLag(); | 91 double time = currentTimeWithoutLag(); |
92 return std::isinf(time) ? time : time - m_storedTimeLag; | 92 return std::isinf(time) ? time : time - m_storedTimeLag; |
93 } | 93 } |
94 | 94 |
95 void Player::updateTimingState(double newCurrentTime) | 95 void Player::updateTimingState(double newCurrentTime, bool shouldSetOutdated) |
96 { | 96 { |
97 ASSERT(!isNull(newCurrentTime)); | 97 ASSERT(!isNull(newCurrentTime)); |
98 m_held = m_paused || !m_playbackRate || limited(newCurrentTime); | 98 m_held = m_paused || !m_playbackRate || limited(newCurrentTime); |
99 if (m_held) { | 99 if (m_held) { |
100 m_holdTime = newCurrentTime; | 100 m_holdTime = newCurrentTime; |
101 m_storedTimeLag = nullValue(); | 101 m_storedTimeLag = nullValue(); |
102 } else { | 102 } else { |
103 m_holdTime = nullValue(); | 103 m_holdTime = nullValue(); |
104 m_storedTimeLag = currentTimeWithoutLag() - newCurrentTime; | 104 m_storedTimeLag = currentTimeWithoutLag() - newCurrentTime; |
105 } | 105 } |
106 setOutdated(); | 106 if (shouldSetOutdated) |
dstockwell
2014/02/24 07:44:07
Shouldn't we be able to derive this from above? Ch
Timothy Loh
2014/03/04 03:13:07
Ok this ends up being a little more complicated be
| |
107 setOutdated(); | |
107 } | 108 } |
108 | 109 |
109 void Player::updateCurrentTimingState() | 110 void Player::updateCurrentTimingState(bool shouldSetOutdated) |
110 { | 111 { |
111 if (m_held) { | 112 if (m_held) { |
112 updateTimingState(m_holdTime); | 113 updateTimingState(m_holdTime, shouldSetOutdated); |
113 } else { | 114 } else { |
114 updateTimingState(currentTimeWithLag()); | 115 updateTimingState(currentTimeWithLag(), shouldSetOutdated); |
115 if (m_held && limited(m_holdTime)) | 116 if (m_held && limited(m_holdTime)) |
116 m_holdTime = m_playbackRate < 0 ? 0 : sourceEnd(); | 117 m_holdTime = m_playbackRate < 0 ? 0 : sourceEnd(); |
117 } | 118 } |
118 } | 119 } |
119 | 120 |
120 double Player::currentTime() | 121 double Player::currentTime() |
121 { | 122 { |
122 updateCurrentTimingState(); | 123 updateCurrentTimingState(false); |
123 if (m_held) | 124 if (m_held) |
124 return m_holdTime; | 125 return m_holdTime; |
125 return currentTimeWithLag(); | 126 return currentTimeWithLag(); |
126 } | 127 } |
127 | 128 |
128 void Player::setCurrentTime(double newCurrentTime) | 129 void Player::setCurrentTime(double newCurrentTime) |
129 { | 130 { |
130 if (!std::isfinite(newCurrentTime)) | 131 if (!std::isfinite(newCurrentTime)) |
131 return; | 132 return; |
132 updateTimingState(newCurrentTime); | 133 updateTimingState(newCurrentTime); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
254 } | 255 } |
255 | 256 |
256 void Player::cancelAnimationOnCompositor() | 257 void Player::cancelAnimationOnCompositor() |
257 { | 258 { |
258 if (hasActiveAnimationsOnCompositor()) | 259 if (hasActiveAnimationsOnCompositor()) |
259 toAnimation(m_content.get())->cancelAnimationOnCompositor(); | 260 toAnimation(m_content.get())->cancelAnimationOnCompositor(); |
260 } | 261 } |
261 | 262 |
262 bool Player::update() | 263 bool Player::update() |
263 { | 264 { |
264 if (!m_timeline) | 265 m_outdated = false; |
266 | |
267 if (!m_timeline || !m_content) | |
265 return false; | 268 return false; |
266 | 269 |
267 double inheritedTime = isNull(m_timeline->currentTime()) ? nullValue() : cur rentTime(); | 270 double inheritedTime = isNull(m_timeline->currentTime()) ? nullValue() : cur rentTime(); |
268 m_outdated = false; | |
269 | |
270 if (!m_content) | |
271 return false; | |
272 | |
273 m_content->updateInheritedTime(inheritedTime); | 271 m_content->updateInheritedTime(inheritedTime); |
274 | 272 |
275 ASSERT(!m_outdated); | 273 ASSERT(!m_outdated); |
276 return m_content->isCurrent() || m_content->isInEffect(); | 274 return m_content->isCurrent() || m_content->isInEffect(); |
277 } | 275 } |
278 | 276 |
279 double Player::timeToEffectChange() | 277 double Player::timeToEffectChange() |
280 { | 278 { |
281 ASSERT(!m_outdated); | 279 ASSERT(!m_outdated); |
282 if (!m_content || !m_playbackRate) | 280 if (!m_content || !m_playbackRate) |
(...skipping 17 matching lines...) Expand all Loading... | |
300 { | 298 { |
301 RELEASE_ASSERT(!paused()); | 299 RELEASE_ASSERT(!paused()); |
302 updateTimingState(pauseTime); | 300 updateTimingState(pauseTime); |
303 if (!m_isPausedForTesting && hasActiveAnimationsOnCompositor()) | 301 if (!m_isPausedForTesting && hasActiveAnimationsOnCompositor()) |
304 toAnimation(m_content.get())->pauseAnimationForTestingOnCompositor(curre ntTime()); | 302 toAnimation(m_content.get())->pauseAnimationForTestingOnCompositor(curre ntTime()); |
305 m_isPausedForTesting = true; | 303 m_isPausedForTesting = true; |
306 pause(); | 304 pause(); |
307 } | 305 } |
308 | 306 |
309 } // namespace | 307 } // namespace |
OLD | NEW |