Implements RLZTrackerDelegate on iOS.
[chromium-blink-merge.git] / cc / animation / element_animations.h
blob6fb2a429d4a818ed2e7702eea92cfaae6c8ed390
1 // Copyright 2015 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.
5 #ifndef CC_ANIMATION_ELEMENT_ANIMATIONS_H_
6 #define CC_ANIMATION_ELEMENT_ANIMATIONS_H_
8 #include "base/containers/linked_list.h"
9 #include "base/memory/ref_counted.h"
10 #include "cc/animation/animation_delegate.h"
11 #include "cc/animation/layer_animation_controller.h"
12 #include "cc/animation/layer_animation_value_provider.h"
13 #include "cc/base/cc_export.h"
15 namespace gfx {
16 class ScrollOffset;
17 class Transform;
20 namespace cc {
22 class AnimationHost;
23 class AnimationPlayer;
24 class FilterOperations;
25 class LayerAnimationController;
26 enum class LayerTreeType;
28 // An ElementAnimations owns a list of all AnimationPlayers, attached to
29 // the layer. Also, it owns LayerAnimationController instance (1:1
30 // relationship)
31 // ElementAnimations object redirects all events from LAC to the list
32 // of animation layers.
33 // This is a CC counterpart for blink::ElementAnimations (in 1:1 relationship).
34 // No pointer to/from respective blink::ElementAnimations object for now.
35 class CC_EXPORT ElementAnimations : public AnimationDelegate,
36 public LayerAnimationValueProvider {
37 public:
38 static scoped_ptr<ElementAnimations> Create(AnimationHost* host);
39 ~ElementAnimations() override;
41 int layer_id() const {
42 return layer_animation_controller_ ? layer_animation_controller_->id() : 0;
45 // Parent AnimationHost.
46 AnimationHost* animation_host() { return animation_host_; }
47 const AnimationHost* animation_host() const { return animation_host_; }
49 LayerAnimationController* layer_animation_controller() const {
50 return layer_animation_controller_.get();
53 void CreateLayerAnimationController(int layer_id);
54 void DestroyLayerAnimationController();
56 void LayerRegistered(int layer_id, LayerTreeType tree_type);
57 void LayerUnregistered(int layer_id, LayerTreeType tree_type);
59 bool has_active_value_observer_for_testing() const {
60 return active_value_observer_;
62 bool has_pending_value_observer_for_testing() const {
63 return pending_value_observer_;
66 void AddPlayer(AnimationPlayer* player);
67 void RemovePlayer(AnimationPlayer* player);
68 bool IsEmpty() const;
70 typedef base::LinkedList<AnimationPlayer> PlayersList;
71 typedef base::LinkNode<AnimationPlayer> PlayersListNode;
72 const PlayersList& players_list() const { return *players_list_.get(); }
74 void PushPropertiesTo(ElementAnimations* element_animations_impl);
76 private:
77 explicit ElementAnimations(AnimationHost* host);
79 void SetFilterMutated(LayerTreeType tree_type,
80 const FilterOperations& filters);
81 void SetOpacityMutated(LayerTreeType tree_type, float opacity);
82 void SetTransformMutated(LayerTreeType tree_type,
83 const gfx::Transform& transform);
84 void SetScrollOffsetMutated(LayerTreeType tree_type,
85 const gfx::ScrollOffset& scroll_offset);
87 void CreateActiveValueObserver();
88 void DestroyActiveValueObserver();
90 void CreatePendingValueObserver();
91 void DestroyPendingValueObserver();
93 // AnimationDelegate implementation
94 void NotifyAnimationStarted(base::TimeTicks monotonic_time,
95 Animation::TargetProperty target_property,
96 int group) override;
97 void NotifyAnimationFinished(base::TimeTicks monotonic_time,
98 Animation::TargetProperty target_property,
99 int group) override;
101 // LayerAnimationValueProvider implementation.
102 gfx::ScrollOffset ScrollOffsetForAnimation() const override;
104 scoped_ptr<PlayersList> players_list_;
106 class ValueObserver;
107 scoped_ptr<ValueObserver> active_value_observer_;
108 scoped_ptr<ValueObserver> pending_value_observer_;
110 // LAC is owned by ElementAnimations (1:1 relationship).
111 scoped_refptr<LayerAnimationController> layer_animation_controller_;
112 AnimationHost* animation_host_;
114 DISALLOW_COPY_AND_ASSIGN(ElementAnimations);
117 } // namespace cc
119 #endif // CC_ANIMATION_ELEMENT_ANIMATIONS_H_