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..3ce5933d305c550db479ad448c8fe50a64918217 |
--- /dev/null |
+++ b/cc/animation/animation_player.h |
@@ -0,0 +1,134 @@ |
+// 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/containers/linked_list.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; |
+enum class LayerTreeType; |
+ |
+// 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 its 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>, |
+ public base::LinkNode<AnimationPlayer>, |
+ 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, LayerTreeType tree_type); |
+ void LayerUnregistered(int layer_id, LayerTreeType tree_type); |
+ |
+ 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_; |
+ } |
+ |
+ // TODO(loyso): Do not share LAC between AnimationPlayers so we don't need |
+ // this method. |
+ void RefreshObservers(); |
+ |
+ private: |
+ friend class base::RefCounted<AnimationPlayer>; |
+ |
+ explicit AnimationPlayer(int id); |
+ ~AnimationPlayer() override; |
+ |
+ void SetNeedsCommit(); |
+ |
+ void SetFilterMutated(LayerTreeType tree_type, |
+ const FilterOperations& filters); |
+ void SetOpacityMutated(LayerTreeType tree_type, float opacity); |
+ void SetTransformMutated(LayerTreeType tree_type, |
+ const gfx::Transform& transform); |
+ void SetScrollOffsetMutated(LayerTreeType tree_type, |
+ 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_ |