Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: third_party/WebKit/Source/modules/compositorworker/WorkletAnimation.h

Issue 2869183002: Initial implementation of WorkletAnimation (Closed)
Patch Set: Rebase Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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/AnimationTimeline.h"
11 #include "core/animation/KeyframeEffectReadOnly.h"
12 #include "core/animation/WorkletAnimationBase.h"
13 #include "modules/ModulesExport.h"
14 #include "platform/animation/CompositorAnimationPlayerClient.h"
15 #include "platform/bindings/ScriptWrappable.h"
16
17 namespace blink {
18
19 class MODULES_EXPORT WorkletAnimation : public WorkletAnimationBase,
20 public ScriptWrappable,
21 public CompositorAnimationPlayerClient,
22 public CompositorAnimationDelegate {
23 DEFINE_WRAPPERTYPEINFO();
24
25 public:
26 enum AnimationPlayState {
27 kIdle,
28 kPending,
29 kRunning,
30 };
31
32 static WorkletAnimation* Create(
33 String animator_name,
34 const HeapVector<Member<KeyframeEffectReadOnly>>&,
35 HeapVector<DocumentTimelineOrScrollTimeline>&,
36 RefPtr<SerializedScriptValue>,
37 ExceptionState&);
38
39 virtual ~WorkletAnimation() {}
40
41 String playState();
42 void play();
43 void cancel();
44
45 // WorkletAnimationBase implementation.
46 bool StartOnCompositor() override;
47
48 // CompositorAnimationPlayerClient implementation.
49 CompositorAnimationPlayer* CompositorPlayer() const override {
50 return compositor_player_ ? compositor_player_->Player() : nullptr;
51 }
52
53 // CompositorAnimationDelegate implementation.
54 void NotifyAnimationStarted(double monotonic_time, int group) override {}
55 void NotifyAnimationFinished(double monotonic_time, int group) override {}
56 void NotifyAnimationAborted(double monotonic_time, int group) override {}
57
58 void AttachCompositorTimeline();
59 void DetachCompositorTimeline();
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 void SetEffectInheritedTimeForTesting(Member<KeyframeEffectReadOnly>, double);
alancutter (OOO until 2018) 2017/06/26 11:57:02 We should remove this if we're not using it.
smcgruer 2017/06/26 21:14:08 Leftover, removed.
71
72 DECLARE_VIRTUAL_TRACE();
73
74 private:
75 WorkletAnimation(String animator_name,
76 Document&,
77 const HeapVector<Member<KeyframeEffectReadOnly>>&,
78 HeapVector<DocumentTimelineOrScrollTimeline>&,
79 RefPtr<SerializedScriptValue>);
80
81 // TODO(smcgruer): This pattern was copied from Animation.h. Document why we
82 // do this, or remove the layer of indirection.
alancutter (OOO until 2018) 2017/06/26 11:57:02 We need to do some clean up in Dispose() that's no
83 class CompositorAnimationPlayerHolder
84 : public GarbageCollectedFinalized<CompositorAnimationPlayerHolder> {
85 USING_PRE_FINALIZER(CompositorAnimationPlayerHolder, Dispose);
86
87 public:
88 static CompositorAnimationPlayerHolder* Create(WorkletAnimation*);
89
90 void Detach();
91
92 DEFINE_INLINE_TRACE() { visitor->Trace(animation_); }
93
94 CompositorAnimationPlayer* Player() const {
95 return compositor_player_.get();
96 }
97
98 private:
99 explicit CompositorAnimationPlayerHolder(WorkletAnimation*);
100
101 void Dispose();
102
103 std::unique_ptr<CompositorAnimationPlayer> compositor_player_;
104 Member<WorkletAnimation> animation_;
105 };
106
107 String animator_name_;
108 AnimationPlayState play_state_;
109
110 Member<Document> document_;
111
112 HeapVector<Member<KeyframeEffectReadOnly>> effects_;
113 HeapVector<DocumentTimelineOrScrollTimeline> timelines_;
114 RefPtr<SerializedScriptValue> options_;
115
116 Member<CompositorAnimationPlayerHolder> compositor_player_;
alancutter (OOO until 2018) 2017/06/26 11:57:02 Shouldn't this be a vector of compositor_players t
smcgruer 2017/06/26 21:14:08 This goes back to flackr's comment in WorkletAnima
117 };
118
119 } // namespace blink
120
121 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698