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 "ui/base/animation/animation_container.h" | 10 #include "ui/base/animation/animation_container.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 LayerAnimationElement::CreateVisibilityElement( | 112 LayerAnimationElement::CreateVisibilityElement( |
113 visibility, duration))); | 113 visibility, duration))); |
114 } | 114 } |
115 | 115 |
116 bool LayerAnimator::GetTargetVisibility() const { | 116 bool LayerAnimator::GetTargetVisibility() const { |
117 LayerAnimationElement::TargetValue target(delegate()); | 117 LayerAnimationElement::TargetValue target(delegate()); |
118 GetTargetValue(&target); | 118 GetTargetValue(&target); |
119 return target.visibility; | 119 return target.visibility; |
120 } | 120 } |
121 | 121 |
| 122 void LayerAnimator::SetBrightness(float brightness) { |
| 123 base::TimeDelta duration = GetTransitionDuration(); |
| 124 scoped_ptr<LayerAnimationElement> element( |
| 125 LayerAnimationElement::CreateBrightnessElement(brightness, duration)); |
| 126 element->set_tween_type(tween_type_); |
| 127 StartAnimation(new LayerAnimationSequence(element.release())); |
| 128 } |
| 129 |
| 130 float LayerAnimator::GetTargetBrightness() const { |
| 131 LayerAnimationElement::TargetValue target(delegate()); |
| 132 GetTargetValue(&target); |
| 133 return target.brightness; |
| 134 } |
| 135 |
| 136 void LayerAnimator::SetGrayscale(float grayscale) { |
| 137 base::TimeDelta duration = GetTransitionDuration(); |
| 138 scoped_ptr<LayerAnimationElement> element( |
| 139 LayerAnimationElement::CreateGrayscaleElement(grayscale, duration)); |
| 140 element->set_tween_type(tween_type_); |
| 141 StartAnimation(new LayerAnimationSequence(element.release())); |
| 142 } |
| 143 |
| 144 float LayerAnimator::GetTargetGrayscale() const { |
| 145 LayerAnimationElement::TargetValue target(delegate()); |
| 146 GetTargetValue(&target); |
| 147 return target.grayscale; |
| 148 } |
| 149 |
122 void LayerAnimator::SetDelegate(LayerAnimationDelegate* delegate) { | 150 void LayerAnimator::SetDelegate(LayerAnimationDelegate* delegate) { |
123 DCHECK(delegate); | 151 DCHECK(delegate); |
124 delegate_ = delegate; | 152 delegate_ = delegate; |
125 } | 153 } |
126 | 154 |
127 void LayerAnimator::StartAnimation(LayerAnimationSequence* animation) { | 155 void LayerAnimator::StartAnimation(LayerAnimationSequence* animation) { |
128 OnScheduled(animation); | 156 OnScheduled(animation); |
129 if (!StartSequenceImmediately(animation)) { | 157 if (!StartSequenceImmediately(animation)) { |
130 // Attempt to preempt a running animation. | 158 // Attempt to preempt a running animation. |
131 switch (preemption_strategy_) { | 159 switch (preemption_strategy_) { |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 } | 610 } |
583 } | 611 } |
584 sequence->OnScheduled(); | 612 sequence->OnScheduled(); |
585 } | 613 } |
586 | 614 |
587 base::TimeDelta LayerAnimator::GetTransitionDuration() const { | 615 base::TimeDelta LayerAnimator::GetTransitionDuration() const { |
588 return transition_duration_; | 616 return transition_duration_; |
589 } | 617 } |
590 | 618 |
591 } // namespace ui | 619 } // namespace ui |
OLD | NEW |