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

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

Issue 12226080: Thread ui transform animations (Closed) Base URL: http://git.chromium.org/chromium/src.git@DefineThreadedLayerAnimationElements
Patch Set: Fix WebContentsViewAuraTest.QuickOverscrollDirectionChange Created 7 years, 9 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
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_id_provider.h" 10 #include "cc/animation_id_provider.h"
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 LayerAnimationSequence* sequence, bool abort) { 582 LayerAnimationSequence* sequence, bool abort) {
583 // For all the running animations, if they animate the same property, 583 // For all the running animations, if they animate the same property,
584 // progress them to the end and remove them. Note, Aborting or Progressing 584 // progress them to the end and remove them. Note, Aborting or Progressing
585 // animations may affect the collection of running animations, so we need to 585 // animations may affect the collection of running animations, so we need to
586 // operate on a copy. 586 // operate on a copy.
587 RunningAnimations running_animations_copy = running_animations_; 587 RunningAnimations running_animations_copy = running_animations_;
588 for (size_t i = 0; i < running_animations_copy.size(); ++i) { 588 for (size_t i = 0; i < running_animations_copy.size(); ++i) {
589 if (!SAFE_INVOKE_BOOL(HasAnimation, running_animations_copy[i])) 589 if (!SAFE_INVOKE_BOOL(HasAnimation, running_animations_copy[i]))
590 continue; 590 continue;
591 591
592 if (running_animations_copy[i].sequence()->HasCommonProperty( 592 if (running_animations_copy[i].sequence()->HasConflictingProperty(
593 sequence->properties())) { 593 sequence->properties())) {
594 scoped_ptr<LayerAnimationSequence> removed( 594 scoped_ptr<LayerAnimationSequence> removed(
595 SAFE_INVOKE_PTR(RemoveAnimation, running_animations_copy[i])); 595 SAFE_INVOKE_PTR(RemoveAnimation, running_animations_copy[i]));
596 if (abort) 596 if (abort)
597 running_animations_copy[i].sequence()->Abort(delegate()); 597 running_animations_copy[i].sequence()->Abort(delegate());
598 else 598 else
599 SAFE_INVOKE_VOID(ProgressAnimationToEnd, running_animations_copy[i]); 599 SAFE_INVOKE_VOID(ProgressAnimationToEnd, running_animations_copy[i]);
600 } 600 }
601 } 601 }
602 602
603 // Same for the queued animations that haven't been started. Again, we'll 603 // Same for the queued animations that haven't been started. Again, we'll
604 // need to operate on a copy. 604 // need to operate on a copy.
605 std::vector<base::WeakPtr<LayerAnimationSequence> > sequences; 605 std::vector<base::WeakPtr<LayerAnimationSequence> > sequences;
606 for (AnimationQueue::iterator queue_iter = animation_queue_.begin(); 606 for (AnimationQueue::iterator queue_iter = animation_queue_.begin();
607 queue_iter != animation_queue_.end(); ++queue_iter) 607 queue_iter != animation_queue_.end(); ++queue_iter)
608 sequences.push_back((*queue_iter)->AsWeakPtr()); 608 sequences.push_back((*queue_iter)->AsWeakPtr());
609 609
610 for (size_t i = 0; i < sequences.size(); ++i) { 610 for (size_t i = 0; i < sequences.size(); ++i) {
611 if (!sequences[i] || !HasAnimation(sequences[i])) 611 if (!sequences[i] || !HasAnimation(sequences[i]))
612 continue; 612 continue;
613 613
614 if (sequences[i]->HasCommonProperty(sequence->properties())) { 614 if (sequences[i]->HasConflictingProperty(sequence->properties())) {
615 scoped_ptr<LayerAnimationSequence> removed(RemoveAnimation(sequences[i])); 615 scoped_ptr<LayerAnimationSequence> removed(RemoveAnimation(sequences[i]));
616 if (abort) 616 if (abort)
617 sequences[i]->Abort(delegate()); 617 sequences[i]->Abort(delegate());
618 else 618 else
619 ProgressAnimationToEnd(sequences[i]); 619 ProgressAnimationToEnd(sequences[i]);
620 } 620 }
621 } 621 }
622 } 622 }
623 623
624 void LayerAnimator::ImmediatelySetNewTarget(LayerAnimationSequence* sequence) { 624 void LayerAnimator::ImmediatelySetNewTarget(LayerAnimationSequence* sequence) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 // need to operate on a copy. 722 // need to operate on a copy.
723 std::vector<base::WeakPtr<LayerAnimationSequence> > sequences; 723 std::vector<base::WeakPtr<LayerAnimationSequence> > sequences;
724 for (AnimationQueue::iterator queue_iter = animation_queue_.begin(); 724 for (AnimationQueue::iterator queue_iter = animation_queue_.begin();
725 queue_iter != animation_queue_.end(); ++queue_iter) 725 queue_iter != animation_queue_.end(); ++queue_iter)
726 sequences.push_back((*queue_iter)->AsWeakPtr()); 726 sequences.push_back((*queue_iter)->AsWeakPtr());
727 727
728 for (size_t i = 0; i < sequences.size(); ++i) { 728 for (size_t i = 0; i < sequences.size(); ++i) {
729 if (!sequences[i] || !HasAnimation(sequences[i])) 729 if (!sequences[i] || !HasAnimation(sequences[i]))
730 continue; 730 continue;
731 731
732 if (!sequences[i]->HasCommonProperty(animated)) { 732 if (!sequences[i]->HasConflictingProperty(animated)) {
733 StartSequenceImmediately(sequences[i].get()); 733 StartSequenceImmediately(sequences[i].get());
734 started_sequence = true; 734 started_sequence = true;
735 break; 735 break;
736 } 736 }
737 737
738 // Animation couldn't be started. Add its properties to the collection so 738 // Animation couldn't be started. Add its properties to the collection so
739 // that we don't start a conflicting animation. For example, if our queue 739 // that we don't start a conflicting animation. For example, if our queue
740 // has the elements { {T,B}, {B} } (that is, an element that animates both 740 // has the elements { {T,B}, {B} } (that is, an element that animates both
741 // the transform and the bounds followed by an element that animates the 741 // the transform and the bounds followed by an element that animates the
742 // bounds), and we're currently animating the transform, we can't start 742 // bounds), and we're currently animating the transform, we can't start
743 // the first element because it animates the transform, too. We cannot 743 // the first element because it animates the transform, too. We cannot
744 // start the second element, either, because the first element animates 744 // start the second element, either, because the first element animates
745 // bounds too, and needs to go first. 745 // bounds too, and needs to go first.
746 animated.insert(sequences[i]->properties().begin(), 746 animated.insert(sequences[i]->properties().begin(),
747 sequences[i]->properties().end()); 747 sequences[i]->properties().end());
748 } 748 }
749 749
750 // If we started a sequence, try again. We may be able to start several. 750 // If we started a sequence, try again. We may be able to start several.
751 } while (started_sequence); 751 } while (started_sequence);
752 } 752 }
753 753
754 bool LayerAnimator::StartSequenceImmediately(LayerAnimationSequence* sequence) { 754 bool LayerAnimator::StartSequenceImmediately(LayerAnimationSequence* sequence) {
755 PurgeDeletedAnimations(); 755 PurgeDeletedAnimations();
756 756
757 // Ensure that no one is animating one of the sequence's properties already. 757 // Ensure that no one is animating one of the sequence's properties already.
758 for (RunningAnimations::const_iterator iter = running_animations_.begin(); 758 for (RunningAnimations::const_iterator iter = running_animations_.begin();
759 iter != running_animations_.end(); ++iter) { 759 iter != running_animations_.end(); ++iter) {
760 if ((*iter).sequence()->HasCommonProperty(sequence->properties())) 760 if ((*iter).sequence()->HasConflictingProperty(sequence->properties()))
761 return false; 761 return false;
762 } 762 }
763 763
764 // All clear, actually start the sequence. Note: base::TimeTicks::Now has 764 // All clear, actually start the sequence. Note: base::TimeTicks::Now has
765 // a resolution that can be as bad as 15ms. If this causes glitches in the 765 // a resolution that can be as bad as 15ms. If this causes glitches in the
766 // animations, this can be switched to HighResNow() (animation uses Now() 766 // animations, this can be switched to HighResNow() (animation uses Now()
767 // internally). 767 // internally).
768 // All LayerAnimators share the same AnimationContainer. Use the 768 // All LayerAnimators share the same AnimationContainer. Use the
769 // last_tick_time() from there to ensure animations started during the same 769 // last_tick_time() from there to ensure animations started during the same
770 // event complete at the same time. 770 // event complete at the same time.
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 } 850 }
851 851
852 LayerAnimator::RunningAnimation::RunningAnimation( 852 LayerAnimator::RunningAnimation::RunningAnimation(
853 const base::WeakPtr<LayerAnimationSequence>& sequence) 853 const base::WeakPtr<LayerAnimationSequence>& sequence)
854 : sequence_(sequence) { 854 : sequence_(sequence) {
855 } 855 }
856 856
857 LayerAnimator::RunningAnimation::~RunningAnimation() { } 857 LayerAnimator::RunningAnimation::~RunningAnimation() { }
858 858
859 } // namespace ui 859 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698