use pathbuilder

Change-Id: I11c18d4ff0e60cc33d742cf49359039395abc6b4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/313256
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
diff --git a/src/pathops/SkPathOpsAsWinding.cpp b/src/pathops/SkPathOpsAsWinding.cpp
index 500dc35..2c227cd 100644
--- a/src/pathops/SkPathOpsAsWinding.cpp
+++ b/src/pathops/SkPathOpsAsWinding.cpp
@@ -321,13 +321,16 @@
         return reversed;
     }
 
-    void reverseMarkedContours(vector<Contour>& contours, SkPath* result) {
+    SkPath reverseMarkedContours(vector<Contour>& contours, SkPathFillType fillType) {
         SkPathPriv::Iterate iterate(fPath);
         auto iter = iterate.begin();
         int verbCount = 0;
+
+        SkPathBuilder result;
+        result.setFillType(fillType);
         for (const Contour& contour : contours) {
-            SkPath reverse;
-            SkPath* temp = contour.fReverse ? &reverse : result;
+            SkPathBuilder reverse;
+            SkPathBuilder* temp = contour.fReverse ? &reverse : &result;
             for (; iter != iterate.end() && verbCount < contour.fVerbEnd; ++iter, ++verbCount) {
                 auto [verb, pts, w] = *iter;
                 switch (verb) {
@@ -352,9 +355,11 @@
                 }
             }
             if (contour.fReverse) {
-                result->reverseAddPath(reverse);
+                SkASSERT(temp == &reverse);
+                SkPathPriv::ReverseAddPath(&result, reverse.detach());
             }
         }
+        return result.detach();
     }
 
 private:
@@ -413,9 +418,6 @@
     if (!reversed) {
         return set_result_path(result, path, fillType);
     }
-    SkPath temp;
-    temp.setFillType(fillType);
-    winder.reverseMarkedContours(contours, &temp);
-    result->swap(temp);
+    *result = winder.reverseMarkedContours(contours, fillType);
     return true;
 }