Fix problems with SampleApp Fuzzer due to issues in iterating over degenerate paths.
The fuzzer gets my vote as best test tool ever.
There are several issues outstanding: crashes in FixedPoint and a crash in the
path filling code that is most likely due to clipping problems (but maybe not).
BUG=425
Review URL: http://codereview.appspot.com/5503080
git-svn-id: http://skia.googlecode.com/svn/trunk@2936 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/core/SkPath.h b/include/core/SkPath.h
index 16cc1f4..98c79a6 100644
--- a/include/core/SkPath.h
+++ b/include/core/SkPath.h
@@ -623,11 +623,17 @@
/** Iterate through all of the segments (lines, quadratics, cubics) of
each contours in a path.
+
+ The iterator cleans up the segments along the way, removing degenerate
+ segments and adding close verbs where necessary. When the forceClose
+ argument is provided, each contour (as defined by a new starting
+ move command) will be completed with a close verb regardless of the
+ contour's contents.
*/
class SK_API Iter {
public:
- Iter();
- Iter(const SkPath&, bool forceClose);
+ Iter();
+ Iter(const SkPath&, bool forceClose);
void setPath(const SkPath&, bool forceClose);
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index 7e6ac8c..22860bf 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -1185,9 +1185,10 @@
fVerbs = path.fVerbs.begin();
fVerbStop = path.fVerbs.end();
fLastPt.fX = fLastPt.fY = 0;
+ fMoveTo.fX = fMoveTo.fY = 0;
fForceClose = SkToU8(forceClose);
fNeedClose = false;
- fSegmentState = kAfterPrimitive_SegmentState;
+ fSegmentState = kAfterClose_SegmentState;
}
bool SkPath::Iter::isClosedContour() const {
@@ -1279,10 +1280,6 @@
unsigned verb = *fVerbs;
switch (verb) {
case kMove_Verb:
- // Set state for the next method.
- fSegmentState = kAfterMove_SegmentState;
- fMoveTo = fPts[0];
-
// Keep a record of this most recent move
lastMoveVerb = fVerbs;
lastMovePt = fPts;
@@ -1385,16 +1382,13 @@
if (fVerbs == fVerbStop) { // might be a trailing moveto
return kDone_Verb;
}
-#ifdef SK_OLD_EMPTY_PATH_BEHAVIOR
fMoveTo = *srcPts;
-#endif
if (pts) {
pts[0] = *srcPts;
}
srcPts += 1;
-#ifdef SK_OLD_EMPTY_PATH_BEHAVIOR
fSegmentState = kAfterMove_SegmentState;
-#else
+#ifndef SK_OLD_EMPTY_PATH_BEHAVIOR
fLastPt = fMoveTo;
#endif
fNeedClose = fForceClose;