aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/GrShapeTest.cpp
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-12-20 13:28:55 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-12-20 18:47:36 +0000
commit2fad74a0fdc5eb3f505a052849c3cbeffa6e2d17 (patch)
tree6a3ec7975dc7ff37a6e8ccfe817fc3ccbd723b18 /tests/GrShapeTest.cpp
parent939e6719abb657096b5837d67d594256aa69da45 (diff)
Make GrRenderTargetContext::drawPath() use GrShape to identify simpler
geometries. Change-Id: I24230efc8bcb60f00c0c855090e3311ad13d7da8 Reviewed-on: https://skia-review.googlesource.com/85962 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
Diffstat (limited to 'tests/GrShapeTest.cpp')
-rw-r--r--tests/GrShapeTest.cpp32
1 files changed, 29 insertions, 3 deletions
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.