aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/effects/SkDashPathEffect.cpp
diff options
context:
space:
mode:
authorGravatar caryclark <caryclark@google.com>2016-03-18 04:44:23 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-18 04:44:23 -0700
commit5e1a24808415df2748822e8082e21a361362cdfe (patch)
tree84ae073681487073f6ed1b0ae3e7f1c84f4ac9ce /src/effects/SkDashPathEffect.cpp
parent05849018c85403a34b88819db1c4bcf713b70a2b (diff)
allow one zero length dash
If the constructed stroke that represents a dash has a single dash of length zero, and the end cap is square or round, draw the cap. The old code initialized the initial dash length to zero, making it ambiguous whether the first length is zero or not. R=robertphillips@google.com BUG=583299 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1805963002 Review URL: https://codereview.chromium.org/1805963002
Diffstat (limited to 'src/effects/SkDashPathEffect.cpp')
-rw-r--r--src/effects/SkDashPathEffect.cpp14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/effects/SkDashPathEffect.cpp b/src/effects/SkDashPathEffect.cpp
index ced0aab69a..3816499915 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);
@@ -23,7 +23,6 @@ SkDashPathEffect::SkDashPathEffect(const SkScalar intervals[], int count, SkScal
fIntervals = (SkScalar*)sk_malloc_throw(sizeof(SkScalar) * count);
fCount = count;
for (int i = 0; i < count; i++) {
- SkASSERT(intervals[i] >= 0);
fIntervals[i] = intervals[i];
}
@@ -38,7 +37,7 @@ SkDashPathEffect::~SkDashPathEffect() {
bool SkDashPathEffect::filterPath(SkPath* dst, const SkPath& src,
SkStrokeRec* rec, const SkRect* cullRect) const {
- return SkDashPath::FilterDashPath(dst, src, rec, cullRect, fIntervals, fCount,
+ return SkDashPath::InternalFilter(dst, src, rec, cullRect, fIntervals, fCount,
fInitialDashLength, fInitialDashIndex, fIntervalLength);
}
@@ -162,7 +161,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 (0 >= rec.getWidth()) {
return false;
}
@@ -388,13 +387,8 @@ void SkDashPathEffect::toString(SkString* str) const {
//////////////////////////////////////////////////////////////////////////////////////////////////
SkPathEffect* SkDashPathEffect::Create(const SkScalar intervals[], int count, SkScalar phase) {
- if ((count < 2) || !SkIsAlign2(count)) {
+ if (!SkDashPath::ValidDashPath(phase, intervals, count)) {
return nullptr;
}
- for (int i = 0; i < count; i++) {
- if (intervals[i] < 0) {
- return nullptr;
- }
- }
return new SkDashPathEffect(intervals, count, phase);
}