Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(294)

Side by Side Diff: cc/animation/element_animations.h

Issue 1894023002: CC Animation: Make ElementAnimations a ref-counted object. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/animation/animation_player.cc ('k') | cc/animation/element_animations.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CC_ANIMATION_ELEMENT_ANIMATIONS_H_ 5 #ifndef CC_ANIMATION_ELEMENT_ANIMATIONS_H_
6 #define CC_ANIMATION_ELEMENT_ANIMATIONS_H_ 6 #define CC_ANIMATION_ELEMENT_ANIMATIONS_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/containers/linked_list.h" 10 #include "base/containers/linked_list.h"
(...skipping 19 matching lines...) Expand all
30 class LayerAnimationController; 30 class LayerAnimationController;
31 enum class LayerTreeType; 31 enum class LayerTreeType;
32 32
33 // An ElementAnimations owns a list of all AnimationPlayers, attached to 33 // An ElementAnimations owns a list of all AnimationPlayers, attached to
34 // the layer. Also, it owns LayerAnimationController instance (1:1 34 // the layer. Also, it owns LayerAnimationController instance (1:1
35 // relationship) 35 // relationship)
36 // ElementAnimations object redirects all events from LAC to the list 36 // ElementAnimations object redirects all events from LAC to the list
37 // of animation layers. 37 // of animation layers.
38 // This is a CC counterpart for blink::ElementAnimations (in 1:1 relationship). 38 // This is a CC counterpart for blink::ElementAnimations (in 1:1 relationship).
39 // No pointer to/from respective blink::ElementAnimations object for now. 39 // No pointer to/from respective blink::ElementAnimations object for now.
40 class CC_EXPORT ElementAnimations : public AnimationDelegate, 40 class CC_EXPORT ElementAnimations : public base::RefCounted<ElementAnimations>,
41 public AnimationDelegate,
41 public LayerAnimationValueObserver, 42 public LayerAnimationValueObserver,
42 public LayerAnimationValueProvider { 43 public LayerAnimationValueProvider {
43 public: 44 public:
44 static std::unique_ptr<ElementAnimations> Create(AnimationHost* host); 45 static scoped_refptr<ElementAnimations> Create(AnimationHost* host);
45 ~ElementAnimations() override;
46 46
47 int layer_id() const { 47 int layer_id() const {
48 return layer_animation_controller_ ? layer_animation_controller_->id() : 0; 48 return layer_animation_controller_ ? layer_animation_controller_->id() : 0;
49 } 49 }
50 50
51 // Parent AnimationHost. 51 // Parent AnimationHost.
52 AnimationHost* animation_host() { return animation_host_; } 52 AnimationHost* animation_host() { return animation_host_; }
53 const AnimationHost* animation_host() const { return animation_host_; } 53 const AnimationHost* animation_host() const { return animation_host_; }
54 54
55 void CreateLayerAnimationController(int layer_id); 55 void CreateLayerAnimationController(int layer_id);
(...skipping 10 matching lines...) Expand all
66 } 66 }
67 67
68 void AddPlayer(AnimationPlayer* player); 68 void AddPlayer(AnimationPlayer* player);
69 void RemovePlayer(AnimationPlayer* player); 69 void RemovePlayer(AnimationPlayer* player);
70 bool IsEmpty() const; 70 bool IsEmpty() const;
71 71
72 typedef base::LinkedList<AnimationPlayer> PlayersList; 72 typedef base::LinkedList<AnimationPlayer> PlayersList;
73 typedef base::LinkNode<AnimationPlayer> PlayersListNode; 73 typedef base::LinkNode<AnimationPlayer> PlayersListNode;
74 const PlayersList& players_list() const { return *players_list_.get(); } 74 const PlayersList& players_list() const { return *players_list_.get(); }
75 75
76 void PushPropertiesTo(ElementAnimations* element_animations_impl); 76 void PushPropertiesTo(
77 scoped_refptr<ElementAnimations> element_animations_impl);
77 78
78 void AddAnimation(std::unique_ptr<Animation> animation); 79 void AddAnimation(std::unique_ptr<Animation> animation);
79 void PauseAnimation(int animation_id, base::TimeDelta time_offset); 80 void PauseAnimation(int animation_id, base::TimeDelta time_offset);
80 void RemoveAnimation(int animation_id); 81 void RemoveAnimation(int animation_id);
81 void AbortAnimation(int animation_id); 82 void AbortAnimation(int animation_id);
82 void AbortAnimations(TargetProperty::Type target_property, 83 void AbortAnimations(TargetProperty::Type target_property,
83 bool needs_completion = false); 84 bool needs_completion = false);
84 85
85 // Returns the active animation animating the given property that is either 86 // Returns the active animation animating the given property that is either
86 // running, or is next to run, if such an animation exists. 87 // running, or is next to run, if such an animation exists.
87 Animation* GetAnimation(TargetProperty::Type target_property) const; 88 Animation* GetAnimation(TargetProperty::Type target_property) const;
88 89
89 // Returns the active animation for the given unique animation id. 90 // Returns the active animation for the given unique animation id.
90 Animation* GetAnimationById(int animation_id) const; 91 Animation* GetAnimationById(int animation_id) const;
91 92
92 void AddEventObserver(LayerAnimationEventObserver* observer); 93 void AddEventObserver(LayerAnimationEventObserver* observer);
93 void RemoveEventObserver(LayerAnimationEventObserver* observer); 94 void RemoveEventObserver(LayerAnimationEventObserver* observer);
94 95
95 private: 96 private:
97 friend class base::RefCounted<ElementAnimations>;
98
96 // TODO(loyso): Erase this when LAC merged into ElementAnimations. 99 // TODO(loyso): Erase this when LAC merged into ElementAnimations.
97 friend class AnimationHost; 100 friend class AnimationHost;
98 101
99 explicit ElementAnimations(AnimationHost* host); 102 explicit ElementAnimations(AnimationHost* host);
103 ~ElementAnimations() override;
100 104
101 // LayerAnimationValueObserver implementation. 105 // LayerAnimationValueObserver implementation.
102 void OnFilterAnimated(LayerTreeType tree_type, 106 void OnFilterAnimated(LayerTreeType tree_type,
103 const FilterOperations& filters) override; 107 const FilterOperations& filters) override;
104 void OnOpacityAnimated(LayerTreeType tree_type, float opacity) override; 108 void OnOpacityAnimated(LayerTreeType tree_type, float opacity) override;
105 void OnTransformAnimated(LayerTreeType tree_type, 109 void OnTransformAnimated(LayerTreeType tree_type,
106 const gfx::Transform& transform) override; 110 const gfx::Transform& transform) override;
107 void OnScrollOffsetAnimated(LayerTreeType tree_type, 111 void OnScrollOffsetAnimated(LayerTreeType tree_type,
108 const gfx::ScrollOffset& scroll_offset) override; 112 const gfx::ScrollOffset& scroll_offset) override;
109 void OnAnimationWaitingForDeletion() override; 113 void OnAnimationWaitingForDeletion() override;
(...skipping 29 matching lines...) Expand all
139 // LAC is owned by ElementAnimations (1:1 relationship). 143 // LAC is owned by ElementAnimations (1:1 relationship).
140 scoped_refptr<LayerAnimationController> layer_animation_controller_; 144 scoped_refptr<LayerAnimationController> layer_animation_controller_;
141 AnimationHost* animation_host_; 145 AnimationHost* animation_host_;
142 146
143 DISALLOW_COPY_AND_ASSIGN(ElementAnimations); 147 DISALLOW_COPY_AND_ASSIGN(ElementAnimations);
144 }; 148 };
145 149
146 } // namespace cc 150 } // namespace cc
147 151
148 #endif // CC_ANIMATION_ELEMENT_ANIMATIONS_H_ 152 #endif // CC_ANIMATION_ELEMENT_ANIMATIONS_H_
OLDNEW
« no previous file with comments | « cc/animation/animation_player.cc ('k') | cc/animation/element_animations.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698