diff options
author | csmartdalton <csmartdalton@google.com> | 2017-03-08 16:10:45 -0700 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-03-09 17:13:42 +0000 |
commit | 6e93584e840fc769e804170aadf64177760ab569 (patch) | |
tree | 8cb5507ae043fa901940c2d09127b783aa6a9496 /src/core/SkGeometry.cpp | |
parent | fe71b9dd69232896cb66b7dd5084bd9a27cdeee2 (diff) |
Add tolerance to quadratic and linear cubic detection
Otherwise these can be misclassified as cusps since there is already
tolerance in the discriminant test.
BUG=skia:
Change-Id: Id02c12f671714cebf799953ebed5335ee4c4d52a
Reviewed-on: https://skia-review.googlesource.com/9355
Reviewed-by: Cary Clark <caryclark@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Diffstat (limited to 'src/core/SkGeometry.cpp')
-rw-r--r-- | src/core/SkGeometry.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/core/SkGeometry.cpp b/src/core/SkGeometry.cpp index 175ea50d8a..c2e9b60fb8 100644 --- a/src/core/SkGeometry.cpp +++ b/src/core/SkGeometry.cpp @@ -550,8 +550,9 @@ static SkCubicType classify_cubic(const SkPoint p[4], const SkScalar d[3]) { } else if (discr < -SK_ScalarNearlyZero) { return kLoop_SkCubicType; } else { - if (0.f == d[0] && 0.f == d[1]) { - return (0.f == d[2] ? kLine_SkCubicType : kQuadratic_SkCubicType); + if (SkScalarAbs(d[0]) < SK_ScalarNearlyZero && SkScalarAbs(d[1]) < SK_ScalarNearlyZero) { + return ((SkScalarAbs(d[2]) < SK_ScalarNearlyZero) ? kLine_SkCubicType + : kQuadratic_SkCubicType); } else { return kCusp_SkCubicType; } |