diff options
author | Brian Salomon <bsalomon@google.com> | 2017-12-21 11:56:42 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-12-21 22:45:15 +0000 |
commit | 72f78c37010eb2bf20be4884d4f376d122830dfd (patch) | |
tree | 3ff52aa1e3f3bc8776e85f9c64f4c371772b336b /tests/GrShapeTest.cpp | |
parent | 6925fc0429424cae67a887e6faa27f168995612a (diff) |
Make GrShape recognize horizontal/vertical dashed lines with 0 off intervals as rrects.
Change-Id: Ic29b41911e0185d36093d5352f4494709e8124ba
Reviewed-on: https://skia-review.googlesource.com/88428
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'tests/GrShapeTest.cpp')
-rw-r--r-- | tests/GrShapeTest.cpp | 134 |
1 files changed, 74 insertions, 60 deletions
diff --git a/tests/GrShapeTest.cpp b/tests/GrShapeTest.cpp index 826d0f864b..2b80a84d63 100644 --- a/tests/GrShapeTest.cpp +++ b/tests/GrShapeTest.cpp @@ -1934,66 +1934,80 @@ DEF_TEST(GrShape_lines, r) { } DEF_TEST(GrShape_stroked_lines, r) { - // Paints to try - SkPaint buttCap; - buttCap.setStyle(SkPaint::kStroke_Style); - buttCap.setStrokeWidth(4); - buttCap.setStrokeCap(SkPaint::kButt_Cap); - - SkPaint squareCap = buttCap; - squareCap.setStrokeCap(SkPaint::kSquare_Cap); - - SkPaint roundCap = buttCap; - roundCap.setStrokeCap(SkPaint::kRound_Cap); - - // vertical - SkPath linePath; - linePath.moveTo(4, 4); - linePath.lineTo(4, 5); - - SkPaint fill; - - make_TestCase(r, linePath, buttCap)->compare( - r, TestCase(r, SkRect::MakeLTRB(2, 4, 6, 5), fill), - TestCase::kAllSame_ComparisonExpecation); - - make_TestCase(r, linePath, squareCap)->compare( - r, TestCase(r, SkRect::MakeLTRB(2, 2, 6, 7), fill), - TestCase::kAllSame_ComparisonExpecation); - - make_TestCase(r, linePath, roundCap)->compare(r, - TestCase(r, SkRRect::MakeRectXY(SkRect::MakeLTRB(2, 2, 6, 7), 2, 2), fill), - TestCase::kAllSame_ComparisonExpecation); - - // horizontal - linePath.reset(); - linePath.moveTo(4, 4); - linePath.lineTo(5, 4); - - make_TestCase(r, linePath, buttCap)->compare( - r, TestCase(r, SkRect::MakeLTRB(4, 2, 5, 6), fill), - TestCase::kAllSame_ComparisonExpecation); - make_TestCase(r, linePath, squareCap)->compare( - r, TestCase(r, SkRect::MakeLTRB(2, 2, 7, 6), fill), - TestCase::kAllSame_ComparisonExpecation); - make_TestCase(r, linePath, roundCap)->compare( - r, TestCase(r, SkRRect::MakeRectXY(SkRect::MakeLTRB(2, 2, 7, 6), 2, 2), fill), - TestCase::kAllSame_ComparisonExpecation); - - // point - linePath.reset(); - linePath.moveTo(4, 4); - linePath.lineTo(4, 4); - - make_TestCase(r, linePath, buttCap)->compare( - r, TestCase(r, SkRect::MakeEmpty(), fill), - TestCase::kAllSame_ComparisonExpecation); - make_TestCase(r, linePath, squareCap)->compare( - r, TestCase(r, SkRect::MakeLTRB(2, 2, 6, 6), fill), - TestCase::kAllSame_ComparisonExpecation); - make_TestCase(r, linePath, roundCap)->compare( - r, TestCase(r, SkRRect::MakeRectXY(SkRect::MakeLTRB(2, 2, 6, 6), 2, 2), fill), - TestCase::kAllSame_ComparisonExpecation); + static constexpr SkScalar kIntervals1[] = {1.f, 0.f}; + auto dash1 = SkDashPathEffect::Make(kIntervals1, SK_ARRAY_COUNT(kIntervals1), 0.f); + REPORTER_ASSERT(r, dash1); + static constexpr SkScalar kIntervals2[] = {10.f, 0.f, 5.f, 0.f}; + auto dash2 = SkDashPathEffect::Make(kIntervals2, SK_ARRAY_COUNT(kIntervals2), 10.f); + REPORTER_ASSERT(r, dash2); + + sk_sp<SkPathEffect> pathEffects[] = {nullptr, std::move(dash1), std::move(dash2)}; + + for (const auto& pe : pathEffects) { + // Paints to try + SkPaint buttCap; + buttCap.setStyle(SkPaint::kStroke_Style); + buttCap.setStrokeWidth(4); + buttCap.setStrokeCap(SkPaint::kButt_Cap); + buttCap.setPathEffect(pe); + + SkPaint squareCap = buttCap; + squareCap.setStrokeCap(SkPaint::kSquare_Cap); + squareCap.setPathEffect(pe); + + SkPaint roundCap = buttCap; + roundCap.setStrokeCap(SkPaint::kRound_Cap); + roundCap.setPathEffect(pe); + + // vertical + SkPath linePath; + linePath.moveTo(4, 4); + linePath.lineTo(4, 5); + + SkPaint fill; + + make_TestCase(r, linePath, buttCap)->compare( + r, TestCase(r, SkRect::MakeLTRB(2, 4, 6, 5), fill), + TestCase::kAllSame_ComparisonExpecation); + + make_TestCase(r, linePath, squareCap)->compare( + r, TestCase(r, SkRect::MakeLTRB(2, 2, 6, 7), fill), + TestCase::kAllSame_ComparisonExpecation); + + make_TestCase(r, linePath, roundCap)->compare(r, + TestCase(r, SkRRect::MakeRectXY(SkRect::MakeLTRB(2, 2, 6, 7), 2, 2), fill), + TestCase::kAllSame_ComparisonExpecation); + + // horizontal + linePath.reset(); + linePath.moveTo(4, 4); + linePath.lineTo(5, 4); + + make_TestCase(r, linePath, buttCap)->compare( + r, TestCase(r, SkRect::MakeLTRB(4, 2, 5, 6), fill), + TestCase::kAllSame_ComparisonExpecation); + make_TestCase(r, linePath, squareCap)->compare( + r, TestCase(r, SkRect::MakeLTRB(2, 2, 7, 6), fill), + TestCase::kAllSame_ComparisonExpecation); + make_TestCase(r, linePath, roundCap)->compare( + r, TestCase(r, SkRRect::MakeRectXY(SkRect::MakeLTRB(2, 2, 7, 6), 2, 2), fill), + TestCase::kAllSame_ComparisonExpecation); + + // point + linePath.reset(); + linePath.moveTo(4, 4); + linePath.lineTo(4, 4); + + make_TestCase(r, linePath, buttCap)->compare( + r, TestCase(r, SkRect::MakeEmpty(), fill), + TestCase::kAllSame_ComparisonExpecation); + make_TestCase(r, linePath, squareCap)->compare( + r, TestCase(r, SkRect::MakeLTRB(2, 2, 6, 6), fill), + TestCase::kAllSame_ComparisonExpecation); + make_TestCase(r, linePath, roundCap)->compare( + r, TestCase(r, SkRRect::MakeRectXY(SkRect::MakeLTRB(2, 2, 6, 6), 2, 2), fill), + TestCase::kAllSame_ComparisonExpecation); + } } DEF_TEST(GrShape_short_path_keys, r) { |