move patheffect virtuals to protected and rename

- change filterPath to safely handle if src and dst are aliases

Bug: skia:8254
Change-Id: I125d19404ca0a610f73271abb5c5455d1d50f9ed
Reviewed-on: https://skia-review.googlesource.com/147466
Commit-Queue: Mike Reed <reed@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Auto-Submit: Mike Reed <reed@google.com>
diff --git a/include/core/SkPathEffect.h b/include/core/SkPathEffect.h
index f60dd86..c99aa8e 100644
--- a/include/core/SkPathEffect.h
+++ b/include/core/SkPathEffect.h
@@ -58,14 +58,13 @@
      *  If this method returns true, the caller will apply (as needed) the
      *  resulting stroke-rec to dst and then draw.
      */
-    virtual bool filterPath(SkPath* dst, const SkPath& src,
-                            SkStrokeRec*, const SkRect* cullR) const = 0;
+    bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect* cullR) const;
 
     /**
      *  Compute a conservative bounds for its effect, given the src bounds.
      *  The baseline implementation just assigns src to dst.
      */
-    virtual void computeFastBounds(SkRect* dst, const SkRect& src) const;
+    void computeFastBounds(SkRect* dst, const SkRect& src) const;
 
     /** \class PointData
 
@@ -112,7 +111,7 @@
      *  Does applying this path effect to 'src' yield a set of points? If so,
      *  optionally return the points in 'results'.
      */
-    virtual bool asPoints(PointData* results, const SkPath& src,
+    bool asPoints(PointData* results, const SkPath& src,
                           const SkStrokeRec&, const SkMatrix&,
                           const SkRect* cullR) const;
 
@@ -143,7 +142,7 @@
                                         //   mod the sum of all intervals
     };
 
-    virtual DashType asADash(DashInfo* info) const;
+    DashType asADash(DashInfo* info) const;
 
     static void InitializeFlattenables();
 
@@ -170,6 +169,18 @@
 protected:
     SkPathEffect() {}
 
+    virtual bool onFilterPath(SkPath*, const SkPath&, SkStrokeRec*, const SkRect*) const = 0;
+    virtual SkRect onComputeFastBounds(const SkRect& src) const {
+        return src;
+    }
+    virtual bool onAsPoints(PointData*, const SkPath&, const SkStrokeRec&, const SkMatrix&,
+                            const SkRect*) const {
+        return false;
+    }
+    virtual DashType onAsADash(DashInfo*) const {
+        return kNone_DashType;
+    }
+
 private:
     // illegal
     SkPathEffect(const SkPathEffect&);
