| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 #ifndef SkPathOpsPoint_DEFINED | 7 #ifndef SkPathOpsPoint_DEFINED |
| 8 #define SkPathOpsPoint_DEFINED | 8 #define SkPathOpsPoint_DEFINED |
| 9 | 9 |
| 10 #include "SkPathOpsTypes.h" | 10 #include "SkPathOpsTypes.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 fX -= v.fX; | 95 fX -= v.fX; |
| 96 fY -= v.fY; | 96 fY -= v.fY; |
| 97 } | 97 } |
| 98 | 98 |
| 99 // note: this can not be implemented with | 99 // note: this can not be implemented with |
| 100 // return approximately_equal(a.fY, fY) && approximately_equal(a.fX, fX); | 100 // return approximately_equal(a.fY, fY) && approximately_equal(a.fX, fX); |
| 101 // because that will not take the magnitude of the values | 101 // because that will not take the magnitude of the values |
| 102 bool approximatelyEqual(const SkDPoint& a) const { | 102 bool approximatelyEqual(const SkDPoint& a) const { |
| 103 double denom = SkTMax(fabs(fX), SkTMax(fabs(fY), | 103 double denom = SkTMax(fabs(fX), SkTMax(fabs(fY), |
| 104 SkTMax(fabs(a.fX), fabs(a.fY)))); | 104 SkTMax(fabs(a.fX), fabs(a.fY)))); |
| 105 if (denom == 0) { | 105 if (precisely_zero(denom)) { |
| 106 return true; | 106 return true; |
| 107 } | 107 } |
| 108 double inv = 1 / denom; | 108 double inv = 1 / denom; |
| 109 return approximately_equal(fX * inv, a.fX * inv) | 109 return approximately_equal(fX * inv, a.fX * inv) |
| 110 && approximately_equal(fY * inv, a.fY * inv); | 110 && approximately_equal(fY * inv, a.fY * inv); |
| 111 } | 111 } |
| 112 | 112 |
| 113 bool approximatelyEqual(const SkPoint& a) const { | 113 bool approximatelyEqual(const SkPoint& a) const { |
| 114 return AlmostEqualUlps(SkDoubleToScalar(fX), a.fX) | 114 return AlmostEqualUlps(SkDoubleToScalar(fX), a.fX) |
| 115 && AlmostEqualUlps(SkDoubleToScalar(fY), a.fY); | 115 && AlmostEqualUlps(SkDoubleToScalar(fY), a.fY); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 double moreRoughlyEqual(const SkDPoint& a) const { | 155 double moreRoughlyEqual(const SkDPoint& a) const { |
| 156 return more_roughly_equal(a.fY, fY) && more_roughly_equal(a.fX, fX); | 156 return more_roughly_equal(a.fY, fY) && more_roughly_equal(a.fX, fX); |
| 157 } | 157 } |
| 158 | 158 |
| 159 double roughlyEqual(const SkDPoint& a) const { | 159 double roughlyEqual(const SkDPoint& a) const { |
| 160 return roughly_equal(a.fY, fY) && roughly_equal(a.fX, fX); | 160 return roughly_equal(a.fY, fY) && roughly_equal(a.fX, fX); |
| 161 } | 161 } |
| 162 }; | 162 }; |
| 163 | 163 |
| 164 #endif | 164 #endif |
| OLD | NEW |