| 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), |
| 58 transition_duration_(transition_duration), | 59 transition_duration_(transition_duration), |
| 59 tween_type_(gfx::Tween::LINEAR), | 60 tween_type_(gfx::Tween::LINEAR), |
| 60 is_started_(false), | 61 is_started_(false), |
| 61 disable_timer_for_test_(false), | 62 disable_timer_for_test_(false), |
| 62 adding_animations_(false) { | 63 adding_animations_(false) { |
| 63 } | 64 } |
| 64 | 65 |
| 65 LayerAnimator::~LayerAnimator() { | 66 LayerAnimator::~LayerAnimator() { |
| 66 for (size_t i = 0; i < running_animations_.size(); ++i) { | 67 for (size_t i = 0; i < running_animations_.size(); ++i) { |
| 67 if (running_animations_[i].is_sequence_alive()) | 68 if (running_animations_[i].is_sequence_alive()) |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 112 |
| 112 ANIMATED_PROPERTY( | 113 ANIMATED_PROPERTY( |
| 113 const gfx::Transform&, TRANSFORM, Transform, gfx::Transform, transform); | 114 const gfx::Transform&, TRANSFORM, Transform, gfx::Transform, transform); |
| 114 ANIMATED_PROPERTY(const gfx::Rect&, BOUNDS, Bounds, gfx::Rect, bounds); | 115 ANIMATED_PROPERTY(const gfx::Rect&, BOUNDS, Bounds, gfx::Rect, bounds); |
| 115 ANIMATED_PROPERTY(float, OPACITY, Opacity, float, opacity); | 116 ANIMATED_PROPERTY(float, OPACITY, Opacity, float, opacity); |
| 116 ANIMATED_PROPERTY(bool, VISIBILITY, Visibility, bool, visibility); | 117 ANIMATED_PROPERTY(bool, VISIBILITY, Visibility, bool, visibility); |
| 117 ANIMATED_PROPERTY(float, BRIGHTNESS, Brightness, float, brightness); | 118 ANIMATED_PROPERTY(float, BRIGHTNESS, Brightness, float, brightness); |
| 118 ANIMATED_PROPERTY(float, GRAYSCALE, Grayscale, float, grayscale); | 119 ANIMATED_PROPERTY(float, GRAYSCALE, Grayscale, float, grayscale); |
| 119 ANIMATED_PROPERTY(SkColor, COLOR, Color, SkColor, color); | 120 ANIMATED_PROPERTY(SkColor, COLOR, Color, SkColor, color); |
| 120 | 121 |
| 122 base::TimeDelta LayerAnimator::GetTransitionDuration() const { |
| 123 return transition_duration_; |
| 124 } |
| 125 |
| 121 void LayerAnimator::SetDelegate(LayerAnimationDelegate* delegate) { | 126 void LayerAnimator::SetDelegate(LayerAnimationDelegate* delegate) { |
| 122 delegate_ = delegate; | 127 delegate_ = delegate; |
| 123 } | 128 } |
| 124 | 129 |
| 125 void LayerAnimator::StartAnimation(LayerAnimationSequence* animation) { | 130 void LayerAnimator::StartAnimation(LayerAnimationSequence* animation) { |
| 126 scoped_refptr<LayerAnimator> retain(this); | 131 scoped_refptr<LayerAnimator> retain(this); |
| 127 OnScheduled(animation); | 132 OnScheduled(animation); |
| 128 if (!StartSequenceImmediately(animation)) { | 133 if (!StartSequenceImmediately(animation)) { |
| 129 // Attempt to preempt a running animation. | 134 // Attempt to preempt a running animation. |
| 130 switch (preemption_strategy_) { | 135 switch (preemption_strategy_) { |
| (...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 if (observers_.might_have_observers()) { | 808 if (observers_.might_have_observers()) { |
| 804 ObserverListBase<LayerAnimationObserver>::Iterator it(observers_); | 809 ObserverListBase<LayerAnimationObserver>::Iterator it(observers_); |
| 805 LayerAnimationObserver* obs; | 810 LayerAnimationObserver* obs; |
| 806 while ((obs = it.GetNext()) != NULL) { | 811 while ((obs = it.GetNext()) != NULL) { |
| 807 sequence->AddObserver(obs); | 812 sequence->AddObserver(obs); |
| 808 } | 813 } |
| 809 } | 814 } |
| 810 sequence->OnScheduled(); | 815 sequence->OnScheduled(); |
| 811 } | 816 } |
| 812 | 817 |
| 813 base::TimeDelta LayerAnimator::GetTransitionDuration() const { | 818 void LayerAnimator::SetTransitionDuration(base::TimeDelta duration) { |
| 814 return transition_duration_; | 819 if (is_transition_duration_locked_) |
| 820 return; |
| 821 transition_duration_ = duration; |
| 815 } | 822 } |
| 816 | 823 |
| 817 void LayerAnimator::ClearAnimationsInternal() { | 824 void LayerAnimator::ClearAnimationsInternal() { |
| 818 PurgeDeletedAnimations(); | 825 PurgeDeletedAnimations(); |
| 819 | 826 |
| 820 // Abort should never affect the set of running animations, but just in case | 827 // Abort should never affect the set of running animations, but just in case |
| 821 // clients are badly behaved, we will use a copy of the running animations. | 828 // clients are badly behaved, we will use a copy of the running animations. |
| 822 RunningAnimations running_animations_copy = running_animations_; | 829 RunningAnimations running_animations_copy = running_animations_; |
| 823 for (size_t i = 0; i < running_animations_copy.size(); ++i) { | 830 for (size_t i = 0; i < running_animations_copy.size(); ++i) { |
| 824 if (!SAFE_INVOKE_BOOL(HasAnimation, running_animations_copy[i])) | 831 if (!SAFE_INVOKE_BOOL(HasAnimation, running_animations_copy[i])) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 846 } | 853 } |
| 847 | 854 |
| 848 LayerAnimator::RunningAnimation::RunningAnimation( | 855 LayerAnimator::RunningAnimation::RunningAnimation( |
| 849 const base::WeakPtr<LayerAnimationSequence>& sequence) | 856 const base::WeakPtr<LayerAnimationSequence>& sequence) |
| 850 : sequence_(sequence) { | 857 : sequence_(sequence) { |
| 851 } | 858 } |
| 852 | 859 |
| 853 LayerAnimator::RunningAnimation::~RunningAnimation() { } | 860 LayerAnimator::RunningAnimation::~RunningAnimation() { } |
| 854 | 861 |
| 855 } // namespace ui | 862 } // namespace ui |
| OLD | NEW |