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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "public/platform/WebCompositorAnimationPlayerClient.h" | 44 #include "public/platform/WebCompositorAnimationPlayerClient.h" |
45 #include "wtf/RefPtr.h" | 45 #include "wtf/RefPtr.h" |
46 | 46 |
47 namespace blink { | 47 namespace blink { |
48 | 48 |
49 class AnimationTimeline; | 49 class AnimationTimeline; |
50 class Element; | 50 class Element; |
51 class ExceptionState; | 51 class ExceptionState; |
52 class WebCompositorAnimationPlayer; | 52 class WebCompositorAnimationPlayer; |
53 | 53 |
54 class CORE_EXPORT Animation final | 54 class CORE_EXPORT Animation final : public RefCountedGarbageCollectedEventTarget
WithInlineData<Animation>, public ActiveDOMObject, public WebCompositorAnimation
Delegate, public WebCompositorAnimationPlayerClient { |
55 : public EventTargetWithInlineData | |
56 , public RefCountedWillBeNoBase<Animation> | |
57 , public ActiveDOMObject | |
58 , public WebCompositorAnimationDelegate | |
59 , public WebCompositorAnimationPlayerClient { | |
60 DEFINE_WRAPPERTYPEINFO(); | 55 DEFINE_WRAPPERTYPEINFO(); |
61 REFCOUNTED_EVENT_TARGET(Animation); | 56 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(Animation); |
62 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Animation); | 57 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Animation); |
63 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(Animation); | 58 #if ENABLE(LAZY_SWEEPING) |
| 59 EAGERLY_FINALIZE(); |
| 60 #else |
| 61 USING_PRE_FINALIZER(Animation, disposeAnimation); |
| 62 #endif |
64 public: | 63 public: |
65 enum AnimationPlayState { | 64 enum AnimationPlayState { |
66 Idle, | 65 Idle, |
67 Pending, | 66 Pending, |
68 Running, | 67 Running, |
69 Paused, | 68 Paused, |
70 Finished | 69 Finished |
71 }; | 70 }; |
72 | 71 |
73 ~Animation(); | 72 ~Animation(); |
74 static PassRefPtrWillBeRawPtr<Animation> create(AnimationEffect*, AnimationT
imeline*); | 73 void disposeAnimation(); |
| 74 static Animation* create(AnimationEffect*, AnimationTimeline*); |
75 | 75 |
76 // Returns whether the animation is finished. | 76 // Returns whether the animation is finished. |
77 bool update(TimingUpdateReason); | 77 bool update(TimingUpdateReason); |
78 | 78 |
79 // timeToEffectChange returns: | 79 // timeToEffectChange returns: |
80 // infinity - if this animation is no longer in effect | 80 // infinity - if this animation is no longer in effect |
81 // 0 - if this animation requires an update on the next frame | 81 // 0 - if this animation requires an update on the next frame |
82 // n - if this animation requires an update after 'n' units of time | 82 // n - if this animation requires an update after 'n' units of time |
83 double timeToEffectChange(); | 83 double timeToEffectChange(); |
84 | 84 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 double startTime() const; | 131 double startTime() const; |
132 double startTimeInternal() const { return m_startTime; } | 132 double startTimeInternal() const { return m_startTime; } |
133 void setStartTime(double); | 133 void setStartTime(double); |
134 void setStartTimeInternal(double); | 134 void setStartTimeInternal(double); |
135 | 135 |
136 double startClip() const { return startClipInternal() * 1000; } | 136 double startClip() const { return startClipInternal() * 1000; } |
137 double endClip() const { return endClipInternal() * 1000; } | 137 double endClip() const { return endClipInternal() * 1000; } |
138 void setStartClip(double t) { setStartClipInternal(t / 1000); } | 138 void setStartClip(double t) { setStartClipInternal(t / 1000); } |
139 void setEndClip(double t) { setEndClipInternal(t / 1000); } | 139 void setEndClip(double t) { setEndClipInternal(t / 1000); } |
140 | 140 |
141 const AnimationEffect* effect() const { return m_content.get(); } | 141 const AnimationEffect* effect() const { return m_content; } |
142 AnimationEffect* effect() { return m_content.get(); } | 142 AnimationEffect* effect() { return m_content; } |
143 void setEffect(AnimationEffect*); | 143 void setEffect(AnimationEffect*); |
144 | 144 |
145 // Pausing via this method is not reflected in the value returned by | 145 // Pausing via this method is not reflected in the value returned by |
146 // paused() and must never overlap with pausing via pause(). | 146 // paused() and must never overlap with pausing via pause(). |
147 void pauseForTesting(double pauseTime); | 147 void pauseForTesting(double pauseTime); |
148 void disableCompositedAnimationForTesting(); | 148 void disableCompositedAnimationForTesting(); |
149 | 149 |
150 // This should only be used for CSS | 150 // This should only be used for CSS |
151 void unpause(); | 151 void unpause(); |
152 | 152 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 | 223 |
224 AnimationPlayState m_playState; | 224 AnimationPlayState m_playState; |
225 double m_playbackRate; | 225 double m_playbackRate; |
226 double m_startTime; | 226 double m_startTime; |
227 double m_holdTime; | 227 double m_holdTime; |
228 double m_startClip; | 228 double m_startClip; |
229 double m_endClip; | 229 double m_endClip; |
230 | 230 |
231 unsigned m_sequenceNumber; | 231 unsigned m_sequenceNumber; |
232 | 232 |
233 typedef ScriptPromiseProperty<RawPtrWillBeMember<Animation>, RawPtrWillBeMem
ber<Animation>, Member<DOMException>> AnimationPromise; | 233 typedef ScriptPromiseProperty<Member<Animation>, Member<Animation>, Member<D
OMException>> AnimationPromise; |
234 PersistentWillBeMember<AnimationPromise> m_finishedPromise; | 234 Member<AnimationPromise> m_finishedPromise; |
235 PersistentWillBeMember<AnimationPromise> m_readyPromise; | 235 Member<AnimationPromise> m_readyPromise; |
236 | 236 |
237 RefPtrWillBeMember<AnimationEffect> m_content; | 237 Member<AnimationEffect> m_content; |
238 RawPtrWillBeMember<AnimationTimeline> m_timeline; | 238 Member<AnimationTimeline> m_timeline; |
239 // Reflects all pausing, including via pauseForTesting(). | 239 // Reflects all pausing, including via pauseForTesting(). |
240 bool m_paused; | 240 bool m_paused; |
241 bool m_held; | 241 bool m_held; |
242 bool m_isPausedForTesting; | 242 bool m_isPausedForTesting; |
243 bool m_isCompositedAnimationDisabledForTesting; | 243 bool m_isCompositedAnimationDisabledForTesting; |
244 | 244 |
245 // This indicates timing information relevant to the animation's effect | 245 // This indicates timing information relevant to the animation's effect |
246 // has changed by means other than the ordinary progression of time | 246 // has changed by means other than the ordinary progression of time |
247 bool m_outdated; | 247 bool m_outdated; |
248 | 248 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 SetCompositorPendingWithEffectChanged, | 282 SetCompositorPendingWithEffectChanged, |
283 DoNotSetCompositorPending, | 283 DoNotSetCompositorPending, |
284 }; | 284 }; |
285 | 285 |
286 class PlayStateUpdateScope { | 286 class PlayStateUpdateScope { |
287 STACK_ALLOCATED(); | 287 STACK_ALLOCATED(); |
288 public: | 288 public: |
289 PlayStateUpdateScope(Animation&, TimingUpdateReason, CompositorPendingCh
ange = SetCompositorPending); | 289 PlayStateUpdateScope(Animation&, TimingUpdateReason, CompositorPendingCh
ange = SetCompositorPending); |
290 ~PlayStateUpdateScope(); | 290 ~PlayStateUpdateScope(); |
291 private: | 291 private: |
292 RawPtrWillBeMember<Animation> m_animation; | 292 Member<Animation> m_animation; |
293 AnimationPlayState m_initialPlayState; | 293 AnimationPlayState m_initialPlayState; |
294 CompositorPendingChange m_compositorPendingChange; | 294 CompositorPendingChange m_compositorPendingChange; |
295 }; | 295 }; |
296 | 296 |
297 // This mirrors the known compositor state. It is created when a compositor | 297 // This mirrors the known compositor state. It is created when a compositor |
298 // animation is started. Updated once the start time is known and each time | 298 // animation is started. Updated once the start time is known and each time |
299 // modifications are pushed to the compositor. | 299 // modifications are pushed to the compositor. |
300 OwnPtr<CompositorState> m_compositorState; | 300 OwnPtr<CompositorState> m_compositorState; |
301 bool m_compositorPending; | 301 bool m_compositorPending; |
302 int m_compositorGroup; | 302 int m_compositorGroup; |
303 | 303 |
304 OwnPtr<WebCompositorAnimationPlayer> m_compositorPlayer; | 304 OwnPtr<WebCompositorAnimationPlayer> m_compositorPlayer; |
305 | 305 |
306 bool m_currentTimePending; | 306 bool m_currentTimePending; |
307 bool m_stateIsBeingUpdated; | 307 bool m_stateIsBeingUpdated; |
308 }; | 308 }; |
309 | 309 |
310 } // namespace blink | 310 } // namespace blink |
311 | 311 |
312 #endif // Animation_h | 312 #endif // Animation_h |
OLD | NEW |