| 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 "SkFloatBits.h" | 7 #include "SkFloatBits.h" |
| 8 #include "SkOpCoincidence.h" | 8 #include "SkOpCoincidence.h" |
| 9 #include "SkPathOpsTypes.h" | 9 #include "SkPathOpsTypes.h" |
| 10 | 10 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 } | 153 } |
| 154 SkFloatIntUnion floatIntA, floatIntB; | 154 SkFloatIntUnion floatIntA, floatIntB; |
| 155 floatIntA.fFloat = a; | 155 floatIntA.fFloat = a; |
| 156 floatIntB.fFloat = b; | 156 floatIntB.fFloat = b; |
| 157 // Different signs means they do not match. | 157 // Different signs means they do not match. |
| 158 if ((floatIntA.fSignBitInt < 0) != (floatIntB.fSignBitInt < 0)) { | 158 if ((floatIntA.fSignBitInt < 0) != (floatIntB.fSignBitInt < 0)) { |
| 159 // Check for equality to make sure +0 == -0 | 159 // Check for equality to make sure +0 == -0 |
| 160 return a == b ? 0 : SK_MaxS32; | 160 return a == b ? 0 : SK_MaxS32; |
| 161 } | 161 } |
| 162 // Find the difference in ULPs. | 162 // Find the difference in ULPs. |
| 163 return abs(floatIntA.fSignBitInt - floatIntB.fSignBitInt); | 163 return SkTAbs(floatIntA.fSignBitInt - floatIntB.fSignBitInt); |
| 164 } | 164 } |
| 165 | 165 |
| 166 // cube root approximation using bit hack for 64-bit float | 166 // cube root approximation using bit hack for 64-bit float |
| 167 // adapted from Kahan's cbrt | 167 // adapted from Kahan's cbrt |
| 168 static double cbrt_5d(double d) { | 168 static double cbrt_5d(double d) { |
| 169 const unsigned int B1 = 715094163; | 169 const unsigned int B1 = 715094163; |
| 170 double t = 0.0; | 170 double t = 0.0; |
| 171 unsigned int* pt = (unsigned int*) &t; | 171 unsigned int* pt = (unsigned int*) &t; |
| 172 unsigned int* px = (unsigned int*) &d; | 172 unsigned int* px = (unsigned int*) &d; |
| 173 pt[1] = px[1] / 3 + B1; | 173 pt[1] = px[1] / 3 + B1; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 SkDEBUGPARAMS(fAngleID(0)) | 212 SkDEBUGPARAMS(fAngleID(0)) |
| 213 SkDEBUGPARAMS(fContourID(0)) | 213 SkDEBUGPARAMS(fContourID(0)) |
| 214 SkDEBUGPARAMS(fPtTID(0)) | 214 SkDEBUGPARAMS(fPtTID(0)) |
| 215 SkDEBUGPARAMS(fSegmentID(0)) | 215 SkDEBUGPARAMS(fSegmentID(0)) |
| 216 SkDEBUGPARAMS(fSpanID(0)) { | 216 SkDEBUGPARAMS(fSpanID(0)) { |
| 217 if (coincidence) { | 217 if (coincidence) { |
| 218 coincidence->debugSetGlobalState(this); | 218 coincidence->debugSetGlobalState(this); |
| 219 } | 219 } |
| 220 } | 220 } |
| 221 | 221 |
| OLD | NEW |