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
This commit is contained in:
bsalomon 2016-06-09 06:03:38 -07:00 committed by Commit bot
parent a9e878c836
commit a058786ae3
3 changed files with 18 additions and 31 deletions

View File

@ -106,7 +106,8 @@ void GrStyle::initPathEffect(SkPathEffect* pe) {
}
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;

View File

@ -219,7 +219,8 @@ bool SkDashPath::InternalFilter(SkPath* dst, const SkPath& src, SkStrokeRec* rec
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;
}

View File

@ -390,18 +390,13 @@ static void test_basic(skiatest::Reporter* reporter, const GEO& geo) {
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 @@ static void test_scale(skiatest::Reporter* reporter, const GEO& geo) {
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 @@ static void test_scale(skiatest::Reporter* reporter, const GEO& geo) {
} 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 @@ static void test_stroke_param_impl(skiatest::Reporter* reporter, const GEO& geo,
} 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>