diff options
author | epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-04-11 17:51:01 +0000 |
---|---|---|
committer | epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-04-11 17:51:01 +0000 |
commit | 94fa43c6255906660c2ff001fb462b6492cbdc07 (patch) | |
tree | 8a4a97ee3a4de91be4abb35d716481dc456884fe /include/core/SkPoint.h | |
parent | 1647a1955fa44654102ae36df7af683bb8874175 (diff) |
Fix SkPathStroker::lineTo() for line with length SK_ScalarNearlyZero
Review URL: https://codereview.appspot.com/5992077
git-svn-id: http://skia.googlecode.com/svn/trunk@3650 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core/SkPoint.h')
-rw-r--r-- | include/core/SkPoint.h | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/include/core/SkPoint.h b/include/core/SkPoint.h index d371e648bb..4570e25613 100644 --- a/include/core/SkPoint.h +++ b/include/core/SkPoint.h @@ -315,11 +315,29 @@ struct SK_API SkPoint { return a.fX != b.fX || a.fY != b.fY; } - /** Return true if this and the given point are componentwise within tol. + /** Return true if this point and the given point are far enough apart + such that a vector between them would be non-degenerate. + + WARNING: Unlike the deprecated version of equalsWithinTolerance(), + this method does not use componentwise comparison. Instead, it + uses a comparison designed to match judgments elsewhere regarding + degeneracy ("points A and B are so close that the vector between them + is essentially zero"). + */ + bool equalsWithinTolerance(const SkPoint& p) const { + return !CanNormalize(fX - p.fX, fY - p.fY); + } + + /** DEPRECATED: Return true if this and the given point are componentwise + within tolerance "tol". + + WARNING: There is no guarantee that the result will reflect judgments + elsewhere regarding degeneracy ("points A and B are so close that the + vector between them is essentially zero"). */ - bool equalsWithinTolerance(const SkPoint& v, SkScalar tol) const { - return SkScalarNearlyZero(fX - v.fX, tol) - && SkScalarNearlyZero(fY - v.fY, tol); + bool equalsWithinTolerance(const SkPoint& p, SkScalar tol) const { + return SkScalarNearlyZero(fX - p.fX, tol) + && SkScalarNearlyZero(fY - p.fY, tol); } /** Returns a new point whose coordinates are the difference between |