Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: ui/compositor/layer_animator.cc

Issue 16136005: Update remaining files to use WeakPtr<T>::get() instead of "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 } 594 }
595 595
596 // Same for the queued animations that haven't been started. Again, we'll 596 // Same for the queued animations that haven't been started. Again, we'll
597 // need to operate on a copy. 597 // need to operate on a copy.
598 std::vector<base::WeakPtr<LayerAnimationSequence> > sequences; 598 std::vector<base::WeakPtr<LayerAnimationSequence> > sequences;
599 for (AnimationQueue::iterator queue_iter = animation_queue_.begin(); 599 for (AnimationQueue::iterator queue_iter = animation_queue_.begin();
600 queue_iter != animation_queue_.end(); ++queue_iter) 600 queue_iter != animation_queue_.end(); ++queue_iter)
601 sequences.push_back((*queue_iter)->AsWeakPtr()); 601 sequences.push_back((*queue_iter)->AsWeakPtr());
602 602
603 for (size_t i = 0; i < sequences.size(); ++i) { 603 for (size_t i = 0; i < sequences.size(); ++i) {
604 if (!sequences[i] || !HasAnimation(sequences[i])) 604 if (!sequences[i].get() || !HasAnimation(sequences[i].get()))
605 continue; 605 continue;
606 606
607 if (sequences[i]->HasConflictingProperty(sequence->properties())) { 607 if (sequences[i]->HasConflictingProperty(sequence->properties())) {
608 scoped_ptr<LayerAnimationSequence> removed(RemoveAnimation(sequences[i])); 608 scoped_ptr<LayerAnimationSequence> removed(
609 RemoveAnimation(sequences[i].get()));
609 if (abort) 610 if (abort)
610 sequences[i]->Abort(delegate()); 611 sequences[i]->Abort(delegate());
611 else 612 else
612 ProgressAnimationToEnd(sequences[i]); 613 ProgressAnimationToEnd(sequences[i].get());
613 } 614 }
614 } 615 }
615 } 616 }
616 617
617 void LayerAnimator::ImmediatelySetNewTarget(LayerAnimationSequence* sequence) { 618 void LayerAnimator::ImmediatelySetNewTarget(LayerAnimationSequence* sequence) {
618 // Need to detect if our sequence gets destroyed. 619 // Need to detect if our sequence gets destroyed.
619 base::WeakPtr<LayerAnimationSequence> weak_sequence_ptr = 620 base::WeakPtr<LayerAnimationSequence> weak_sequence_ptr =
620 sequence->AsWeakPtr(); 621 sequence->AsWeakPtr();
621 622
622 const bool abort = false; 623 const bool abort = false;
623 RemoveAllAnimationsWithACommonProperty(sequence, abort); 624 RemoveAllAnimationsWithACommonProperty(sequence, abort);
624 if (!weak_sequence_ptr) 625 if (!weak_sequence_ptr.get())
625 return; 626 return;
626 627
627 LayerAnimationSequence* removed = RemoveAnimation(sequence); 628 LayerAnimationSequence* removed = RemoveAnimation(sequence);
628 DCHECK(removed == NULL || removed == sequence); 629 DCHECK(removed == NULL || removed == sequence);
629 if (!weak_sequence_ptr) 630 if (!weak_sequence_ptr.get())
630 return; 631 return;
631 632
632 ProgressAnimationToEnd(sequence); 633 ProgressAnimationToEnd(sequence);
633 if (!weak_sequence_ptr) 634 if (!weak_sequence_ptr.get())
634 return; 635 return;
635 636
636 delete sequence; 637 delete sequence;
637 } 638 }
638 639
639 void LayerAnimator::ImmediatelyAnimateToNewTarget( 640 void LayerAnimator::ImmediatelyAnimateToNewTarget(
640 LayerAnimationSequence* sequence) { 641 LayerAnimationSequence* sequence) {
641 // Need to detect if our sequence gets destroyed. 642 // Need to detect if our sequence gets destroyed.
642 base::WeakPtr<LayerAnimationSequence> weak_sequence_ptr = 643 base::WeakPtr<LayerAnimationSequence> weak_sequence_ptr =
643 sequence->AsWeakPtr(); 644 sequence->AsWeakPtr();
644 645
645 const bool abort = true; 646 const bool abort = true;
646 RemoveAllAnimationsWithACommonProperty(sequence, abort); 647 RemoveAllAnimationsWithACommonProperty(sequence, abort);
647 if (!weak_sequence_ptr) 648 if (!weak_sequence_ptr.get())
648 return; 649 return;
649 650
650 AddToQueueIfNotPresent(sequence); 651 AddToQueueIfNotPresent(sequence);
651 if (!weak_sequence_ptr) 652 if (!weak_sequence_ptr.get())
652 return; 653 return;
653 654
654 StartSequenceImmediately(sequence); 655 StartSequenceImmediately(sequence);
655 } 656 }
656 657
657 void LayerAnimator::EnqueueNewAnimation(LayerAnimationSequence* sequence) { 658 void LayerAnimator::EnqueueNewAnimation(LayerAnimationSequence* sequence) {
658 // It is assumed that if there was no conflicting animation, we would 659 // It is assumed that if there was no conflicting animation, we would
659 // not have been called. No need to check for a collision; just 660 // not have been called. No need to check for a collision; just
660 // add to the queue. 661 // add to the queue.
661 animation_queue_.push_back(make_linked_ptr(sequence)); 662 animation_queue_.push_back(make_linked_ptr(sequence));
662 ProcessQueue(); 663 ProcessQueue();
663 } 664 }
664 665
665 void LayerAnimator::ReplaceQueuedAnimations(LayerAnimationSequence* sequence) { 666 void LayerAnimator::ReplaceQueuedAnimations(LayerAnimationSequence* sequence) {
666 // Need to detect if our sequence gets destroyed. 667 // Need to detect if our sequence gets destroyed.
667 base::WeakPtr<LayerAnimationSequence> weak_sequence_ptr = 668 base::WeakPtr<LayerAnimationSequence> weak_sequence_ptr =
668 sequence->AsWeakPtr(); 669 sequence->AsWeakPtr();
669 670
670 // Remove all animations that aren't running. Note: at each iteration i is 671 // Remove all animations that aren't running. Note: at each iteration i is
671 // incremented or an element is removed from the queue, so 672 // incremented or an element is removed from the queue, so
672 // animation_queue_.size() - i is always decreasing and we are always making 673 // animation_queue_.size() - i is always decreasing and we are always making
673 // progress towards the loop terminating. 674 // progress towards the loop terminating.
674 for (size_t i = 0; i < animation_queue_.size();) { 675 for (size_t i = 0; i < animation_queue_.size();) {
675 if (!weak_sequence_ptr) 676 if (!weak_sequence_ptr.get())
676 break; 677 break;
677 678
678 PurgeDeletedAnimations(); 679 PurgeDeletedAnimations();
679 680
680 bool is_running = false; 681 bool is_running = false;
681 for (RunningAnimations::const_iterator iter = running_animations_.begin(); 682 for (RunningAnimations::const_iterator iter = running_animations_.begin();
682 iter != running_animations_.end(); ++iter) { 683 iter != running_animations_.end(); ++iter) {
683 if ((*iter).sequence() == animation_queue_[i].get()) { 684 if ((*iter).sequence() == animation_queue_[i].get()) {
684 is_running = true; 685 is_running = true;
685 break; 686 break;
(...skipping 26 matching lines...) Expand all
712 // Try to find an animation that doesn't conflict with an animated 713 // Try to find an animation that doesn't conflict with an animated
713 // property or a property that will be animated before it. Note: starting 714 // property or a property that will be animated before it. Note: starting
714 // the animation may indirectly cause more animations to be started, so we 715 // the animation may indirectly cause more animations to be started, so we
715 // need to operate on a copy. 716 // need to operate on a copy.
716 std::vector<base::WeakPtr<LayerAnimationSequence> > sequences; 717 std::vector<base::WeakPtr<LayerAnimationSequence> > sequences;
717 for (AnimationQueue::iterator queue_iter = animation_queue_.begin(); 718 for (AnimationQueue::iterator queue_iter = animation_queue_.begin();
718 queue_iter != animation_queue_.end(); ++queue_iter) 719 queue_iter != animation_queue_.end(); ++queue_iter)
719 sequences.push_back((*queue_iter)->AsWeakPtr()); 720 sequences.push_back((*queue_iter)->AsWeakPtr());
720 721
721 for (size_t i = 0; i < sequences.size(); ++i) { 722 for (size_t i = 0; i < sequences.size(); ++i) {
722 if (!sequences[i] || !HasAnimation(sequences[i])) 723 if (!sequences[i].get() || !HasAnimation(sequences[i].get()))
723 continue; 724 continue;
724 725
725 if (!sequences[i]->HasConflictingProperty(animated)) { 726 if (!sequences[i]->HasConflictingProperty(animated)) {
726 StartSequenceImmediately(sequences[i].get()); 727 StartSequenceImmediately(sequences[i].get());
727 started_sequence = true; 728 started_sequence = true;
728 break; 729 break;
729 } 730 }
730 731
731 // Animation couldn't be started. Add its properties to the collection so 732 // Animation couldn't be started. Add its properties to the collection so
732 // that we don't start a conflicting animation. For example, if our queue 733 // that we don't start a conflicting animation. For example, if our queue
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 } 844 }
844 845
845 LayerAnimator::RunningAnimation::RunningAnimation( 846 LayerAnimator::RunningAnimation::RunningAnimation(
846 const base::WeakPtr<LayerAnimationSequence>& sequence) 847 const base::WeakPtr<LayerAnimationSequence>& sequence)
847 : sequence_(sequence) { 848 : sequence_(sequence) {
848 } 849 }
849 850
850 LayerAnimator::RunningAnimation::~RunningAnimation() { } 851 LayerAnimator::RunningAnimation::~RunningAnimation() { }
851 852
852 } // namespace ui 853 } // namespace ui
OLDNEW
« cc/resources/video_resource_updater.cc ('K') | « ui/compositor/layer_animator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698