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; |
shans
2014/10/15 03:38:01
I like this patch already
dstockwell
2014/10/15 08:30:04
Ack.
| |
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 // This won't be needed when AnimationPlayer is moved to Oilpan. | 153 // This won't be needed when AnimationPlayer is moved to Oilpan. |
154 bool canFree() const; | 154 bool canFree() const; |
155 #endif | 155 #endif |
156 | 156 |
157 virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<Even tListener>, bool useCapture = false) OVERRIDE; | 157 virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<Even tListener>, bool useCapture = false) OVERRIDE; |
158 | 158 |
159 virtual void trace(Visitor*) OVERRIDE; | 159 virtual void trace(Visitor*) OVERRIDE; |
160 | 160 |
161 private: | 161 private: |
162 AnimationPlayer(ExecutionContext*, AnimationTimeline&, AnimationNode*); | 162 AnimationPlayer(ExecutionContext*, AnimationTimeline&, AnimationNode*); |
163 | |
163 double sourceEnd() const; | 164 double sourceEnd() const; |
164 bool limited(double currentTime) const; | 165 bool limited(double currentTime) const; |
166 | |
167 AnimationPlayState calculatePlayState(); | |
168 double calculateCurrentTime() const; | |
169 | |
170 void unpauseInternal(); | |
171 void uncancel(); | |
165 void setPlaybackRateInternal(double); | 172 void setPlaybackRateInternal(double); |
166 void updateCurrentTimingState(TimingUpdateReason); | 173 void updateCurrentTimingState(TimingUpdateReason); |
167 void unpauseInternal(); | |
168 void uncancel(); | |
169 void setFinished(bool); | |
170 | 174 |
175 | |
176 AnimationPlayState m_playState; | |
171 double m_playbackRate; | 177 double m_playbackRate; |
172 | |
173 double m_startTime; | 178 double m_startTime; |
174 double m_holdTime; | 179 double m_holdTime; |
175 | 180 |
176 unsigned m_sequenceNumber; | 181 unsigned m_sequenceNumber; |
177 | 182 |
178 RefPtrWillBeMember<AnimationNode> m_content; | 183 RefPtrWillBeMember<AnimationNode> m_content; |
179 RawPtrWillBeMember<AnimationTimeline> m_timeline; | 184 RawPtrWillBeMember<AnimationTimeline> m_timeline; |
180 // Reflects all pausing, including via pauseForTesting(). | 185 // Reflects all pausing, including via pauseForTesting(). |
181 bool m_paused; | 186 bool m_paused; |
182 bool m_held; | 187 bool m_held; |
(...skipping 25 matching lines...) Expand all Loading... | |
208 , sourceChanged(false) | 213 , sourceChanged(false) |
209 , pendingAction(Start) | 214 , pendingAction(Start) |
210 { } | 215 { } |
211 double startTime; | 216 double startTime; |
212 double holdTime; | 217 double holdTime; |
213 double playbackRate; | 218 double playbackRate; |
214 bool sourceChanged; | 219 bool sourceChanged; |
215 CompositorAction pendingAction; | 220 CompositorAction pendingAction; |
216 }; | 221 }; |
217 | 222 |
223 class PlayStateUpdateScope { | |
224 STACK_ALLOCATED(); | |
225 public: | |
226 PlayStateUpdateScope(AnimationPlayer&, TimingUpdateReason); | |
227 ~PlayStateUpdateScope(); | |
228 private: | |
229 AnimationPlayer& m_player; | |
230 AnimationPlayState m_initial; | |
231 }; | |
232 | |
218 // This mirrors the known compositor state. It is created when a compositor | 233 // 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 | 234 // animation is started. Updated once the start time is known and each time |
220 // modifications are pushed to the compositor. | 235 // modifications are pushed to the compositor. |
221 OwnPtr<CompositorState> m_compositorState; | 236 OwnPtr<CompositorState> m_compositorState; |
222 bool m_compositorPending; | 237 bool m_compositorPending; |
223 bool m_currentTimePending; | 238 bool m_currentTimePending; |
224 bool m_idle; | |
225 }; | 239 }; |
226 | 240 |
227 } // namespace blink | 241 } // namespace blink |
228 | 242 |
229 #endif | 243 #endif |
OLD | NEW |