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

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

Issue 2869183002: Initial implementation of WorkletAnimation (Closed)
Patch Set: DCHECK for threaded animation support 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 static WorkletAnimation* Create(
27 String animator_name,
28 const HeapVector<Member<KeyframeEffectReadOnly>>&,
29 HeapVector<DocumentTimelineOrScrollTimeline>&,
30 RefPtr<SerializedScriptValue>,
31 ExceptionState&);
32
33 virtual ~WorkletAnimation() {}
34
35 // WorkletAnimationBase implementation.
36 void Update() override;
37
38 // CompositorAnimationPlayerClient implementation.
39 CompositorAnimationPlayer* CompositorPlayer() const override {
40 return compositor_player_ ? compositor_player_->Player() : nullptr;
41 }
42
43 // CompositorAnimationDelegate implementation.
44 void NotifyAnimationStarted(double monotonic_time, int group) override {
45 LOG(INFO) << "WorkletAnimation::NotifyAnimationStarted";
46 }
47 void NotifyAnimationFinished(double monotonic_time, int group) override {
48 LOG(INFO) << "WorkletAnimation::NotifyAnimationFinished";
49 }
50 void NotifyAnimationAborted(double monotonic_time, int group) override {
51 LOG(INFO) << "WorkletAnimation::NotifyAnimationAborted";
flackr 2017/06/07 17:21:33 This was probably testing code, but I don't think
smcgruer 2017/06/07 18:23:25 It was testing code, removed.
52 }
53
54 void AttachCompositorTimeline();
55 void DetachCompositorTimeline();
56 void Dispose();
57
58 String Name() { return animator_name_; }
59
60 const HeapVector<DocumentTimelineOrScrollTimeline>& Timelines() {
61 return timelines_;
62 }
63
64 const RefPtr<SerializedScriptValue> UserData() { return user_data_; }
65
66 void SetEffectInheritedTimeForTesting(Member<KeyframeEffectReadOnly>, double);
67
68 DECLARE_VIRTUAL_TRACE();
69
70 private:
71 WorkletAnimation(String animator_name,
72 const HeapVector<Member<KeyframeEffectReadOnly>>&,
73 HeapVector<DocumentTimelineOrScrollTimeline>&,
74 RefPtr<SerializedScriptValue>,
75 AnimationTimeline&);
76
77 // TODO(smcgruer): This pattern was copied from Animation.h. Document why we
78 // do this, or remove the layer of indirection.
79 class CompositorAnimationPlayerHolder
majidvp 2017/06/06 17:23:14 Perhaps we should make this a public class in Comp
smcgruer 2017/06/07 18:23:25 Difficult; they take an Animation*/WorkletAnimatio
80 : public GarbageCollectedFinalized<CompositorAnimationPlayerHolder> {
81 USING_PRE_FINALIZER(CompositorAnimationPlayerHolder, Dispose);
82
83 public:
84 static CompositorAnimationPlayerHolder* Create(WorkletAnimation*);
85
86 void Detach();
87
88 DEFINE_INLINE_TRACE() { visitor->Trace(animation_); }
89
90 CompositorAnimationPlayer* Player() const {
91 return compositor_player_.get();
92 }
93
94 private:
95 explicit CompositorAnimationPlayerHolder(WorkletAnimation*);
96
97 void Dispose();
98
99 std::unique_ptr<CompositorAnimationPlayer> compositor_player_;
100 Member<WorkletAnimation> animation_;
101 };
102
103 String animator_name_;
104 HeapVector<Member<KeyframeEffectReadOnly>> effects_;
105 HeapVector<DocumentTimelineOrScrollTimeline> timelines_;
106 RefPtr<SerializedScriptValue> user_data_;
107
108 Member<AnimationTimeline> main_document_timeline_;
109
110 Member<CompositorAnimationPlayerHolder> compositor_player_;
111
112 bool on_compositor_;
113 };
114
115 } // namespace blink
116
117 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698