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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 // effect on animations that are explicitly started or scheduled. The default | 173 // effect on animations that are explicitly started or scheduled. The default |
174 // is Tween::LINEAR. | 174 // is Tween::LINEAR. |
175 void set_tween_type(gfx::Tween::Type tween_type) { tween_type_ = tween_type; } | 175 void set_tween_type(gfx::Tween::Type tween_type) { tween_type_ = tween_type; } |
176 gfx::Tween::Type tween_type() const { return tween_type_; } | 176 gfx::Tween::Type tween_type() const { return tween_type_; } |
177 | 177 |
178 // For testing purposes only. | 178 // For testing purposes only. |
179 void set_disable_timer_for_test(bool disable_timer) { | 179 void set_disable_timer_for_test(bool disable_timer) { |
180 disable_timer_for_test_ = disable_timer; | 180 disable_timer_for_test_ = disable_timer; |
181 } | 181 } |
182 | 182 |
183 void set_last_step_time(base::TimeTicks time) { | 183 void set_last_step_time(gfx::FrameTime time) { |
184 last_step_time_ = time; | 184 last_step_time_ = time; |
185 } | 185 } |
186 base::TimeTicks last_step_time() const { return last_step_time_; } | 186 gfx::FrameTime last_step_time() const { return last_step_time_; } |
187 | 187 |
188 protected: | 188 protected: |
189 virtual ~LayerAnimator(); | 189 virtual ~LayerAnimator(); |
190 | 190 |
191 LayerAnimationDelegate* delegate() { return delegate_; } | 191 LayerAnimationDelegate* delegate() { return delegate_; } |
192 const LayerAnimationDelegate* delegate() const { return delegate_; } | 192 const LayerAnimationDelegate* delegate() const { return delegate_; } |
193 | 193 |
194 // Virtual for testing. | 194 // Virtual for testing. |
195 virtual void ProgressAnimation(LayerAnimationSequence* sequence, | 195 virtual void ProgressAnimation(LayerAnimationSequence* sequence, |
196 base::TimeTicks now); | 196 gfx::FrameTime now); |
197 | 197 |
198 void ProgressAnimationToEnd(LayerAnimationSequence* sequence); | 198 void ProgressAnimationToEnd(LayerAnimationSequence* sequence); |
199 | 199 |
200 // Returns true if the sequence is owned by this animator. | 200 // Returns true if the sequence is owned by this animator. |
201 bool HasAnimation(LayerAnimationSequence* sequence) const; | 201 bool HasAnimation(LayerAnimationSequence* sequence) const; |
202 | 202 |
203 private: | 203 private: |
204 friend class base::RefCounted<LayerAnimator>; | 204 friend class base::RefCounted<LayerAnimator>; |
205 friend class ScopedLayerAnimationSettings; | 205 friend class ScopedLayerAnimationSettings; |
206 friend class LayerAnimatorTestController; | 206 friend class LayerAnimatorTestController; |
207 | 207 |
208 class RunningAnimation { | 208 class RunningAnimation { |
209 public: | 209 public: |
210 RunningAnimation(const base::WeakPtr<LayerAnimationSequence>& sequence); | 210 RunningAnimation(const base::WeakPtr<LayerAnimationSequence>& sequence); |
211 ~RunningAnimation(); | 211 ~RunningAnimation(); |
212 | 212 |
213 bool is_sequence_alive() const { return !!sequence_.get(); } | 213 bool is_sequence_alive() const { return !!sequence_.get(); } |
214 LayerAnimationSequence* sequence() const { return sequence_.get(); } | 214 LayerAnimationSequence* sequence() const { return sequence_.get(); } |
215 | 215 |
216 private: | 216 private: |
217 base::WeakPtr<LayerAnimationSequence> sequence_; | 217 base::WeakPtr<LayerAnimationSequence> sequence_; |
218 | 218 |
219 // Copy and assign are allowed. | 219 // Copy and assign are allowed. |
220 }; | 220 }; |
221 | 221 |
222 typedef std::vector<RunningAnimation> RunningAnimations; | 222 typedef std::vector<RunningAnimation> RunningAnimations; |
223 typedef std::deque<linked_ptr<LayerAnimationSequence> > AnimationQueue; | 223 typedef std::deque<linked_ptr<LayerAnimationSequence> > AnimationQueue; |
224 | 224 |
225 // Implementation of AnimationContainerElement | 225 // Implementation of AnimationContainerElement |
226 virtual void SetStartTime(base::TimeTicks start_time) OVERRIDE; | 226 virtual void SetStartTime(gfx::FrameTime start_time) OVERRIDE; |
227 virtual void Step(base::TimeTicks time_now) OVERRIDE; | 227 virtual void Step(gfx::FrameTime time_now) OVERRIDE; |
228 virtual base::TimeDelta GetTimerInterval() const OVERRIDE; | 228 virtual base::TimeDelta GetTimerInterval() const OVERRIDE; |
229 | 229 |
230 // Finishes all animations by either advancing them to their final state or by | 230 // Finishes all animations by either advancing them to their final state or by |
231 // aborting them. | 231 // aborting them. |
232 void StopAnimatingInternal(bool abort); | 232 void StopAnimatingInternal(bool abort); |
233 | 233 |
234 // Starts or stops stepping depending on whether thare are running animations. | 234 // Starts or stops stepping depending on whether thare are running animations. |
235 void UpdateAnimationState(); | 235 void UpdateAnimationState(); |
236 | 236 |
237 // Removes the sequences from both the running animations and the queue. | 237 // Removes the sequences from both the running animations and the queue. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 // Determines how animations are replaced. | 317 // Determines how animations are replaced. |
318 PreemptionStrategy preemption_strategy_; | 318 PreemptionStrategy preemption_strategy_; |
319 | 319 |
320 // The default length of animations. | 320 // The default length of animations. |
321 base::TimeDelta transition_duration_; | 321 base::TimeDelta transition_duration_; |
322 | 322 |
323 // The default tween type for implicit transitions | 323 // The default tween type for implicit transitions |
324 gfx::Tween::Type tween_type_; | 324 gfx::Tween::Type tween_type_; |
325 | 325 |
326 // Used for coordinating the starting of animations. | 326 // Used for coordinating the starting of animations. |
327 base::TimeTicks last_step_time_; | 327 gfx::FrameTime last_step_time_; |
328 | 328 |
329 // True if we are being stepped by our container. | 329 // True if we are being stepped by our container. |
330 bool is_started_; | 330 bool is_started_; |
331 | 331 |
332 // This prevents the animator from automatically stepping through animations | 332 // This prevents the animator from automatically stepping through animations |
333 // and allows for manual stepping. | 333 // and allows for manual stepping. |
334 bool disable_timer_for_test_; | 334 bool disable_timer_for_test_; |
335 | 335 |
336 // Prevents timer adjustments in case when we start multiple animations | 336 // Prevents timer adjustments in case when we start multiple animations |
337 // with preemption strategies that discard previous animations. | 337 // with preemption strategies that discard previous animations. |
338 bool adding_animations_; | 338 bool adding_animations_; |
339 | 339 |
340 // Observers are notified when layer animations end, are scheduled or are | 340 // Observers are notified when layer animations end, are scheduled or are |
341 // aborted. | 341 // aborted. |
342 ObserverList<LayerAnimationObserver> observers_; | 342 ObserverList<LayerAnimationObserver> observers_; |
343 | 343 |
344 DISALLOW_COPY_AND_ASSIGN(LayerAnimator); | 344 DISALLOW_COPY_AND_ASSIGN(LayerAnimator); |
345 }; | 345 }; |
346 | 346 |
347 } // namespace ui | 347 } // namespace ui |
348 | 348 |
349 #endif // UI_COMPOSITOR_LAYER_ANIMATOR_H_ | 349 #endif // UI_COMPOSITOR_LAYER_ANIMATOR_H_ |
OLD | NEW |