| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 89 |
| 90 void operator-=(const SkDVector& v) { | 90 void operator-=(const SkDVector& v) { |
| 91 fX -= v.fX; | 91 fX -= v.fX; |
| 92 fY -= v.fY; | 92 fY -= v.fY; |
| 93 } | 93 } |
| 94 | 94 |
| 95 // note: this can not be implemented with | 95 // note: this can not be implemented with |
| 96 // return approximately_equal(a.fY, fY) && approximately_equal(a.fX, fX); | 96 // return approximately_equal(a.fY, fY) && approximately_equal(a.fX, fX); |
| 97 // because that will not take the magnitude of the values | 97 // because that will not take the magnitude of the values |
| 98 bool approximatelyEqual(const SkDPoint& a) const { | 98 bool approximatelyEqual(const SkDPoint& a) const { |
| 99 double denom = SkTMax<double>(fabs(fX), SkTMax<double>(fabs(fY), | 99 double denom = SkTMax(fabs(fX), SkTMax(fabs(fY), |
| 100 SkTMax<double>(fabs(a.fX), fabs(a.fY)))); | 100 SkTMax(fabs(a.fX), fabs(a.fY)))); |
| 101 if (denom == 0) { | 101 if (denom == 0) { |
| 102 return true; | 102 return true; |
| 103 } | 103 } |
| 104 double inv = 1 / denom; | 104 double inv = 1 / denom; |
| 105 return approximately_equal(fX * inv, a.fX * inv) | 105 return approximately_equal(fX * inv, a.fX * inv) |
| 106 && approximately_equal(fY * inv, a.fY * inv); | 106 && approximately_equal(fY * inv, a.fY * inv); |
| 107 } | 107 } |
| 108 | 108 |
| 109 bool approximatelyEqual(const SkPoint& a) const { | 109 bool approximatelyEqual(const SkPoint& a) const { |
| 110 double denom = SkTMax<double>(fabs(fX), SkTMax<double>(fabs(fY), | 110 double denom = SkTMax(fabs(fX), SkTMax(fabs(fY), |
| 111 SkScalarToDouble(SkTMax<SkScalar>(fabsf(a.fX), fabsf(a.fY))))); | 111 SkScalarToDouble(SkTMax(fabsf(a.fX), fabsf(a.fY))))); |
| 112 if (denom == 0) { | 112 if (denom == 0) { |
| 113 return true; | 113 return true; |
| 114 } | 114 } |
| 115 double inv = 1 / denom; | 115 double inv = 1 / denom; |
| 116 return approximately_equal(fX * inv, a.fX * inv) | 116 return approximately_equal(fX * inv, a.fX * inv) |
| 117 && approximately_equal(fY * inv, a.fY * inv); | 117 && approximately_equal(fY * inv, a.fY * inv); |
| 118 } | 118 } |
| 119 | 119 |
| 120 bool approximatelyEqualHalf(const SkDPoint& a) const { | 120 bool approximatelyEqualHalf(const SkDPoint& a) const { |
| 121 double denom = SkTMax<double>(fabs(fX), SkTMax<double>(fabs(fY), | 121 double denom = SkTMax(fabs(fX), SkTMax(fabs(fY), |
| 122 SkTMax<double>(fabs(a.fX), fabs(a.fY)))); | 122 SkTMax(fabs(a.fX), fabs(a.fY)))); |
| 123 if (denom == 0) { | 123 if (denom == 0) { |
| 124 return true; | 124 return true; |
| 125 } | 125 } |
| 126 double inv = 1 / denom; | 126 double inv = 1 / denom; |
| 127 return approximately_equal_half(fX * inv, a.fX * inv) | 127 return approximately_equal_half(fX * inv, a.fX * inv) |
| 128 && approximately_equal_half(fY * inv, a.fY * inv); | 128 && approximately_equal_half(fY * inv, a.fY * inv); |
| 129 } | 129 } |
| 130 | 130 |
| 131 bool approximatelyZero() const { | 131 bool approximatelyZero() const { |
| 132 return approximately_zero(fX) && approximately_zero(fY); | 132 return approximately_zero(fX) && approximately_zero(fY); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 150 double moreRoughlyEqual(const SkDPoint& a) const { | 150 double moreRoughlyEqual(const SkDPoint& a) const { |
| 151 return more_roughly_equal(a.fY, fY) && more_roughly_equal(a.fX, fX); | 151 return more_roughly_equal(a.fY, fY) && more_roughly_equal(a.fX, fX); |
| 152 } | 152 } |
| 153 | 153 |
| 154 double roughlyEqual(const SkDPoint& a) const { | 154 double roughlyEqual(const SkDPoint& a) const { |
| 155 return roughly_equal(a.fY, fY) && roughly_equal(a.fX, fX); | 155 return roughly_equal(a.fY, fY) && roughly_equal(a.fX, fX); |
| 156 } | 156 } |
| 157 }; | 157 }; |
| 158 | 158 |
| 159 #endif | 159 #endif |
| OLD | NEW |