diff options
author | bungeman <bungeman@google.com> | 2016-03-18 05:10:23 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-18 05:10:23 -0700 |
commit | 6f0749cfc7f93880bd6b8acfdc61900cda4a81fe (patch) | |
tree | 0fb054893ced56e90a8baf02400744b45a5b2321 /src/effects/SkDashPathEffect.cpp | |
parent | 5e1a24808415df2748822e8082e21a361362cdfe (diff) |
Revert of allow one zero length dash (patchset #8 id:140001 of https://codereview.chromium.org/1805963002/ )
Reason for revert:
Causes the dash bench to crash.
Example crash:
https://build.chromium.org/p/client.skia/builders/Perf-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release/builds/5581/steps/nanobench/logs/stdio
Original issue's description:
> 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
>
> Committed: https://skia.googlesource.com/skia/+/5e1a24808415df2748822e8082e21a361362cdfe
TBR=robertphillips@google.com,reed@google.com,caryclark@google.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=583299
Review URL: https://codereview.chromium.org/1808303004
Diffstat (limited to 'src/effects/SkDashPathEffect.cpp')
-rw-r--r-- | src/effects/SkDashPathEffect.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/effects/SkDashPathEffect.cpp b/src/effects/SkDashPathEffect.cpp index 3816499915..ced0aab69a 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(-1) + , fInitialDashLength(0) , fInitialDashIndex(0) , fIntervalLength(0) { SkASSERT(intervals); @@ -23,6 +23,7 @@ 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]; } @@ -37,7 +38,7 @@ SkDashPathEffect::~SkDashPathEffect() { bool SkDashPathEffect::filterPath(SkPath* dst, const SkPath& src, SkStrokeRec* rec, const SkRect* cullRect) const { - return SkDashPath::InternalFilter(dst, src, rec, cullRect, fIntervals, fCount, + return SkDashPath::FilterDashPath(dst, src, rec, cullRect, fIntervals, fCount, fInitialDashLength, fInitialDashIndex, fIntervalLength); } @@ -161,7 +162,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 (0 >= rec.getWidth()) { + if (fInitialDashLength < 0 || 0 >= rec.getWidth()) { return false; } @@ -387,8 +388,13 @@ void SkDashPathEffect::toString(SkString* str) const { ////////////////////////////////////////////////////////////////////////////////////////////////// SkPathEffect* SkDashPathEffect::Create(const SkScalar intervals[], int count, SkScalar phase) { - if (!SkDashPath::ValidDashPath(phase, intervals, count)) { + if ((count < 2) || !SkIsAlign2(count)) { return nullptr; } + for (int i = 0; i < count; i++) { + if (intervals[i] < 0) { + return nullptr; + } + } return new SkDashPathEffect(intervals, count, phase); } |