| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 // 0 - if this player requires an update on the next frame | 67 // 0 - if this player requires an update on the next frame |
| 68 // n - if this player requires an update after 'n' units of time | 68 // n - if this player requires an update after 'n' units of time |
| 69 double timeToEffectChange(); | 69 double timeToEffectChange(); |
| 70 | 70 |
| 71 void cancel(); | 71 void cancel(); |
| 72 | 72 |
| 73 double currentTime(bool& isNull); | 73 double currentTime(bool& isNull); |
| 74 double currentTime(); | 74 double currentTime(); |
| 75 void setCurrentTime(double newCurrentTime); | 75 void setCurrentTime(double newCurrentTime); |
| 76 | 76 |
| 77 double calculateCurrentTime() const; | 77 double currentTimeInternal() const; |
| 78 double currentTimeInternal(); | 78 |
| 79 void setCurrentTimeInternal(double newCurrentTime, TimingUpdateReason = Timi
ngUpdateOnDemand); | 79 void setCurrentTimeInternal(double newCurrentTime, TimingUpdateReason = Timi
ngUpdateOnDemand); |
| 80 | |
| 81 bool paused() const { return m_paused && !m_isPausedForTesting; } | 80 bool paused() const { return m_paused && !m_isPausedForTesting; } |
| 82 String playState(); | 81 static const char* playStateString(AnimationPlayState); |
| 83 AnimationPlayState playStateInternal(); | 82 String playState() { return playStateString(playStateInternal()); } |
| 83 AnimationPlayState playStateInternal() const; |
| 84 | 84 |
| 85 void pause(); | 85 void pause(); |
| 86 void play(); | 86 void play(); |
| 87 void reverse(); | 87 void reverse(); |
| 88 void finish(ExceptionState&); | 88 void finish(ExceptionState&); |
| 89 bool finished() { return !m_idle && limited(currentTimeInternal()); } | 89 bool finished() const { return m_playState != Idle && limited(currentTimeInt
ernal()); } |
| 90 bool playing() { return !(finished() || m_paused || m_isPausedForTesting ||
m_idle); } | 90 bool playing() const { return !(playStateInternal() == Idle || finished() ||
m_paused || m_isPausedForTesting); } |
| 91 // FIXME: Resolve whether finished() should just return the flag, and | 91 // FIXME: Resolve whether finished() should just return the flag, and |
| 92 // remove this method. | 92 // remove this method. |
| 93 bool finishedInternal() const { return m_finished; } | 93 bool finishedInternal() const { return m_finished; } |
| 94 | 94 |
| 95 DEFINE_ATTRIBUTE_EVENT_LISTENER(finish); | 95 DEFINE_ATTRIBUTE_EVENT_LISTENER(finish); |
| 96 | 96 |
| 97 virtual const AtomicString& interfaceName() const override; | 97 virtual const AtomicString& interfaceName() const override; |
| 98 virtual ExecutionContext* executionContext() const override; | 98 virtual ExecutionContext* executionContext() const override; |
| 99 virtual bool hasPendingActivity() const override; | 99 virtual bool hasPendingActivity() const override; |
| 100 virtual void stop() override; | 100 virtual void stop() override; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 129 | 129 |
| 130 void setOutdated(); | 130 void setOutdated(); |
| 131 bool outdated() { return m_outdated; } | 131 bool outdated() { return m_outdated; } |
| 132 | 132 |
| 133 bool canStartAnimationOnCompositor(); | 133 bool canStartAnimationOnCompositor(); |
| 134 bool maybeStartAnimationOnCompositor(); | 134 bool maybeStartAnimationOnCompositor(); |
| 135 void cancelAnimationOnCompositor(); | 135 void cancelAnimationOnCompositor(); |
| 136 bool hasActiveAnimationsOnCompositor(); | 136 bool hasActiveAnimationsOnCompositor(); |
| 137 void setCompositorPending(bool sourceChanged = false); | 137 void setCompositorPending(bool sourceChanged = false); |
| 138 void notifyCompositorStartTime(double timelineTime); | 138 void notifyCompositorStartTime(double timelineTime); |
| 139 void notifyStartTime(double timelineTime); |
| 139 | 140 |
| 140 | 141 |
| 141 void preCommit(bool startOnCompositor); | 142 void preCommit(bool startOnCompositor); |
| 142 void postCommit(double timelineTime); | 143 void postCommit(double timelineTime); |
| 143 | 144 |
| 144 unsigned sequenceNumber() const { return m_sequenceNumber; } | 145 unsigned sequenceNumber() const { return m_sequenceNumber; } |
| 145 | 146 |
| 146 static bool hasLowerPriority(AnimationPlayer* player1, AnimationPlayer* play
er2) | 147 static bool hasLowerPriority(AnimationPlayer* player1, AnimationPlayer* play
er2) |
| 147 { | 148 { |
| 148 return player1->sequenceNumber() < player2->sequenceNumber(); | 149 return player1->sequenceNumber() < player2->sequenceNumber(); |
| 149 } | 150 } |
| 150 | 151 |
| 151 #if !ENABLE(OILPAN) | 152 #if !ENABLE(OILPAN) |
| 152 // Checks if the AnimationStack is the last reference holder to the Player. | 153 // Checks if the AnimationStack is the last reference holder to the Player. |
| 153 // This won't be needed when AnimationPlayer is moved to Oilpan. | 154 // This won't be needed when AnimationPlayer is moved to Oilpan. |
| 154 bool canFree() const; | 155 bool canFree() const; |
| 155 #endif | 156 #endif |
| 156 | 157 |
| 157 virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<Even
tListener>, bool useCapture = false) override; | 158 virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<Even
tListener>, bool useCapture = false) override; |
| 158 | 159 |
| 159 virtual void trace(Visitor*) override; | 160 virtual void trace(Visitor*) override; |
| 160 | 161 |
| 161 private: | 162 private: |
| 162 AnimationPlayer(ExecutionContext*, AnimationTimeline&, AnimationNode*); | 163 AnimationPlayer(ExecutionContext*, AnimationTimeline&, AnimationNode*); |
| 164 |
| 163 double sourceEnd() const; | 165 double sourceEnd() const; |
| 164 bool limited(double currentTime) const; | 166 bool limited(double currentTime) const; |
| 167 |
| 168 AnimationPlayState calculatePlayState(); |
| 169 double calculateCurrentTime() const; |
| 170 |
| 171 void unpauseInternal(); |
| 172 void uncancel(); |
| 165 void setPlaybackRateInternal(double); | 173 void setPlaybackRateInternal(double); |
| 166 void updateCurrentTimingState(TimingUpdateReason); | 174 void updateCurrentTimingState(TimingUpdateReason); |
| 167 void unpauseInternal(); | |
| 168 void uncancel(); | |
| 169 void setFinished(bool); | |
| 170 | 175 |
| 176 |
| 177 AnimationPlayState m_playState; |
| 171 double m_playbackRate; | 178 double m_playbackRate; |
| 172 | |
| 173 double m_startTime; | 179 double m_startTime; |
| 174 double m_holdTime; | 180 double m_holdTime; |
| 175 | 181 |
| 176 unsigned m_sequenceNumber; | 182 unsigned m_sequenceNumber; |
| 177 | 183 |
| 178 RefPtrWillBeMember<AnimationNode> m_content; | 184 RefPtrWillBeMember<AnimationNode> m_content; |
| 179 RawPtrWillBeMember<AnimationTimeline> m_timeline; | 185 RawPtrWillBeMember<AnimationTimeline> m_timeline; |
| 180 // Reflects all pausing, including via pauseForTesting(). | 186 // Reflects all pausing, including via pauseForTesting(). |
| 181 bool m_paused; | 187 bool m_paused; |
| 182 bool m_held; | 188 bool m_held; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 208 , sourceChanged(false) | 214 , sourceChanged(false) |
| 209 , pendingAction(Start) | 215 , pendingAction(Start) |
| 210 { } | 216 { } |
| 211 double startTime; | 217 double startTime; |
| 212 double holdTime; | 218 double holdTime; |
| 213 double playbackRate; | 219 double playbackRate; |
| 214 bool sourceChanged; | 220 bool sourceChanged; |
| 215 CompositorAction pendingAction; | 221 CompositorAction pendingAction; |
| 216 }; | 222 }; |
| 217 | 223 |
| 224 enum CompositorPendingChange { |
| 225 SetCompositorPending, |
| 226 SetCompositorPendingWithSourceChanged, |
| 227 DoNotSetCompositorPending, |
| 228 }; |
| 229 |
| 230 class PlayStateUpdateScope { |
| 231 STACK_ALLOCATED(); |
| 232 public: |
| 233 PlayStateUpdateScope(AnimationPlayer&, TimingUpdateReason, CompositorPen
dingChange = SetCompositorPending); |
| 234 ~PlayStateUpdateScope(); |
| 235 private: |
| 236 AnimationPlayer& m_player; |
| 237 AnimationPlayState m_initial; |
| 238 CompositorPendingChange m_compositorPendingChange; |
| 239 }; |
| 240 |
| 218 // This mirrors the known compositor state. It is created when a compositor | 241 // This mirrors the known compositor state. It is created when a compositor |
| 219 // animation is started. Updated once the start time is known and each time | 242 // animation is started. Updated once the start time is known and each time |
| 220 // modifications are pushed to the compositor. | 243 // modifications are pushed to the compositor. |
| 221 OwnPtr<CompositorState> m_compositorState; | 244 OwnPtr<CompositorState> m_compositorState; |
| 222 bool m_compositorPending; | 245 bool m_compositorPending; |
| 223 bool m_currentTimePending; | 246 bool m_currentTimePending; |
| 224 bool m_idle; | |
| 225 }; | 247 }; |
| 226 | 248 |
| 227 } // namespace blink | 249 } // namespace blink |
| 228 | 250 |
| 229 #endif | 251 #endif |
| OLD | NEW |