diff options
Diffstat (limited to 'src/effects/Sk1DPathEffect.cpp')
-rw-r--r-- | src/effects/Sk1DPathEffect.cpp | 60 |
1 files changed, 28 insertions, 32 deletions
diff --git a/src/effects/Sk1DPathEffect.cpp b/src/effects/Sk1DPathEffect.cpp index 4be6f975d3..041886e1db 100644 --- a/src/effects/Sk1DPathEffect.cpp +++ b/src/effects/Sk1DPathEffect.cpp @@ -35,33 +35,39 @@ bool Sk1DPathEffect::filterPath(SkPath* dst, const SkPath& src, SkPath1DPathEffect::SkPath1DPathEffect(const SkPath& path, SkScalar advance, SkScalar phase, Style style) : fPath(path) { - SkASSERT(advance > 0 && !path.isEmpty()); - // cleanup their phase parameter, inverting it so that it becomes an - // offset along the path (to match the interpretation in PostScript) - if (phase < 0) { - phase = -phase; - if (phase > advance) { - phase = SkScalarMod(phase, advance); - } + if (advance <= 0 || path.isEmpty()) { + SkDEBUGF(("SkPath1DPathEffect can't use advance <= 0\n")); + fAdvance = 0; // signals we can't draw anything + fInitialOffset = 0; + fStyle = kStyleCount; } else { - if (phase > advance) { - phase = SkScalarMod(phase, advance); + // cleanup their phase parameter, inverting it so that it becomes an + // offset along the path (to match the interpretation in PostScript) + if (phase < 0) { + phase = -phase; + if (phase > advance) { + phase = SkScalarMod(phase, advance); + } + } else { + if (phase > advance) { + phase = SkScalarMod(phase, advance); + } + phase = advance - phase; } - phase = advance - phase; - } - // now catch the edge case where phase == advance (within epsilon) - if (phase >= advance) { - phase = 0; - } - SkASSERT(phase >= 0); + // now catch the edge case where phase == advance (within epsilon) + if (phase >= advance) { + phase = 0; + } + SkASSERT(phase >= 0); - fAdvance = advance; - fInitialOffset = phase; + fAdvance = advance; + fInitialOffset = phase; - if ((unsigned)style > kMorph_Style) { - SkDEBUGF(("SkPath1DPathEffect style enum out of range %d\n", style)); + if ((unsigned)style >= kStyleCount) { + SkDEBUGF(("SkPath1DPathEffect style enum out of range %d\n", style)); + } + fStyle = style; } - fStyle = style; } bool SkPath1DPathEffect::filterPath(SkPath* dst, const SkPath& src, @@ -201,13 +207,3 @@ void SkPath1DPathEffect::toString(SkString* str) const { str->appendf(")"); } #endif - -/////////////////////////////////////////////////////////////////////////////////////////////////// - -SkPathEffect* SkPath1DPathEffect::Create(const SkPath& path, SkScalar advance, SkScalar phase, - Style style) { - if (advance <= 0 || path.isEmpty()) { - return nullptr; - } - return new SkPath1DPathEffect(path, advance, phase, style); -} |