| 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 159 |
| 160 if (outdated) { | 160 if (outdated) { |
| 161 setOutdated(); | 161 setOutdated(); |
| 162 } | 162 } |
| 163 } | 163 } |
| 164 | 164 |
| 165 // Update timing to reflect updated animation clock due to tick | 165 // Update timing to reflect updated animation clock due to tick |
| 166 void AnimationPlayer::updateCurrentTimingState(TimingUpdateReason reason) | 166 void AnimationPlayer::updateCurrentTimingState(TimingUpdateReason reason) |
| 167 { | 167 { |
| 168 if (m_held) { | 168 if (m_held) { |
| 169 // Add hystersis due to floating point error accumulation | 169 double newCurrentTime = m_holdTime; |
| 170 if (!isNull(m_startTime) && m_timeline && !limited(calculateCurrentTime(
) + 0.001 * m_playbackRate) && playStateInternal() == Finished) { | 170 if (playStateInternal() == Finished && !isNull(m_startTime) && m_timelin
e) { |
| 171 m_held = false; | 171 // Add hystersis due to floating point error accumulation |
| 172 setCurrentTimeInternal(calculateCurrentTime(), reason); | 172 if (!limited(calculateCurrentTime() + 0.001 * m_playbackRate)) { |
| 173 return; | 173 // The current time became unlimited, eg. due to a backwards |
| 174 // seek of the timeline. |
| 175 newCurrentTime = calculateCurrentTime(); |
| 176 } else if (!limited(m_holdTime)) { |
| 177 // The hold time became unlimited, eg. due to the source content |
| 178 // becoming longer. |
| 179 newCurrentTime = clampTo<double>(calculateCurrentTime(), 0, sour
ceEnd()); |
| 180 } |
| 174 } | 181 } |
| 175 setCurrentTimeInternal(m_holdTime, reason); | 182 setCurrentTimeInternal(newCurrentTime, reason); |
| 176 return; | 183 } else if (limited(calculateCurrentTime())) { |
| 184 m_held = true; |
| 185 m_holdTime = m_playbackRate < 0 ? 0 : sourceEnd(); |
| 177 } | 186 } |
| 178 if (!limited(calculateCurrentTime())) | |
| 179 return; | |
| 180 m_held = true; | |
| 181 m_holdTime = m_playbackRate < 0 ? 0 : sourceEnd(); | |
| 182 } | 187 } |
| 183 | 188 |
| 184 double AnimationPlayer::startTime(bool& isNull) const | 189 double AnimationPlayer::startTime(bool& isNull) const |
| 185 { | 190 { |
| 186 double result = startTime(); | 191 double result = startTime(); |
| 187 isNull = std::isnan(result); | 192 isNull = std::isnan(result); |
| 188 return result; | 193 return result; |
| 189 } | 194 } |
| 190 | 195 |
| 191 double AnimationPlayer::startTime() const | 196 double AnimationPlayer::startTime() const |
| (...skipping 23 matching lines...) Expand all Loading... |
| 215 double AnimationPlayer::currentTimeInternal() const | 220 double AnimationPlayer::currentTimeInternal() const |
| 216 { | 221 { |
| 217 double result = m_held ? m_holdTime : calculateCurrentTime(); | 222 double result = m_held ? m_holdTime : calculateCurrentTime(); |
| 218 #if ENABLE(ASSERT) | 223 #if ENABLE(ASSERT) |
| 219 const_cast<AnimationPlayer*>(this)->updateCurrentTimingState(TimingUpdateOnD
emand); | 224 const_cast<AnimationPlayer*>(this)->updateCurrentTimingState(TimingUpdateOnD
emand); |
| 220 ASSERT(result == (m_held ? m_holdTime : calculateCurrentTime())); | 225 ASSERT(result == (m_held ? m_holdTime : calculateCurrentTime())); |
| 221 #endif | 226 #endif |
| 222 return result; | 227 return result; |
| 223 } | 228 } |
| 224 | 229 |
| 230 double AnimationPlayer::unlimitedCurrentTimeInternal() const |
| 231 { |
| 232 #if ENABLE(ASSERT) |
| 233 currentTimeInternal(); |
| 234 #endif |
| 235 return playStateInternal() == Paused || isNull(m_startTime) |
| 236 ? currentTimeInternal() |
| 237 : calculateCurrentTime(); |
| 238 } |
| 239 |
| 225 void AnimationPlayer::preCommit(int compositorGroup, bool startOnCompositor) | 240 void AnimationPlayer::preCommit(int compositorGroup, bool startOnCompositor) |
| 226 { | 241 { |
| 227 PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand, DoNotSetCompos
itorPending); | 242 PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand, DoNotSetCompos
itorPending); |
| 228 | 243 |
| 229 bool softChange = m_compositorState && (paused() || m_compositorState->playb
ackRate != m_playbackRate); | 244 bool softChange = m_compositorState && (paused() || m_compositorState->playb
ackRate != m_playbackRate); |
| 230 bool hardChange = m_compositorState && (m_compositorState->sourceChanged ||
m_compositorState->startTime != m_startTime); | 245 bool hardChange = m_compositorState && (m_compositorState->sourceChanged ||
m_compositorState->startTime != m_startTime); |
| 231 | 246 |
| 232 // FIXME: softChange && !hardChange should generate a Pause/ThenStart, | 247 // FIXME: softChange && !hardChange should generate a Pause/ThenStart, |
| 233 // not a Cancel, but we can't communicate these to the compositor yet. | 248 // not a Cancel, but we can't communicate these to the compositor yet. |
| 234 | 249 |
| (...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 930 visitor->trace(m_content); | 945 visitor->trace(m_content); |
| 931 visitor->trace(m_timeline); | 946 visitor->trace(m_timeline); |
| 932 visitor->trace(m_pendingFinishedEvent); | 947 visitor->trace(m_pendingFinishedEvent); |
| 933 visitor->trace(m_finishedPromise); | 948 visitor->trace(m_finishedPromise); |
| 934 visitor->trace(m_readyPromise); | 949 visitor->trace(m_readyPromise); |
| 935 EventTargetWithInlineData::trace(visitor); | 950 EventTargetWithInlineData::trace(visitor); |
| 936 ActiveDOMObject::trace(visitor); | 951 ActiveDOMObject::trace(visitor); |
| 937 } | 952 } |
| 938 | 953 |
| 939 } // namespace | 954 } // namespace |
| OLD | NEW |