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 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
791 if (observers_.might_have_observers()) { | 796 if (observers_.might_have_observers()) { |
792 ObserverListBase<LayerAnimationObserver>::Iterator it(observers_); | 797 ObserverListBase<LayerAnimationObserver>::Iterator it(observers_); |
793 LayerAnimationObserver* obs; | 798 LayerAnimationObserver* obs; |
794 while ((obs = it.GetNext()) != NULL) { | 799 while ((obs = it.GetNext()) != NULL) { |
795 sequence->AddObserver(obs); | 800 sequence->AddObserver(obs); |
796 } | 801 } |
797 } | 802 } |
798 sequence->OnScheduled(); | 803 sequence->OnScheduled(); |
799 } | 804 } |
800 | 805 |
801 base::TimeDelta LayerAnimator::GetTransitionDuration() const { | 806 void LayerAnimator::SetTransitionDuration(base::TimeDelta duration) { |
802 return transition_duration_; | 807 if (is_transition_duration_locked_) |
| 808 return; |
| 809 transition_duration_ = duration; |
803 } | 810 } |
804 | 811 |
805 void LayerAnimator::ClearAnimationsInternal() { | 812 void LayerAnimator::ClearAnimationsInternal() { |
806 PurgeDeletedAnimations(); | 813 PurgeDeletedAnimations(); |
807 | 814 |
808 // Abort should never affect the set of running animations, but just in case | 815 // Abort should never affect the set of running animations, but just in case |
809 // clients are badly behaved, we will use a copy of the running animations. | 816 // clients are badly behaved, we will use a copy of the running animations. |
810 RunningAnimations running_animations_copy = running_animations_; | 817 RunningAnimations running_animations_copy = running_animations_; |
811 for (size_t i = 0; i < running_animations_copy.size(); ++i) { | 818 for (size_t i = 0; i < running_animations_copy.size(); ++i) { |
812 if (!SAFE_INVOKE_BOOL(HasAnimation, running_animations_copy[i])) | 819 if (!SAFE_INVOKE_BOOL(HasAnimation, running_animations_copy[i])) |
(...skipping 21 matching lines...) Expand all Loading... |
834 } | 841 } |
835 | 842 |
836 LayerAnimator::RunningAnimation::RunningAnimation( | 843 LayerAnimator::RunningAnimation::RunningAnimation( |
837 const base::WeakPtr<LayerAnimationSequence>& sequence) | 844 const base::WeakPtr<LayerAnimationSequence>& sequence) |
838 : sequence_(sequence) { | 845 : sequence_(sequence) { |
839 } | 846 } |
840 | 847 |
841 LayerAnimator::RunningAnimation::~RunningAnimation() { } | 848 LayerAnimator::RunningAnimation::~RunningAnimation() { } |
842 | 849 |
843 } // namespace ui | 850 } // namespace ui |
OLD | NEW |