| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 return container; | 48 return container; |
| 49 } | 49 } |
| 50 | 50 |
| 51 } // namespace | 51 } // namespace |
| 52 | 52 |
| 53 // LayerAnimator public -------------------------------------------------------- | 53 // LayerAnimator public -------------------------------------------------------- |
| 54 | 54 |
| 55 LayerAnimator::LayerAnimator(base::TimeDelta transition_duration) | 55 LayerAnimator::LayerAnimator(base::TimeDelta transition_duration) |
| 56 : delegate_(NULL), | 56 : delegate_(NULL), |
| 57 preemption_strategy_(IMMEDIATELY_SET_NEW_TARGET), | 57 preemption_strategy_(IMMEDIATELY_SET_NEW_TARGET), |
| 58 is_transition_duration_locked_(false), | |
| 59 transition_duration_(transition_duration), | 58 transition_duration_(transition_duration), |
| 60 tween_type_(gfx::Tween::LINEAR), | 59 tween_type_(gfx::Tween::LINEAR), |
| 61 is_started_(false), | 60 is_started_(false), |
| 62 disable_timer_for_test_(false), | 61 disable_timer_for_test_(false), |
| 63 adding_animations_(false) { | 62 adding_animations_(false) { |
| 64 } | 63 } |
| 65 | 64 |
| 66 LayerAnimator::~LayerAnimator() { | 65 LayerAnimator::~LayerAnimator() { |
| 67 for (size_t i = 0; i < running_animations_.size(); ++i) { | 66 for (size_t i = 0; i < running_animations_.size(); ++i) { |
| 68 if (running_animations_[i].is_sequence_alive()) | 67 if (running_animations_[i].is_sequence_alive()) |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 | 111 |
| 113 ANIMATED_PROPERTY( | 112 ANIMATED_PROPERTY( |
| 114 const gfx::Transform&, TRANSFORM, Transform, gfx::Transform, transform); | 113 const gfx::Transform&, TRANSFORM, Transform, gfx::Transform, transform); |
| 115 ANIMATED_PROPERTY(const gfx::Rect&, BOUNDS, Bounds, gfx::Rect, bounds); | 114 ANIMATED_PROPERTY(const gfx::Rect&, BOUNDS, Bounds, gfx::Rect, bounds); |
| 116 ANIMATED_PROPERTY(float, OPACITY, Opacity, float, opacity); | 115 ANIMATED_PROPERTY(float, OPACITY, Opacity, float, opacity); |
| 117 ANIMATED_PROPERTY(bool, VISIBILITY, Visibility, bool, visibility); | 116 ANIMATED_PROPERTY(bool, VISIBILITY, Visibility, bool, visibility); |
| 118 ANIMATED_PROPERTY(float, BRIGHTNESS, Brightness, float, brightness); | 117 ANIMATED_PROPERTY(float, BRIGHTNESS, Brightness, float, brightness); |
| 119 ANIMATED_PROPERTY(float, GRAYSCALE, Grayscale, float, grayscale); | 118 ANIMATED_PROPERTY(float, GRAYSCALE, Grayscale, float, grayscale); |
| 120 ANIMATED_PROPERTY(SkColor, COLOR, Color, SkColor, color); | 119 ANIMATED_PROPERTY(SkColor, COLOR, Color, SkColor, color); |
| 121 | 120 |
| 122 base::TimeDelta LayerAnimator::GetTransitionDuration() const { | |
| 123 return transition_duration_; | |
| 124 } | |
| 125 | |
| 126 void LayerAnimator::SetDelegate(LayerAnimationDelegate* delegate) { | 121 void LayerAnimator::SetDelegate(LayerAnimationDelegate* delegate) { |
| 127 delegate_ = delegate; | 122 delegate_ = delegate; |
| 128 } | 123 } |
| 129 | 124 |
| 130 void LayerAnimator::StartAnimation(LayerAnimationSequence* animation) { | 125 void LayerAnimator::StartAnimation(LayerAnimationSequence* animation) { |
| 131 scoped_refptr<LayerAnimator> retain(this); | 126 scoped_refptr<LayerAnimator> retain(this); |
| 132 OnScheduled(animation); | 127 OnScheduled(animation); |
| 133 if (!StartSequenceImmediately(animation)) { | 128 if (!StartSequenceImmediately(animation)) { |
| 134 // Attempt to preempt a running animation. | 129 // Attempt to preempt a running animation. |
| 135 switch (preemption_strategy_) { | 130 switch (preemption_strategy_) { |
| (...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 if (observers_.might_have_observers()) { | 791 if (observers_.might_have_observers()) { |
| 797 ObserverListBase<LayerAnimationObserver>::Iterator it(observers_); | 792 ObserverListBase<LayerAnimationObserver>::Iterator it(observers_); |
| 798 LayerAnimationObserver* obs; | 793 LayerAnimationObserver* obs; |
| 799 while ((obs = it.GetNext()) != NULL) { | 794 while ((obs = it.GetNext()) != NULL) { |
| 800 sequence->AddObserver(obs); | 795 sequence->AddObserver(obs); |
| 801 } | 796 } |
| 802 } | 797 } |
| 803 sequence->OnScheduled(); | 798 sequence->OnScheduled(); |
| 804 } | 799 } |
| 805 | 800 |
| 806 void LayerAnimator::SetTransitionDuration(base::TimeDelta duration) { | 801 base::TimeDelta LayerAnimator::GetTransitionDuration() const { |
| 807 if (is_transition_duration_locked_) | 802 return transition_duration_; |
| 808 return; | |
| 809 transition_duration_ = duration; | |
| 810 } | 803 } |
| 811 | 804 |
| 812 void LayerAnimator::ClearAnimationsInternal() { | 805 void LayerAnimator::ClearAnimationsInternal() { |
| 813 PurgeDeletedAnimations(); | 806 PurgeDeletedAnimations(); |
| 814 | 807 |
| 815 // Abort should never affect the set of running animations, but just in case | 808 // Abort should never affect the set of running animations, but just in case |
| 816 // clients are badly behaved, we will use a copy of the running animations. | 809 // clients are badly behaved, we will use a copy of the running animations. |
| 817 RunningAnimations running_animations_copy = running_animations_; | 810 RunningAnimations running_animations_copy = running_animations_; |
| 818 for (size_t i = 0; i < running_animations_copy.size(); ++i) { | 811 for (size_t i = 0; i < running_animations_copy.size(); ++i) { |
| 819 if (!SAFE_INVOKE_BOOL(HasAnimation, running_animations_copy[i])) | 812 if (!SAFE_INVOKE_BOOL(HasAnimation, running_animations_copy[i])) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 841 } | 834 } |
| 842 | 835 |
| 843 LayerAnimator::RunningAnimation::RunningAnimation( | 836 LayerAnimator::RunningAnimation::RunningAnimation( |
| 844 const base::WeakPtr<LayerAnimationSequence>& sequence) | 837 const base::WeakPtr<LayerAnimationSequence>& sequence) |
| 845 : sequence_(sequence) { | 838 : sequence_(sequence) { |
| 846 } | 839 } |
| 847 | 840 |
| 848 LayerAnimator::RunningAnimation::~RunningAnimation() { } | 841 LayerAnimator::RunningAnimation::~RunningAnimation() { } |
| 849 | 842 |
| 850 } // namespace ui | 843 } // namespace ui |
| OLD | NEW |