diff options
author | Robert Phillips <robertphillips@google.com> | 2018-02-05 09:15:20 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-02-05 14:44:46 +0000 |
commit | d587ebe9ea6e06c45b69c71ee1fa32ef6b86296a (patch) | |
tree | d3945da1c2238af8c54276fdd513efb7020cec7f | |
parent | e8fabb2665d12ee289bc3af5b7e93c5b12396e2d (diff) |
Remove assert from SkStroke.cpp
If we can't trust the contains tests on the bounding boxes we're already in a bad place.
With this change we'll somewhat arbitrarily get one of the two contours but, hopefully,
given the degeneracy of the geometry it won't matter which one dominates.
BUG=skia:6491
Change-Id: Id6f92f9331dc04a2555267781b07e5218345ef1b
Reviewed-on: https://skia-review.googlesource.com/103460
Reviewed-by: Cary Clark <caryclark@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
-rw-r--r-- | src/core/SkStroke.cpp | 5 | ||||
-rw-r--r-- | tests/StrokeTest.cpp | 20 |
2 files changed, 23 insertions, 2 deletions
diff --git a/src/core/SkStroke.cpp b/src/core/SkStroke.cpp index ab8df833c1..4568dc1610 100644 --- a/src/core/SkStroke.cpp +++ b/src/core/SkStroke.cpp @@ -299,8 +299,9 @@ void SkPathStroker::finishContour(bool close, bool currIsLine) { fOuter.close(); if (fCanIgnoreCenter) { - if (!fOuter.getBounds().contains(fInner.getBounds())) { - SkASSERT(fInner.getBounds().contains(fOuter.getBounds())); + // If we can ignore the center just make sure the larger of the two paths + // is preserved and don't add the smaller one. + if (fInner.getBounds().contains(fOuter.getBounds())) { fInner.swap(fOuter); } } else { diff --git a/tests/StrokeTest.cpp b/tests/StrokeTest.cpp index 43b293fc12..2feaea0ec3 100644 --- a/tests/StrokeTest.cpp +++ b/tests/StrokeTest.cpp @@ -160,8 +160,28 @@ static void test_strokerec_equality(skiatest::Reporter* reporter) { } } +// From skbug.com/6491. The large stroke width can cause numerical instabilities. +static void test_big_stroke(skiatest::Reporter* reporter) { + SkPaint paint; + paint.setStyle(SkPaint::kStrokeAndFill_Style); + paint.setStrokeWidth(1.49679073e+10f); + + SkPath path; + path.setFillType(SkPath::kWinding_FillType); + path.moveTo(SkBits2Float(0x46380000), SkBits2Float(0xc6380000)); // 11776, -11776 + path.lineTo(SkBits2Float(0x46a00000), SkBits2Float(0xc6a00000)); // 20480, -20480 + path.lineTo(SkBits2Float(0x468c0000), SkBits2Float(0xc68c0000)); // 17920, -17920 + path.lineTo(SkBits2Float(0x46100000), SkBits2Float(0xc6100000)); // 9216, -9216 + path.lineTo(SkBits2Float(0x46380000), SkBits2Float(0xc6380000)); // 11776, -11776 + path.close(); + + SkPath strokeAndFillPath; + paint.getFillPath(path, &strokeAndFillPath); +} + DEF_TEST(Stroke, reporter) { test_strokecubic(reporter); test_strokerect(reporter); test_strokerec_equality(reporter); + test_big_stroke(reporter); } |