Iter::next takes a bool (defaults to true for now) if we want to consume degenerates.
authorreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 16 May 2012 17:16:46 +0000 (17:16 +0000)
committerreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 16 May 2012 17:16:46 +0000 (17:16 +0000)
path-filling and stroking pass false, as they already are written to handle
small segments (and it makes next() run 2x faster if you pass false).
Review URL: https://codereview.appspot.com/6214049

git-svn-id: http://skia.googlecode.com/svn/trunk@3974 2bbb7eff-a529-9590-31e7-b0007b416f81

include/core/SkPath.h
src/core/SkEdgeBuilder.cpp
src/core/SkPath.cpp
src/core/SkRegion_path.cpp
src/core/SkScan_Hairline.cpp
src/core/SkStroke.cpp
src/effects/SkCornerPathEffect.cpp
src/utils/SkDumpCanvas.cpp
src/utils/SkParsePath.cpp

index 4453abd..03108df 100644 (file)
@@ -684,9 +684,16 @@ public:
             segments have been visited, return kDone_Verb.
 
             @param  pts The points representing the current verb and/or segment
+            @param doConsumeDegerates If true, first scan for segments that are
+                   deemed degenerate (too short) and skip those.
             @return The verb for the current segment
         */
-        Verb next(SkPoint pts[4]);
+        Verb next(SkPoint pts[4], bool doConsumeDegerates = true) {
+            if (doConsumeDegerates) {
+                this->consumeDegenerateSegments();
+            }
+            return this->doNext(pts);
+        }
 
         /** If next() returns kLine_Verb, then this query returns true if the
             line was the result of a close() command (i.e. the end point is the
@@ -717,6 +724,7 @@ public:
         inline const SkPoint& cons_moveTo();
         Verb autoClose(SkPoint pts[2]);
         void consumeDegenerateSegments();
+        Verb doNext(SkPoint pts[4]);
     };
 
     /** Iterate through the verbs in the path, providing the associated points.
index 01417e4..7474ba9 100644 (file)
@@ -92,7 +92,7 @@ int SkEdgeBuilder::build(const SkPath& path, const SkIRect* iclip,
         setShiftedClip(&clip, *iclip, shiftUp);
         SkEdgeClipper clipper;
 
-        while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
+        while ((verb = iter.next(pts, false)) != SkPath::kDone_Verb) {
             switch (verb) {
                 case SkPath::kMove_Verb:
                 case SkPath::kClose_Verb:
@@ -123,7 +123,7 @@ int SkEdgeBuilder::build(const SkPath& path, const SkIRect* iclip,
             }
         }
     } else {
-        while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
+        while ((verb = iter.next(pts, false)) != SkPath::kDone_Verb) {
             switch (verb) {
                 case SkPath::kMove_Verb:
                 case SkPath::kClose_Verb:
index 1a48830..ee6a171 100644 (file)
@@ -1265,7 +1265,7 @@ void SkPath::transform(const SkMatrix& matrix, SkPath* dst) const {
         SkPoint         pts[4];
         SkPath::Verb    verb;
 
-        while ((verb = iter.next(pts)) != kDone_Verb) {
+        while ((verb = iter.next(pts, false)) != kDone_Verb) {
             switch (verb) {
                 case kMove_Verb:
                     tmp.moveTo(pts[0]);
@@ -1498,9 +1498,8 @@ void SkPath::Iter::consumeDegenerateSegments() {
     }
 }
 
-SkPath::Verb SkPath::Iter::next(SkPoint ptsParam[4]) {
+SkPath::Verb SkPath::Iter::doNext(SkPoint ptsParam[4]) {
     SkASSERT(ptsParam);
-    this->consumeDegenerateSegments();
 
     if (fVerbs == fVerbStop) {
         // Close the curve if requested and if there is some curve to close
@@ -1689,7 +1688,7 @@ void SkPath::dump(bool forceClose, const char title[]) const {
     SkDebugf("path: forceClose=%s %s\n", forceClose ? "true" : "false",
              title ? title : "");
 
-    while ((verb = iter.next(pts)) != kDone_Verb) {
+    while ((verb = iter.next(pts, false)) != kDone_Verb) {
         switch (verb) {
             case kMove_Verb:
 #ifdef SK_CAN_USE_FLOAT
index 85fd6bf..5ea792a 100644 (file)
@@ -243,7 +243,7 @@ static int count_path_runtype_values(const SkPath& path, int* itop, int* ibot) {
     SkScalar    top = SkIntToScalar(SK_MaxS16);
     SkScalar    bot = SkIntToScalar(SK_MinS16);
 
-    while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
+    while ((verb = iter.next(pts, false)) != SkPath::kDone_Verb) {
         maxEdges += gPathVerbToMaxEdges[verb];
 
         int lastIndex = gPathVerbToInitialLastIndex[verb];
index ffdf92f..2a9660a 100644 (file)
@@ -303,7 +303,7 @@ static void hair_path(const SkPath& path, const SkRasterClip& rclip, SkBlitter*
     SkPoint         pts[4];
     SkPath::Verb    verb;
 
-    while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
+    while ((verb = iter.next(pts, false)) != SkPath::kDone_Verb) {
         switch (verb) {
             case SkPath::kLine_Verb:
                 lineproc(pts[0], pts[1], clip, blitter);
index 1c9b0c0..fd7dccc 100644 (file)
@@ -591,7 +591,7 @@ void SkStroke::strokePath(const SkPath& src, SkPath* dst) const {
     SkPoint         pts[4];
     SkPath::Verb    verb, lastSegment = SkPath::kMove_Verb;
 
-    while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
+    while ((verb = iter.next(pts, false)) != SkPath::kDone_Verb) {
         switch (verb) {
             case SkPath::kMove_Verb:
                 APPLY_PROC(proc, &pts[0], 1);
index bf59a27..4746231 100644 (file)
@@ -56,7 +56,7 @@ bool SkCornerPathEffect::filterPath(SkPath* dst, const SkPath& src,
     lastCorner.set(0, 0);
 
     for (;;) {
-        switch (verb = iter.next(pts)) {
+        switch (verb = iter.next(pts, false)) {
             case SkPath::kMove_Verb:
                     // close out the previous (open) contour
                 if (SkPath::kLine_Verb == prevVerb) {
index 72a5c92..8a9ab7a 100644 (file)
@@ -33,7 +33,7 @@ static void dumpVerbs(const SkPath& path, SkString* str) {
     SkPath::Iter iter(path, false);
     SkPoint pts[4];
     for (;;) {
-        switch (iter.next(pts)) {
+        switch (iter.next(pts, false)) {
             case SkPath::kMove_Verb:
                 str->appendf(" M%g,%g", pts[0].fX, pts[0].fY);
                 break;
index 6030493..22433e6 100644 (file)
@@ -220,7 +220,7 @@ void SkParsePath::ToSVGString(const SkPath& path, SkString* str) {
     SkPoint         pts[4];
 
     for (;;) {
-        switch (iter.next(pts)) {
+        switch (iter.next(pts, false)) {
             case SkPath::kMove_Verb:
                 append_scalars(&stream, 'M', &pts[0].fX, 2);
                 break;