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

Side by Side Diff: src/effects/Sk1DPathEffect.cpp

Issue 1721743002: Revert of fix misc asserts and checks found by fuzzer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « samplecode/SampleFilterFuzz.cpp ('k') | src/effects/SkAlphaThresholdFilter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "Sk1DPathEffect.h" 10 #include "Sk1DPathEffect.h"
(...skipping 17 matching lines...) Expand all
28 } 28 }
29 } while (meas.nextContour()); 29 } while (meas.nextContour());
30 return true; 30 return true;
31 } 31 }
32 32
33 /////////////////////////////////////////////////////////////////////////////// 33 ///////////////////////////////////////////////////////////////////////////////
34 34
35 SkPath1DPathEffect::SkPath1DPathEffect(const SkPath& path, SkScalar advance, 35 SkPath1DPathEffect::SkPath1DPathEffect(const SkPath& path, SkScalar advance,
36 SkScalar phase, Style style) : fPath(path) 36 SkScalar phase, Style style) : fPath(path)
37 { 37 {
38 SkASSERT(advance > 0 && !path.isEmpty()); 38 if (advance <= 0 || path.isEmpty()) {
39 // cleanup their phase parameter, inverting it so that it becomes an 39 SkDEBUGF(("SkPath1DPathEffect can't use advance <= 0\n"));
40 // offset along the path (to match the interpretation in PostScript) 40 fAdvance = 0; // signals we can't draw anything
41 if (phase < 0) { 41 fInitialOffset = 0;
42 phase = -phase; 42 fStyle = kStyleCount;
43 if (phase > advance) { 43 } else {
44 phase = SkScalarMod(phase, advance); 44 // cleanup their phase parameter, inverting it so that it becomes an
45 // offset along the path (to match the interpretation in PostScript)
46 if (phase < 0) {
47 phase = -phase;
48 if (phase > advance) {
49 phase = SkScalarMod(phase, advance);
50 }
51 } else {
52 if (phase > advance) {
53 phase = SkScalarMod(phase, advance);
54 }
55 phase = advance - phase;
45 } 56 }
46 } else { 57 // now catch the edge case where phase == advance (within epsilon)
47 if (phase > advance) { 58 if (phase >= advance) {
48 phase = SkScalarMod(phase, advance); 59 phase = 0;
49 } 60 }
50 phase = advance - phase; 61 SkASSERT(phase >= 0);
62
63 fAdvance = advance;
64 fInitialOffset = phase;
65
66 if ((unsigned)style >= kStyleCount) {
67 SkDEBUGF(("SkPath1DPathEffect style enum out of range %d\n", style)) ;
68 }
69 fStyle = style;
51 } 70 }
52 // now catch the edge case where phase == advance (within epsilon)
53 if (phase >= advance) {
54 phase = 0;
55 }
56 SkASSERT(phase >= 0);
57
58 fAdvance = advance;
59 fInitialOffset = phase;
60
61 if ((unsigned)style > kMorph_Style) {
62 SkDEBUGF(("SkPath1DPathEffect style enum out of range %d\n", style));
63 }
64 fStyle = style;
65 } 71 }
66 72
67 bool SkPath1DPathEffect::filterPath(SkPath* dst, const SkPath& src, 73 bool SkPath1DPathEffect::filterPath(SkPath* dst, const SkPath& src,
68 SkStrokeRec* rec, const SkRect* cullRect) const { 74 SkStrokeRec* rec, const SkRect* cullRect) const {
69 if (fAdvance > 0) { 75 if (fAdvance > 0) {
70 rec->setFillStyle(); 76 rec->setFillStyle();
71 return this->INHERITED::filterPath(dst, src, rec, cullRect); 77 return this->INHERITED::filterPath(dst, src, rec, cullRect);
72 } 78 }
73 return false; 79 return false;
74 } 80 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 200
195 201
196 #ifndef SK_IGNORE_TO_STRING 202 #ifndef SK_IGNORE_TO_STRING
197 void SkPath1DPathEffect::toString(SkString* str) const { 203 void SkPath1DPathEffect::toString(SkString* str) const {
198 str->appendf("SkPath1DPathEffect: ("); 204 str->appendf("SkPath1DPathEffect: (");
199 // TODO: add path and style 205 // TODO: add path and style
200 str->appendf("advance: %.2f phase %.2f", fAdvance, fInitialOffset); 206 str->appendf("advance: %.2f phase %.2f", fAdvance, fInitialOffset);
201 str->appendf(")"); 207 str->appendf(")");
202 } 208 }
203 #endif 209 #endif
204
205 //////////////////////////////////////////////////////////////////////////////// ///////////////////
206
207 SkPathEffect* SkPath1DPathEffect::Create(const SkPath& path, SkScalar advance, S kScalar phase,
208 Style style) {
209 if (advance <= 0 || path.isEmpty()) {
210 return nullptr;
211 }
212 return new SkPath1DPathEffect(path, advance, phase, style);
213 }
OLDNEW
« 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