| 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 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/linked_ptr.h" | 12 #include "base/memory/linked_ptr.h" |
| 13 #include "base/memory/ref_counted.h" |
| 13 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
| 14 #include "base/time.h" | 15 #include "base/time.h" |
| 15 #include "ui/base/animation/animation_container_element.h" | 16 #include "ui/base/animation/animation_container_element.h" |
| 16 #include "ui/base/animation/tween.h" | 17 #include "ui/base/animation/tween.h" |
| 17 #include "ui/compositor/compositor_export.h" | 18 #include "ui/compositor/compositor_export.h" |
| 18 #include "ui/compositor/layer_animation_element.h" | 19 #include "ui/compositor/layer_animation_element.h" |
| 19 | 20 |
| 20 namespace gfx { | 21 namespace gfx { |
| 21 class Rect; | 22 class Rect; |
| 22 } | 23 } |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 // Virtual for testing. | 180 // Virtual for testing. |
| 180 virtual bool ProgressAnimation(LayerAnimationSequence* sequence, | 181 virtual bool ProgressAnimation(LayerAnimationSequence* sequence, |
| 181 base::TimeDelta delta); | 182 base::TimeDelta delta); |
| 182 | 183 |
| 183 // Returns true if the sequence is owned by this animator. | 184 // Returns true if the sequence is owned by this animator. |
| 184 bool HasAnimation(LayerAnimationSequence* sequence) const; | 185 bool HasAnimation(LayerAnimationSequence* sequence) const; |
| 185 | 186 |
| 186 private: | 187 private: |
| 187 friend class ScopedLayerAnimationSettings; | 188 friend class ScopedLayerAnimationSettings; |
| 188 | 189 |
| 190 class DestroyedTracker; |
| 191 |
| 192 // Used by FinishAnimation() to indicate if this has been destroyed. |
| 193 enum DestroyedType { |
| 194 DESTROYED, |
| 195 NOT_DESTROYED, |
| 196 }; |
| 197 |
| 189 // We need to keep track of the start time of every running animation. | 198 // We need to keep track of the start time of every running animation. |
| 190 struct RunningAnimation { | 199 struct RunningAnimation { |
| 191 RunningAnimation(LayerAnimationSequence* sequence, | 200 RunningAnimation(LayerAnimationSequence* sequence, |
| 192 base::TimeTicks start_time) | 201 base::TimeTicks start_time) |
| 193 : sequence(sequence), | 202 : sequence(sequence), |
| 194 start_time(start_time) { | 203 start_time(start_time) { |
| 195 } | 204 } |
| 196 LayerAnimationSequence* sequence; | 205 LayerAnimationSequence* sequence; |
| 197 base::TimeTicks start_time; | 206 base::TimeTicks start_time; |
| 198 }; | 207 }; |
| 199 | 208 |
| 200 typedef std::vector<RunningAnimation> RunningAnimations; | 209 typedef std::vector<RunningAnimation> RunningAnimations; |
| 201 typedef std::deque<linked_ptr<LayerAnimationSequence> > AnimationQueue; | 210 typedef std::deque<linked_ptr<LayerAnimationSequence> > AnimationQueue; |
| 202 | 211 |
| 203 // Implementation of AnimationContainerElement | 212 // Implementation of AnimationContainerElement |
| 204 virtual void SetStartTime(base::TimeTicks start_time) OVERRIDE; | 213 virtual void SetStartTime(base::TimeTicks start_time) OVERRIDE; |
| 205 virtual void Step(base::TimeTicks time_now) OVERRIDE; | 214 virtual void Step(base::TimeTicks time_now) OVERRIDE; |
| 206 virtual base::TimeDelta GetTimerInterval() const OVERRIDE; | 215 virtual base::TimeDelta GetTimerInterval() const OVERRIDE; |
| 207 | 216 |
| 208 // Starts or stops stepping depending on whether thare are running animations. | 217 // Starts or stops stepping depending on whether thare are running animations. |
| 209 void UpdateAnimationState(); | 218 void UpdateAnimationState(); |
| 210 | 219 |
| 211 // Removes the sequences from both the running animations and the queue. | 220 // Removes the sequences from both the running animations and the queue. |
| 212 // Returns a pointer to the removed animation, if any. NOTE: the caller is | 221 // Returns a pointer to the removed animation, if any. NOTE: the caller is |
| 213 // responsible for deleting the returned pointer. | 222 // responsible for deleting the returned pointer. |
| 214 LayerAnimationSequence* RemoveAnimation( | 223 LayerAnimationSequence* RemoveAnimation( |
| 215 LayerAnimationSequence* sequence) WARN_UNUSED_RESULT; | 224 LayerAnimationSequence* sequence) WARN_UNUSED_RESULT; |
| 216 | 225 |
| 217 // Progresses to the end of the sequence before removing it. | 226 // Progresses to the end of the sequence before removing it. |
| 218 void FinishAnimation(LayerAnimationSequence* sequence); | 227 DestroyedType FinishAnimation( |
| 228 LayerAnimationSequence* sequence) WARN_UNUSED_RESULT; |
| 219 | 229 |
| 220 // Finishes any running animation with zero duration. | 230 // Finishes any running animation with zero duration. |
| 221 void FinishAnyAnimationWithZeroDuration(); | 231 void FinishAnyAnimationWithZeroDuration(); |
| 222 | 232 |
| 223 // Clears the running animations and the queue. No sequences are progressed. | 233 // Clears the running animations and the queue. No sequences are progressed. |
| 224 void ClearAnimations(); | 234 void ClearAnimations(); |
| 225 | 235 |
| 226 // Returns the running animation animating the given property, if any. | 236 // Returns the running animation animating the given property, if any. |
| 227 RunningAnimation* GetRunningAnimation( | 237 RunningAnimation* GetRunningAnimation( |
| 228 LayerAnimationElement::AnimatableProperty property); | 238 LayerAnimationElement::AnimatableProperty property); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 // Slows down all animations for visual debugging. | 316 // Slows down all animations for visual debugging. |
| 307 static bool slow_animation_mode_; | 317 static bool slow_animation_mode_; |
| 308 | 318 |
| 309 // Amount to slow animations for debugging. | 319 // Amount to slow animations for debugging. |
| 310 static int slow_animation_scale_factor_; | 320 static int slow_animation_scale_factor_; |
| 311 | 321 |
| 312 // Observers are notified when layer animations end, are scheduled or are | 322 // Observers are notified when layer animations end, are scheduled or are |
| 313 // aborted. | 323 // aborted. |
| 314 ObserverList<LayerAnimationObserver> observers_; | 324 ObserverList<LayerAnimationObserver> observers_; |
| 315 | 325 |
| 326 scoped_refptr<DestroyedTracker> destroyed_tracker_; |
| 327 |
| 316 DISALLOW_COPY_AND_ASSIGN(LayerAnimator); | 328 DISALLOW_COPY_AND_ASSIGN(LayerAnimator); |
| 317 }; | 329 }; |
| 318 | 330 |
| 319 } // namespace ui | 331 } // namespace ui |
| 320 | 332 |
| 321 #endif // UI_COMPOSITOR_LAYER_ANIMATOR_H_ | 333 #endif // UI_COMPOSITOR_LAYER_ANIMATOR_H_ |
| OLD | NEW |