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

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

Issue 2189813002: ElementAnimations should hold an ObservableList of AnimationPlayers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: apply loyso's comment Created 4 years, 4 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 | « no previous file | cc/animation/animation_player.cc » ('j') | cc/animation/element_animations.h » ('J')
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_ANIMATION_PLAYER_H_ 5 #ifndef CC_ANIMATION_ANIMATION_PLAYER_H_
6 #define CC_ANIMATION_ANIMATION_PLAYER_H_ 6 #define CC_ANIMATION_ANIMATION_PLAYER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/containers/linked_list.h" 10 #include "base/containers/linked_list.h"
loyso (OOO) 2016/08/05 00:19:51 It becomes unused.
ymalik 2016/08/05 00:54:04 Done.
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "cc/animation/animation.h" 14 #include "cc/animation/animation.h"
15 #include "cc/animation/animation_curve.h" 15 #include "cc/animation/animation_curve.h"
16 #include "cc/animation/element_animations.h" 16 #include "cc/animation/element_animations.h"
17 #include "cc/base/cc_export.h" 17 #include "cc/base/cc_export.h"
18 18
19 namespace cc { 19 namespace cc {
20 20
21 class AnimationDelegate; 21 class AnimationDelegate;
22 class AnimationHost; 22 class AnimationHost;
23 class AnimationTimeline; 23 class AnimationTimeline;
24 class ElementAnimations; 24 class ElementAnimations;
25 25
26 // An AnimationPlayer owns all animations to be run on particular CC Layer. 26 // An AnimationPlayer owns all animations to be run on particular CC Layer.
27 // Multiple AnimationPlayers can be attached to one layer. In this case, 27 // Multiple AnimationPlayers can be attached to one layer. In this case,
28 // they share common ElementAnimations so the 28 // they share common ElementAnimations so the
29 // ElementAnimations-to-Layer relationship is 1:1. 29 // ElementAnimations-to-Layer relationship is 1:1.
30 // For now, the blink logic is responsible for handling of conflicting 30 // For now, the blink logic is responsible for handling of conflicting
31 // same-property animations. 31 // same-property animations.
32 // Each AnimationPlayer has its copy on the impl thread. 32 // Each AnimationPlayer has its copy on the impl thread.
33 // This is a CC counterpart for blink::AnimationPlayer (in 1:1 relationship). 33 // This is a CC counterpart for blink::AnimationPlayer (in 1:1 relationship).
34 class CC_EXPORT AnimationPlayer : public base::RefCounted<AnimationPlayer>, 34 class CC_EXPORT AnimationPlayer : public base::RefCounted<AnimationPlayer> {
35 public base::LinkNode<AnimationPlayer> {
36 public: 35 public:
37 static scoped_refptr<AnimationPlayer> Create(int id); 36 static scoped_refptr<AnimationPlayer> Create(int id);
38 scoped_refptr<AnimationPlayer> CreateImplInstance() const; 37 scoped_refptr<AnimationPlayer> CreateImplInstance() const;
39 38
40 int id() const { return id_; } 39 int id() const { return id_; }
41 ElementId element_id() const { return element_id_; } 40 ElementId element_id() const { return element_id_; }
42 41
43 // Parent AnimationHost. AnimationPlayer can be detached from 42 // Parent AnimationHost. AnimationPlayer can be detached from
44 // AnimationTimeline. 43 // AnimationTimeline.
45 AnimationHost* animation_host() { return animation_host_; } 44 AnimationHost* animation_host() { return animation_host_; }
(...skipping 22 matching lines...) Expand all
68 void AddAnimation(std::unique_ptr<Animation> animation); 67 void AddAnimation(std::unique_ptr<Animation> animation);
69 void PauseAnimation(int animation_id, double time_offset); 68 void PauseAnimation(int animation_id, double time_offset);
70 void RemoveAnimation(int animation_id); 69 void RemoveAnimation(int animation_id);
71 void AbortAnimation(int animation_id); 70 void AbortAnimation(int animation_id);
72 void AbortAnimations(TargetProperty::Type target_property, 71 void AbortAnimations(TargetProperty::Type target_property,
73 bool needs_completion); 72 bool needs_completion);
74 73
75 void PushPropertiesTo(AnimationPlayer* player_impl); 74 void PushPropertiesTo(AnimationPlayer* player_impl);
76 75
77 // AnimationDelegate routing. 76 // AnimationDelegate routing.
78 void NotifyAnimationStarted(base::TimeTicks monotonic_time, 77 void OnAnimationStarted(base::TimeTicks monotonic_time,
loyso (OOO) 2016/08/05 00:13:25 Any rationale for renaming? The comment "Animation
ymalik 2016/08/05 00:54:04 I did it because most uses of ObserverList had "on
79 TargetProperty::Type target_property, 78 TargetProperty::Type target_property,
80 int group); 79 int group);
81 void NotifyAnimationFinished(base::TimeTicks monotonic_time, 80 void OnAnimationFinished(base::TimeTicks monotonic_time,
82 TargetProperty::Type target_property, 81 TargetProperty::Type target_property,
83 int group); 82 int group);
84 void NotifyAnimationAborted(base::TimeTicks monotonic_time, 83 void OnAnimationAborted(base::TimeTicks monotonic_time,
85 TargetProperty::Type target_property, 84 TargetProperty::Type target_property,
86 int group); 85 int group);
87 void NotifyAnimationTakeover(base::TimeTicks monotonic_time, 86 void OnAnimationTakeover(base::TimeTicks monotonic_time,
88 TargetProperty::Type target_property, 87 TargetProperty::Type target_property,
89 double animation_start_time, 88 double animation_start_time,
90 std::unique_ptr<AnimationCurve> curve); 89 std::unique_ptr<AnimationCurve> curve);
91 90
92 // Whether this player has animations waiting to get sent to ElementAnimations 91 // Whether this player has animations waiting to get sent to ElementAnimations
93 bool has_pending_animations_for_testing() const { 92 bool has_pending_animations_for_testing() const {
94 return !animations_.empty(); 93 return !animations_.empty();
95 } 94 }
96 95
96 protected:
loyso (OOO) 2016/08/05 00:13:25 No reason for private section now. This is a final
ymalik 2016/08/05 00:54:04 You're right. Done.
97 explicit AnimationPlayer(int id);
98 virtual ~AnimationPlayer();
99
97 private: 100 private:
98 friend class base::RefCounted<AnimationPlayer>; 101 friend class base::RefCounted<AnimationPlayer>;
99 102
100 explicit AnimationPlayer(int id);
101 ~AnimationPlayer();
102
103 void SetNeedsCommit(); 103 void SetNeedsCommit();
104 104
105 void RegisterPlayer(); 105 void RegisterPlayer();
106 void UnregisterPlayer(); 106 void UnregisterPlayer();
107 107
108 void BindElementAnimations(); 108 void BindElementAnimations();
109 void UnbindElementAnimations(); 109 void UnbindElementAnimations();
110 110
111 // We accumulate added animations in animations_ container 111 // We accumulate added animations in animations_ container
112 // if element_animations_ is a nullptr. It allows us to add/remove animations 112 // if element_animations_ is a nullptr. It allows us to add/remove animations
113 // to non-attached AnimationPlayers. 113 // to non-attached AnimationPlayers.
114 std::vector<std::unique_ptr<Animation>> animations_; 114 std::vector<std::unique_ptr<Animation>> animations_;
115 115
116 AnimationHost* animation_host_; 116 AnimationHost* animation_host_;
117 AnimationTimeline* animation_timeline_; 117 AnimationTimeline* animation_timeline_;
118 // element_animations isn't null if player attached to an element (layer). 118 // element_animations isn't null if player attached to an element (layer).
119 scoped_refptr<ElementAnimations> element_animations_; 119 scoped_refptr<ElementAnimations> element_animations_;
120 AnimationDelegate* animation_delegate_; 120 AnimationDelegate* animation_delegate_;
121 121
122 int id_; 122 int id_;
123 ElementId element_id_; 123 ElementId element_id_;
124 124
125 DISALLOW_COPY_AND_ASSIGN(AnimationPlayer); 125 DISALLOW_COPY_AND_ASSIGN(AnimationPlayer);
126 }; 126 };
127 127
128 } // namespace cc 128 } // namespace cc
129 129
130 #endif // CC_ANIMATION_ANIMATION_PLAYER_H_ 130 #endif // CC_ANIMATION_ANIMATION_PLAYER_H_
OLDNEW
« no previous file with comments | « no previous file | cc/animation/animation_player.cc » ('j') | cc/animation/element_animations.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698