Remove SkPath::RawIter from tests/tools/samplecode

Change-Id: I66c1b4aee9b07a4db294ed0cd82d01f3097c6acb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/287857
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
diff --git a/samplecode/SampleAAGeometry.cpp b/samplecode/SampleAAGeometry.cpp
index 5f2e624..bc708ea 100644
--- a/samplecode/SampleAAGeometry.cpp
+++ b/samplecode/SampleAAGeometry.cpp
@@ -129,73 +129,63 @@
 
 static void add_path_segment(int index, SkPath* path) {
     SkPath result;
-    SkPoint pts[4];
     SkPoint firstPt = { 0, 0 };  // init to avoid warning
     SkPoint lastPt = { 0, 0 };  // init to avoid warning
-    SkPath::Verb verb;
-    SkPath::RawIter iter(*path);
     int counter = -1;
-    while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
-        SkScalar weight  SK_INIT_TO_AVOID_WARNING;
+    SkPoint chop[7];
+    SkConic conicChop[2];
+    for (auto [verb, pts, w] : SkPathPriv::Iterate(*path)) {
         if (++counter == index) {
             switch (verb) {
-                case SkPath::kLine_Verb:
+                case SkPathVerb::kLine:
                     result.lineTo((pts[0].fX + pts[1].fX) / 2, (pts[0].fY + pts[1].fY) / 2);
                     break;
-                case SkPath::kQuad_Verb: {
-                    SkPoint chop[5];
+                case SkPathVerb::kQuad: {
                     SkChopQuadAtHalf(pts, chop);
                     result.quadTo(chop[1], chop[2]);
-                    pts[1] = chop[3];
+                    pts = chop + 2;
                     } break;
-                case SkPath::kConic_Verb: {
-                    SkConic chop[2];
+                case SkPathVerb::kConic: {
                     SkConic conic;
-                    conic.set(pts, iter.conicWeight());
-                    if (!conic.chopAt(0.5f, chop)) {
+                    conic.set(pts, *w);
+                    if (!conic.chopAt(0.5f, conicChop)) {
                         return;
                     }
-                    result.conicTo(chop[0].fPts[1], chop[0].fPts[2], chop[0].fW);
-                    pts[1] = chop[1].fPts[1];
-                    weight = chop[1].fW;
+                    result.conicTo(conicChop[0].fPts[1], conicChop[0].fPts[2], conicChop[0].fW);
+                    pts = conicChop[1].fPts;
+                    w = &conicChop[1].fW;
                     } break;
-                case SkPath::kCubic_Verb: {
-                    SkPoint chop[7];
+                case SkPathVerb::kCubic: {
                     SkChopCubicAtHalf(pts, chop);
                     result.cubicTo(chop[1], chop[2], chop[3]);
-                    pts[1] = chop[4];
-                    pts[2] = chop[5];
+                    pts = chop + 3;
                     } break;
-                case SkPath::kClose_Verb: {
+                case SkPathVerb::kClose: {
                     result.lineTo((lastPt.fX + firstPt.fX) / 2, (lastPt.fY + firstPt.fY) / 2);
                     } break;
                 default:
                     SkASSERT(0);
             }
-        } else if (verb == SkPath::kConic_Verb) {
-            weight = iter.conicWeight();
         }
         switch (verb) {
-            case SkPath::kMove_Verb:
+            case SkPathVerb::kMove:
                 result.moveTo(firstPt = pts[0]);
                 break;
-            case SkPath::kLine_Verb:
+            case SkPathVerb::kLine:
                 result.lineTo(lastPt = pts[1]);
                 break;
-            case SkPath::kQuad_Verb:
+            case SkPathVerb::kQuad:
                 result.quadTo(pts[1], lastPt = pts[2]);
                 break;
-            case SkPath::kConic_Verb:
-                result.conicTo(pts[1], lastPt = pts[2], weight);
+            case SkPathVerb::kConic:
+                result.conicTo(pts[1], lastPt = pts[2], *w);
                 break;
-            case SkPath::kCubic_Verb:
+            case SkPathVerb::kCubic:
                 result.cubicTo(pts[1], pts[2], lastPt = pts[3]);
                 break;
-            case SkPath::kClose_Verb:
+            case SkPathVerb::kClose:
                 result.close();
                 break;
-            case SkPath::kDone_Verb:
-                break;
             default:
                 SkASSERT(0);
         }
@@ -205,35 +195,30 @@
 
 static void delete_path_segment(int index, SkPath* path) {
     SkPath result;
-    SkPoint pts[4];
-    SkPath::Verb verb;
-    SkPath::RawIter iter(*path);
     int counter = -1;
-    while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
+    for (auto [verb, pts, w] : SkPathPriv::Iterate(*path)) {
         if (++counter == index) {
             continue;
         }
         switch (verb) {
-            case SkPath::kMove_Verb:
+            case SkPathVerb::kMove:
                 result.moveTo(pts[0]);
                 break;
-            case SkPath::kLine_Verb:
+            case SkPathVerb::kLine:
                 result.lineTo(pts[1]);
                 break;
-            case SkPath::kQuad_Verb:
+            case SkPathVerb::kQuad:
                 result.quadTo(pts[1], pts[2]);
                 break;
-            case SkPath::kConic_Verb:
-                result.conicTo(pts[1], pts[2], iter.conicWeight());
+            case SkPathVerb::kConic:
+                result.conicTo(pts[1], pts[2], *w);
                 break;
-            case SkPath::kCubic_Verb:
+            case SkPathVerb::kCubic:
                 result.cubicTo(pts[1], pts[2], pts[3]);
                 break;
-            case SkPath::kClose_Verb:
+            case SkPathVerb::kClose:
                 result.close();
                 break;
-            case SkPath::kDone_Verb:
-                break;
             default:
                 SkASSERT(0);
         }
diff --git a/samplecode/SamplePathText.cpp b/samplecode/SamplePathText.cpp
index 1f42b36..a8b65e3 100644
--- a/samplecode/SamplePathText.cpp
+++ b/samplecode/SamplePathText.cpp
@@ -10,6 +10,7 @@
 #include "include/core/SkPath.h"
 #include "include/utils/SkRandom.h"
 #include "samplecode/Sample.h"
+#include "src/core/SkPathPriv.h"
 #include "src/core/SkScalerCache.h"
 #include "src/core/SkStrikeCache.h"
 #include "src/core/SkStrikeSpec.h"
@@ -280,35 +281,30 @@
             backpath->reset();
             backpath->setFillType(SkPathFillType::kEvenOdd);
 
-            SkPath::RawIter iter(glyph.fPath);
-            SkPath::Verb verb;
-            SkPoint pts[4];
-
-            while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
+            for (auto [verb, pts, w] : SkPathPriv::Iterate(glyph.fPath)) {
                 switch (verb) {
-                    case SkPath::kMove_Verb: {
+                    case SkPathVerb::kMove: {
                         SkPoint pt = fWaves.apply(tsec, matrix, pts[0]);
                         backpath->moveTo(pt.x(), pt.y());
                         break;
                     }
-                    case SkPath::kLine_Verb: {
+                    case SkPathVerb::kLine: {
                         SkPoint endpt = fWaves.apply(tsec, matrix, pts[1]);
                         backpath->lineTo(endpt.x(), endpt.y());
                         break;
                     }
-                    case SkPath::kQuad_Verb: {
+                    case SkPathVerb::kQuad: {
                         SkPoint controlPt = fWaves.apply(tsec, matrix, pts[1]);
                         SkPoint endpt = fWaves.apply(tsec, matrix, pts[2]);
                         backpath->quadTo(controlPt.x(), controlPt.y(), endpt.x(), endpt.y());
                         break;
                     }
-                    case SkPath::kClose_Verb: {
+                    case SkPathVerb::kClose: {
                         backpath->close();
                         break;
                     }
-                    case SkPath::kCubic_Verb:
-                    case SkPath::kConic_Verb:
-                    case SkPath::kDone_Verb:
+                    case SkPathVerb::kCubic:
+                    case SkPathVerb::kConic:
                         SK_ABORT("Unexpected path verb");
                         break;
                 }
diff --git a/samplecode/SampleQuadStroker.cpp b/samplecode/SampleQuadStroker.cpp
index c82145d..37f0e4b 100644
--- a/samplecode/SampleQuadStroker.cpp
+++ b/samplecode/SampleQuadStroker.cpp
@@ -28,6 +28,7 @@
 #include "include/utils/SkTextUtils.h"
 #include "samplecode/Sample.h"
 #include "src/core/SkGeometry.h"
+#include "src/core/SkPathPriv.h"
 #include "src/core/SkPointPriv.h"
 #include "src/core/SkStroke.h"
 #include "tools/ToolUtils.h"
@@ -42,18 +43,14 @@
 }
 
 static int getOnCurvePoints(const SkPath& path, SkPoint storage[]) {
-    SkPath::RawIter iter(path);
-    SkPoint pts[4];
-    SkPath::Verb verb;
-
     int count = 0;
-    while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
+    for (auto [verb, pts, w] : SkPathPriv::Iterate(path)) {
         switch (verb) {
-            case SkPath::kMove_Verb:
-            case SkPath::kLine_Verb:
-            case SkPath::kQuad_Verb:
-            case SkPath::kConic_Verb:
-            case SkPath::kCubic_Verb:
+            case SkPathVerb::kMove:
+            case SkPathVerb::kLine:
+            case SkPathVerb::kQuad:
+            case SkPathVerb::kConic:
+            case SkPathVerb::kCubic:
                 storage[count++] = pts[0];
                 break;
             default:
@@ -64,25 +61,21 @@
 }
 
 static void getContourCounts(const SkPath& path, SkTArray<int>* contourCounts) {
-    SkPath::RawIter iter(path);
-    SkPoint pts[4];
-    SkPath::Verb verb;
-
     int count = 0;
-    while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
+    for (auto [verb, pts, w] : SkPathPriv::Iterate(path)) {
         switch (verb) {
-            case SkPath::kMove_Verb:
-            case SkPath::kLine_Verb:
+            case SkPathVerb::kMove:
+            case SkPathVerb::kLine:
                 count += 1;
                 break;
-            case SkPath::kQuad_Verb:
-            case SkPath::kConic_Verb:
+            case SkPathVerb::kQuad:
+            case SkPathVerb::kConic:
                 count += 2;
                 break;
-            case SkPath::kCubic_Verb:
+            case SkPathVerb::kCubic:
                 count += 3;
                 break;
-            case SkPath::kClose_Verb:
+            case SkPathVerb::kClose:
                 contourCounts->push_back(count);
                 count = 0;
                 break;
@@ -356,14 +349,14 @@
         for (SkScalar dist = 0; dist <= total; dist += delta) {
             ++ribs;
         }
-        SkPath::RawIter iter(path);
-        SkPoint pts[4];
-        if (SkPath::kMove_Verb != iter.next(pts)) {
+        const uint8_t* verbs = SkPathPriv::VerbData(path);
+        if (path.countVerbs() < 2 || SkPath::kMove_Verb != verbs[0]) {
             SkASSERT(0);
             return;
         }
-        SkPath::Verb verb = iter.next(pts);
+        auto verb = static_cast<SkPath::Verb>(verbs[1]);
         SkASSERT(SkPath::kLine_Verb <= verb && verb <= SkPath::kCubic_Verb);
+        const SkPoint* pts = SkPathPriv::PointData(path);
         SkPoint pos, tan;
         for (int index = 0; index < ribs; ++index) {
             SkScalar t = (SkScalar) index / ribs;
@@ -379,7 +372,7 @@
                     tan = SkEvalQuadTangentAt(pts, t);
                     break;
                 case SkPath::kConic_Verb: {
-                    SkConic conic(pts, iter.conicWeight());
+                    SkConic conic(pts, SkPathPriv::ConicWeightData(path)[0]);
                     pos = conic.evalAt(t);
                     tan = conic.evalTangentAt(t);
                     } break;