move perspective-clipper into SkPathPriv

From here we can start trying it out for real
- skottie could call it directly
- SkDraw could call it for the raster-backend

Change-Id: I703838241d67c539afd3d3e31d0ddf1c66645799
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/258001
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Mike Reed <reed@google.com>
diff --git a/samplecode/SampleClip.cpp b/samplecode/SampleClip.cpp
index bff7704..ccfda1e 100644
--- a/samplecode/SampleClip.cpp
+++ b/samplecode/SampleClip.cpp
@@ -13,6 +13,7 @@
 #include "include/utils/SkRandom.h"
 #include "samplecode/Sample.h"
 #include "src/core/SkClipOpPriv.h"
+#include "src/core/SkPathPriv.h"
 
 constexpr int W = 150;
 constexpr int H = 200;
@@ -270,26 +271,6 @@
     rec.fResult->transform(mx);
 }
 
-// true means use clippedPath.
-// false means there was no clipping -- use the original path
-static bool clip(const SkPath& path, const SkHalfPlane& plane, SkPath* clippedPath) {
-    switch (plane.test(path.getBounds())) {
-        case SkHalfPlane::kAllPositive:
-            return false;
-        case SkHalfPlane::kMixed: {
-            SkPoint pts[2];
-            if (plane.twoPts(pts)) {
-                clip(path, pts[0], pts[1], clippedPath);
-                return true;
-            }
-        } break;
-        default: break; // handled outside of the switch
-    }
-    // clipped out (or failed)
-    clippedPath->reset();
-    return true;
-}
-
 static void draw_halfplane(SkCanvas* canvas, SkPoint p0, SkPoint p1, SkColor c) {
     SkVector v = p1 - p0;
     p0 = p0 - v * 1000;
@@ -540,11 +521,10 @@
             canvas->restore();
         }
 
-        SkHalfPlane hpw = half_plane_w0(mx);
 
         SkColor planeColor = SK_ColorBLUE;
         SkPath clippedPath, *path = &fPath;
-        if (clip(fPath, hpw, &clippedPath)) {
+        if (SkPathPriv::PerspectiveClip(fPath, mx, &clippedPath)) {
             path = &clippedPath;
             planeColor = SK_ColorRED;
         }
@@ -553,6 +533,7 @@
         canvas->drawPath(*path, paint);
         canvas->restore();
 
+        SkHalfPlane hpw = half_plane_w0(mx);
         draw_halfplane(canvas, hpw, planeColor);
     }