From 2fad74a0fdc5eb3f505a052849c3cbeffa6e2d17 Mon Sep 17 00:00:00 2001 From: Brian Salomon Date: Wed, 20 Dec 2017 13:28:55 -0500 Subject: Make GrRenderTargetContext::drawPath() use GrShape to identify simpler geometries. Change-Id: I24230efc8bcb60f00c0c855090e3311ad13d7da8 Reviewed-on: https://skia-review.googlesource.com/85962 Commit-Queue: Brian Salomon Reviewed-by: Brian Osman --- tests/GrShapeTest.cpp | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'tests/GrShapeTest.cpp') diff --git a/tests/GrShapeTest.cpp b/tests/GrShapeTest.cpp index 259026c8d0..826d0f864b 100644 --- a/tests/GrShapeTest.cpp +++ b/tests/GrShapeTest.cpp @@ -1490,6 +1490,8 @@ DEF_TEST(GrShape_empty_shape, reporter) { SkPaint stroke; stroke.setStrokeWidth(2.f); stroke.setStyle(SkPaint::kStroke_Style); + stroke.setStrokeJoin(SkPaint::kRound_Join); + stroke.setStrokeCap(SkPaint::kRound_Cap); TestCase strokeEmptyCase(reporter, emptyPath, stroke); strokeEmptyCase.compare(reporter, fillEmptyCase, TestCase::kAllSame_ComparisonExpecation); TestCase strokeInvertedEmptyCase(reporter, invertedEmptyPath, stroke); @@ -1509,25 +1511,49 @@ DEF_TEST(GrShape_empty_shape, reporter) { dashAndStrokeInvertexEmptyCase.compare(reporter, fillEmptyCase, TestCase::kAllSame_ComparisonExpecation); - // A shape made from an empty rrect should behave the same as an empty path. - SkRRect emptyRRect = SkRRect::MakeRect(SkRect::MakeEmpty()); + // A shape made from an empty rrect should behave the same as an empty path when filled but not + // when stroked. However, dashing an empty rrect produces an empty path leaving nothing to + // stroke - so equivalent to filling an empty path. + SkRRect emptyRRect = SkRRect::MakeEmpty(); REPORTER_ASSERT(reporter, emptyRRect.getType() == SkRRect::kEmpty_Type); + + TestCase fillEmptyRRectCase(reporter, emptyRRect, fill); + fillEmptyRRectCase.compare(reporter, fillEmptyCase, TestCase::kAllSame_ComparisonExpecation); + + TestCase strokeEmptyRRectCase(reporter, emptyRRect, stroke); + strokeEmptyRRectCase.compare(reporter, strokeEmptyCase, + TestCase::kAllDifferent_ComparisonExpecation); + TestCase dashAndStrokeEmptyRRectCase(reporter, emptyRRect, dashAndStroke); dashAndStrokeEmptyRRectCase.compare(reporter, fillEmptyCase, TestCase::kAllSame_ComparisonExpecation); + static constexpr SkPath::Direction kDir = SkPath::kCCW_Direction; static constexpr int kStart = 0; + + TestCase fillInvertedEmptyRRectCase(reporter, emptyRRect, kDir, kStart, true, GrStyle(fill)); + fillInvertedEmptyRRectCase.compare(reporter, fillInvertedEmptyCase, + TestCase::kAllSame_ComparisonExpecation); + + TestCase strokeInvertedEmptyRRectCase(reporter, emptyRRect, kDir, kStart, true, + GrStyle(stroke)); + strokeInvertedEmptyRRectCase.compare(reporter, strokeInvertedEmptyCase, + TestCase::kAllDifferent_ComparisonExpecation); + TestCase dashAndStrokeEmptyInvertedRRectCase(reporter, emptyRRect, kDir, kStart, true, GrStyle(dashAndStroke)); - // Dashing ignores inverseness so this is equivalent to the non-inverted empty fill. dashAndStrokeEmptyInvertedRRectCase.compare(reporter, fillEmptyCase, TestCase::kAllSame_ComparisonExpecation); // Same for a rect. SkRect emptyRect = SkRect::MakeEmpty(); + TestCase fillEmptyRectCase(reporter, emptyRect, fill); + fillEmptyRectCase.compare(reporter, fillEmptyCase, TestCase::kAllSame_ComparisonExpecation); + TestCase dashAndStrokeEmptyRectCase(reporter, emptyRect, dashAndStroke); dashAndStrokeEmptyRectCase.compare(reporter, fillEmptyCase, TestCase::kAllSame_ComparisonExpecation); + TestCase dashAndStrokeEmptyInvertedRectCase(reporter, SkRRect::MakeRect(emptyRect), kDir, kStart, true, GrStyle(dashAndStroke)); // Dashing ignores inverseness so this is equivalent to the non-inverted empty fill. -- cgit v1.2.3