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

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

Issue 2349643003: CC Animation: Extract PropertyAnimationState as a non-nested struct. (Closed)
Patch Set: Created 4 years, 3 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
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 <bitset> 8 #include <bitset>
9 #include <vector> 9 #include <vector>
10 10
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/animation/element_id.h" 17 #include "cc/animation/element_id.h"
18 #include "cc/base/cc_export.h" 18 #include "cc/base/cc_export.h"
19 19
20 namespace cc { 20 namespace cc {
21 21
22 class AnimationDelegate; 22 class AnimationDelegate;
23 class AnimationEvents; 23 class AnimationEvents;
24 class AnimationHost; 24 class AnimationHost;
25 class AnimationTimeline; 25 class AnimationTimeline;
26 struct PropertyAnimationState;
26 27
27 // An AnimationPlayer owns all animations to be run on particular CC Layer. 28 // An AnimationPlayer owns all animations to be run on particular CC Layer.
28 // Multiple AnimationPlayers can be attached to one layer. In this case, 29 // Multiple AnimationPlayers can be attached to one layer. In this case,
29 // they share common ElementAnimations so the 30 // they share common ElementAnimations so the
30 // ElementAnimations-to-Layer relationship is 1:1. 31 // ElementAnimations-to-Layer relationship is 1:1.
31 // For now, the blink logic is responsible for handling of conflicting 32 // For now, the blink logic is responsible for handling of conflicting
32 // same-property animations. 33 // same-property animations.
33 // Each AnimationPlayer has its copy on the impl thread. 34 // Each AnimationPlayer has its copy on the impl thread.
34 // This is a CC counterpart for blink::AnimationPlayer (in 1:1 relationship). 35 // This is a CC counterpart for blink::AnimationPlayer (in 1:1 relationship).
35 class CC_EXPORT AnimationPlayer : public base::RefCounted<AnimationPlayer> { 36 class CC_EXPORT AnimationPlayer : public base::RefCounted<AnimationPlayer> {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 bool HasActiveAnimation() const; 88 bool HasActiveAnimation() const;
88 89
89 // Returns true if there are any animations at all to process. 90 // Returns true if there are any animations at all to process.
90 bool has_any_animation() const { return !animations_.empty(); } 91 bool has_any_animation() const { return !animations_.empty(); }
91 92
92 bool needs_push_properties() const { return needs_push_properties_; } 93 bool needs_push_properties() const { return needs_push_properties_; }
93 void SetNeedsPushProperties(); 94 void SetNeedsPushProperties();
94 95
95 bool HasNonDeletedAnimation() const; 96 bool HasNonDeletedAnimation() const;
96 97
97 using Animations = std::vector<std::unique_ptr<Animation>>;
98 const Animations& animations() const { return animations_; }
99
100 bool needs_to_start_animations() const { return needs_to_start_animations_; } 98 bool needs_to_start_animations() const { return needs_to_start_animations_; }
101 99
102 void StartAnimations(base::TimeTicks monotonic_time); 100 void StartAnimations(base::TimeTicks monotonic_time);
103 void PromoteStartedAnimations(base::TimeTicks monotonic_time, 101 void PromoteStartedAnimations(base::TimeTicks monotonic_time,
104 AnimationEvents* events); 102 AnimationEvents* events);
105 void MarkAnimationsForDeletion(base::TimeTicks monotonic_time, 103 void MarkAnimationsForDeletion(base::TimeTicks monotonic_time,
106 AnimationEvents* events); 104 AnimationEvents* events);
107 void TickAnimations(base::TimeTicks monotonic_time); 105 void TickAnimations(base::TimeTicks monotonic_time);
108 void MarkFinishedAnimations(base::TimeTicks monotonic_time); 106 void MarkFinishedAnimations(base::TimeTicks monotonic_time);
109 107
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 bool HasElementInActiveList() const; 145 bool HasElementInActiveList() const;
148 gfx::ScrollOffset ScrollOffsetForAnimation() const; 146 gfx::ScrollOffset ScrollOffsetForAnimation() const;
149 147
150 // Returns the active animation animating the given property that is either 148 // Returns the active animation animating the given property that is either
151 // running, or is next to run, if such an animation exists. 149 // running, or is next to run, if such an animation exists.
152 Animation* GetAnimation(TargetProperty::Type target_property) const; 150 Animation* GetAnimation(TargetProperty::Type target_property) const;
153 151
154 // Returns the active animation for the given unique animation id. 152 // Returns the active animation for the given unique animation id.
155 Animation* GetAnimationById(int animation_id) const; 153 Animation* GetAnimationById(int animation_id) const;
156 154
155 void GetPropertyAnimationStateFor(TargetProperty::Type property,
156 PropertyAnimationState* state) const;
157
157 private: 158 private:
158 friend class base::RefCounted<AnimationPlayer>; 159 friend class base::RefCounted<AnimationPlayer>;
159 160
160 explicit AnimationPlayer(int id); 161 explicit AnimationPlayer(int id);
161 ~AnimationPlayer(); 162 ~AnimationPlayer();
162 163
163 // A set of target properties. TargetProperty must be 0-based enum. 164 // A set of target properties. TargetProperty must be 0-based enum.
164 using TargetProperties = 165 using TargetProperties =
165 std::bitset<TargetProperty::LAST_TARGET_PROPERTY + 1>; 166 std::bitset<TargetProperty::LAST_TARGET_PROPERTY + 1>;
166 167
167 void SetNeedsCommit(); 168 void SetNeedsCommit();
168 169
169 void RegisterPlayer(); 170 void RegisterPlayer();
170 void UnregisterPlayer(); 171 void UnregisterPlayer();
171 172
172 void BindElementAnimations(); 173 void BindElementAnimations();
173 void UnbindElementAnimations(); 174 void UnbindElementAnimations();
174 175
175 void AnimationAddedForProperty(TargetProperty::Type target_property); 176 void AnimationAddedForProperty(TargetProperty::Type target_property);
176 177
177 void MarkAbortedAnimationsForDeletion( 178 void MarkAbortedAnimationsForDeletion(
178 AnimationPlayer* animation_player_impl) const; 179 AnimationPlayer* animation_player_impl) const;
179 void PurgeAnimationsMarkedForDeletion(); 180 void PurgeAnimationsMarkedForDeletion();
180 void PushNewAnimationsToImplThread( 181 void PushNewAnimationsToImplThread(
181 AnimationPlayer* animation_player_impl) const; 182 AnimationPlayer* animation_player_impl) const;
182 void RemoveAnimationsCompletedOnMainThread( 183 void RemoveAnimationsCompletedOnMainThread(
183 AnimationPlayer* animation_player_impl) const; 184 AnimationPlayer* animation_player_impl) const;
184 void PushPropertiesToImplThread(AnimationPlayer* animation_player_impl); 185 void PushPropertiesToImplThread(AnimationPlayer* animation_player_impl);
185 186
187 using Animations = std::vector<std::unique_ptr<Animation>>;
186 Animations animations_; 188 Animations animations_;
187 189
188 AnimationHost* animation_host_; 190 AnimationHost* animation_host_;
189 AnimationTimeline* animation_timeline_; 191 AnimationTimeline* animation_timeline_;
190 // element_animations isn't null if player attached to an element (layer). 192 // element_animations isn't null if player attached to an element (layer).
191 scoped_refptr<ElementAnimations> element_animations_; 193 scoped_refptr<ElementAnimations> element_animations_;
192 AnimationDelegate* animation_delegate_; 194 AnimationDelegate* animation_delegate_;
193 195
194 int id_; 196 int id_;
195 ElementId element_id_; 197 ElementId element_id_;
196 bool needs_push_properties_; 198 bool needs_push_properties_;
197 base::TimeTicks last_tick_time_; 199 base::TimeTicks last_tick_time_;
198 200
199 // Only try to start animations when new animations are added or when the 201 // Only try to start animations when new animations are added or when the
200 // previous attempt at starting animations failed to start all animations. 202 // previous attempt at starting animations failed to start all animations.
201 bool needs_to_start_animations_; 203 bool needs_to_start_animations_;
202 204
203 DISALLOW_COPY_AND_ASSIGN(AnimationPlayer); 205 DISALLOW_COPY_AND_ASSIGN(AnimationPlayer);
204 }; 206 };
205 207
206 } // namespace cc 208 } // namespace cc
207 209
208 #endif // CC_ANIMATION_ANIMATION_PLAYER_H_ 210 #endif // CC_ANIMATION_ANIMATION_PLAYER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698