diff --git a/include/effects/Sk1DPathEffect.h b/include/effects/Sk1DPathEffect.h
index 022505f..bfaa896 100644
--- a/include/effects/Sk1DPathEffect.h
+++ b/include/effects/Sk1DPathEffect.h
@@ -17,10 +17,9 @@
 // This class is not exported to java.
 class SK_API Sk1DPathEffect : public SkPathEffect {
 public:
-    virtual bool filterPath(SkPath* dst, const SkPath& src,
-                            SkStrokeRec*, const SkRect*) const override;
-
 protected:
+    bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override;
+
     /** Called at the start of each contour, returns the initial offset
         into that contour.
     */
@@ -59,14 +58,12 @@
     */
     static sk_sp<SkPathEffect> Make(const SkPath& path, SkScalar advance, SkScalar phase, Style);
 
-    virtual bool filterPath(SkPath*, const SkPath&,
-                            SkStrokeRec*, const SkRect*) const override;
-
     Factory getFactory() const override { return CreateProc; }
 
 protected:
     SkPath1DPathEffect(const SkPath& path, SkScalar advance, SkScalar phase, Style);
     void flatten(SkWriteBuffer&) const override;
+    bool onFilterPath(SkPath*, const SkPath&, SkStrokeRec*, const SkRect*) const override;
 
     // overrides from Sk1DPathEffect
     SkScalar begin(SkScalar contourLength) const override;
diff --git a/include/effects/Sk2DPathEffect.h b/include/effects/Sk2DPathEffect.h
index 3bdf5de..e29ce1e 100644
--- a/include/effects/Sk2DPathEffect.h
+++ b/include/effects/Sk2DPathEffect.h
@@ -14,9 +14,6 @@
 #include "SkMatrix.h"
 
 class SK_API Sk2DPathEffect : public SkPathEffect {
-public:
-    bool filterPath(SkPath*, const SkPath&, SkStrokeRec*, const SkRect*) const override;
-
 protected:
     /** New virtual, to be overridden by subclasses.
         This is called once from filterPath, and provides the
@@ -39,6 +36,7 @@
     // protected so that subclasses can call this during unflattening
     explicit Sk2DPathEffect(const SkMatrix& mat);
     void flatten(SkWriteBuffer&) const override;
+    bool onFilterPath(SkPath*, const SkPath&, SkStrokeRec*, const SkRect*) const override;
 
 private:
     SkMatrix    fMatrix, fInverse;
@@ -61,8 +59,6 @@
         return sk_sp<SkPathEffect>(new SkLine2DPathEffect(width, matrix));
     }
 
-    virtual bool filterPath(SkPath* dst, const SkPath& src,
-                            SkStrokeRec*, const SkRect*) const override;
 
     Factory getFactory() const override { return CreateProc; }
 
@@ -72,6 +68,7 @@
             SkASSERT(width >= 0);
         }
     void flatten(SkWriteBuffer&) const override;
+    bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override;
 
     void nextSpan(int u, int v, int ucount, SkPath*) const override;
 
diff --git a/include/effects/SkCornerPathEffect.h b/include/effects/SkCornerPathEffect.h
index e1c57e7..f35f32e 100644
--- a/include/effects/SkCornerPathEffect.h
+++ b/include/effects/SkCornerPathEffect.h
@@ -25,9 +25,6 @@
         return radius > 0 ? sk_sp<SkPathEffect>(new SkCornerPathEffect(radius)) : nullptr;
     }
 
-    virtual bool filterPath(SkPath* dst, const SkPath& src,
-                            SkStrokeRec*, const SkRect*) const override;
-
     Factory getFactory() const override { return CreateProc; }
 
 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
@@ -41,6 +38,7 @@
 
     explicit SkCornerPathEffect(SkScalar radius);
     void flatten(SkWriteBuffer&) const override;
+    bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override;
 
 private:
     SkScalar    fRadius;
diff --git a/include/effects/SkDiscretePathEffect.h b/include/effects/SkDiscretePathEffect.h
index fc53f2a..99bfb3a 100644
--- a/include/effects/SkDiscretePathEffect.h
+++ b/include/effects/SkDiscretePathEffect.h
@@ -32,9 +32,6 @@
     */
     static sk_sp<SkPathEffect> Make(SkScalar segLength, SkScalar dev, uint32_t seedAssist = 0);
 
-    virtual bool filterPath(SkPath* dst, const SkPath& src,
-                            SkStrokeRec*, const SkRect*) const override;
-
     Factory getFactory() const override { return CreateProc; }
 
 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
@@ -46,6 +43,7 @@
                          SkScalar deviation,
                          uint32_t seedAssist);
     void flatten(SkWriteBuffer&) const override;
+    bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override;
 
 private:
     static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&);
