| 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/document_timeline_or_scroll_timeline.h" |
| 10 #include "core/animation/Animation.h" |
| 11 #include "core/animation/KeyframeEffectReadOnly.h" |
| 12 #include "core/animation/WorkletAnimationBase.h" |
| 13 #include "modules/ModulesExport.h" |
| 14 #include "platform/animation/CompositorAnimationDelegate.h" |
| 15 #include "platform/animation/CompositorAnimationPlayer.h" |
| 16 #include "platform/animation/CompositorAnimationPlayerClient.h" |
| 17 #include "platform/bindings/ScriptWrappable.h" |
| 18 |
| 19 namespace blink { |
| 20 |
| 21 // The main-thread controller for a single AnimationWorklet animator instance. |
| 22 // |
| 23 // WorkletAnimation instances exist in the document execution context (i.e. in |
| 24 // the main javascript thread), and are a type of animation that delegates |
| 25 // actual playback to an 'animator instance'. The animator instance runs in a |
| 26 // separate worklet execution context (which can either also be on the main |
| 27 // thread or may be in a separate worklet thread). |
| 28 // |
| 29 // All methods in this class should be called in the document execution context. |
| 30 // |
| 31 // Spec: https://wicg.github.io/animation-worklet/#worklet-animation-desc |
| 32 class MODULES_EXPORT WorkletAnimation : public WorkletAnimationBase, |
| 33 public ScriptWrappable, |
| 34 public CompositorAnimationPlayerClient, |
| 35 public CompositorAnimationDelegate { |
| 36 DEFINE_WRAPPERTYPEINFO(); |
| 37 USING_PRE_FINALIZER(WorkletAnimation, Dispose); |
| 38 |
| 39 public: |
| 40 static WorkletAnimation* Create( |
| 41 String animator_name, |
| 42 const HeapVector<Member<KeyframeEffectReadOnly>>&, |
| 43 HeapVector<DocumentTimelineOrScrollTimeline>&, |
| 44 RefPtr<SerializedScriptValue>, |
| 45 ExceptionState&); |
| 46 |
| 47 virtual ~WorkletAnimation() {} |
| 48 |
| 49 String playState(); |
| 50 void play(); |
| 51 void cancel(); |
| 52 |
| 53 // WorkletAnimationBase implementation. |
| 54 bool StartOnCompositor() override; |
| 55 |
| 56 // CompositorAnimationPlayerClient implementation. |
| 57 CompositorAnimationPlayer* CompositorPlayer() const override { |
| 58 return compositor_player_.get(); |
| 59 } |
| 60 |
| 61 // CompositorAnimationDelegate implementation. |
| 62 void NotifyAnimationStarted(double monotonic_time, int group) override {} |
| 63 void NotifyAnimationFinished(double monotonic_time, int group) override {} |
| 64 void NotifyAnimationAborted(double monotonic_time, int group) override {} |
| 65 |
| 66 void Dispose(); |
| 67 |
| 68 const String& Name() { return animator_name_; } |
| 69 |
| 70 const HeapVector<DocumentTimelineOrScrollTimeline>& Timelines() { |
| 71 return timelines_; |
| 72 } |
| 73 |
| 74 const RefPtr<SerializedScriptValue> Options() { return options_; } |
| 75 |
| 76 DECLARE_VIRTUAL_TRACE(); |
| 77 |
| 78 private: |
| 79 WorkletAnimation(const String& animator_name, |
| 80 Document&, |
| 81 const HeapVector<Member<KeyframeEffectReadOnly>>&, |
| 82 HeapVector<DocumentTimelineOrScrollTimeline>&, |
| 83 RefPtr<SerializedScriptValue>); |
| 84 |
| 85 const String animator_name_; |
| 86 Animation::AnimationPlayState play_state_; |
| 87 |
| 88 Member<Document> document_; |
| 89 |
| 90 HeapVector<Member<KeyframeEffectReadOnly>> effects_; |
| 91 HeapVector<DocumentTimelineOrScrollTimeline> timelines_; |
| 92 RefPtr<SerializedScriptValue> options_; |
| 93 |
| 94 std::unique_ptr<CompositorAnimationPlayer> compositor_player_; |
| 95 }; |
| 96 |
| 97 } // namespace blink |
| 98 |
| 99 #endif |
| OLD | NEW |