diff options
author | Brian Salomon <bsalomon@google.com> | 2017-12-15 11:31:05 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-12-19 21:10:36 +0000 |
commit | 0a241ce808511ceb1c72d6f2473b01b455ac5101 (patch) | |
tree | c137018f24c515dde2d85d4eb6d3f0b7ed0081a7 /tests | |
parent | ab10c8258d7588bb9c353a8ecc1944747a4fac62 (diff) |
Don't canonicalize empty SkRRects. They stroke differently.
Make insetting greater than width or height collapse to a point/line.
SkPath::addRRect() doesn't ignore an empty SkRRect.
Change-Id: I933a3419a6d75be534f1d8328faa715772045f67
Reviewed-on: https://skia-review.googlesource.com/85680
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/PathTest.cpp | 5 | ||||
-rw-r--r-- | tests/RoundRectTest.cpp | 15 |
2 files changed, 19 insertions, 1 deletions
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp index 88ca3f8f05..4bb8c88ae1 100644 --- a/tests/PathTest.cpp +++ b/tests/PathTest.cpp @@ -3662,7 +3662,10 @@ static void test_rrect(skiatest::Reporter* reporter) { SkRect emptyR = {10, 20, 10, 30}; rr.setRectRadii(emptyR, radii); p.addRRect(rr); - REPORTER_ASSERT(reporter, p.isEmpty()); + // The round rect is "empty" in that it has no fill area. However, + // the path isn't "empty" in that it should have verbs and points. + REPORTER_ASSERT(reporter, !p.isEmpty()); + p.reset(); SkRect largeR = {0, 0, SK_ScalarMax, SK_ScalarMax}; rr.setRectRadii(largeR, radii); p.addRRect(rr); diff --git a/tests/RoundRectTest.cpp b/tests/RoundRectTest.cpp index 43a51430ab..a32e347b6f 100644 --- a/tests/RoundRectTest.cpp +++ b/tests/RoundRectTest.cpp @@ -71,36 +71,51 @@ static void test_empty(skiatest::Reporter* reporter) { for (size_t i = 0; i < SK_ARRAY_COUNT(oooRects); ++i) { r.setRect(oooRects[i]); REPORTER_ASSERT(reporter, !r.isEmpty()); + REPORTER_ASSERT(reporter, r.rect() == oooRects[i].makeSorted()); r.setOval(oooRects[i]); REPORTER_ASSERT(reporter, !r.isEmpty()); + REPORTER_ASSERT(reporter, r.rect() == oooRects[i].makeSorted()); r.setRectXY(oooRects[i], 1, 2); REPORTER_ASSERT(reporter, !r.isEmpty()); + REPORTER_ASSERT(reporter, r.rect() == oooRects[i].makeSorted()); r.setNinePatch(oooRects[i], 0, 1, 2, 3); REPORTER_ASSERT(reporter, !r.isEmpty()); + REPORTER_ASSERT(reporter, r.rect() == oooRects[i].makeSorted()); r.setRectRadii(oooRects[i], radii); REPORTER_ASSERT(reporter, !r.isEmpty()); + REPORTER_ASSERT(reporter, r.rect() == oooRects[i].makeSorted()); } for (size_t i = 0; i < SK_ARRAY_COUNT(emptyRects); ++i) { r.setRect(emptyRects[i]); REPORTER_ASSERT(reporter, r.isEmpty()); + REPORTER_ASSERT(reporter, r.rect() == emptyRects[i]); r.setOval(emptyRects[i]); REPORTER_ASSERT(reporter, r.isEmpty()); + REPORTER_ASSERT(reporter, r.rect() == emptyRects[i]); r.setRectXY(emptyRects[i], 1, 2); REPORTER_ASSERT(reporter, r.isEmpty()); + REPORTER_ASSERT(reporter, r.rect() == emptyRects[i]); r.setNinePatch(emptyRects[i], 0, 1, 2, 3); REPORTER_ASSERT(reporter, r.isEmpty()); + REPORTER_ASSERT(reporter, r.rect() == emptyRects[i]); r.setRectRadii(emptyRects[i], radii); REPORTER_ASSERT(reporter, r.isEmpty()); + REPORTER_ASSERT(reporter, r.rect() == emptyRects[i]); } + + r.setRect({SK_ScalarNaN, 10, 10, 20}); + REPORTER_ASSERT(reporter, r == SkRRect::MakeEmpty()); + r.setRect({0, 10, 10, SK_ScalarInfinity}); + REPORTER_ASSERT(reporter, r == SkRRect::MakeEmpty()); } static const SkScalar kWidth = 100.0f; |