diff --git a/samplecode/SampleTextEffects.cpp b/samplecode/SampleTextEffects.cpp
index 7f3fcb7..8e87880 100644
--- a/samplecode/SampleTextEffects.cpp
+++ b/samplecode/SampleTextEffects.cpp
@@ -77,8 +77,8 @@
 class InverseFillPE : public SkPathEffect {
 public:
     InverseFillPE() {}
-    virtual bool filterPath(SkPath* dst, const SkPath& src,
-                            SkStrokeRec*, const SkRect*) const override {
+    virtual bool onFilterPath(SkPath* dst, const SkPath& src,
+                              SkStrokeRec*, const SkRect*) const override {
         *dst = src;
         dst->setFillType(SkPath::kInverseWinding_FillType);
         return true;
diff --git a/src/core/SkPathEffect.cpp b/src/core/SkPathEffect.cpp
index e315275..ef0a473 100644
--- a/src/core/SkPathEffect.cpp
+++ b/src/core/SkPathEffect.cpp
@@ -12,17 +12,32 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
-void SkPathEffect::computeFastBounds(SkRect* dst, const SkRect& src) const {
-    *dst = src;
-}
-
-bool SkPathEffect::asPoints(PointData* results, const SkPath& src,
-                    const SkStrokeRec&, const SkMatrix&, const SkRect*) const {
+bool SkPathEffect::filterPath(SkPath* dst, const SkPath& src, SkStrokeRec* rec,
+                              const SkRect* bounds) const {
+    SkPath tmp, *tmpDst = dst;
+    if (dst == &src) {
+        tmpDst = &tmp;
+    }
+    if (this->onFilterPath(tmpDst, src, rec, bounds)) {
+        if (dst == &src) {
+            *dst = tmp;
+        }
+        return true;
+    }
     return false;
 }
 
+void SkPathEffect::computeFastBounds(SkRect* dst, const SkRect& src) const {
+    *dst = this->onComputeFastBounds(src);
+}
+
+bool SkPathEffect::asPoints(PointData* results, const SkPath& src,
+                    const SkStrokeRec& rec, const SkMatrix& mx, const SkRect* rect) const {
+    return this->onAsPoints(results, src, rec, mx, rect);
+}
+
 SkPathEffect::DashType SkPathEffect::asADash(DashInfo* info) const {
-    return kNone_DashType;
+    return this->onAsADash(info);
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -79,18 +94,6 @@
         return sk_sp<SkPathEffect>(new SkComposePathEffect(outer, inner));
     }
 
-    bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec* rec,
-                    const SkRect* cullRect) const override {
-        SkPath          tmp;
-        const SkPath*   ptr = &src;
-
-        if (fPE1->filterPath(&tmp, src, rec, cullRect)) {
-            ptr = &tmp;
-        }
-        return fPE0->filterPath(dst, *ptr, rec, cullRect);
-    }
-
-
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposePathEffect)
 
 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
@@ -101,6 +104,17 @@
     SkComposePathEffect(sk_sp<SkPathEffect> outer, sk_sp<SkPathEffect> inner)
         : INHERITED(outer, inner) {}
 
+    bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec* rec,
+                      const SkRect* cullRect) const override {
+        SkPath          tmp;
+        const SkPath*   ptr = &src;
+
+        if (fPE1->filterPath(&tmp, src, rec, cullRect)) {
+            ptr = &tmp;
+        }
+        return fPE0->filterPath(dst, *ptr, rec, cullRect);
+    }
+
 private:
     // illegal
     SkComposePathEffect(const SkComposePathEffect&);
@@ -140,14 +154,6 @@
         return sk_sp<SkPathEffect>(new SkSumPathEffect(first, second));
     }
 
-    bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec* rec,
-                    const SkRect* cullRect) const override {
-        // use bit-or so that we always call both, even if the first one succeeds
-        return fPE0->filterPath(dst, src, rec, cullRect) |
-               fPE1->filterPath(dst, src, rec, cullRect);
-    }
-
-
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSumPathEffect)
 
 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
@@ -156,7 +162,14 @@
 
 protected:
     SkSumPathEffect(sk_sp<SkPathEffect> first, sk_sp<SkPathEffect> second)
