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

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

Issue 2357533002: CC Animation: Use std::bitset to update animation state. (Closed)
Patch Set: Clean it up. 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
« no previous file with comments | « no previous file | cc/animation/animation_player.cc » ('j') | cc/animation/element_animations.cc » ('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 <bitset>
9 #include <vector> 8 #include <vector>
10 9
11 #include "base/macros.h" 10 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
13 #include "base/time/time.h" 12 #include "base/time/time.h"
14 #include "cc/animation/animation.h" 13 #include "cc/animation/animation.h"
15 #include "cc/animation/animation_curve.h" 14 #include "cc/animation/animation_curve.h"
16 #include "cc/animation/element_animations.h" 15 #include "cc/animation/element_animations.h"
17 #include "cc/animation/element_id.h" 16 #include "cc/animation/element_id.h"
18 #include "cc/base/cc_export.h" 17 #include "cc/base/cc_export.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 void StartAnimations(base::TimeTicks monotonic_time); 99 void StartAnimations(base::TimeTicks monotonic_time);
101 void PromoteStartedAnimations(base::TimeTicks monotonic_time, 100 void PromoteStartedAnimations(base::TimeTicks monotonic_time,
102 AnimationEvents* events); 101 AnimationEvents* events);
103 void MarkAnimationsForDeletion(base::TimeTicks monotonic_time, 102 void MarkAnimationsForDeletion(base::TimeTicks monotonic_time,
104 AnimationEvents* events); 103 AnimationEvents* events);
105 void TickAnimations(base::TimeTicks monotonic_time); 104 void TickAnimations(base::TimeTicks monotonic_time);
106 void MarkFinishedAnimations(base::TimeTicks monotonic_time); 105 void MarkFinishedAnimations(base::TimeTicks monotonic_time);
107 106
108 // Make animations affect active elements if and only if they affect 107 // Make animations affect active elements if and only if they affect
109 // pending elements. Any animations that no longer affect any elements 108 // pending elements. Any animations that no longer affect any elements
110 // are deleted. 109 // are deleted. Returns a set of properties with animations activated.
111 void ActivateAnimations(bool* changed_transform_animation, 110 TargetProperties ActivateAnimations();
112 bool* changed_opacity_animation,
113 bool* changed_filter_animation);
114 111
115 bool HasFilterAnimationThatInflatesBounds() const; 112 bool HasFilterAnimationThatInflatesBounds() const;
116 bool HasTransformAnimationThatInflatesBounds() const; 113 bool HasTransformAnimationThatInflatesBounds() const;
117 114
118 bool TransformAnimationBoundsForBox(const gfx::BoxF& box, 115 bool TransformAnimationBoundsForBox(const gfx::BoxF& box,
119 gfx::BoxF* bounds) const; 116 gfx::BoxF* bounds) const;
120 bool HasAnimationThatAffectsScale() const; 117 bool HasAnimationThatAffectsScale() const;
121 bool HasOnlyTranslationTransforms(ElementListType list_type) const; 118 bool HasOnlyTranslationTransforms(ElementListType list_type) const;
122 bool AnimationsPreserveAxisAlignment() const; 119 bool AnimationsPreserveAxisAlignment() const;
123 120
(...skipping 21 matching lines...) Expand all
145 bool HasElementInActiveList() const; 142 bool HasElementInActiveList() const;
146 gfx::ScrollOffset ScrollOffsetForAnimation() const; 143 gfx::ScrollOffset ScrollOffsetForAnimation() const;
147 144
148 // Returns the active animation animating the given property that is either 145 // Returns the active animation animating the given property that is either
149 // running, or is next to run, if such an animation exists. 146 // running, or is next to run, if such an animation exists.
150 Animation* GetAnimation(TargetProperty::Type target_property) const; 147 Animation* GetAnimation(TargetProperty::Type target_property) const;
151 148
152 // Returns the active animation for the given unique animation id. 149 // Returns the active animation for the given unique animation id.
153 Animation* GetAnimationById(int animation_id) const; 150 Animation* GetAnimationById(int animation_id) const;
154 151
155 void GetPropertyAnimationStateFor(TargetProperty::Type property, 152 void GetPropertyAnimationState(PropertyAnimationState* pending_state,
156 PropertyAnimationState* state) const; 153 PropertyAnimationState* active_state) const;
157 154
158 private: 155 private:
159 friend class base::RefCounted<AnimationPlayer>; 156 friend class base::RefCounted<AnimationPlayer>;
160 157
161 explicit AnimationPlayer(int id); 158 explicit AnimationPlayer(int id);
162 ~AnimationPlayer(); 159 ~AnimationPlayer();
163 160
164 // A set of target properties. TargetProperty must be 0-based enum.
165 using TargetProperties =
166 std::bitset<TargetProperty::LAST_TARGET_PROPERTY + 1>;
167
168 void SetNeedsCommit(); 161 void SetNeedsCommit();
169 162
170 void RegisterPlayer(); 163 void RegisterPlayer();
171 void UnregisterPlayer(); 164 void UnregisterPlayer();
172 165
173 void BindElementAnimations(); 166 void BindElementAnimations();
174 void UnbindElementAnimations(); 167 void UnbindElementAnimations();
175 168
176 void AnimationAddedForProperty(TargetProperty::Type target_property); 169 void AnimationAddedForProperty(TargetProperty::Type target_property);
177 170
(...skipping 23 matching lines...) Expand all
201 // Only try to start animations when new animations are added or when the 194 // Only try to start animations when new animations are added or when the
202 // previous attempt at starting animations failed to start all animations. 195 // previous attempt at starting animations failed to start all animations.
203 bool needs_to_start_animations_; 196 bool needs_to_start_animations_;
204 197
205 DISALLOW_COPY_AND_ASSIGN(AnimationPlayer); 198 DISALLOW_COPY_AND_ASSIGN(AnimationPlayer);
206 }; 199 };
207 200
208 } // namespace cc 201 } // namespace cc
209 202
210 #endif // CC_ANIMATION_ANIMATION_PLAYER_H_ 203 #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.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698