From 0a241ce808511ceb1c72d6f2473b01b455ac5101 Mon Sep 17 00:00:00 2001 From: Brian Salomon Date: Fri, 15 Dec 2017 11:31:05 -0500 Subject: 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 Commit-Queue: Brian Salomon --- tests/RoundRectTest.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests/RoundRectTest.cpp') 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; -- cgit v1.2.3