Chromium Code Reviews| Index: third_party/WebKit/Source/modules/compositorworker/WorkletAnimation.h |
| diff --git a/third_party/WebKit/Source/modules/compositorworker/WorkletAnimation.h b/third_party/WebKit/Source/modules/compositorworker/WorkletAnimation.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8c0e5755d79214ff7c5cffbb5f7ffe24c1b99ceb |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/modules/compositorworker/WorkletAnimation.h |
| @@ -0,0 +1,117 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef WorkletAnimation_h |
| +#define WorkletAnimation_h |
| + |
| +#include "bindings/core/v8/serialization/SerializedScriptValue.h" |
| +#include "bindings/modules/v8/DocumentTimelineOrScrollTimeline.h" |
| +#include "core/animation/AnimationTimeline.h" |
| +#include "core/animation/KeyframeEffectReadOnly.h" |
| +#include "core/animation/WorkletAnimationBase.h" |
| +#include "modules/ModulesExport.h" |
| +#include "platform/animation/CompositorAnimationPlayerClient.h" |
| +#include "platform/bindings/ScriptWrappable.h" |
| + |
| +namespace blink { |
| + |
| +class MODULES_EXPORT WorkletAnimation : public WorkletAnimationBase, |
| + public ScriptWrappable, |
| + public CompositorAnimationPlayerClient, |
| + public CompositorAnimationDelegate { |
| + DEFINE_WRAPPERTYPEINFO(); |
| + |
| + public: |
| + static WorkletAnimation* Create( |
| + String animator_name, |
| + const HeapVector<Member<KeyframeEffectReadOnly>>&, |
| + HeapVector<DocumentTimelineOrScrollTimeline>&, |
| + RefPtr<SerializedScriptValue>, |
| + ExceptionState&); |
| + |
| + virtual ~WorkletAnimation() {} |
| + |
| + // WorkletAnimationBase implementation. |
| + void Update() override; |
| + |
| + // CompositorAnimationPlayerClient implementation. |
| + CompositorAnimationPlayer* CompositorPlayer() const override { |
| + return compositor_player_ ? compositor_player_->Player() : nullptr; |
| + } |
| + |
| + // CompositorAnimationDelegate implementation. |
| + void NotifyAnimationStarted(double monotonic_time, int group) override { |
| + LOG(INFO) << "WorkletAnimation::NotifyAnimationStarted"; |
| + } |
| + void NotifyAnimationFinished(double monotonic_time, int group) override { |
| + LOG(INFO) << "WorkletAnimation::NotifyAnimationFinished"; |
| + } |
| + void NotifyAnimationAborted(double monotonic_time, int group) override { |
| + 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.
|
| + } |
| + |
| + void AttachCompositorTimeline(); |
| + void DetachCompositorTimeline(); |
| + void Dispose(); |
| + |
| + String Name() { return animator_name_; } |
| + |
| + const HeapVector<DocumentTimelineOrScrollTimeline>& Timelines() { |
| + return timelines_; |
| + } |
| + |
| + const RefPtr<SerializedScriptValue> UserData() { return user_data_; } |
| + |
| + void SetEffectInheritedTimeForTesting(Member<KeyframeEffectReadOnly>, double); |
| + |
| + DECLARE_VIRTUAL_TRACE(); |
| + |
| + private: |
| + WorkletAnimation(String animator_name, |
| + const HeapVector<Member<KeyframeEffectReadOnly>>&, |
| + HeapVector<DocumentTimelineOrScrollTimeline>&, |
| + RefPtr<SerializedScriptValue>, |
| + AnimationTimeline&); |
| + |
| + // TODO(smcgruer): This pattern was copied from Animation.h. Document why we |
| + // do this, or remove the layer of indirection. |
| + 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
|
| + : public GarbageCollectedFinalized<CompositorAnimationPlayerHolder> { |
| + USING_PRE_FINALIZER(CompositorAnimationPlayerHolder, Dispose); |
| + |
| + public: |
| + static CompositorAnimationPlayerHolder* Create(WorkletAnimation*); |
| + |
| + void Detach(); |
| + |
| + DEFINE_INLINE_TRACE() { visitor->Trace(animation_); } |
| + |
| + CompositorAnimationPlayer* Player() const { |
| + return compositor_player_.get(); |
| + } |
| + |
| + private: |
| + explicit CompositorAnimationPlayerHolder(WorkletAnimation*); |
| + |
| + void Dispose(); |
| + |
| + std::unique_ptr<CompositorAnimationPlayer> compositor_player_; |
| + Member<WorkletAnimation> animation_; |
| + }; |
| + |
| + String animator_name_; |
| + HeapVector<Member<KeyframeEffectReadOnly>> effects_; |
| + HeapVector<DocumentTimelineOrScrollTimeline> timelines_; |
| + RefPtr<SerializedScriptValue> user_data_; |
| + |
| + Member<AnimationTimeline> main_document_timeline_; |
| + |
| + Member<CompositorAnimationPlayerHolder> compositor_player_; |
| + |
| + bool on_compositor_; |
| +}; |
| + |
| +} // namespace blink |
| + |
| +#endif |