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 "base/logging.h" | 5 #include "base/logging.h" |
6 #include "cc/animation/timing_function.h" | 6 #include "cc/animation/timing_function.h" |
7 | 7 |
8 namespace cc { | 8 namespace cc { |
9 | 9 |
10 TimingFunction::TimingFunction() {} | 10 TimingFunction::TimingFunction() {} |
(...skipping 27 matching lines...) Expand all Loading... |
38 } | 38 } |
39 | 39 |
40 void CubicBezierTimingFunction::Range(float* min, float* max) const { | 40 void CubicBezierTimingFunction::Range(float* min, float* max) const { |
41 double min_d = 0; | 41 double min_d = 0; |
42 double max_d = 1; | 42 double max_d = 1; |
43 bezier_.Range(&min_d, &max_d); | 43 bezier_.Range(&min_d, &max_d); |
44 *min = static_cast<float>(min_d); | 44 *min = static_cast<float>(min_d); |
45 *max = static_cast<float>(max_d); | 45 *max = static_cast<float>(max_d); |
46 } | 46 } |
47 | 47 |
| 48 float CubicBezierTimingFunction::Velocity(double x) const { |
| 49 return static_cast<float>(bezier_.Slope(x)); |
| 50 } |
| 51 |
48 // These numbers come from | 52 // These numbers come from |
49 // http://www.w3.org/TR/css3-transitions/#transition-timing-function_tag. | 53 // http://www.w3.org/TR/css3-transitions/#transition-timing-function_tag. |
50 scoped_ptr<TimingFunction> EaseTimingFunction::Create() { | 54 scoped_ptr<TimingFunction> EaseTimingFunction::Create() { |
51 return CubicBezierTimingFunction::Create( | 55 return CubicBezierTimingFunction::Create( |
52 0.25, 0.1, 0.25, 1.0).PassAs<TimingFunction>(); | 56 0.25, 0.1, 0.25, 1.0).PassAs<TimingFunction>(); |
53 } | 57 } |
54 | 58 |
55 scoped_ptr<TimingFunction> EaseInTimingFunction::Create() { | 59 scoped_ptr<TimingFunction> EaseInTimingFunction::Create() { |
56 return CubicBezierTimingFunction::Create( | 60 return CubicBezierTimingFunction::Create( |
57 0.42, 0.0, 1.0, 1.0).PassAs<TimingFunction>(); | 61 0.42, 0.0, 1.0, 1.0).PassAs<TimingFunction>(); |
58 } | 62 } |
59 | 63 |
60 scoped_ptr<TimingFunction> EaseOutTimingFunction::Create() { | 64 scoped_ptr<TimingFunction> EaseOutTimingFunction::Create() { |
61 return CubicBezierTimingFunction::Create( | 65 return CubicBezierTimingFunction::Create( |
62 0.0, 0.0, 0.58, 1.0).PassAs<TimingFunction>(); | 66 0.0, 0.0, 0.58, 1.0).PassAs<TimingFunction>(); |
63 } | 67 } |
64 | 68 |
65 scoped_ptr<TimingFunction> EaseInOutTimingFunction::Create() { | 69 scoped_ptr<TimingFunction> EaseInOutTimingFunction::Create() { |
66 return CubicBezierTimingFunction::Create( | 70 return CubicBezierTimingFunction::Create( |
67 0.42, 0.0, 0.58, 1).PassAs<TimingFunction>(); | 71 0.42, 0.0, 0.58, 1).PassAs<TimingFunction>(); |
68 } | 72 } |
69 | 73 |
70 } // namespace cc | 74 } // namespace cc |
OLD | NEW |