| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 , m_sequenceNumber(nextSequenceNumber()) | 70 , m_sequenceNumber(nextSequenceNumber()) |
| 71 , m_content(content) | 71 , m_content(content) |
| 72 , m_timeline(&timeline) | 72 , m_timeline(&timeline) |
| 73 , m_paused(false) | 73 , m_paused(false) |
| 74 , m_held(true) | 74 , m_held(true) |
| 75 , m_isPausedForTesting(false) | 75 , m_isPausedForTesting(false) |
| 76 , m_outdated(true) | 76 , m_outdated(true) |
| 77 , m_finished(true) | 77 , m_finished(true) |
| 78 , m_compositorState(nullptr) | 78 , m_compositorState(nullptr) |
| 79 , m_compositorPending(true) | 79 , m_compositorPending(true) |
| 80 , m_compositorGroup(0) |
| 80 , m_currentTimePending(false) | 81 , m_currentTimePending(false) |
| 81 { | 82 { |
| 82 if (m_content) { | 83 if (m_content) { |
| 83 if (m_content->player()) { | 84 if (m_content->player()) { |
| 84 m_content->player()->cancel(); | 85 m_content->player()->cancel(); |
| 85 m_content->player()->setSource(0); | 86 m_content->player()->setSource(0); |
| 86 } | 87 } |
| 87 m_content->attach(this); | 88 m_content->attach(this); |
| 88 } | 89 } |
| 89 } | 90 } |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 double AnimationPlayer::currentTimeInternal() const | 197 double AnimationPlayer::currentTimeInternal() const |
| 197 { | 198 { |
| 198 double result = m_held ? m_holdTime : calculateCurrentTime(); | 199 double result = m_held ? m_holdTime : calculateCurrentTime(); |
| 199 #if ENABLE(ASSERT) | 200 #if ENABLE(ASSERT) |
| 200 const_cast<AnimationPlayer*>(this)->updateCurrentTimingState(TimingUpdateOnD
emand); | 201 const_cast<AnimationPlayer*>(this)->updateCurrentTimingState(TimingUpdateOnD
emand); |
| 201 ASSERT(result == (m_held ? m_holdTime : calculateCurrentTime())); | 202 ASSERT(result == (m_held ? m_holdTime : calculateCurrentTime())); |
| 202 #endif | 203 #endif |
| 203 return result; | 204 return result; |
| 204 } | 205 } |
| 205 | 206 |
| 206 void AnimationPlayer::preCommit(bool startOnCompositor) | 207 void AnimationPlayer::preCommit(int compositorGroup, bool startOnCompositor) |
| 207 { | 208 { |
| 208 if (m_compositorState && m_compositorState->pendingAction == Start) { | 209 if (m_compositorState && m_compositorState->pendingAction == Start) { |
| 209 // Still waiting for a start time. | 210 // Still waiting for a start time. |
| 210 return; | 211 return; |
| 211 } | 212 } |
| 212 | 213 |
| 213 PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand, DoNotSetCompos
itorPending); | 214 PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand, DoNotSetCompos
itorPending); |
| 214 | 215 |
| 215 bool softChange = m_compositorState && (paused() || m_compositorState->playb
ackRate != m_playbackRate); | 216 bool softChange = m_compositorState && (paused() || m_compositorState->playb
ackRate != m_playbackRate); |
| 216 bool hardChange = m_compositorState && (m_compositorState->sourceChanged ||
(m_compositorState->startTime != m_startTime && !std::isnan(m_compositorState->s
tartTime) && !std::isnan(m_startTime))); | 217 bool hardChange = m_compositorState && (m_compositorState->sourceChanged ||
(m_compositorState->startTime != m_startTime && !std::isnan(m_compositorState->s
tartTime) && !std::isnan(m_startTime))); |
| 217 | 218 |
| 218 // FIXME: softChange && !hardChange should generate a Pause/ThenStart, | 219 // FIXME: softChange && !hardChange should generate a Pause/ThenStart, |
| 219 // not a Cancel, but we can't communicate these to the compositor yet. | 220 // not a Cancel, but we can't communicate these to the compositor yet. |
| 220 | 221 |
| 221 bool changed = softChange || hardChange; | 222 bool changed = softChange || hardChange; |
| 222 bool shouldCancel = (!playing() && m_compositorState) || changed; | 223 bool shouldCancel = (!playing() && m_compositorState) || changed; |
| 223 bool shouldStart = playing() && (!m_compositorState || changed); | 224 bool shouldStart = playing() && (!m_compositorState || changed); |
| 224 | 225 |
| 225 if (shouldCancel) { | 226 if (shouldCancel) { |
| 226 cancelAnimationOnCompositor(); | 227 cancelAnimationOnCompositor(); |
| 227 m_compositorState = nullptr; | 228 m_compositorState = nullptr; |
| 228 } | 229 } |
| 229 | 230 |
| 230 if (!shouldStart) { | 231 if (!shouldStart) { |
| 231 m_currentTimePending = false; | 232 m_currentTimePending = false; |
| 232 } | 233 } |
| 233 | 234 |
| 234 if (shouldStart && startOnCompositor && maybeStartAnimationOnCompositor()) { | 235 if (shouldStart) { |
| 235 m_compositorState = adoptPtr(new CompositorState(*this)); | 236 m_compositorGroup = compositorGroup; |
| 237 if (startOnCompositor && maybeStartAnimationOnCompositor()) { |
| 238 m_compositorState = adoptPtr(new CompositorState(*this)); |
| 239 } |
| 236 } | 240 } |
| 237 } | 241 } |
| 238 | 242 |
| 239 void AnimationPlayer::postCommit(double timelineTime) | 243 void AnimationPlayer::postCommit(double timelineTime) |
| 240 { | 244 { |
| 241 PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand, DoNotSetCompos
itorPending); | 245 PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand, DoNotSetCompos
itorPending); |
| 242 | 246 |
| 243 m_compositorPending = false; | 247 m_compositorPending = false; |
| 244 | 248 |
| 245 if (!m_compositorState || m_compositorState->pendingAction == None) | 249 if (!m_compositorState || m_compositorState->pendingAction == None) |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 double startTime = timeline()->zeroTime() + startTimeInternal(); | 620 double startTime = timeline()->zeroTime() + startTimeInternal(); |
| 617 if (reversed) { | 621 if (reversed) { |
| 618 startTime -= sourceEnd() / fabs(m_playbackRate); | 622 startTime -= sourceEnd() / fabs(m_playbackRate); |
| 619 } | 623 } |
| 620 | 624 |
| 621 double timeOffset = 0; | 625 double timeOffset = 0; |
| 622 if (std::isnan(startTime)) { | 626 if (std::isnan(startTime)) { |
| 623 timeOffset = reversed ? sourceEnd() - currentTimeInternal() : currentTim
eInternal(); | 627 timeOffset = reversed ? sourceEnd() - currentTimeInternal() : currentTim
eInternal(); |
| 624 timeOffset = timeOffset / fabs(m_playbackRate); | 628 timeOffset = timeOffset / fabs(m_playbackRate); |
| 625 } | 629 } |
| 626 return toAnimation(m_content.get())->maybeStartAnimationOnCompositor(startTi
me, timeOffset, m_playbackRate); | 630 ASSERT(m_compositorGroup != 0); |
| 631 return toAnimation(m_content.get())->maybeStartAnimationOnCompositor(m_compo
sitorGroup, startTime, timeOffset, m_playbackRate); |
| 627 } | 632 } |
| 628 | 633 |
| 629 void AnimationPlayer::setCompositorPending(bool sourceChanged) | 634 void AnimationPlayer::setCompositorPending(bool sourceChanged) |
| 630 { | 635 { |
| 631 // FIXME: Animation could notify this directly? | 636 // FIXME: Animation could notify this directly? |
| 632 if (!hasActiveAnimationsOnCompositor()) { | 637 if (!hasActiveAnimationsOnCompositor()) { |
| 633 m_compositorState.release(); | 638 m_compositorState.release(); |
| 634 } | 639 } |
| 635 if (sourceChanged && m_compositorState) { | 640 if (sourceChanged && m_compositorState) { |
| 636 m_compositorState->sourceChanged = true; | 641 m_compositorState->sourceChanged = true; |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 | 838 |
| 834 void AnimationPlayer::trace(Visitor* visitor) | 839 void AnimationPlayer::trace(Visitor* visitor) |
| 835 { | 840 { |
| 836 visitor->trace(m_content); | 841 visitor->trace(m_content); |
| 837 visitor->trace(m_timeline); | 842 visitor->trace(m_timeline); |
| 838 visitor->trace(m_pendingFinishedEvent); | 843 visitor->trace(m_pendingFinishedEvent); |
| 839 EventTargetWithInlineData::trace(visitor); | 844 EventTargetWithInlineData::trace(visitor); |
| 840 } | 845 } |
| 841 | 846 |
| 842 } // namespace | 847 } // namespace |
| OLD | NEW |