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

Unified Diff: src/pathops/SkPathOpsTypes.cpp

Issue 18058007: path ops work in progress (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: try try again 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') | src/pathops/SkReduceOrder.h » ('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 b071ca537157266c9ec67641985ccb0d2514e089..999e1b215d1500279043e51756dd2d062185cef2 100644
--- a/src/pathops/SkPathOpsTypes.cpp
+++ b/src/pathops/SkPathOpsTypes.cpp
@@ -7,11 +7,11 @@
#include "SkFloatBits.h"
#include "SkPathOpsTypes.h"
-const int UlpsEpsilon = 16;
+
// from http://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
// FIXME: move to SkFloatBits.h
-bool AlmostEqualUlps(float A, float B) {
+static bool equal_ulps(float A, float B, int epsilon) {
SkFloatIntUnion floatIntA, floatIntB;
floatIntA.fFloat = A;
floatIntB.fFloat = B;
@@ -23,7 +23,17 @@ bool AlmostEqualUlps(float A, float B) {
}
// Find the difference in ULPs.
int ulpsDiff = abs(floatIntA.fSignBitInt - floatIntB.fSignBitInt);
- return ulpsDiff <= UlpsEpsilon;
+ return ulpsDiff <= epsilon;
+}
+
+bool AlmostEqualUlps(float A, float B) {
+ const int UlpsEpsilon = 16;
+ return equal_ulps(A, B, UlpsEpsilon);
+}
+
+bool RoughlyEqualUlps(float A, float B) {
+ const int UlpsEpsilon = 256;
+ return equal_ulps(A, B, UlpsEpsilon);
}
// cube root approximation using bit hack for 64-bit float
« no previous file with comments | « src/pathops/SkPathOpsTypes.h ('k') | src/pathops/SkReduceOrder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698