Chromium Code Reviews| Index: cc/animation/animation_player.h |
| diff --git a/cc/animation/animation_player.h b/cc/animation/animation_player.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1194748c686b7bf2a22bdb07e324a0baa83e9c96 |
| --- /dev/null |
| +++ b/cc/animation/animation_player.h |
| @@ -0,0 +1,125 @@ |
| +// Copyright 2015 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 CC_ANIMATION_ANIMATION_PLAYER_H_ |
| +#define CC_ANIMATION_ANIMATION_PLAYER_H_ |
| + |
| +#include "base/memory/ref_counted.h" |
| +#include "cc/animation/layer_animation_controller.h" |
| +#include "cc/animation/layer_animation_value_observer.h" |
| +#include "cc/animation/layer_animation_value_provider.h" |
| +#include "cc/base/cc_export.h" |
| + |
| +namespace gfx { |
| +class ScrollOffset; |
| +class Transform; |
| +} |
| + |
| +namespace cc { |
| + |
| +class AnimationHost; |
| +class AnimationTimeline; |
| +class FilterOperations; |
| +class Layer; |
| + |
| +// An AnimationPlayer owns all animations to be run on particular CC Layer. |
| +// Multiple AnimationPlayers can be attached to one layer. In this case, |
| +// they share common LayerAnimationController (temp solution) so the |
| +// LayerAnimationController-to-Layer relationship stays the same (1:1, LACs |
| +// have same IDs as their correspondent Layers). |
| +// For now, the blink logic is responsible for handling conflicting |
| +// same-property animations. |
| +// Each AnimationPlayer has it's copy on the impl thread. |
| +// This is a CC counterpart for blink::AnimationPlayer (in 1:1 relationship). |
| +class CC_EXPORT AnimationPlayer : public base::RefCounted<AnimationPlayer>, |
|
Ian Vollick
2015/05/05 03:52:06
Why RefCounted?
loyso (OOO)
2015/05/05 06:51:18
It's in shared ownership between blink::AnimationP
Ian Vollick
2015/05/07 13:58:42
This is probably a dumb question, but can players
loyso (OOO)
2015/05/08 01:04:35
Yes, sure. Typically you create them in blink in a
loyso (OOO)
2015/06/22 07:48:51
Class diagrams added to the design doc.
Ian Vollick
2015/06/22 13:58:39
These diagrams are amazing. Thank you!
|
| + public LayerAnimationValueProvider { |
| + public: |
| + static scoped_refptr<AnimationPlayer> Create(int id); |
| + scoped_refptr<AnimationPlayer> CreateImplInstance() const; |
| + |
| + int id() const { return id_; } |
| + int layer_id() const { return layer_id_; } |
| + |
| + // Parent AnimationHost. AnimationPlayer can be detached from |
| + // AnimationTimeline. |
| + AnimationHost* animation_host() { return animation_host_; } |
| + const AnimationHost* animation_host() const { return animation_host_; } |
| + void SetAnimationHost(AnimationHost* animation_host); |
| + |
| + // Parent AnimationTimeline. |
| + AnimationTimeline* animation_timeline() { return animation_timeline_; } |
| + const AnimationTimeline* animation_timeline() const { |
| + return animation_timeline_; |
| + } |
| + void SetAnimationTimeline(AnimationTimeline* timeline); |
| + |
| + LayerAnimationController* layer_animation_controller() const { |
| + return layer_animation_controller_.get(); |
| + } |
| + |
| + void set_layer_animation_delegate(AnimationDelegate* delegate); |
| + |
| + void AttachLayer(int layer_id); |
| + void DetachLayer(); |
| + |
| + void LayerRegistered(int layer_id, bool is_active_tree); |
| + void LayerUnregistered(int layer_id, bool is_active_tree); |
| + |
| + void AddAnimation(scoped_ptr<Animation> animation); |
| + void PauseAnimation(int animation_id, double time_offset); |
| + void RemoveAnimation(int animation_id); |
| + |
| + void PushPropertiesTo(AnimationPlayer* player_impl); |
| + |
| + bool has_active_value_observer_for_testing() const { |
| + return active_value_observer_; |
| + } |
| + bool has_pending_value_observer_for_testing() const { |
| + return pending_value_observer_; |
| + } |
| + |
| + private: |
| + friend class base::RefCounted<AnimationPlayer>; |
| + |
| + explicit AnimationPlayer(int id); |
| + ~AnimationPlayer() override; |
| + |
| + void SetNeedsCommit(); |
| + |
| + void SetFilterMutated(bool active_tree, const FilterOperations& filters); |
| + void SetOpacityMutated(bool active_tree, float opacity); |
| + void SetTransformMutated(bool active_tree, const gfx::Transform& transform); |
| + void SetScrollOffsetMutated(bool active_tree, |
| + const gfx::ScrollOffset& scroll_offset); |
| + |
| + void AddControllerToTimeline(); |
| + void RemoveControllerFromTimeline(); |
| + |
| + void CreateActiveValueObserver(); |
| + void DestroyActiveValueObserver(); |
| + |
| + void CreatePendingValueObserver(); |
| + void DestroyPendingValueObserver(); |
| + |
| + // LayerAnimationValueProvider implementation. |
| + gfx::ScrollOffset ScrollOffsetForAnimation() const override; |
| + |
| + class ValueObserver; |
| + scoped_ptr<ValueObserver> active_value_observer_; |
| + scoped_ptr<ValueObserver> pending_value_observer_; |
| + |
| + scoped_refptr<LayerAnimationController> layer_animation_controller_; |
| + AnimationHost* animation_host_; |
| + AnimationTimeline* animation_timeline_; |
| + AnimationDelegate* layer_animation_delegate_; |
| + |
| + int id_; |
| + int layer_id_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(AnimationPlayer); |
| +}; |
| + |
| +} // namespace cc |
| + |
| +#endif // CC_ANIMATION_ANIMATION_PLAYER_H_ |