Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(557)

Unified Diff: src/effects/SkDashPathEffect.cpp

Issue 1805963002: allow one zero length dash (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: use explicit bad params flag Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/effects/SkDashPathEffect.cpp
diff --git a/src/effects/SkDashPathEffect.cpp b/src/effects/SkDashPathEffect.cpp
index ced0aab69a9930efbbd216127f776dd5d8c2770d..7e7e48c7b3b54f15dd6141c611443488d29fe6f2 100644
--- a/src/effects/SkDashPathEffect.cpp
+++ b/src/effects/SkDashPathEffect.cpp
@@ -14,7 +14,7 @@
SkDashPathEffect::SkDashPathEffect(const SkScalar intervals[], int count, SkScalar phase)
: fPhase(0)
- , fInitialDashLength(0)
+ , fInitialDashLength(-1)
, fInitialDashIndex(0)
, fIntervalLength(0) {
SkASSERT(intervals);
@@ -28,7 +28,7 @@ SkDashPathEffect::SkDashPathEffect(const SkScalar intervals[], int count, SkScal
}
// set the internal data members
- SkDashPath::CalcDashParameters(phase, fIntervals, fCount,
+ fValidParameters = SkDashPath::CalcDashParameters(phase, fIntervals, fCount,
&fInitialDashLength, &fInitialDashIndex, &fIntervalLength, &fPhase);
}
@@ -38,6 +38,9 @@ SkDashPathEffect::~SkDashPathEffect() {
bool SkDashPathEffect::filterPath(SkPath* dst, const SkPath& src,
SkStrokeRec* rec, const SkRect* cullRect) const {
+ if (!fValidParameters) {
+ return false;
+ }
return SkDashPath::FilterDashPath(dst, src, rec, cullRect, fIntervals, fCount,
fInitialDashLength, fInitialDashIndex, fIntervalLength);
}
@@ -162,7 +165,7 @@ bool SkDashPathEffect::asPoints(PointData* results,
const SkMatrix& matrix,
const SkRect* cullRect) const {
// width < 0 -> fill && width == 0 -> hairline so requiring width > 0 rules both out
- if (fInitialDashLength < 0 || 0 >= rec.getWidth()) {
+ if (!fValidParameters || 0 >= rec.getWidth()) {
return false;
}

Powered by Google App Engine
This is Rietveld 408576698