OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 UI_COMPOSITOR_LAYER_ANIMATOR_H_ | 5 #ifndef UI_COMPOSITOR_LAYER_ANIMATOR_H_ |
6 #define UI_COMPOSITOR_LAYER_ANIMATOR_H_ | 6 #define UI_COMPOSITOR_LAYER_ANIMATOR_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 // Virtual for testing. | 172 // Virtual for testing. |
173 virtual bool ProgressAnimation(LayerAnimationSequence* sequence, | 173 virtual bool ProgressAnimation(LayerAnimationSequence* sequence, |
174 base::TimeDelta delta); | 174 base::TimeDelta delta); |
175 | 175 |
176 // Returns true if the sequence is owned by this animator. | 176 // Returns true if the sequence is owned by this animator. |
177 bool HasAnimation(LayerAnimationSequence* sequence) const; | 177 bool HasAnimation(LayerAnimationSequence* sequence) const; |
178 | 178 |
179 private: | 179 private: |
180 friend class ScopedLayerAnimationSettings; | 180 friend class ScopedLayerAnimationSettings; |
181 | 181 |
| 182 // Used by FinishAnimation() to indicate if this has been destroyed. |
| 183 enum DestroyedType { |
| 184 DESTROYED, |
| 185 NOT_DESTROYED, |
| 186 }; |
| 187 |
182 // We need to keep track of the start time of every running animation. | 188 // We need to keep track of the start time of every running animation. |
183 struct RunningAnimation { | 189 struct RunningAnimation { |
184 RunningAnimation(LayerAnimationSequence* sequence, | 190 RunningAnimation(LayerAnimationSequence* sequence, |
185 base::TimeTicks start_time) | 191 base::TimeTicks start_time) |
186 : sequence(sequence), | 192 : sequence(sequence), |
187 start_time(start_time) { | 193 start_time(start_time) { |
188 } | 194 } |
189 LayerAnimationSequence* sequence; | 195 LayerAnimationSequence* sequence; |
190 base::TimeTicks start_time; | 196 base::TimeTicks start_time; |
191 }; | 197 }; |
192 | 198 |
193 typedef std::vector<RunningAnimation> RunningAnimations; | 199 typedef std::vector<RunningAnimation> RunningAnimations; |
194 typedef std::deque<linked_ptr<LayerAnimationSequence> > AnimationQueue; | 200 typedef std::deque<linked_ptr<LayerAnimationSequence> > AnimationQueue; |
195 | 201 |
196 // Implementation of AnimationContainerElement | 202 // Implementation of AnimationContainerElement |
197 virtual void SetStartTime(base::TimeTicks start_time) OVERRIDE; | 203 virtual void SetStartTime(base::TimeTicks start_time) OVERRIDE; |
198 virtual void Step(base::TimeTicks time_now) OVERRIDE; | 204 virtual void Step(base::TimeTicks time_now) OVERRIDE; |
199 virtual base::TimeDelta GetTimerInterval() const OVERRIDE; | 205 virtual base::TimeDelta GetTimerInterval() const OVERRIDE; |
200 | 206 |
201 // Starts or stops stepping depending on whether thare are running animations. | 207 // Starts or stops stepping depending on whether thare are running animations. |
202 void UpdateAnimationState(); | 208 void UpdateAnimationState(); |
203 | 209 |
204 // Removes the sequences from both the running animations and the queue. | 210 // Removes the sequences from both the running animations and the queue. |
205 // Returns a pointer to the removed animation, if any. NOTE: the caller is | 211 // Returns a pointer to the removed animation, if any. NOTE: the caller is |
206 // responsible for deleting the returned pointer. | 212 // responsible for deleting the returned pointer. |
207 LayerAnimationSequence* RemoveAnimation( | 213 LayerAnimationSequence* RemoveAnimation( |
208 LayerAnimationSequence* sequence) WARN_UNUSED_RESULT; | 214 LayerAnimationSequence* sequence) WARN_UNUSED_RESULT; |
209 | 215 |
210 // Progresses to the end of the sequence before removing it. | 216 // Progresses to the end of the sequence before removing it. |
211 void FinishAnimation(LayerAnimationSequence* sequence); | 217 DestroyedType FinishAnimation( |
| 218 LayerAnimationSequence* sequence) WARN_UNUSED_RESULT; |
212 | 219 |
213 // Finishes any running animation with zero duration. | 220 // Finishes any running animation with zero duration. |
214 void FinishAnyAnimationWithZeroDuration(); | 221 void FinishAnyAnimationWithZeroDuration(); |
215 | 222 |
216 // Clears the running animations and the queue. No sequences are progressed. | 223 // Clears the running animations and the queue. No sequences are progressed. |
217 void ClearAnimations(); | 224 void ClearAnimations(); |
218 | 225 |
219 // Returns the running animation animating the given property, if any. | 226 // Returns the running animation animating the given property, if any. |
220 RunningAnimation* GetRunningAnimation( | 227 RunningAnimation* GetRunningAnimation( |
221 LayerAnimationElement::AnimatableProperty property); | 228 LayerAnimationElement::AnimatableProperty property); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 // Slows down all animations for visual debugging. | 306 // Slows down all animations for visual debugging. |
300 static bool slow_animation_mode_; | 307 static bool slow_animation_mode_; |
301 | 308 |
302 // Amount to slow animations for debugging. | 309 // Amount to slow animations for debugging. |
303 static int slow_animation_scale_factor_; | 310 static int slow_animation_scale_factor_; |
304 | 311 |
305 // Observers are notified when layer animations end, are scheduled or are | 312 // Observers are notified when layer animations end, are scheduled or are |
306 // aborted. | 313 // aborted. |
307 ObserverList<LayerAnimationObserver> observers_; | 314 ObserverList<LayerAnimationObserver> observers_; |
308 | 315 |
| 316 // Set to true in the destructor (if non-NULL). Used to detect deletion while |
| 317 // calling out. |
| 318 bool* destroyed_; |
| 319 |
309 DISALLOW_COPY_AND_ASSIGN(LayerAnimator); | 320 DISALLOW_COPY_AND_ASSIGN(LayerAnimator); |
310 }; | 321 }; |
311 | 322 |
312 } // namespace ui | 323 } // namespace ui |
313 | 324 |
314 #endif // UI_COMPOSITOR_LAYER_ANIMATOR_H_ | 325 #endif // UI_COMPOSITOR_LAYER_ANIMATOR_H_ |
OLD | NEW |