Make SkDashPathEffect fail for stroke+fill style (in addition to fill style)
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2048183002
Review-Url: https://codereview.chromium.org/2048183002
diff --git a/src/gpu/GrStyle.cpp b/src/gpu/GrStyle.cpp
index 3698c31..bb1f03d 100644
--- a/src/gpu/GrStyle.cpp
+++ b/src/gpu/GrStyle.cpp
@@ -106,7 +106,8 @@
}
SkPathEffect::DashInfo info;
if (SkPathEffect::kDash_DashType == pe->asADash(&info)) {
- if (fStrokeRec.getStyle() != SkStrokeRec::kFill_Style) {
+ SkStrokeRec::Style recStyle = fStrokeRec.getStyle();
+ if (recStyle != SkStrokeRec::kFill_Style && recStyle != SkStrokeRec::kStrokeAndFill_Style) {
fDashInfo.fType = SkPathEffect::kDash_DashType;
fDashInfo.fIntervals.reset(info.fCount);
fDashInfo.fPhase = info.fPhase;
diff --git a/src/utils/SkDashPath.cpp b/src/utils/SkDashPath.cpp
index d766b0d..833c7cc 100644
--- a/src/utils/SkDashPath.cpp
+++ b/src/utils/SkDashPath.cpp
@@ -219,7 +219,8 @@
SkScalar intervalLength) {
// we do nothing if the src wants to be filled
- if (rec->isFillStyle()) {
+ SkStrokeRec::Style style = rec->getStyle();
+ if (SkStrokeRec::kFill_Style == style || SkStrokeRec::kStrokeAndFill_Style == style) {
return false;
}
diff --git a/tests/GrShapeTest.cpp b/tests/GrShapeTest.cpp
index 295d630..246bab6 100644
--- a/tests/GrShapeTest.cpp
+++ b/tests/GrShapeTest.cpp
@@ -390,18 +390,13 @@
stroke2RoundBevelAndFillDash.setStyle(SkPaint::kStrokeAndFill_Style);
TestCase stroke2RoundBevelAndFillDashCase(geo, stroke2RoundBevelAndFillDash, reporter);
expectations.fPEHasValidKey = true;
- expectations.fPEHasEffect = true;
+ expectations.fPEHasEffect = false;
expectations.fStrokeApplies = true;
stroke2RoundBevelAndFillDashCase.testExpectations(reporter, expectations);
TestCase(geo, stroke2RoundBevelAndFillDash, reporter).compare(
reporter, stroke2RoundBevelAndFillDashCase, TestCase::kAllSame_ComparisonExpecation);
-
- stroke2RoundBevelAndFillCase.compare(reporter, stroke2RoundBevelCase,
- TestCase::kSameUpToStroke_ComparisonExpecation);
- stroke2RoundBevelAndFillDashCase.compare(reporter, stroke2RoundBevelDashCase,
- TestCase::kSameUpToStroke_ComparisonExpecation);
- stroke2RoundBevelAndFillCase.compare(reporter, stroke2RoundBevelAndFillDashCase,
- TestCase::kSameUpToPE_ComparisonExpecation);
+ stroke2RoundBevelAndFillDashCase.compare(reporter, stroke2RoundBevelAndFillCase,
+ TestCase::kAllSame_ComparisonExpecation);
SkPaint hairline;
hairline.setStyle(SkPaint::kStroke_Style);
@@ -455,6 +450,11 @@
strokeAndFill.setStyle(SkPaint::kStrokeAndFill_Style);
TestCase strokeAndFillCase1(geo, strokeAndFill, reporter, kS1);
TestCase strokeAndFillCase2(geo, strokeAndFill, reporter, kS2);
+ SkPaint strokeAndFillDash = strokeDash;
+ strokeAndFillDash.setStyle(SkPaint::kStrokeAndFill_Style);
+ // Dash is ignored for stroke and fill
+ TestCase strokeAndFillDashCase1(geo, strokeAndFillDash, reporter, kS1);
+ TestCase strokeAndFillDashCase2(geo, strokeAndFillDash, reporter, kS2);
// Scale affects the stroke. Though, this can wind up creating a rect when the input is a rect.
// In that case we wind up with a pure geometry key and the geometries are the same.
SkRRect rrect;
@@ -469,15 +469,13 @@
} else {
strokeAndFillCase1.compare(reporter, strokeAndFillCase2,
TestCase::kSameUpToStroke_ComparisonExpecation);
+ strokeAndFillDashCase1.compare(reporter, strokeAndFillDashCase2,
+ TestCase::kSameUpToStroke_ComparisonExpecation);
}
-
- SkPaint strokeAndFillDash = strokeDash;
- strokeAndFillDash.setStyle(SkPaint::kStrokeAndFill_Style);
- TestCase strokeAndFillDashCase1(geo, strokeAndFillDash, reporter, kS1);
- TestCase strokeAndFillDashCase2(geo, strokeAndFillDash, reporter, kS2);
- // Scale affects the path effect and stroke.
- strokeAndFillDashCase1.compare(reporter, strokeAndFillDashCase2,
- TestCase::kSameUpToPE_ComparisonExpecation);
+ strokeAndFillDashCase1.compare(reporter, strokeAndFillCase1,
+ TestCase::kAllSame_ComparisonExpecation);
+ strokeAndFillDashCase2.compare(reporter, strokeAndFillCase2,
+ TestCase::kAllSame_ComparisonExpecation);
}
template <typename GEO, typename T>
@@ -538,19 +536,6 @@
} else {
dashACase.compare(reporter, dashBCase, TestCase::kAllSame_ComparisonExpecation);
}
-
- SkPaint dashStrokeAndFillA = dashA, dashStrokeAndFillB = dashB;
- dashStrokeAndFillA.setStyle(SkPaint::kStrokeAndFill_Style);
- dashStrokeAndFillB.setStyle(SkPaint::kStrokeAndFill_Style);
- TestCase dashStrokeAndFillACase(geo, dashStrokeAndFillA, reporter);
- TestCase dashStrokeAndFillBCase(geo, dashStrokeAndFillB, reporter);
- if (paramAffectsDashAndStroke) {
- dashStrokeAndFillACase.compare(reporter, dashStrokeAndFillBCase,
- TestCase::kSameUpToStroke_ComparisonExpecation);
- } else {
- dashStrokeAndFillACase.compare(reporter, dashStrokeAndFillBCase,
- TestCase::kAllSame_ComparisonExpecation);
- }
}
template <typename GEO, typename T>