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 #include "SkIntersections.h" | 7 #include "SkIntersections.h" |
8 #include "SkLineParameters.h" | 8 #include "SkLineParameters.h" |
9 #include "SkPathOpsCubic.h" | 9 #include "SkPathOpsCubic.h" |
10 #include "SkPathOpsQuad.h" | 10 #include "SkPathOpsQuad.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 if (approximately_zero(A) && (approximately_zero_inverse(p) || approximately
_zero_inverse(q))) { | 115 if (approximately_zero(A) && (approximately_zero_inverse(p) || approximately
_zero_inverse(q))) { |
116 if (approximately_zero(B)) { | 116 if (approximately_zero(B)) { |
117 s[0] = 0; | 117 s[0] = 0; |
118 return C == 0; | 118 return C == 0; |
119 } | 119 } |
120 s[0] = -C / B; | 120 s[0] = -C / B; |
121 return 1; | 121 return 1; |
122 } | 122 } |
123 /* normal form: x^2 + px + q = 0 */ | 123 /* normal form: x^2 + px + q = 0 */ |
124 const double p2 = p * p; | 124 const double p2 = p * p; |
125 if (!AlmostEqualUlps(p2, q) && p2 < q) { | 125 if (!AlmostDequalUlps(p2, q) && p2 < q) { |
126 return 0; | 126 return 0; |
127 } | 127 } |
128 double sqrt_D = 0; | 128 double sqrt_D = 0; |
129 if (p2 > q) { | 129 if (p2 > q) { |
130 sqrt_D = sqrt(p2 - q); | 130 sqrt_D = sqrt(p2 - q); |
131 } | 131 } |
132 s[0] = sqrt_D - p; | 132 s[0] = sqrt_D - p; |
133 s[1] = -sqrt_D - p; | 133 s[1] = -sqrt_D - p; |
134 return 1 + !AlmostEqualUlps(s[0], s[1]); | 134 return 1 + !AlmostDequalUlps(s[0], s[1]); |
135 } | 135 } |
136 | 136 |
137 bool SkDQuad::isLinear(int startIndex, int endIndex) const { | 137 bool SkDQuad::isLinear(int startIndex, int endIndex) const { |
138 SkLineParameters lineParameters; | 138 SkLineParameters lineParameters; |
139 lineParameters.quadEndPoints(*this, startIndex, endIndex); | 139 lineParameters.quadEndPoints(*this, startIndex, endIndex); |
140 // FIXME: maybe it's possible to avoid this and compare non-normalized | 140 // FIXME: maybe it's possible to avoid this and compare non-normalized |
141 lineParameters.normalize(); | 141 lineParameters.normalize(); |
142 double distance = lineParameters.controlPtDistance(*this); | 142 double distance = lineParameters.controlPtDistance(*this); |
143 return approximately_zero(distance); | 143 return approximately_zero(distance); |
144 } | 144 } |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 SkDebugf("{{"); | 346 SkDebugf("{{"); |
347 int index = 0; | 347 int index = 0; |
348 do { | 348 do { |
349 fPts[index].dump(); | 349 fPts[index].dump(); |
350 SkDebugf(", "); | 350 SkDebugf(", "); |
351 } while (++index < 2); | 351 } while (++index < 2); |
352 fPts[index].dump(); | 352 fPts[index].dump(); |
353 SkDebugf("}}\n"); | 353 SkDebugf("}}\n"); |
354 } | 354 } |
355 #endif | 355 #endif |
OLD | NEW |