-    : INHERITED(first, second) {}
+        : INHERITED(first, second) {}
+
+    bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec* rec,
+                      const SkRect* cullRect) const override {
+        // use bit-or so that we always call both, even if the first one succeeds
+        return fPE0->filterPath(dst, src, rec, cullRect) |
+               fPE1->filterPath(dst, src, rec, cullRect);
+    }
 
 private:
     // illegal
diff --git a/src/effects/Sk1DPathEffect.cpp b/src/effects/Sk1DPathEffect.cpp
index 9195933..72a128d 100644
--- a/src/effects/Sk1DPathEffect.cpp
+++ b/src/effects/Sk1DPathEffect.cpp
@@ -16,8 +16,8 @@
 // Put in a governor to limit crash values from looping too long (and allocating too much ram).
 #define MAX_REASONABLE_ITERATIONS   100000
 
-bool Sk1DPathEffect::filterPath(SkPath* dst, const SkPath& src,
-                                SkStrokeRec*, const SkRect*) const {
+bool Sk1DPathEffect::onFilterPath(SkPath* dst, const SkPath& src,
+                                  SkStrokeRec*, const SkRect*) const {
     SkPathMeasure   meas(src, false);
     do {
         int governor = MAX_REASONABLE_ITERATIONS;
@@ -69,10 +69,10 @@
     fStyle = style;
 }
 
-bool SkPath1DPathEffect::filterPath(SkPath* dst, const SkPath& src,
-                            SkStrokeRec* rec, const SkRect* cullRect) const {
+bool SkPath1DPathEffect::onFilterPath(SkPath* dst, const SkPath& src,
+                                      SkStrokeRec* rec, const SkRect* cullRect) const {
     rec->setFillStyle();
-    return this->INHERITED::filterPath(dst, src, rec, cullRect);
+    return this->INHERITED::onFilterPath(dst, src, rec, cullRect);
 }
 
 static bool morphpoints(SkPoint dst[], const SkPoint src[], int count,
diff --git a/src/effects/Sk2DPathEffect.cpp b/src/effects/Sk2DPathEffect.cpp
index 6c2c4c2..2458682 100644
--- a/src/effects/Sk2DPathEffect.cpp
+++ b/src/effects/Sk2DPathEffect.cpp
@@ -18,8 +18,8 @@
     fMatrixIsInvertible = fMatrix.invert(&fInverse);
 }
 
-bool Sk2DPathEffect::filterPath(SkPath* dst, const SkPath& src,
-                                SkStrokeRec*, const SkRect*) const {
+bool Sk2DPathEffect::onFilterPath(SkPath* dst, const SkPath& src,
+                                  SkStrokeRec*, const SkRect*) const {
     if (!fMatrixIsInvertible) {
         return false;
     }
@@ -76,8 +76,8 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
-bool SkLine2DPathEffect::filterPath(SkPath* dst, const SkPath& src,
-                            SkStrokeRec* rec, const SkRect* cullRect) const {
+bool SkLine2DPathEffect::onFilterPath(SkPath* dst, const SkPath& src,
+                                      SkStrokeRec* rec, const SkRect* cullRect) const {
     if (this->INHERITED::filterPath(dst, src, rec, cullRect)) {
         rec->setStrokeStyle(fWidth);
         return true;
diff --git a/src/effects/SkCornerPathEffect.cpp b/src/effects/SkCornerPathEffect.cpp
index a88bc32..d8f2d70 100644
--- a/src/effects/SkCornerPathEffect.cpp
+++ b/src/effects/SkCornerPathEffect.cpp
@@ -35,8 +35,8 @@
     }
 }
 
-bool SkCornerPathEffect::filterPath(SkPath* dst, const SkPath& src,
-                                    SkStrokeRec*, const SkRect*) const {
+bool SkCornerPathEffect::onFilterPath(SkPath* dst, const SkPath& src,
+                                      SkStrokeRec*, const SkRect*) const {
     if (fRadius <= 0) {
         return false;
     }
diff --git a/src/effects/SkDashImpl.h b/src/effects/SkDashImpl.h
index 7f1de77..c1bf462 100644
--- a/src/effects/SkDashImpl.h
+++ b/src/effects/SkDashImpl.h
@@ -14,13 +14,6 @@
 public:
     SkDashImpl(const SkScalar intervals[], int count, SkScalar phase);
 
-    bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override;
-
-    bool asPoints(PointData* results, const SkPath& src, const SkStrokeRec&, const SkMatrix&,
-                  const SkRect*) const override;
-
-    DashType asADash(DashInfo* info) const override;
-
     Factory getFactory() const override { return CreateProc; }
 
 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
@@ -30,6 +23,12 @@
 protected:
     ~SkDashImpl() override;
     void flatten(SkWriteBuffer&) const override;
+    bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override;
+
+    bool onAsPoints(PointData* results, const SkPath& src, const SkStrokeRec&, const SkMatrix&,
+                    const SkRect*) const override;
+
+    DashType onAsADash(DashInfo* info) const override;
 
 private:
     static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&);
diff --git a/src/effects/SkDashPathEffect.cpp b/src/effects/SkDashPathEffect.cpp
index a243409..cc414f7 100644
--- a/src/effects/SkDashPathEffect.cpp
+++ b/src/effects/SkDashPathEffect.cpp
@@ -40,8 +40,8 @@
     sk_free(fIntervals);
 }
 
-bool SkDashImpl::filterPath(SkPath* dst, const SkPath& src, SkStrokeRec* rec,
-                            const SkRect* cullRect) const {
+bool SkDashImpl::onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec* rec,
+                              const SkRect* cullRect) const {
     return SkDashPath::InternalFilter(dst, src, rec, cullRect, fIntervals, fCount,
                                       fInitialDashLength, fInitialDashIndex, fIntervalLength);
 }
@@ -164,8 +164,8 @@
 // we need to:
 //      allow kRound_Cap capping (could allow rotations in the matrix with this)
 //      allow paths to be returned
-bool SkDashImpl::asPoints(PointData* results, const SkPath& src, const SkStrokeRec& rec,
-                          const SkMatrix& matrix, const SkRect* cullRect) const {
+bool SkDashImpl::onAsPoints(PointData* results, const SkPath& src, const SkStrokeRec& rec,
+                            const SkMatrix& matrix, const SkRect* cullRect) const {
     // width < 0 -> fill && width == 0 -> hairline so requiring width > 0 rules both out
     if (0 >= rec.getWidth()) {
         return false;
@@ -357,7 +357,7 @@
     return true;
 }
 
-SkPathEffect::DashType SkDashImpl::asADash(DashInfo* info) const {
+SkPathEffect::DashType SkDashImpl::onAsADash(DashInfo* info) const {
     if (info) {
         if (info->fCount >= fCount && info->fIntervals) {
             memcpy(info->fIntervals, fIntervals, fCount * sizeof(SkScalar));
diff --git a/src/effects/SkDiscretePathEffect.cpp b/src/effects/SkDiscretePathEffect.cpp
index 46cd42b..2c913d8 100644
--- a/src/effects/SkDiscretePathEffect.cpp
+++ b/src/effects/SkDiscretePathEffect.cpp
@@ -81,8 +81,8 @@
     uint32_t fSeed;
 };
 
-bool SkDiscretePathEffect::filterPath(SkPath* dst, const SkPath& src,
-                                      SkStrokeRec* rec, const SkRect*) const {
+bool SkDiscretePathEffect::onFilterPath(SkPath* dst, const SkPath& src,
+                                        SkStrokeRec* rec, const SkRect*) const {
     bool doFill = rec->isFillStyle();
 
     SkPathMeasure   meas(src, doFill);
diff --git a/src/effects/SkOpPE.h b/src/effects/SkOpPE.h
index d6883d0..6f6e114 100644
--- a/src/effects/SkOpPE.h
+++ b/src/effects/SkOpPE.h
@@ -14,12 +14,11 @@
 public:
     SkOpPE(sk_sp<SkPathEffect> one, sk_sp<SkPathEffect> two, SkPathOp op);
 
-    bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override;
-
     Factory getFactory() const override { return CreateProc; }
 
 protected:
     void flatten(SkWriteBuffer&) const override;
+    bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override;
 
 private:
     static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&);
@@ -36,12 +35,11 @@
 public:
     SkMatrixPE(const SkMatrix&);
 
-    bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override;
-
     Factory getFactory() const override { return CreateProc; }
 
 protected:
     void flatten(SkWriteBuffer&) const override;
+    bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override;
 
 private:
     static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&);
@@ -56,12 +54,12 @@
 public:
     SkStrokePE(SkScalar width, SkPaint::Join, SkPaint::Cap, SkScalar miter);
 
-    bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override;
-
     Factory getFactory() const override { return CreateProc; }
 
 protected:
     void flatten(SkWriteBuffer&) const override;
+    bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override;
+    // TODO: override onComputeFastBounds (I think)
 
 private:
     static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&);
diff --git a/src/effects/SkOpPathEffect.cpp b/src/effects/SkOpPathEffect.cpp
index 3c09b9e..1623b86 100644
--- a/src/effects/SkOpPathEffect.cpp
+++ b/src/effects/SkOpPathEffect.cpp
@@ -18,8 +18,8 @@
 SkOpPE::SkOpPE(sk_sp<SkPathEffect> one, sk_sp<SkPathEffect> two, SkPathOp op)
     : fOne(std::move(one)), fTwo(std::move(two)), fOp(op) {}
 
-bool SkOpPE::filterPath(SkPath* dst, const SkPath& src, SkStrokeRec* rec,
-                        const SkRect* cull) const {
+bool SkOpPE::onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec* rec,
+                          const SkRect* cull) const {
     SkPath one, two;
     if (fOne) {
         if (!fOne->filterPath(&one, src, rec, cull)) {
@@ -71,7 +71,7 @@
     SkASSERT(matrix.isFinite());
 }
 
-bool SkMatrixPE::filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const {
+bool SkMatrixPE::onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const {
     src.transform(fMatrix, dst);
     return true;
 }
@@ -99,7 +99,7 @@
 SkStrokePE::SkStrokePE(SkScalar width, SkPaint::Join join, SkPaint::Cap cap, SkScalar miter)
     : fWidth(width), fMiter(miter), fJoin(join), fCap(cap) {}
 
-bool SkStrokePE::filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const {
+bool SkStrokePE::onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const {
     SkStrokeRec rec(SkStrokeRec::kFill_InitStyle);
     rec.setStrokeStyle(fWidth);
     rec.setStrokeParams(fCap, fJoin, fMiter);
diff --git a/src/effects/SkTrimPE.h b/src/effects/SkTrimPE.h
index 0f29987..cbaab89 100644
--- a/src/effects/SkTrimPE.h
+++ b/src/effects/SkTrimPE.h
@@ -17,12 +17,11 @@
 public:
     SkTrimPE(SkScalar startT, SkScalar stopT, SkTrimPathEffect::Mode);
 
-    bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override;
-
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTrimPE)
 
 protected:
     void flatten(SkWriteBuffer&) const override;
+    bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override;
 
 private:
     const SkScalar               fStartT,
diff --git a/src/effects/SkTrimPathEffect.cpp b/src/effects/SkTrimPathEffect.cpp
index 3a8d094..3ca70b5 100644
--- a/src/effects/SkTrimPathEffect.cpp
+++ b/src/effects/SkTrimPathEffect.cpp
@@ -53,7 +53,7 @@
 SkTrimPE::SkTrimPE(SkScalar startT, SkScalar stopT, SkTrimPathEffect::Mode mode)
     : fStartT(startT), fStopT(stopT), fMode(mode) {}
 
-bool SkTrimPE::filterPath(SkPath* dst, const SkPath& src, SkStrokeRec* rec,
+bool SkTrimPE::onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec* rec,
                             const SkRect* cullRect) const {
     if (fStartT >= fStopT) {
         SkASSERT(fMode == SkTrimPathEffect::Mode::kNormal);
diff --git a/src/gpu/GrTestUtils.cpp b/src/gpu/GrTestUtils.cpp
index e29e8f5..4f0dc3b 100644
--- a/src/gpu/GrTestUtils.cpp
+++ b/src/gpu/GrTestUtils.cpp
@@ -285,13 +285,13 @@
                                    &fInitialDashIndex, &fIntervalLength, &fPhase);
 }
 
-    bool TestDashPathEffect::filterPath(SkPath* dst, const SkPath& src, SkStrokeRec* rec,
-                                     const SkRect* cullRect) const {
+    bool TestDashPathEffect::onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec* rec,
+                                          const SkRect* cullRect) const {
     return SkDashPath::InternalFilter(dst, src, rec, cullRect, fIntervals.get(), fCount,
                                       fInitialDashLength, fInitialDashIndex, fIntervalLength);
 }
 
-SkPathEffect::DashType TestDashPathEffect::asADash(DashInfo* info) const {
+SkPathEffect::DashType TestDashPathEffect::onAsADash(DashInfo* info) const {
     if (info) {
         if (info->fCount >= fCount && info->fIntervals) {
             memcpy(info->fIntervals, fIntervals.get(), fCount * sizeof(SkScalar));
diff --git a/src/gpu/GrTestUtils.h b/src/gpu/GrTestUtils.h
index 64c7662..ffc48aa 100644
--- a/src/gpu/GrTestUtils.h
+++ b/src/gpu/GrTestUtils.h
@@ -72,10 +72,12 @@
         return sk_sp<SkPathEffect>(new TestDashPathEffect(intervals, count, phase));
     }
 
-    bool filterPath(SkPath* dst, const SkPath&, SkStrokeRec* , const SkRect*) const override;
-    DashType asADash(DashInfo* info) const override;
     Factory getFactory() const override { return nullptr; }
 
+protected:
+    bool onFilterPath(SkPath* dst, const SkPath&, SkStrokeRec* , const SkRect*) const override;
+    DashType onAsADash(DashInfo* info) const override;
+
 private:
     TestDashPathEffect(const SkScalar* intervals, int count, SkScalar phase);
 
diff --git a/tests/GrShapeTest.cpp b/tests/GrShapeTest.cpp
index 905ff44..81afbb9 100644
--- a/tests/GrShapeTest.cpp
+++ b/tests/GrShapeTest.cpp
@@ -1152,17 +1152,21 @@
             return kRRect;
         }
 
-        bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*,
-                        const SkRect* cullR) const override {
+        static sk_sp<SkPathEffect> Make() { return sk_sp<SkPathEffect>(new RRectPathEffect); }
+        Factory getFactory() const override { return nullptr; }
+
+    protected:
+        bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*,
+                          const SkRect* cullR) const override {
             dst->reset();
             dst->addRRect(RRect());
             return true;
         }
-        void computeFastBounds(SkRect* dst, const SkRect& src) const override {
-            *dst = RRect().getBounds();
+
+        SkRect onComputeFastBounds(const SkRect& src) const override {
+            return RRect().getBounds();
         }
-        static sk_sp<SkPathEffect> Make() { return sk_sp<SkPathEffect>(new RRectPathEffect); }
-        Factory getFactory() const override { return nullptr; }
+
     private:
         RRectPathEffect() {}
     };
@@ -1229,8 +1233,12 @@
      */
     class AddLineTosPathEffect : SkPathEffect {
     public:
-        bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*,
-                        const SkRect* cullR) const override {
+        static sk_sp<SkPathEffect> Make() { return sk_sp<SkPathEffect>(new AddLineTosPathEffect); }
+        Factory getFactory() const override { return nullptr; }
+
+    protected:
+        bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*,
+                          const SkRect* cullR) const override {
             *dst = src;
             // To avoid triggering data-based keying of paths with few verbs we add many segments.
             for (int i = 0; i < 100; ++i) {
@@ -1238,13 +1246,12 @@
             }
             return true;
         }
-        void computeFastBounds(SkRect* dst, const SkRect& src) const override {
-            *dst = src;
-            SkRectPriv::GrowToInclude(dst, {0, 0});
-            SkRectPriv::GrowToInclude(dst, {100, 100});
+        SkRect onComputeFastBounds(const SkRect& src) const override {
+            SkRect dst = src;
+            SkRectPriv::GrowToInclude(&dst, {0, 0});
+            SkRectPriv::GrowToInclude(&dst, {100, 100});
+            return dst;
         }
-        static sk_sp<SkPathEffect> Make() { return sk_sp<SkPathEffect>(new AddLineTosPathEffect); }
-        Factory getFactory() const override { return nullptr; }
     private:
         AddLineTosPathEffect() {}
     };
@@ -1270,17 +1277,18 @@
      */
     class MakeHairlinePathEffect : SkPathEffect {
     public:
-        bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec* strokeRec,
-                        const SkRect* cullR) const override {
-            *dst = src;
-            strokeRec->setHairlineStyle();
-            return true;
-        }
-        void computeFastBounds(SkRect* dst, const SkRect& src) const override { *dst = src; }
         static sk_sp<SkPathEffect> Make() {
             return sk_sp<SkPathEffect>(new MakeHairlinePathEffect);
         }
         Factory getFactory() const override { return nullptr; }
+
+    protected:
+        bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec* strokeRec,
+                          const SkRect* cullR) const override {
+            *dst = src;
+            strokeRec->setHairlineStyle();
+            return true;
+        }
     private:
         MakeHairlinePathEffect() {}
     };
@@ -1351,21 +1359,22 @@
      */
     class EmptyPathEffect : SkPathEffect {
     public:
-        bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*,
-                        const SkRect* cullR) const override {
+        static sk_sp<SkPathEffect> Make(bool invert) {
+            return sk_sp<SkPathEffect>(new EmptyPathEffect(invert));
+        }
+        Factory getFactory() const override { return nullptr; }
+    protected:
+        bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*,
+                          const SkRect* cullR) const override {
             dst->reset();
             if (fInvert) {
                 dst->toggleInverseFillType();
             }
             return true;
         }
-        void computeFastBounds(SkRect* dst, const SkRect& src) const override {
-            dst->setEmpty();
+        SkRect onComputeFastBounds(const SkRect& src) const override {
+            return { 0, 0, 0, 0 };
         }
-        static sk_sp<SkPathEffect> Make(bool invert) {
-            return sk_sp<SkPathEffect>(new EmptyPathEffect(invert));
-        }
-        Factory getFactory() const override { return nullptr; }
     private:
         bool fInvert;
         EmptyPathEffect(bool invert) : fInvert(invert) {}
@@ -1437,15 +1446,13 @@
      */
     class FailurePathEffect : SkPathEffect {
     public:
-        bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*,
-                        const SkRect* cullR) const override {
-            return false;
-        }
-        void computeFastBounds(SkRect* dst, const SkRect& src) const override {
-            *dst = src;
-        }
         static sk_sp<SkPathEffect> Make() { return sk_sp<SkPathEffect>(new FailurePathEffect); }
         Factory getFactory() const override { return nullptr; }
+    protected:
+        bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*,
+                          const SkRect* cullR) const override {
+            return false;
+        }
     private:
         FailurePathEffect() {}
     };