OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 <algorithm> | 5 #include <algorithm> |
6 #include <cmath> | 6 #include <cmath> |
7 | 7 |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "cc/animation/timing_function.h" | 9 #include "cc/animation/timing_function.h" |
10 | 10 |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 scoped_ptr<TimingFunction> EaseOutTimingFunction::Create() { | 155 scoped_ptr<TimingFunction> EaseOutTimingFunction::Create() { |
156 return CubicBezierTimingFunction::Create( | 156 return CubicBezierTimingFunction::Create( |
157 0.0, 0.0, 0.58, 1.0).PassAs<TimingFunction>(); | 157 0.0, 0.0, 0.58, 1.0).PassAs<TimingFunction>(); |
158 } | 158 } |
159 | 159 |
160 scoped_ptr<TimingFunction> EaseInOutTimingFunction::Create() { | 160 scoped_ptr<TimingFunction> EaseInOutTimingFunction::Create() { |
161 return CubicBezierTimingFunction::Create( | 161 return CubicBezierTimingFunction::Create( |
162 0.42, 0.0, 0.58, 1).PassAs<TimingFunction>(); | 162 0.42, 0.0, 0.58, 1).PassAs<TimingFunction>(); |
163 } | 163 } |
164 | 164 |
| 165 scoped_ptr<StepsTimingFunction> StepsTimingFunction::Create( |
| 166 int steps, bool stepsAtStart) { |
| 167 return make_scoped_ptr(new StepsTimingFunction(steps, stepsAtStart)); |
| 168 } |
| 169 |
| 170 StepsTimingFunction::StepsTimingFunction(int steps, |
| 171 bool stepsAtStart) |
| 172 : steps_(steps), stepsAtStart_(stepsAtStart) {} |
| 173 |
| 174 StepsTimingFunction::~StepsTimingFunction() {} |
| 175 |
| 176 float StepsTimingFunction::GetValue(double x) const { |
| 177 return std::min(1.0, (floor(steps_ * x) + stepsAtStart_) / steps_); |
| 178 } |
| 179 |
| 180 scoped_ptr<AnimationCurve> StepsTimingFunction::Clone() const { |
| 181 return make_scoped_ptr( |
| 182 new StepsTimingFunction(*this)).PassAs<AnimationCurve>(); |
| 183 } |
| 184 |
| 185 void StepsTimingFunction::Range(float* min, float* max) const { |
| 186 *min = static_cast<float>(stepsAtStart_) / static_cast<float>(steps_); |
| 187 *max = 1.0; |
| 188 } |
| 189 |
165 } // namespace cc | 190 } // namespace cc |
OLD | NEW |