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 #include "ui/compositor/layer_animator.h" | 5 #include "ui/compositor/layer_animator.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "cc/animation/animation_id_provider.h" | 10 #include "cc/animation/animation_id_provider.h" |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 if (running_animations_copy[i].sequence()->IsFinished(now)) { | 402 if (running_animations_copy[i].sequence()->IsFinished(now)) { |
403 SAFE_INVOKE_VOID(FinishAnimation, running_animations_copy[i], false); | 403 SAFE_INVOKE_VOID(FinishAnimation, running_animations_copy[i], false); |
404 } else { | 404 } else { |
405 SAFE_INVOKE_VOID(ProgressAnimation, running_animations_copy[i], now); | 405 SAFE_INVOKE_VOID(ProgressAnimation, running_animations_copy[i], now); |
406 } | 406 } |
407 } | 407 } |
408 } | 408 } |
409 | 409 |
410 void LayerAnimator::StopAnimatingInternal(bool abort) { | 410 void LayerAnimator::StopAnimatingInternal(bool abort) { |
411 scoped_refptr<LayerAnimator> retain(this); | 411 scoped_refptr<LayerAnimator> retain(this); |
412 while (is_animating()) { | 412 while (is_animating() && delegate()) { |
413 // We're going to attempt to finish the first running animation. Let's | 413 // We're going to attempt to finish the first running animation. Let's |
414 // ensure that it's valid. | 414 // ensure that it's valid. |
415 PurgeDeletedAnimations(); | 415 PurgeDeletedAnimations(); |
416 | 416 |
417 // If we've purged all running animations, attempt to start one up. | 417 // If we've purged all running animations, attempt to start one up. |
418 if (running_animations_.empty()) | 418 if (running_animations_.empty()) |
419 ProcessQueue(); | 419 ProcessQueue(); |
420 | 420 |
421 DCHECK(!running_animations_.empty()); | 421 DCHECK(!running_animations_.empty()); |
422 | 422 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 } | 510 } |
511 | 511 |
512 void LayerAnimator::FinishAnimation( | 512 void LayerAnimator::FinishAnimation( |
513 LayerAnimationSequence* sequence, bool abort) { | 513 LayerAnimationSequence* sequence, bool abort) { |
514 scoped_refptr<LayerAnimator> retain(this); | 514 scoped_refptr<LayerAnimator> retain(this); |
515 scoped_ptr<LayerAnimationSequence> removed(RemoveAnimation(sequence)); | 515 scoped_ptr<LayerAnimationSequence> removed(RemoveAnimation(sequence)); |
516 if (abort) | 516 if (abort) |
517 sequence->Abort(delegate()); | 517 sequence->Abort(delegate()); |
518 else | 518 else |
519 ProgressAnimationToEnd(sequence); | 519 ProgressAnimationToEnd(sequence); |
| 520 if (!delegate()) |
| 521 return; |
520 ProcessQueue(); | 522 ProcessQueue(); |
521 UpdateAnimationState(); | 523 UpdateAnimationState(); |
522 } | 524 } |
523 | 525 |
524 void LayerAnimator::FinishAnyAnimationWithZeroDuration() { | 526 void LayerAnimator::FinishAnyAnimationWithZeroDuration() { |
525 scoped_refptr<LayerAnimator> retain(this); | 527 scoped_refptr<LayerAnimator> retain(this); |
526 // Special case: if we've started a 0 duration animation, just finish it now | 528 // Special case: if we've started a 0 duration animation, just finish it now |
527 // and get rid of it. We need to make a copy because Progress may indirectly | 529 // and get rid of it. We need to make a copy because Progress may indirectly |
528 // cause new animations to start running. | 530 // cause new animations to start running. |
529 RunningAnimations running_animations_copy = running_animations_; | 531 RunningAnimations running_animations_copy = running_animations_; |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 } | 855 } |
854 | 856 |
855 LayerAnimator::RunningAnimation::RunningAnimation( | 857 LayerAnimator::RunningAnimation::RunningAnimation( |
856 const base::WeakPtr<LayerAnimationSequence>& sequence) | 858 const base::WeakPtr<LayerAnimationSequence>& sequence) |
857 : sequence_(sequence) { | 859 : sequence_(sequence) { |
858 } | 860 } |
859 | 861 |
860 LayerAnimator::RunningAnimation::~RunningAnimation() { } | 862 LayerAnimator::RunningAnimation::~RunningAnimation() { } |
861 | 863 |
862 } // namespace ui | 864 } // namespace ui |
OLD | NEW |