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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 106 |
107 // Start an animation sequence. If an animation for the same property is in | 107 // Start an animation sequence. If an animation for the same property is in |
108 // progress, it needs to be interrupted with the new animation. The animator | 108 // progress, it needs to be interrupted with the new animation. The animator |
109 // takes ownership of this animation sequence. | 109 // takes ownership of this animation sequence. |
110 void StartAnimation(LayerAnimationSequence* animation); | 110 void StartAnimation(LayerAnimationSequence* animation); |
111 | 111 |
112 // Schedule an animation to be run when possible. The animator takes ownership | 112 // Schedule an animation to be run when possible. The animator takes ownership |
113 // of this animation sequence. | 113 // of this animation sequence. |
114 void ScheduleAnimation(LayerAnimationSequence* animation); | 114 void ScheduleAnimation(LayerAnimationSequence* animation); |
115 | 115 |
116 // Starts the animations to be run together. Obviously will not work if | 116 // Starts the animations to be run together, ensuring that the first elements |
117 // they animate any common properties. The animator takes ownership of the | 117 // in these sequences have the same effective start time even when some of |
| 118 // them start on the compositor thread (but there is no such guarantee for |
| 119 // the effective start time of subsequent elements). Obviously will not work |
| 120 // if they animate any common properties. The animator takes ownership of the |
118 // animation sequences. Takes PreemptionStrategy into account. | 121 // animation sequences. Takes PreemptionStrategy into account. |
119 void StartTogether(const std::vector<LayerAnimationSequence*>& animations); | 122 void StartTogether(const std::vector<LayerAnimationSequence*>& animations); |
120 | 123 |
121 // Schedules the animations to be run together. Obviously will not work if | 124 // Schedules the animations to be run together, ensuring that the first |
122 // they animate any common properties. The animator takes ownership of the | 125 // elements in these sequences have the same effective start time even when |
123 // animation sequences. | 126 // some of them start on the compositor thread (but there is no such guarantee |
| 127 // for the effective start time of subsequent elements). Obviously will not |
| 128 // work if they animate any common properties. The animator takes ownership |
| 129 // of the animation sequences. |
124 void ScheduleTogether(const std::vector<LayerAnimationSequence*>& animations); | 130 void ScheduleTogether(const std::vector<LayerAnimationSequence*>& animations); |
125 | 131 |
126 // Schedules a pause for length |duration| of all the specified properties. | 132 // Schedules a pause for length |duration| of all the specified properties. |
127 // End the list with -1. | 133 // End the list with -1. |
128 void SchedulePauseForProperties( | 134 void SchedulePauseForProperties( |
129 base::TimeDelta duration, | 135 base::TimeDelta duration, |
130 LayerAnimationElement::AnimatableProperty property, | 136 LayerAnimationElement::AnimatableProperty property, |
131 ...); | 137 ...); |
132 | 138 |
133 // Returns true if there is an animation in the queue (animations remain in | 139 // Returns true if there is an animation in the queue (animations remain in |
(...skipping 18 matching lines...) Expand all Loading... |
152 | 158 |
153 // This is similar to StopAnimating, but aborts rather than finishes the | 159 // This is similar to StopAnimating, but aborts rather than finishes the |
154 // animations and notifies all observers. | 160 // animations and notifies all observers. |
155 void AbortAllAnimations() { StopAnimatingInternal(true); } | 161 void AbortAllAnimations() { StopAnimatingInternal(true); } |
156 | 162 |
157 // These functions are used for adding or removing observers from the observer | 163 // These functions are used for adding or removing observers from the observer |
158 // list. The observers are notified when animations end. | 164 // list. The observers are notified when animations end. |
159 void AddObserver(LayerAnimationObserver* observer); | 165 void AddObserver(LayerAnimationObserver* observer); |
160 void RemoveObserver(LayerAnimationObserver* observer); | 166 void RemoveObserver(LayerAnimationObserver* observer); |
161 | 167 |
| 168 // Called when a threaded animation is actually started. |
| 169 void OnThreadedAnimationStarted(const cc::AnimationEvent& event); |
| 170 |
162 // This determines how implicit animations will be tweened. This has no | 171 // This determines how implicit animations will be tweened. This has no |
163 // effect on animations that are explicitly started or scheduled. The default | 172 // effect on animations that are explicitly started or scheduled. The default |
164 // is Tween::LINEAR. | 173 // is Tween::LINEAR. |
165 void set_tween_type(Tween::Type tween_type) { tween_type_ = tween_type; } | 174 void set_tween_type(Tween::Type tween_type) { tween_type_ = tween_type; } |
166 Tween::Type tween_type() const { return tween_type_; } | 175 Tween::Type tween_type() const { return tween_type_; } |
167 | 176 |
168 // For testing purposes only. | 177 // For testing purposes only. |
169 void set_disable_timer_for_test(bool disable_timer) { | 178 void set_disable_timer_for_test(bool disable_timer) { |
170 disable_timer_for_test_ = disable_timer; | 179 disable_timer_for_test_ = disable_timer; |
171 } | 180 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 base::TimeTicks now); | 218 base::TimeTicks now); |
210 | 219 |
211 void ProgressAnimationToEnd(LayerAnimationSequence* sequence); | 220 void ProgressAnimationToEnd(LayerAnimationSequence* sequence); |
212 | 221 |
213 // Returns true if the sequence is owned by this animator. | 222 // Returns true if the sequence is owned by this animator. |
214 bool HasAnimation(LayerAnimationSequence* sequence) const; | 223 bool HasAnimation(LayerAnimationSequence* sequence) const; |
215 | 224 |
216 private: | 225 private: |
217 friend class base::RefCounted<LayerAnimator>; | 226 friend class base::RefCounted<LayerAnimator>; |
218 friend class ScopedLayerAnimationSettings; | 227 friend class ScopedLayerAnimationSettings; |
| 228 friend class LayerAnimatorTestController; |
219 | 229 |
220 class RunningAnimation { | 230 class RunningAnimation { |
221 public: | 231 public: |
222 RunningAnimation(const base::WeakPtr<LayerAnimationSequence>& sequence); | 232 RunningAnimation(const base::WeakPtr<LayerAnimationSequence>& sequence); |
223 ~RunningAnimation(); | 233 ~RunningAnimation(); |
224 | 234 |
225 bool is_sequence_alive() const { return !!sequence_; } | 235 bool is_sequence_alive() const { return !!sequence_; } |
226 LayerAnimationSequence* sequence() const { return sequence_.get(); } | 236 LayerAnimationSequence* sequence() const { return sequence_.get(); } |
227 | 237 |
228 private: | 238 private: |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 // Observers are notified when layer animations end, are scheduled or are | 371 // Observers are notified when layer animations end, are scheduled or are |
362 // aborted. | 372 // aborted. |
363 ObserverList<LayerAnimationObserver> observers_; | 373 ObserverList<LayerAnimationObserver> observers_; |
364 | 374 |
365 DISALLOW_COPY_AND_ASSIGN(LayerAnimator); | 375 DISALLOW_COPY_AND_ASSIGN(LayerAnimator); |
366 }; | 376 }; |
367 | 377 |
368 } // namespace ui | 378 } // namespace ui |
369 | 379 |
370 #endif // UI_COMPOSITOR_LAYER_ANIMATOR_H_ | 380 #endif // UI_COMPOSITOR_LAYER_ANIMATOR_H_ |
OLD | NEW |