Chromium Code Reviews| 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 14 matching lines...) Expand all Loading... | |
| 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 namespace { |
| 41 | 42 |
| 42 double effectiveTime(double time) { return isNull(time) ? 0 : time; } | 43 double effectiveTime(double time) { return isNull(time) ? 0 : time; } |
| 43 | 44 |
| 44 } // namespace | 45 } // namespace |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 75 update(); | 76 update(); |
| 76 } | 77 } |
| 77 | 78 |
| 78 double Player::currentTimeBeforeDrift() const | 79 double Player::currentTimeBeforeDrift() const |
| 79 { | 80 { |
| 80 if (isNull(m_startTime)) | 81 if (isNull(m_startTime)) |
| 81 return 0; | 82 return 0; |
| 82 return (effectiveTime(m_timeline.currentTime()) - startTime()) * m_playbackR ate; | 83 return (effectiveTime(m_timeline.currentTime()) - startTime()) * m_playbackR ate; |
| 83 } | 84 } |
| 84 | 85 |
| 86 bool Player::maybeStartCompositorAnimations() | |
| 87 { | |
| 88 // FIXME: Support starting compositor animations that have a fixed | |
| 89 // start time. | |
| 90 ASSERT(!hasStartTime()); | |
| 91 if (!m_content || !m_content->isAnimation()) | |
| 92 return false; | |
| 93 | |
| 94 return toAnimation(m_content.get())->maybeStartCompositorAnimations(); | |
| 95 } | |
| 96 | |
| 97 bool Player::isRunningCompositorAnimations() | |
| 98 { | |
| 99 if (!m_content || !m_content->isAnimation()) | |
| 100 return false; | |
| 101 return toAnimation(m_content.get())->isRunningCompositorAnimations(); | |
| 102 } | |
| 103 | |
| 104 void Player::cancelCompositorAnimations() | |
| 105 { | |
| 106 if (isRunningCompositorAnimations()) | |
| 107 toAnimation(m_content.get())->cancelCompositorAnimations(); | |
| 108 } | |
| 109 | |
| 85 double Player::pausedTimeDrift() const | 110 double Player::pausedTimeDrift() const |
| 86 { | 111 { |
| 87 ASSERT(pausedInternal()); | 112 ASSERT(pausedInternal()); |
| 88 return currentTimeBeforeDrift() - m_pauseStartTime; | 113 return currentTimeBeforeDrift() - m_pauseStartTime; |
| 89 } | 114 } |
| 90 | 115 |
| 91 double Player::timeDrift() const | 116 double Player::timeDrift() const |
| 92 { | 117 { |
| 93 return pausedInternal() ? pausedTimeDrift() : m_timeDrift; | 118 return pausedInternal() ? pausedTimeDrift() : m_timeDrift; |
| 94 } | 119 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 if (pausedInternal()) | 157 if (pausedInternal()) |
| 133 m_pauseStartTime = seekTime; | 158 m_pauseStartTime = seekTime; |
| 134 else | 159 else |
| 135 m_timeDrift = currentTimeBeforeDrift() - seekTime; | 160 m_timeDrift = currentTimeBeforeDrift() - seekTime; |
| 136 | 161 |
| 137 update(); | 162 update(); |
| 138 } | 163 } |
| 139 | 164 |
| 140 void Player::pauseForTesting() | 165 void Player::pauseForTesting() |
| 141 { | 166 { |
| 142 ASSERT(!paused()); | 167 // FIXME: Need to support pausing compositor animations to pass virtual/thre aded tests. |
| 168 RELEASE_ASSERT(!isRunningCompositorAnimations()); | |
| 169 RELEASE_ASSERT(!paused()); | |
| 143 m_isPausedForTesting = true; | 170 m_isPausedForTesting = true; |
| 144 setPausedImpl(true); | 171 setPausedImpl(true); |
| 145 } | 172 } |
| 146 | 173 |
| 147 void Player::setPaused(bool newValue) | 174 void Player::setPaused(bool newValue) |
| 148 { | 175 { |
| 149 ASSERT(!m_isPausedForTesting); | 176 ASSERT(!m_isPausedForTesting); |
| 150 setPausedImpl(newValue); | 177 setPausedImpl(newValue); |
| 151 } | 178 } |
| 152 | 179 |
| 153 void Player::setPausedImpl(bool newValue) | 180 void Player::setPausedImpl(bool newValue) |
| 154 { | 181 { |
| 155 if (pausedInternal() == newValue) | 182 if (pausedInternal() == newValue) |
| 156 return; | 183 return; |
| 157 | 184 |
| 158 if (newValue) | 185 if (newValue) { |
| 186 cancelCompositorAnimations(); | |
| 159 m_pauseStartTime = currentTime(); | 187 m_pauseStartTime = currentTime(); |
| 160 else { | 188 } else { |
| 161 m_timeDrift = pausedTimeDrift(); | 189 m_timeDrift = pausedTimeDrift(); |
| 162 m_pauseStartTime = nullValue(); | 190 m_pauseStartTime = nullValue(); |
|
shans
2013/11/18 21:55:01
TODO: restart compositor animations?
dstockwell
2013/11/19 02:04:58
Done.
| |
| 163 } | 191 } |
| 164 } | 192 } |
| 165 | 193 |
| 166 void Player::setPlaybackRate(double newRate) | 194 void Player::setPlaybackRate(double newRate) |
| 167 { | 195 { |
| 168 double previousTime = currentTime(); | 196 double previousTime = currentTime(); |
| 169 m_playbackRate = newRate; | 197 m_playbackRate = newRate; |
| 170 setCurrentTime(previousTime); | 198 setCurrentTime(previousTime); |
| 171 } | 199 } |
| 172 | 200 |
| 173 } // namespace | 201 } // namespace |
| OLD | NEW |