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..eec2e7f335e1584c1502ba1e1890cabcf5c7261b |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/modules/compositorworker/WorkletAnimation.h |
| @@ -0,0 +1,121 @@ |
| +// 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: |
| + enum AnimationPlayState { |
| + kIdle, |
| + kPending, |
| + kRunning, |
| + }; |
| + |
| + static WorkletAnimation* Create( |
| + String animator_name, |
| + const HeapVector<Member<KeyframeEffectReadOnly>>&, |
| + HeapVector<DocumentTimelineOrScrollTimeline>&, |
| + RefPtr<SerializedScriptValue>, |
| + ExceptionState&); |
| + |
| + virtual ~WorkletAnimation() {} |
| + |
| + String playState(); |
| + void play(); |
| + void cancel(); |
| + |
| + // WorkletAnimationBase implementation. |
| + bool StartOnCompositor() override; |
| + |
| + // CompositorAnimationPlayerClient implementation. |
| + CompositorAnimationPlayer* CompositorPlayer() const override { |
| + return compositor_player_ ? compositor_player_->Player() : nullptr; |
| + } |
| + |
| + // CompositorAnimationDelegate implementation. |
| + void NotifyAnimationStarted(double monotonic_time, int group) override {} |
| + void NotifyAnimationFinished(double monotonic_time, int group) override {} |
| + void NotifyAnimationAborted(double monotonic_time, int group) override {} |
| + |
| + void AttachCompositorTimeline(); |
| + void DetachCompositorTimeline(); |
| + void Dispose(); |
| + |
| + String Name() { return animator_name_; } |
| + |
| + const HeapVector<DocumentTimelineOrScrollTimeline>& Timelines() { |
| + return timelines_; |
| + } |
| + |
| + const RefPtr<SerializedScriptValue> Options() { return options_; } |
| + |
| + 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.
|
| + |
| + DECLARE_VIRTUAL_TRACE(); |
| + |
| + private: |
| + WorkletAnimation(String animator_name, |
| + Document&, |
| + const HeapVector<Member<KeyframeEffectReadOnly>>&, |
| + HeapVector<DocumentTimelineOrScrollTimeline>&, |
| + RefPtr<SerializedScriptValue>); |
| + |
| + // TODO(smcgruer): This pattern was copied from Animation.h. Document why we |
| + // 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
|
| + class CompositorAnimationPlayerHolder |
| + : 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_; |
| + AnimationPlayState play_state_; |
| + |
| + Member<Document> document_; |
| + |
| + HeapVector<Member<KeyframeEffectReadOnly>> effects_; |
| + HeapVector<DocumentTimelineOrScrollTimeline> timelines_; |
| + RefPtr<SerializedScriptValue> options_; |
| + |
| + 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
|
| +}; |
| + |
| +} // namespace blink |
| + |
| +#endif |