Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(814)

Unified Diff: src/pathops/SkPathOpsTypes.cpp

Issue 19543005: turn off debugging printfs (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: remove unused code Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pathops/SkPathOpsTypes.h ('k') | tests/PathOpsAngleTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pathops/SkPathOpsTypes.cpp
diff --git a/src/pathops/SkPathOpsTypes.cpp b/src/pathops/SkPathOpsTypes.cpp
index a076d155f2ffeda23e596d2c82188a6150b383bf..8135c57025757fa0b2f2d815a052b39e53b5e7e5 100644
--- a/src/pathops/SkPathOpsTypes.cpp
+++ b/src/pathops/SkPathOpsTypes.cpp
@@ -11,40 +11,40 @@
// from http://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
// FIXME: move to SkFloatBits.h
-static bool equal_ulps(float A, float B, int epsilon) {
+static bool equal_ulps(float a, float b, int epsilon) {
SkFloatIntUnion floatIntA, floatIntB;
- floatIntA.fFloat = A;
- floatIntB.fFloat = B;
+ floatIntA.fFloat = a;
+ floatIntB.fFloat = b;
// Different signs means they do not match.
if ((floatIntA.fSignBitInt < 0) != (floatIntB.fSignBitInt < 0)) {
// Check for equality to make sure +0 == -0
- return A == B;
+ return a == b;
}
// Find the difference in ULPs.
int ulpsDiff = abs(floatIntA.fSignBitInt - floatIntB.fSignBitInt);
return ulpsDiff <= epsilon;
}
-static bool less_ulps(float A, float B, int epsilon) {
+static bool less_ulps(float a, float b, int epsilon) {
SkFloatIntUnion floatIntA, floatIntB;
- floatIntA.fFloat = A;
- floatIntB.fFloat = B;
+ floatIntA.fFloat = a;
+ floatIntB.fFloat = b;
// Check different signs with float epsilon since we only care if they're both close to 0.
if ((floatIntA.fSignBitInt < 0) != (floatIntB.fSignBitInt < 0)) {
- return A <= B + FLT_EPSILON * epsilon;
+ return a <= b + FLT_EPSILON * epsilon;
}
// Find the difference in ULPs.
return floatIntA.fSignBitInt <= floatIntB.fSignBitInt + epsilon;
}
-bool AlmostEqualUlps(float A, float B) {
+bool AlmostEqualUlps(float a, float b) {
const int UlpsEpsilon = 16;
- return equal_ulps(A, B, UlpsEpsilon);
+ return equal_ulps(a, b, UlpsEpsilon);
}
-bool RoughlyEqualUlps(float A, float B) {
+bool RoughlyEqualUlps(float a, float b) {
const int UlpsEpsilon = 256;
- return equal_ulps(A, B, UlpsEpsilon);
+ return equal_ulps(a, b, UlpsEpsilon);
}
bool AlmostBetweenUlps(float a, float b, float c) {
@@ -53,6 +53,19 @@ bool AlmostBetweenUlps(float a, float b, float c) {
: less_ulps(b, a, UlpsEpsilon) && less_ulps(c, b, UlpsEpsilon);
}
+int UlpsDistance(float a, float b) {
+ SkFloatIntUnion floatIntA, floatIntB;
+ floatIntA.fFloat = a;
+ floatIntB.fFloat = b;
+ // Different signs means they do not match.
+ if ((floatIntA.fSignBitInt < 0) != (floatIntB.fSignBitInt < 0)) {
+ // Check for equality to make sure +0 == -0
+ return a == b ? 0 : SK_MaxS32;
+ }
+ // Find the difference in ULPs.
+ return abs(floatIntA.fSignBitInt - floatIntB.fSignBitInt);
+}
+
// cube root approximation using bit hack for 64-bit float
// adapted from Kahan's cbrt
static double cbrt_5d(double d) {
« no previous file with comments | « src/pathops/SkPathOpsTypes.h ('k') | tests/PathOpsAngleTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698