| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/gfx/geometry/cubic_bezier.h" | 5 #include "ui/gfx/geometry/cubic_bezier.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 if (0 < t1 && t1 < 1) | 125 if (0 < t1 && t1 < 1) |
| 126 sol1 = SampleCurveY(t1); | 126 sol1 = SampleCurveY(t1); |
| 127 | 127 |
| 128 if (0 < t2 && t2 < 1) | 128 if (0 < t2 && t2 < 1) |
| 129 sol2 = SampleCurveY(t2); | 129 sol2 = SampleCurveY(t2); |
| 130 | 130 |
| 131 range_min_ = std::min(std::min(range_min_, sol1), sol2); | 131 range_min_ = std::min(std::min(range_min_, sol1), sol2); |
| 132 range_max_ = std::max(std::max(range_max_, sol1), sol2); | 132 range_max_ = std::max(std::max(range_max_, sol1), sol2); |
| 133 } | 133 } |
| 134 | 134 |
| 135 double CubicBezier::GetDefaultEpsilon() { |
| 136 return kBezierEpsilon; |
| 137 } |
| 138 |
| 135 double CubicBezier::SolveCurveX(double x, double epsilon) const { | 139 double CubicBezier::SolveCurveX(double x, double epsilon) const { |
| 136 DCHECK_GE(x, 0.0); | 140 DCHECK_GE(x, 0.0); |
| 137 DCHECK_LE(x, 1.0); | 141 DCHECK_LE(x, 1.0); |
| 138 | 142 |
| 139 double t0; | 143 double t0; |
| 140 double t1; | 144 double t1; |
| 141 double t2; | 145 double t2; |
| 142 double x2; | 146 double x2; |
| 143 double d2; | 147 double d2; |
| 144 int i; | 148 int i; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 | 204 |
| 201 double CubicBezier::GetX2() const { | 205 double CubicBezier::GetX2() const { |
| 202 return (bx_ + cx_) / 3.0 + GetX1(); | 206 return (bx_ + cx_) / 3.0 + GetX1(); |
| 203 } | 207 } |
| 204 | 208 |
| 205 double CubicBezier::GetY2() const { | 209 double CubicBezier::GetY2() const { |
| 206 return (by_ + cy_) / 3.0 + GetY1(); | 210 return (by_ + cy_) / 3.0 + GetY1(); |
| 207 } | 211 } |
| 208 | 212 |
| 209 } // namespace gfx | 213 } // namespace gfx |
| OLD | NEW |