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

Unified Diff: src/effects/Sk1DPathEffect.cpp

Issue 1719993002: fix misc asserts and checks found by fuzzer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: hide the creation of the typeface as well Created 4 years, 10 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
« no previous file with comments | « samplecode/SampleFilterFuzz.cpp ('k') | src/effects/SkAlphaThresholdFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/Sk1DPathEffect.cpp
diff --git a/src/effects/Sk1DPathEffect.cpp b/src/effects/Sk1DPathEffect.cpp
index 041886e1db9f146f870a034d19b3e5deb4c2e4f4..4be6f975d3bfa792e7cec3fbe35a25c566699850 100644
--- a/src/effects/Sk1DPathEffect.cpp
+++ b/src/effects/Sk1DPathEffect.cpp
@@ -35,39 +35,33 @@ bool Sk1DPathEffect::filterPath(SkPath* dst, const SkPath& src,
SkPath1DPathEffect::SkPath1DPathEffect(const SkPath& path, SkScalar advance,
SkScalar phase, Style style) : fPath(path)
{
- 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 {
- // 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;
+ 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);
}
- // now catch the edge case where phase == advance (within epsilon)
- if (phase >= advance) {
- phase = 0;
+ } else {
+ if (phase > advance) {
+ phase = SkScalarMod(phase, advance);
}
- SkASSERT(phase >= 0);
+ phase = advance - phase;
+ }
+ // 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 >= kStyleCount) {
- SkDEBUGF(("SkPath1DPathEffect style enum out of range %d\n", style));
- }
- fStyle = style;
+ if ((unsigned)style > kMorph_Style) {
+ SkDEBUGF(("SkPath1DPathEffect style enum out of range %d\n", style));
}
+ fStyle = style;
}
bool SkPath1DPathEffect::filterPath(SkPath* dst, const SkPath& src,
@@ -207,3 +201,13 @@ 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);
+}
« no previous file with comments | « samplecode/SampleFilterFuzz.cpp ('k') | src/effects/SkAlphaThresholdFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698