| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef WorkletAnimation_h |
| 6 #define WorkletAnimation_h |
| 7 |
| 8 #include "bindings/core/v8/serialization/SerializedScriptValue.h" |
| 9 #include "bindings/modules/v8/DocumentTimelineOrScrollTimeline.h" |
| 10 #include "core/animation/KeyframeEffectReadOnly.h" |
| 11 #include "core/animation/WorkletAnimationBase.h" |
| 12 #include "modules/ModulesExport.h" |
| 13 #include "platform/animation/CompositorAnimationDelegate.h" |
| 14 #include "platform/animation/CompositorAnimationPlayer.h" |
| 15 #include "platform/animation/CompositorAnimationPlayerClient.h" |
| 16 #include "platform/bindings/ScriptWrappable.h" |
| 17 |
| 18 namespace blink { |
| 19 |
| 20 class MODULES_EXPORT WorkletAnimation : public WorkletAnimationBase, |
| 21 public ScriptWrappable, |
| 22 public CompositorAnimationPlayerClient, |
| 23 public CompositorAnimationDelegate { |
| 24 DEFINE_WRAPPERTYPEINFO(); |
| 25 USING_PRE_FINALIZER(WorkletAnimation, Dispose); |
| 26 |
| 27 public: |
| 28 enum AnimationPlayState { |
| 29 kIdle, |
| 30 kPending, |
| 31 kRunning, |
| 32 }; |
| 33 |
| 34 static WorkletAnimation* Create( |
| 35 String animator_name, |
| 36 const HeapVector<Member<KeyframeEffectReadOnly>>&, |
| 37 HeapVector<DocumentTimelineOrScrollTimeline>&, |
| 38 RefPtr<SerializedScriptValue>, |
| 39 ExceptionState&); |
| 40 |
| 41 virtual ~WorkletAnimation() {} |
| 42 |
| 43 String playState(); |
| 44 void play(); |
| 45 void cancel(); |
| 46 |
| 47 // WorkletAnimationBase implementation. |
| 48 bool StartOnCompositor() override; |
| 49 |
| 50 // CompositorAnimationPlayerClient implementation. |
| 51 CompositorAnimationPlayer* CompositorPlayer() const override { |
| 52 return compositor_player_.get(); |
| 53 } |
| 54 |
| 55 // CompositorAnimationDelegate implementation. |
| 56 void NotifyAnimationStarted(double monotonic_time, int group) override {} |
| 57 void NotifyAnimationFinished(double monotonic_time, int group) override {} |
| 58 void NotifyAnimationAborted(double monotonic_time, int group) override {} |
| 59 |
| 60 void Dispose(); |
| 61 |
| 62 String Name() { return animator_name_; } |
| 63 |
| 64 const HeapVector<DocumentTimelineOrScrollTimeline>& Timelines() { |
| 65 return timelines_; |
| 66 } |
| 67 |
| 68 const RefPtr<SerializedScriptValue> Options() { return options_; } |
| 69 |
| 70 DECLARE_VIRTUAL_TRACE(); |
| 71 |
| 72 private: |
| 73 WorkletAnimation(String animator_name, |
| 74 Document&, |
| 75 const HeapVector<Member<KeyframeEffectReadOnly>>&, |
| 76 HeapVector<DocumentTimelineOrScrollTimeline>&, |
| 77 RefPtr<SerializedScriptValue>); |
| 78 |
| 79 String animator_name_; |
| 80 AnimationPlayState play_state_; |
| 81 |
| 82 Member<Document> document_; |
| 83 |
| 84 HeapVector<Member<KeyframeEffectReadOnly>> effects_; |
| 85 HeapVector<DocumentTimelineOrScrollTimeline> timelines_; |
| 86 RefPtr<SerializedScriptValue> options_; |
| 87 |
| 88 std::unique_ptr<CompositorAnimationPlayer> compositor_player_; |
| 89 }; |
| 90 |
| 91 } // namespace blink |
| 92 |
| 93 #endif |
| OLD | NEW |