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

Unified Diff: src/core/SkStroke.cpp

Issue 22947005: fine-tune tolerance for pinchy quads in stroker (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 4 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 | « gm/aaclip.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkStroke.cpp
diff --git a/src/core/SkStroke.cpp b/src/core/SkStroke.cpp
index d094ef65b72a49e2f5933bd974049feab623b47f..20372247330cdcf36e3286e3bc767e62578d451f 100644
--- a/src/core/SkStroke.cpp
+++ b/src/core/SkStroke.cpp
@@ -30,9 +30,18 @@ static inline bool normals_too_curvy(const SkVector& norm0, SkVector& norm1) {
}
static inline bool normals_too_pinchy(const SkVector& norm0, SkVector& norm1) {
- static const SkScalar kTooPinchyNormalDotProd = -SK_Scalar1 * 999 / 1000;
-
- return SkPoint::DotProduct(norm0, norm1) <= kTooPinchyNormalDotProd;
+ // if the dot-product is -1, then we are definitely too pinchy. We tweak
+ // that by an epsilon to ensure we have significant bits in our test
+ static const int kMinSigBitsForDot = 8;
+ static const SkScalar kDotEpsilon = FLT_EPSILON * (1 << kMinSigBitsForDot);
+ static const SkScalar kTooPinchyNormalDotProd = kDotEpsilon - 1;
+
+ // just some sanity asserts to help document the expected range
+ SkASSERT(kTooPinchyNormalDotProd >= -1);
+ SkASSERT(kTooPinchyNormalDotProd < SkDoubleToScalar(-0.999));
+
+ SkScalar dot = SkPoint::DotProduct(norm0, norm1);
+ return dot <= kTooPinchyNormalDotProd;
}
static bool set_normal_unitnormal(const SkPoint& before, const SkPoint& after,
« no previous file with comments | « gm/aaclip.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698