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 21 matching lines...) Expand all Loading... |
32 #define AnimationPlayer_h | 32 #define AnimationPlayer_h |
33 | 33 |
34 #include "bindings/core/v8/ScriptPromise.h" | 34 #include "bindings/core/v8/ScriptPromise.h" |
35 #include "bindings/core/v8/ScriptPromiseProperty.h" | 35 #include "bindings/core/v8/ScriptPromiseProperty.h" |
36 #include "core/CSSPropertyNames.h" | 36 #include "core/CSSPropertyNames.h" |
37 #include "core/animation/AnimationNode.h" | 37 #include "core/animation/AnimationNode.h" |
38 #include "core/dom/ActiveDOMObject.h" | 38 #include "core/dom/ActiveDOMObject.h" |
39 #include "core/dom/DOMException.h" | 39 #include "core/dom/DOMException.h" |
40 #include "core/events/EventTarget.h" | 40 #include "core/events/EventTarget.h" |
41 #include "platform/heap/Handle.h" | 41 #include "platform/heap/Handle.h" |
| 42 #include "public/platform/WebCompositorAnimationDelegate.h" |
| 43 #include "public/platform/WebCompositorAnimationPlayerClient.h" |
42 #include "wtf/RefPtr.h" | 44 #include "wtf/RefPtr.h" |
43 | 45 |
44 namespace blink { | 46 namespace blink { |
45 | 47 |
46 class AnimationTimeline; | 48 class AnimationTimeline; |
47 class Element; | 49 class Element; |
48 class ExceptionState; | 50 class ExceptionState; |
| 51 class WebCompositorAnimationPlayer; |
49 | 52 |
50 class AnimationPlayer final | 53 class AnimationPlayer final |
51 : public EventTargetWithInlineData | 54 : public EventTargetWithInlineData |
52 , public RefCountedWillBeNoBase<AnimationPlayer> | 55 , public RefCountedWillBeNoBase<AnimationPlayer> |
53 , public ActiveDOMObject { | 56 , public ActiveDOMObject |
| 57 , public WebCompositorAnimationDelegate |
| 58 , public WebCompositorAnimationPlayerClient { |
54 DEFINE_WRAPPERTYPEINFO(); | 59 DEFINE_WRAPPERTYPEINFO(); |
55 REFCOUNTED_EVENT_TARGET(AnimationPlayer); | 60 REFCOUNTED_EVENT_TARGET(AnimationPlayer); |
56 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(AnimationPlayer); | 61 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(AnimationPlayer); |
57 public: | 62 public: |
58 enum AnimationPlayState { | 63 enum AnimationPlayState { |
59 Idle, | 64 Idle, |
60 Pending, | 65 Pending, |
61 Running, | 66 Running, |
62 Paused, | 67 Paused, |
63 Finished | 68 Finished |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 | 138 |
134 // Pausing via this method is not reflected in the value returned by | 139 // Pausing via this method is not reflected in the value returned by |
135 // paused() and must never overlap with pausing via pause(). | 140 // paused() and must never overlap with pausing via pause(). |
136 void pauseForTesting(double pauseTime); | 141 void pauseForTesting(double pauseTime); |
137 // This should only be used for CSS | 142 // This should only be used for CSS |
138 void unpause(); | 143 void unpause(); |
139 | 144 |
140 void setOutdated(); | 145 void setOutdated(); |
141 bool outdated() { return m_outdated; } | 146 bool outdated() { return m_outdated; } |
142 | 147 |
143 bool canStartAnimationOnCompositor(); | 148 bool canStartAnimationOnCompositor() const; |
| 149 bool isCandidateForAnimationOnCompositor() const; |
144 bool maybeStartAnimationOnCompositor(); | 150 bool maybeStartAnimationOnCompositor(); |
145 void cancelAnimationOnCompositor(); | 151 void cancelAnimationOnCompositor(); |
146 void restartAnimationOnCompositor(); | 152 void restartAnimationOnCompositor(); |
147 void cancelIncompatibleAnimationsOnCompositor(); | 153 void cancelIncompatibleAnimationsOnCompositor(); |
148 bool hasActiveAnimationsOnCompositor(); | 154 bool hasActiveAnimationsOnCompositor(); |
149 void setCompositorPending(bool sourceChanged = false); | 155 void setCompositorPending(bool sourceChanged = false); |
150 void notifyCompositorStartTime(double timelineTime); | 156 void notifyCompositorStartTime(double timelineTime); |
151 void notifyStartTime(double timelineTime); | 157 void notifyStartTime(double timelineTime); |
| 158 // WebCompositorAnimationPlayerClient implementation. |
| 159 WebCompositorAnimationPlayer* compositorPlayer() const override { return m_c
ompositorPlayer.get(); } |
152 | 160 |
153 bool affects(const Element&, CSSPropertyID) const; | 161 bool affects(const Element&, CSSPropertyID) const; |
154 | 162 |
155 void preCommit(int compositorGroup, bool startOnCompositor); | 163 void preCommit(int compositorGroup, bool startOnCompositor); |
156 void postCommit(double timelineTime); | 164 void postCommit(double timelineTime); |
157 | 165 |
158 unsigned sequenceNumber() const { return m_sequenceNumber; } | 166 unsigned sequenceNumber() const { return m_sequenceNumber; } |
159 int compositorGroup() const { return m_compositorGroup; } | 167 int compositorGroup() const { return m_compositorGroup; } |
160 | 168 |
161 static bool hasLowerPriority(const AnimationPlayer* player1, const Animation
Player* player2) | 169 static bool hasLowerPriority(const AnimationPlayer* player1, const Animation
Player* player2) |
(...skipping 14 matching lines...) Expand all Loading... |
176 AnimationPlayState calculatePlayState(); | 184 AnimationPlayState calculatePlayState(); |
177 double calculateCurrentTime() const; | 185 double calculateCurrentTime() const; |
178 | 186 |
179 void unpauseInternal(); | 187 void unpauseInternal(); |
180 void setPlaybackRateInternal(double); | 188 void setPlaybackRateInternal(double); |
181 void updateCurrentTimingState(TimingUpdateReason); | 189 void updateCurrentTimingState(TimingUpdateReason); |
182 | 190 |
183 void beginUpdatingState(); | 191 void beginUpdatingState(); |
184 void endUpdatingState(); | 192 void endUpdatingState(); |
185 | 193 |
| 194 void createCompositorPlayer(); |
| 195 void destroyCompositorPlayer(); |
| 196 void attachCompositorTimeline(); |
| 197 void detachCompositorTimeline(); |
| 198 void attachCompositedLayers(); |
| 199 void detachCompositedLayers(); |
| 200 // WebCompositorAnimationDelegate implementation. |
| 201 void notifyAnimationStarted(double monotonicTime, int group) override; |
| 202 void notifyAnimationFinished(double monotonicTime, int group) override { } |
| 203 |
186 AnimationPlayState m_playState; | 204 AnimationPlayState m_playState; |
187 double m_playbackRate; | 205 double m_playbackRate; |
188 double m_startTime; | 206 double m_startTime; |
189 double m_holdTime; | 207 double m_holdTime; |
190 | 208 |
191 unsigned m_sequenceNumber; | 209 unsigned m_sequenceNumber; |
192 | 210 |
193 typedef ScriptPromiseProperty<RawPtrWillBeMember<AnimationPlayer>, RawPtrWil
lBeMember<AnimationPlayer>, RefPtrWillBeMember<DOMException>> AnimationPlayerPro
mise; | 211 typedef ScriptPromiseProperty<RawPtrWillBeMember<AnimationPlayer>, RawPtrWil
lBeMember<AnimationPlayer>, RefPtrWillBeMember<DOMException>> AnimationPlayerPro
mise; |
194 PersistentWillBeMember<AnimationPlayerPromise> m_finishedPromise; | 212 PersistentWillBeMember<AnimationPlayerPromise> m_finishedPromise; |
195 PersistentWillBeMember<AnimationPlayerPromise> m_readyPromise; | 213 PersistentWillBeMember<AnimationPlayerPromise> m_readyPromise; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 CompositorPendingChange m_compositorPendingChange; | 269 CompositorPendingChange m_compositorPendingChange; |
252 }; | 270 }; |
253 | 271 |
254 // This mirrors the known compositor state. It is created when a compositor | 272 // This mirrors the known compositor state. It is created when a compositor |
255 // animation is started. Updated once the start time is known and each time | 273 // animation is started. Updated once the start time is known and each time |
256 // modifications are pushed to the compositor. | 274 // modifications are pushed to the compositor. |
257 OwnPtr<CompositorState> m_compositorState; | 275 OwnPtr<CompositorState> m_compositorState; |
258 bool m_compositorPending; | 276 bool m_compositorPending; |
259 int m_compositorGroup; | 277 int m_compositorGroup; |
260 | 278 |
| 279 OwnPtr<WebCompositorAnimationPlayer> m_compositorPlayer; |
| 280 |
261 bool m_currentTimePending; | 281 bool m_currentTimePending; |
262 bool m_stateIsBeingUpdated; | 282 bool m_stateIsBeingUpdated; |
263 | |
264 }; | 283 }; |
265 | 284 |
266 } // namespace blink | 285 } // namespace blink |
267 | 286 |
268 #endif // AnimationPlayer_h | 287 #endif // AnimationPlayer_h |
OLD | NEW |