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_GFX_COMPOSITOR_LAYER_ANIMATOR_H_ | 5 #ifndef UI_GFX_COMPOSITOR_LAYER_ANIMATOR_H_ |
6 #define UI_GFX_COMPOSITOR_LAYER_ANIMATOR_H_ | 6 #define UI_GFX_COMPOSITOR_LAYER_ANIMATOR_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <deque> | 9 #include <deque> |
10 #include <vector> | 10 #include <vector> |
(...skipping 15 matching lines...) Expand all Loading... |
26 class Animation; | 26 class Animation; |
27 class Layer; | 27 class Layer; |
28 class LayerAnimationSequence; | 28 class LayerAnimationSequence; |
29 class LayerAnimationDelegate; | 29 class LayerAnimationDelegate; |
30 class LayerAnimationObserver; | 30 class LayerAnimationObserver; |
31 class ScopedLayerAnimationSettings; | 31 class ScopedLayerAnimationSettings; |
32 class Transform; | 32 class Transform; |
33 | 33 |
34 // When a property of layer needs to be changed it is set by way of | 34 // When a property of layer needs to be changed it is set by way of |
35 // LayerAnimator. This enables LayerAnimator to animate property changes. | 35 // LayerAnimator. This enables LayerAnimator to animate property changes. |
| 36 // NB: during many tests, set_disable_animations_for_test is used and causes |
| 37 // all animations to complete immediately. |
36 class COMPOSITOR_EXPORT LayerAnimator : public AnimationContainerElement { | 38 class COMPOSITOR_EXPORT LayerAnimator : public AnimationContainerElement { |
37 public: | 39 public: |
38 enum PreemptionStrategy { | 40 enum PreemptionStrategy { |
39 IMMEDIATELY_SET_NEW_TARGET, | 41 IMMEDIATELY_SET_NEW_TARGET, |
40 IMMEDIATELY_ANIMATE_TO_NEW_TARGET, | 42 IMMEDIATELY_ANIMATE_TO_NEW_TARGET, |
41 ENQUEUE_NEW_ANIMATION, | 43 ENQUEUE_NEW_ANIMATION, |
42 REPLACE_QUEUED_ANIMATIONS, | 44 REPLACE_QUEUED_ANIMATIONS, |
43 BLEND_WITH_CURRENT_ANIMATION | 45 BLEND_WITH_CURRENT_ANIMATION |
44 }; | 46 }; |
45 | 47 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 103 |
102 // Stops animating the given property. No effect if there is no running | 104 // Stops animating the given property. No effect if there is no running |
103 // animation for the given property. Skips to the final state of the | 105 // animation for the given property. Skips to the final state of the |
104 // animation. | 106 // animation. |
105 void StopAnimatingProperty( | 107 void StopAnimatingProperty( |
106 LayerAnimationElement::AnimatableProperty property); | 108 LayerAnimationElement::AnimatableProperty property); |
107 | 109 |
108 // Stops all animation and clears any queued animations. | 110 // Stops all animation and clears any queued animations. |
109 void StopAnimating(); | 111 void StopAnimating(); |
110 | 112 |
111 // For testing purposes only. | |
112 void set_disable_timer_for_test(bool enabled) { | |
113 disable_timer_for_test_ = enabled; | |
114 } | |
115 base::TimeTicks get_last_step_time_for_test() { return last_step_time_; } | |
116 | |
117 // These functions are used for adding or removing observers from the observer | 113 // These functions are used for adding or removing observers from the observer |
118 // list. The observers are notified when animations end. | 114 // list. The observers are notified when animations end. |
119 void AddObserver(LayerAnimationObserver* observer); | 115 void AddObserver(LayerAnimationObserver* observer); |
120 void RemoveObserver(LayerAnimationObserver* observer); | 116 void RemoveObserver(LayerAnimationObserver* observer); |
121 | 117 |
| 118 // For testing purposes only. |
| 119 void set_disable_timer_for_test(bool disable_timer) { |
| 120 disable_timer_for_test_ = disable_timer; |
| 121 } |
| 122 base::TimeTicks last_step_time() const { return last_step_time_; } |
| 123 |
| 124 // When set to true, all animations complete immediately. |
| 125 static void set_disable_animations_for_test(bool disable_animations) { |
| 126 disable_animations_for_test_ = disable_animations; |
| 127 } |
| 128 |
122 protected: | 129 protected: |
123 LayerAnimationDelegate* delegate() { return delegate_; } | 130 LayerAnimationDelegate* delegate() { return delegate_; } |
124 const LayerAnimationDelegate* delegate() const { return delegate_; } | 131 const LayerAnimationDelegate* delegate() const { return delegate_; } |
125 | 132 |
126 private: | 133 private: |
127 friend class ScopedLayerAnimationSettings; | 134 friend class ScopedLayerAnimationSettings; |
128 | 135 |
129 // We need to keep track of the start time of every running animation. | 136 // We need to keep track of the start time of every running animation. |
130 struct RunningAnimation { | 137 struct RunningAnimation { |
131 RunningAnimation(LayerAnimationSequence* sequence, | 138 RunningAnimation(LayerAnimationSequence* sequence, |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 // Used for coordinating the starting of animations. | 233 // Used for coordinating the starting of animations. |
227 base::TimeTicks last_step_time_; | 234 base::TimeTicks last_step_time_; |
228 | 235 |
229 // True if we are being stepped by our container. | 236 // True if we are being stepped by our container. |
230 bool is_started_; | 237 bool is_started_; |
231 | 238 |
232 // This prevents the animator from automatically stepping through animations | 239 // This prevents the animator from automatically stepping through animations |
233 // and allows for manual stepping. | 240 // and allows for manual stepping. |
234 bool disable_timer_for_test_; | 241 bool disable_timer_for_test_; |
235 | 242 |
| 243 // This causes all animations to complete immediately. |
| 244 static bool disable_animations_for_test_; |
| 245 |
236 // Observers are notified when layer animations end, are scheduled or are | 246 // Observers are notified when layer animations end, are scheduled or are |
237 // aborted. | 247 // aborted. |
238 ObserverList<LayerAnimationObserver> observers_; | 248 ObserverList<LayerAnimationObserver> observers_; |
239 | 249 |
240 DISALLOW_COPY_AND_ASSIGN(LayerAnimator); | 250 DISALLOW_COPY_AND_ASSIGN(LayerAnimator); |
241 }; | 251 }; |
242 | 252 |
243 } // namespace ui | 253 } // namespace ui |
244 | 254 |
245 #endif // UI_GFX_COMPOSITOR_LAYER_ANIMATOR_H_ | 255 #endif // UI_GFX_COMPOSITOR_LAYER_ANIMATOR_H_ |
OLD | NEW |