Reland of "switch patheffects over to sk_sp (patchset #5 id:80001 of https://codereview.chromium.org/1813553005/ )"

This reverts commit f28ad894272018fd2855e3f77ea1236ea0cce1c0.

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1813123003

TBR=

Review URL: https://codereview.chromium.org/1813123003
diff --git a/bench/DashBench.cpp b/bench/DashBench.cpp
index e3d8364..43db54c 100644
--- a/bench/DashBench.cpp
+++ b/bench/DashBench.cpp
@@ -72,9 +72,7 @@
         SkPath path;
         this->makePath(&path);
 
-        SkAutoTUnref<SkPathEffect> effect(SkDashPathEffect::Create(fIntervals.begin(),
-                                          fIntervals.count(), 0));
-        paint.setPathEffect(effect);
+        paint.setPathEffect(SkDashPathEffect::Make(fIntervals.begin(), fIntervals.count(), 0));
 
         if (fDoClip) {
             SkRect r = path.getBounds();
@@ -179,7 +177,7 @@
 class MakeDashBench : public Benchmark {
     SkString fName;
     SkPath   fPath;
-    SkAutoTUnref<SkPathEffect> fPE;
+    sk_sp<SkPathEffect> fPE;
 
 public:
     MakeDashBench(void (*proc)(SkPath*), const char name[])  {
@@ -187,7 +185,7 @@
         proc(&fPath);
 
         SkScalar vals[] = { SkIntToScalar(4), SkIntToScalar(4) };
-        fPE.reset(SkDashPathEffect::Create(vals, 2, 0));
+        fPE = SkDashPathEffect::Make(vals, 2, 0);
     }
 
 protected:
@@ -216,7 +214,7 @@
     SkString fName;
     SkScalar fStrokeWidth;
     bool     fIsRound;
-    SkAutoTUnref<SkPathEffect> fPE;
+    sk_sp<SkPathEffect> fPE;
 
 public:
     DashLineBench(SkScalar width, bool isRound)  {
@@ -225,7 +223,7 @@
         fIsRound = isRound;
 
         SkScalar vals[] = { SK_Scalar1, SK_Scalar1 };
-        fPE.reset(SkDashPathEffect::Create(vals, 2, 0));
+        fPE = SkDashPathEffect::Make(vals, 2, 0);
     }
 
 protected:
@@ -254,7 +252,7 @@
     int      fStrokeWidth;
     bool     fDoAA;
 
-    SkAutoTUnref<SkPathEffect> fPathEffect;
+    sk_sp<SkPathEffect> fPathEffect;
 
 public:
     DrawPointsDashingBench(int dashLength, int strokeWidth, bool doAA)
@@ -264,7 +262,7 @@
         fDoAA = doAA;
 
         SkScalar vals[] = { SkIntToScalar(dashLength), SkIntToScalar(dashLength) };
-        fPathEffect.reset(SkDashPathEffect::Create(vals, 2, SK_Scalar1));
+        fPathEffect = SkDashPathEffect::Make(vals, 2, SK_Scalar1);
     }
 
 protected:
@@ -301,7 +299,7 @@
     SkString fName;
     SkScalar fStrokeWidth;
     SkPoint  fPts[2];
-    SkAutoTUnref<SkPathEffect> fPathEffect;
+    sk_sp<SkPathEffect> fPathEffect;
 
 public:
     enum LineType {
@@ -324,8 +322,7 @@
         // deliberately pick intervals that won't be caught by asPoints(), so
         // we can test the filterPath code-path.
         const SkScalar intervals[] = { 20, 10, 10, 10 };
-        fPathEffect.reset(SkDashPathEffect::Create(intervals,
-                                                   SK_ARRAY_COUNT(intervals), 0));
+        fPathEffect = SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 0);
 
         SkScalar cx = 640 / 2;  // center X
         SkScalar cy = 480 / 2;  // center Y
@@ -381,7 +378,7 @@
     int      fStrokeWidth;
     bool     fDoAA;
 
-    SkAutoTUnref<SkPathEffect> fPathEffect;
+    sk_sp<SkPathEffect> fPathEffect;
 
 public:
     DashGridBench(int dashLength, int strokeWidth, bool doAA) {
@@ -390,7 +387,7 @@
         fDoAA = doAA;
 
         SkScalar vals[] = { SkIntToScalar(dashLength), SkIntToScalar(dashLength) };
-        fPathEffect.reset(SkDashPathEffect::Create(vals, 2, SK_Scalar1));
+        fPathEffect = SkDashPathEffect::Make(vals, 2, SK_Scalar1);
     }
 
 protected:
diff --git a/gm/arcto.cpp b/gm/arcto.cpp
index 584fca3..fcbc3d5 100644
--- a/gm/arcto.cpp
+++ b/gm/arcto.cpp
@@ -223,6 +223,6 @@
   SkScalar length = meas.getLength();
   SkScalar intervals[] = {0, length };
   int intervalCount = (int) SK_ARRAY_COUNT(intervals);
-  p.setPathEffect(SkDashPathEffect::Create(intervals, intervalCount, 0))->unref();
+  p.setPathEffect(SkDashPathEffect::Make(intervals, intervalCount, 0));
   canvas->drawPath(path, p);
 }
diff --git a/gm/bug530095.cpp b/gm/bug530095.cpp
index 76f6bc8..fa88c01 100644
--- a/gm/bug530095.cpp
+++ b/gm/bug530095.cpp
@@ -20,13 +20,13 @@
     paint.setStrokeWidth(26);
     SkScalar intervals[] = {700, 700 };
     int intervalCount = (int) SK_ARRAY_COUNT(intervals);
-    paint.setPathEffect(SkDashPathEffect::Create(intervals, intervalCount, -40))->unref();
+    paint.setPathEffect(SkDashPathEffect::Make(intervals, intervalCount, -40));
     canvas->drawPath(path1, paint);
 
     paint.setStrokeWidth(0.26f);
     SkScalar smIntervals[] = {7, 7 };
     int smIntervalCount = (int) SK_ARRAY_COUNT(smIntervals);
-    paint.setPathEffect(SkDashPathEffect::Create(smIntervals, smIntervalCount, -0.40f))->unref();
+    paint.setPathEffect(SkDashPathEffect::Make(smIntervals, smIntervalCount, -0.40f));
     canvas->save();
     canvas->scale(100, 100);
     canvas->translate(4, 0);
@@ -34,14 +34,14 @@
     canvas->restore();
 
     paint.setStrokeWidth(26);
-    paint.setPathEffect(SkDashPathEffect::Create(intervals, intervalCount, 0))->unref();
+    paint.setPathEffect(SkDashPathEffect::Make(intervals, intervalCount, 0));
     canvas->save();
     canvas->translate(0, 400);
     canvas->drawPath(path1, paint);
     canvas->restore();
 
     paint.setStrokeWidth(0.26f);
-    paint.setPathEffect(SkDashPathEffect::Create(smIntervals, smIntervalCount, 0))->unref();
+    paint.setPathEffect(SkDashPathEffect::Make(smIntervals, smIntervalCount, 0));
     canvas->scale(100, 100);
     canvas->translate(4, 4);
     canvas->drawPath(path2, paint);
@@ -54,8 +54,7 @@
     p.setStyle(SkPaint::kStroke_Style);
     p.setStrokeCap(SkPaint::kRound_Cap);
     p.setStrokeWidth(10);
-    SkScalar intervals[] = { 100, 100 };
-    SkPathEffect* dash = SkDashPathEffect::Create(intervals, SK_ARRAY_COUNT(intervals), 100);
-    p.setPathEffect(dash)->unref();
+    const SkScalar intervals[] = { 100, 100 };
+    p.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 100));
     canvas->drawLine(20, 20, 120, 20, p);
 }
diff --git a/gm/dashcircle.cpp b/gm/dashcircle.cpp
index cddd913..a02c7d0 100644
--- a/gm/dashcircle.cpp
+++ b/gm/dashcircle.cpp
@@ -68,7 +68,7 @@
             for (int index = 0; index < dashExample.length; ++index) {
                 intervals[index] = dashExample.pattern[index] * dashLength;
             }
-            p.setPathEffect(SkDashPathEffect::Create(intervals, intervalCount, 0))->unref();
+            p.setPathEffect(SkDashPathEffect::Make(intervals, intervalCount, 0));
             canvas->drawPath(circle, p);
             canvas->translate(0, radius * 2 + 50);
         }
diff --git a/gm/dashcubics.cpp b/gm/dashcubics.cpp
index 1773303..7736f2b 100644
--- a/gm/dashcubics.cpp
+++ b/gm/dashcubics.cpp
@@ -14,26 +14,24 @@
 /*
  *  Inspired by http://code.google.com/p/chromium/issues/detail?id=112145
  */
-static void flower(SkCanvas* canvas, const SkPath& path,
-                   SkScalar intervals[2], SkPaint::Join join) {
-        SkPathEffect* pe = SkDashPathEffect::Create(intervals, 2, 0);
+static void flower(SkCanvas* canvas, const SkPath& path, SkScalar intervals[2],
+                   SkPaint::Join join) {
+    SkPaint paint;
+    paint.setAntiAlias(true);
+    paint.setStyle(SkPaint::kStroke_Style);
+    paint.setStrokeJoin(join);
+    paint.setStrokeWidth(42);
+    canvas->drawPath(path, paint);
 
-        SkPaint paint;
-        paint.setAntiAlias(true);
-        paint.setStyle(SkPaint::kStroke_Style);
-        paint.setStrokeJoin(join);
-        paint.setStrokeWidth(42);
-        canvas->drawPath(path, paint);
+    paint.setColor(SK_ColorRED);
+    paint.setStrokeWidth(21);
+    paint.setPathEffect(SkDashPathEffect::Make(intervals, 2, 0));
+    canvas->drawPath(path, paint);
 
-        paint.setColor(SK_ColorRED);
-        paint.setStrokeWidth(21);
-        paint.setPathEffect(pe)->unref();
-        canvas->drawPath(path, paint);
-
-        paint.setColor(SK_ColorGREEN);
-        paint.setPathEffect(nullptr);
-        paint.setStrokeWidth(0);
-        canvas->drawPath(path, paint);
+    paint.setColor(SK_ColorGREEN);
+    paint.setPathEffect(nullptr);
+    paint.setStrokeWidth(0);
+    canvas->drawPath(path, paint);
 }
 
 DEF_SIMPLE_GM(dashcubics, canvas, 860, 700) {
diff --git a/gm/dashing.cpp b/gm/dashing.cpp
index c728d15..6cb1dea 100644
--- a/gm/dashing.cpp
+++ b/gm/dashing.cpp
@@ -21,8 +21,7 @@
         SkIntToScalar(off),
     };
 
-    SkAutoTUnref<SkPathEffect> effect(SkDashPathEffect::Create(intervals, 2, phase));
-    p.setPathEffect(effect);
+    p.setPathEffect(SkDashPathEffect::Make(intervals, 2, phase));
     canvas->drawLine(startX, startY, finalX, finalY, p);
 }
 
@@ -175,7 +174,7 @@
                 vals[i] = SkIntToScalar(*intervals++);
             }
             SkScalar phase = vals[0] / 2;
-            paint.setPathEffect(SkDashPathEffect::Create(vals, count, phase))->unref();
+            paint.setPathEffect(SkDashPathEffect::Make(vals, count, phase));
 
             for (size_t x = 0; x < SK_ARRAY_COUNT(gProc); ++x) {
                 SkPath path;
@@ -223,7 +222,7 @@
 
         SkScalar intervals[2] = { dashLength, dashLength };
 
-        p.setPathEffect(SkDashPathEffect::Create(intervals, 2, phase))->unref();
+        p.setPathEffect(SkDashPathEffect::Make(intervals, 2, phase));
 
         SkPoint pts[2];
 
@@ -499,7 +498,7 @@
     p.setStyle(SkPaint::kStroke_Style);
     p.setStrokeWidth(1);
     const SkScalar intervals[] = { 1, 1 };
-    p.setPathEffect(SkDashPathEffect::Create(intervals, SK_ARRAY_COUNT(intervals), 0))->unref();
+    p.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 0));
     canvas->drawPath(lines, p);
 }
 
@@ -510,7 +509,7 @@
     p.setStrokeWidth(80);
 
     const SkScalar intervals[] = { 2, 2 };
-    p.setPathEffect(SkDashPathEffect::Create(intervals, SK_ARRAY_COUNT(intervals), 0))->unref();
+    p.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 0));
     canvas->drawRect(SkRect::MakeXYWH(-10000, 100, 20000, 20), p);
 }
 
@@ -540,7 +539,7 @@
     p.setARGB(0xff, 0xbb, 0x00, 0x00);
     sk_tool_utils::set_portable_typeface(&p);
     const SkScalar intervals[] = { 12, 12 };
-    p.setPathEffect(SkDashPathEffect::Create(intervals, SK_ARRAY_COUNT(intervals), 0))->unref();
+    p.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 0));
     canvas->drawText("Sausages", 8, 10, 90, p);
     canvas->drawLine(8, 120, 456, 120, p);
 }
diff --git a/gm/pathcontourstart.cpp b/gm/pathcontourstart.cpp
index de3644c..dbda7c3 100644
--- a/gm/pathcontourstart.cpp
+++ b/gm/pathcontourstart.cpp
@@ -26,14 +26,11 @@
             intervals.push_back(len);
         }
 
-        SkAutoTUnref<SkPathEffect> effect(
-            SkDashPathEffect::Create(intervals.begin(), intervals.count(), 0));
-
         fDashPaint.setAntiAlias(true);
         fDashPaint.setStyle(SkPaint::kStroke_Style);
         fDashPaint.setStrokeWidth(6);
         fDashPaint.setColor(0xff008000);
-        fDashPaint.setPathEffect(effect);
+        fDashPaint.setPathEffect(SkDashPathEffect::Make(intervals.begin(), intervals.count(), 0));
 
         fPointsPaint.setColor(0xff800000);
         fPointsPaint.setStrokeWidth(3);
diff --git a/gm/patheffects.cpp b/gm/patheffects.cpp
index 517d02e..9821b3a 100644
--- a/gm/patheffects.cpp
+++ b/gm/patheffects.cpp
@@ -17,15 +17,14 @@
 
 static void compose_pe(SkPaint* paint) {
     SkPathEffect* pe = paint->getPathEffect();
-    SkPathEffect* corner = SkCornerPathEffect::Create(25);
-    SkPathEffect* compose;
+    sk_sp<SkPathEffect> corner = SkCornerPathEffect::Make(25);
+    sk_sp<SkPathEffect> compose;
     if (pe) {
-        compose = SkComposePathEffect::Create(pe, corner);
-        corner->unref();
+        compose = SkComposePathEffect::Make(sk_ref_sp(pe), corner);
     } else {
         compose = corner;
     }
-    paint->setPathEffect(compose)->unref();
+    paint->setPathEffect(compose);
 }
 
 static void hair_pe(SkPaint* paint) {
@@ -45,8 +44,7 @@
 static void dash_pe(SkPaint* paint) {
     SkScalar inter[] = { 20, 10, 10, 10 };
     paint->setStrokeWidth(12);
-    paint->setPathEffect(SkDashPathEffect::Create(inter, SK_ARRAY_COUNT(inter),
-                                                  0))->unref();
+    paint->setPathEffect(SkDashPathEffect::Make(inter, SK_ARRAY_COUNT(inter), 0));
     compose_pe(paint);
 }
 
@@ -69,8 +67,8 @@
     path.offset(SkIntToScalar(-6), 0);
     scale(&path, 1.5f);
 
-    paint->setPathEffect(SkPath1DPathEffect::Create(path, SkIntToScalar(21), 0,
-                                SkPath1DPathEffect::kRotate_Style))->unref();
+    paint->setPathEffect(SkPath1DPathEffect::Make(path, SkIntToScalar(21), 0,
+                                                  SkPath1DPathEffect::kRotate_Style));
     compose_pe(paint);
 }
 
@@ -83,21 +81,21 @@
 }
 
 static void discrete_pe(SkPaint* paint) {
-    paint->setPathEffect(SkDiscretePathEffect::Create(10, 4))->unref();
+    paint->setPathEffect(SkDiscretePathEffect::Make(10, 4));
 }
 
-static SkPathEffect* MakeTileEffect() {
+static sk_sp<SkPathEffect> MakeTileEffect() {
     SkMatrix m;
     m.setScale(SkIntToScalar(12), SkIntToScalar(12));
 
     SkPath path;
     path.addCircle(0, 0, SkIntToScalar(5));
 
-    return SkPath2DPathEffect::Create(m, path);
+    return SkPath2DPathEffect::Make(m, path);
 }
 
 static void tile_pe(SkPaint* paint) {
-    paint->setPathEffect(MakeTileEffect())->unref();
+    paint->setPathEffect(MakeTileEffect());
 }
 
 static const PE_Proc gPE2[] = { fill_pe, discrete_pe, tile_pe };
diff --git a/gm/strokes.cpp b/gm/strokes.cpp
index 261db9c..f64a876 100644
--- a/gm/strokes.cpp
+++ b/gm/strokes.cpp
@@ -128,7 +128,7 @@
             canvas->drawPath(fMoveZfPath, strokePaint);
             dashPaint = strokePaint;
             const SkScalar intervals[] = { 0, 10 };
-            dashPaint.setPathEffect(SkDashPathEffect::Create(intervals, 2, 0))->unref();
+            dashPaint.setPathEffect(SkDashPathEffect::Make(intervals, 2, 0));
             SkPath fillPath;
             dashPaint.getFillPath(fDashedfPath, &fillPath);
             canvas->translate(0, 20);
diff --git a/gm/stroketext.cpp b/gm/stroketext.cpp
index d0a9882..b247d8a 100644
--- a/gm/stroketext.cpp
+++ b/gm/stroketext.cpp
@@ -55,7 +55,7 @@
 
     canvas->translate(200, 0);
     SkPaint p(paint);
-    p.setPathEffect(SkDashPathEffect::Create(intervals, SK_ARRAY_COUNT(intervals), phase))->unref();
+    p.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), phase));
     draw_text_stroked(canvas, p, 10);
 }
 
diff --git a/gm/textbloblooper.cpp b/gm/textbloblooper.cpp
index 8d462c9..d544902 100644
--- a/gm/textbloblooper.cpp
+++ b/gm/textbloblooper.cpp
@@ -66,18 +66,18 @@
     paint->setMaskFilter(mf)->unref();
 }
 
-static SkPathEffect* make_tile_effect() {
+static sk_sp<SkPathEffect> make_tile_effect() {
     SkMatrix m;
     m.setScale(1.f, 1.f);
 
     SkPath path;
     path.addCircle(0, 0, SkIntToScalar(5));
 
-    return SkPath2DPathEffect::Create(m, path);
+    return SkPath2DPathEffect::Make(m, path);
 }
 
 static void path_effect(SkPaint* paint) {
-    paint->setPathEffect(make_tile_effect())->unref();
+    paint->setPathEffect(make_tile_effect());
 }
 
 static sk_sp<SkShader> make_shader(const SkRect& bounds) {
diff --git a/gm/texteffects.cpp b/gm/texteffects.cpp
index 6ad3d23..aa3d375 100644
--- a/gm/texteffects.cpp
+++ b/gm/texteffects.cpp
@@ -77,7 +77,7 @@
 static void r5(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
     rastBuilder->addLayer(p);
 
-    p.setPathEffect(SkDiscretePathEffect::Create(SK_Scalar1*4, SK_Scalar1*3))->unref();
+    p.setPathEffect(SkDiscretePathEffect::Make(SK_Scalar1*4, SK_Scalar1*3));
     p.setXfermodeMode(SkXfermode::kSrcOut_Mode);
     rastBuilder->addLayer(p);
 }
@@ -95,17 +95,17 @@
 
 #include "Sk2DPathEffect.h"
 
-static SkPathEffect* MakeDotEffect(SkScalar radius, const SkMatrix& matrix) {
+static sk_sp<SkPathEffect> MakeDotEffect(SkScalar radius, const SkMatrix& matrix) {
     SkPath path;
     path.addCircle(0, 0, radius);
-    return SkPath2DPathEffect::Create(matrix, path);
+    return SkPath2DPathEffect::Make(matrix, path);
 }
 
 static void r7(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
     SkMatrix    lattice;
     lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0);
     lattice.postSkew(SK_Scalar1/3, 0, 0, 0);
-    p.setPathEffect(MakeDotEffect(SK_Scalar1*4, lattice))->unref();
+    p.setPathEffect(MakeDotEffect(SK_Scalar1*4, lattice));
     rastBuilder->addLayer(p);
 }
 
@@ -115,7 +115,7 @@
     SkMatrix    lattice;
     lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0);
     lattice.postSkew(SK_Scalar1/3, 0, 0, 0);
-    p.setPathEffect(MakeDotEffect(SK_Scalar1*2, lattice))->unref();
+    p.setPathEffect(MakeDotEffect(SK_Scalar1*2, lattice));
     p.setXfermodeMode(SkXfermode::kClear_Mode);
     rastBuilder->addLayer(p);
 
@@ -132,7 +132,7 @@
     SkMatrix    lattice;
     lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0);
     lattice.postRotate(SkIntToScalar(30), 0, 0);
-    p.setPathEffect(SkLine2DPathEffect::Create(SK_Scalar1*2, lattice))->unref();
+    p.setPathEffect(SkLine2DPathEffect::Make(SK_Scalar1*2, lattice));
     p.setXfermodeMode(SkXfermode::kClear_Mode);
     rastBuilder->addLayer(p);
 
diff --git a/gyp/skia_for_android_framework_defines.gypi b/gyp/skia_for_android_framework_defines.gypi
index 10995f4..d6324bd 100644
--- a/gyp/skia_for_android_framework_defines.gypi
+++ b/gyp/skia_for_android_framework_defines.gypi
@@ -20,6 +20,7 @@
       'SK_SUPPORT_LEGACY_GRADIENT_DITHERING',
       'SK_SUPPORT_LEGACY_DRAWFILTER',
       'SK_SUPPORT_LEGACY_CREATESHADER_PTR',
+      'SK_SUPPORT_LEGACY_PATHEFFECT_PTR',
     ],
   },
 }
diff --git a/include/core/SkPaint.h b/include/core/SkPaint.h
index 39ee1e0..8266eaa 100644
--- a/include/core/SkPaint.h
+++ b/include/core/SkPaint.h
@@ -561,8 +561,10 @@
                         paint
         @return         effect
     */
-    SkPathEffect* setPathEffect(SkPathEffect* effect);
     void setPathEffect(sk_sp<SkPathEffect>);
+#ifdef SK_SUPPORT_LEGACY_PATHEFFECT_PTR
+    SkPathEffect* setPathEffect(SkPathEffect* effect);
+#endif
 
     /** Get the paint's maskfilter object.
         <p />
diff --git a/include/core/SkPathEffect.h b/include/core/SkPathEffect.h
index a77b946..fd59573 100644
--- a/include/core/SkPathEffect.h
+++ b/include/core/SkPathEffect.h
@@ -154,16 +154,14 @@
     for managing the lifetimes of its two arguments.
 */
 class SkPairPathEffect : public SkPathEffect {
-public:
-    virtual ~SkPairPathEffect();
-
 protected:
-    SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1);
+    SkPairPathEffect(sk_sp<SkPathEffect> pe0, sk_sp<SkPathEffect> pe1);
 
     void flatten(SkWriteBuffer&) const override;
 
     // these are visible to our subclasses
-    SkPathEffect* fPE0, *fPE1;
+    sk_sp<SkPathEffect> fPE0;
+    sk_sp<SkPathEffect> fPE1;
 
     SK_TO_STRING_OVERRIDE()
 
@@ -183,16 +181,22 @@
         The reference counts for outer and inner are both incremented in the constructor,
         and decremented in the destructor.
     */
-    static SkPathEffect* Create(SkPathEffect* outer, SkPathEffect* inner) {
+    static sk_sp<SkPathEffect> Make(sk_sp<SkPathEffect> outer, sk_sp<SkPathEffect> inner) {
         if (!outer) {
-            return SkSafeRef(inner);
+            return inner;
         }
         if (!inner) {
-            return SkSafeRef(outer);
+            return outer;
         }
-        return new SkComposePathEffect(outer, inner);
+        return sk_sp<SkPathEffect>(new SkComposePathEffect(outer, inner));
     }
 
+#ifdef SK_SUPPORT_LEGACY_PATHEFFECT_PTR
+    static SkPathEffect* Create(SkPathEffect* outer, SkPathEffect* inner) {
+        return Make(sk_ref_sp(outer), sk_ref_sp(inner)).release();
+    }
+#endif
+
     virtual bool filterPath(SkPath* dst, const SkPath& src,
                             SkStrokeRec*, const SkRect*) const override;
 
@@ -204,7 +208,8 @@
 #endif
 
 protected:
-    SkComposePathEffect(SkPathEffect* outer, SkPathEffect* inner) : INHERITED(outer, inner) {}
+    SkComposePathEffect(sk_sp<SkPathEffect> outer, sk_sp<SkPathEffect> inner)
+        : INHERITED(outer, inner) {}
 
 private:
     // illegal
@@ -226,16 +231,21 @@
         The reference counts for first and second are both incremented in the constructor,
         and decremented in the destructor.
     */
-    static SkPathEffect* Create(SkPathEffect* first, SkPathEffect* second) {
+    static sk_sp<SkPathEffect> Make(sk_sp<SkPathEffect> first, sk_sp<SkPathEffect> second) {
         if (!first) {
-            return SkSafeRef(second);
+            return second;
         }
         if (!second) {
-            return SkSafeRef(first);
+            return first;
         }
-        return new SkSumPathEffect(first, second);
+        return sk_sp<SkPathEffect>(new SkSumPathEffect(first, second));
     }
 
+#ifdef SK_SUPPORT_LEGACY_PATHEFFECT_PTR
+    static SkPathEffect* Create(SkPathEffect* first, SkPathEffect* second) {
+        return Make(sk_ref_sp(first), sk_ref_sp(second)).release();
+    }
+#endif
     virtual bool filterPath(SkPath* dst, const SkPath& src,
                             SkStrokeRec*, const SkRect*) const override;
 
@@ -247,7 +257,8 @@
 #endif
 
 protected:
-    SkSumPathEffect(SkPathEffect* first, SkPathEffect* second) : INHERITED(first, second) {}
+    SkSumPathEffect(sk_sp<SkPathEffect> first, sk_sp<SkPathEffect> second)
+        : INHERITED(first, second) {}
 
 private:
     // illegal
diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h
index d7a7911..796180f 100644
--- a/include/core/SkTypes.h
+++ b/include/core/SkTypes.h
@@ -15,6 +15,10 @@
 #include <stddef.h>
 #include <stdint.h>
 
+#ifndef SK_SUPPORT_LEGACY_PATHEFFECT_PTR
+    #define SK_SUPPORT_LEGACY_PATHEFFECT_PTR
+#endif
+
 #if defined(SK_ARM_HAS_NEON)
     #include <arm_neon.h>
 #elif SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2
diff --git a/include/effects/Sk1DPathEffect.h b/include/effects/Sk1DPathEffect.h
index 03c6966..d5315a8 100644
--- a/include/effects/Sk1DPathEffect.h
+++ b/include/effects/Sk1DPathEffect.h
@@ -56,7 +56,13 @@
         @param style how to transform path at each point (based on the current
                      position and tangent)
     */
-    static SkPathEffect* Create(const SkPath& path, SkScalar advance, SkScalar phase, Style);
+    static sk_sp<SkPathEffect> Make(const SkPath& path, SkScalar advance, SkScalar phase, Style);
+
+#ifdef SK_SUPPORT_LEGACY_PATHEFFECT_PTR
+    static SkPathEffect* Create(const SkPath& path, SkScalar advance, SkScalar phase, Style s) {
+        return Make(path, advance, phase, s).release();
+    }
+#endif
 
     virtual bool filterPath(SkPath*, const SkPath&,
                             SkStrokeRec*, const SkRect*) const override;
diff --git a/include/effects/Sk2DPathEffect.h b/include/effects/Sk2DPathEffect.h
index 73da83c..823a6ad 100644
--- a/include/effects/Sk2DPathEffect.h
+++ b/include/effects/Sk2DPathEffect.h
@@ -55,8 +55,8 @@
 
 class SK_API SkLine2DPathEffect : public Sk2DPathEffect {
 public:
-    static SkPathEffect* Create(SkScalar width, const SkMatrix& matrix) {
-        return new SkLine2DPathEffect(width, matrix);
+    static sk_sp<SkPathEffect> Make(SkScalar width, const SkMatrix& matrix) {
+        return sk_sp<SkPathEffect>(new SkLine2DPathEffect(width, matrix));
     }
 
     virtual bool filterPath(SkPath* dst, const SkPath& src,
@@ -84,8 +84,8 @@
      *  Stamp the specified path to fill the shape, using the matrix to define
      *  the latice.
      */
-    static SkPathEffect* Create(const SkMatrix& matrix, const SkPath& path) {
-        return new SkPath2DPathEffect(matrix, path);
+    static sk_sp<SkPathEffect> Make(const SkMatrix& matrix, const SkPath& path) {
+        return sk_sp<SkPathEffect>(new SkPath2DPathEffect(matrix, path));
     }
 
     SK_TO_STRING_OVERRIDE()
diff --git a/include/effects/SkArcToPathEffect.h b/include/effects/SkArcToPathEffect.h
index 4716ea1..fcf4a3a 100644
--- a/include/effects/SkArcToPathEffect.h
+++ b/include/effects/SkArcToPathEffect.h
@@ -15,11 +15,11 @@
     /** radius must be > 0 to have an effect. It specifies the distance from each corner
         that should be "rounded".
     */
-    static SkPathEffect* Create(SkScalar radius) {
+    static sk_sp<SkPathEffect> Make(SkScalar radius) {
         if (radius <= 0) {
             return NULL;
         }
-        return new SkArcToPathEffect(radius);
+        return sk_sp<SkPathEffect>(new SkArcToPathEffect(radius));
     }
 
     bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override;
diff --git a/include/effects/SkCornerPathEffect.h b/include/effects/SkCornerPathEffect.h
index 13095f0..cf03463 100644
--- a/include/effects/SkCornerPathEffect.h
+++ b/include/effects/SkCornerPathEffect.h
@@ -20,7 +20,15 @@
     /** radius must be > 0 to have an effect. It specifies the distance from each corner
         that should be "rounded".
     */
-    static SkPathEffect* Create(SkScalar radius) { return new SkCornerPathEffect(radius); }
+    static sk_sp<SkPathEffect> Make(SkScalar radius) {
+        return sk_sp<SkPathEffect>(new SkCornerPathEffect(radius));
+    }
+
+#ifdef SK_SUPPORT_LEGACY_PATHEFFECT_PTR
+    static SkPathEffect* Create(SkScalar radius) {
+        return Make(radius).release();
+    }
+#endif
 
     virtual bool filterPath(SkPath* dst, const SkPath& src,
                             SkStrokeRec*, const SkRect*) const override;
diff --git a/include/effects/SkDashPathEffect.h b/include/effects/SkDashPathEffect.h
index 08b0a46..ccb1a4e 100644
--- a/include/effects/SkDashPathEffect.h
+++ b/include/effects/SkDashPathEffect.h
@@ -36,7 +36,13 @@
 
         Note: only affects stroked paths.
     */
-    static SkPathEffect* Create(const SkScalar intervals[], int count, SkScalar phase);
+    static sk_sp<SkPathEffect> Make(const SkScalar intervals[], int count, SkScalar phase);
+
+#ifdef SK_SUPPORT_LEGACY_PATHEFFECT_PTR
+    static SkPathEffect* Create(const SkScalar intervals[], int count, SkScalar phase) {
+        return Make(intervals, count, phase).release();
+    }
+#endif
 
     virtual bool filterPath(SkPath* dst, const SkPath& src,
                             SkStrokeRec*, const SkRect*) const override;
diff --git a/include/effects/SkDiscretePathEffect.h b/include/effects/SkDiscretePathEffect.h
index a49e2d8..78d4516 100644
--- a/include/effects/SkDiscretePathEffect.h
+++ b/include/effects/SkDiscretePathEffect.h
@@ -29,9 +29,13 @@
                           they can pass in a different seedAssist to get a
                           different set of path segments.
     */
+    static sk_sp<SkPathEffect> Make(SkScalar segLength, SkScalar dev, uint32_t seedAssist = 0);
+
+#ifdef SK_SUPPORT_LEGACY_PATHEFFECT_PTR
     static SkPathEffect* Create(SkScalar segLength, SkScalar deviation, uint32_t seedAssist = 0) {
-        return new SkDiscretePathEffect(segLength, deviation, seedAssist);
+        return Make(segLength, deviation, seedAssist).release();
     }
+#endif
 
     virtual bool filterPath(SkPath* dst, const SkPath& src,
                             SkStrokeRec*, const SkRect*) const override;
diff --git a/samplecode/ClockFaceView.cpp b/samplecode/ClockFaceView.cpp
index 11684e1..f5b43fb 100644
--- a/samplecode/ClockFaceView.cpp
+++ b/samplecode/ClockFaceView.cpp
@@ -132,16 +132,16 @@
 
 SkFlattenable* InverseFillPE::CreateProc(SkReadBuffer& buffer) { return new InverseFillPE; }
 
-static SkPathEffect* makepe(float interp, SkTDArray<SkPoint>* pts) {
+static sk_sp<SkPathEffect> makepe(float interp, SkTDArray<SkPoint>* pts) {
     SkMatrix    lattice;
     SkScalar    rad = 3 + SkIntToScalar(4) * (1 - interp);
     lattice.setScale(rad*2, rad*2, 0, 0);
     lattice.postSkew(SK_Scalar1/3, 0, 0, 0);
-    return new Dot2DPathEffect(rad, lattice, pts);
+    return sk_make_sp<Dot2DPathEffect>(rad, lattice, pts);
 }
 
 static void r7(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p, SkScalar interp) {
-    p.setPathEffect(makepe(SkScalarToFloat(interp), nullptr))->unref();
+    p.setPathEffect(makepe(SkScalarToFloat(interp), nullptr));
     rastBuilder->addLayer(p);
 #if 0
     p.setPathEffect(new InverseFillPE())->unref();
@@ -201,7 +201,7 @@
 
     static void drawdots(SkCanvas* canvas, const SkPaint& orig) {
         SkTDArray<SkPoint> pts;
-        SkPathEffect* pe = makepe(0, &pts);
+        auto pe = makepe(0, &pts);
 
         SkStrokeRec rec(SkStrokeRec::kFill_InitStyle);
         SkPath path, dstPath;
@@ -212,8 +212,7 @@
         p.setAntiAlias(true);
         p.setStrokeWidth(10);
         p.setColor(SK_ColorRED);
-        canvas->drawPoints(SkCanvas::kPoints_PointMode, pts.count(), pts.begin(),
-                           p);
+        canvas->drawPoints(SkCanvas::kPoints_PointMode, pts.count(), pts.begin(), p);
     }
 
     virtual void onDraw(SkCanvas* canvas) {
diff --git a/samplecode/SampleAll.cpp b/samplecode/SampleAll.cpp
index 90fc5bd..7c0557f 100644
--- a/samplecode/SampleAll.cpp
+++ b/samplecode/SampleAll.cpp
@@ -141,7 +141,7 @@
 static void r5(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
     rastBuilder->addLayer(p);
 
-    p.setPathEffect(SkDiscretePathEffect::Create(SK_Scalar1*4, SK_Scalar1*3))->unref();
+    p.setPathEffect(SkDiscretePathEffect::Make(SK_Scalar1*4, SK_Scalar1*3));
     p.setXfermodeMode(SkXfermode::kSrcOut_Mode);
     rastBuilder->addLayer(p);
 }
@@ -184,7 +184,7 @@
     SkMatrix    lattice;
     lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0);
     lattice.postSkew(SK_Scalar1/3, 0, 0, 0);
-    p.setPathEffect(new Dot2DPathEffect(SK_Scalar1*4, lattice))->unref();
+    p.setPathEffect(sk_make_sp<Dot2DPathEffect>(SK_Scalar1*4, lattice));
     rastBuilder->addLayer(p);
 }
 
@@ -194,7 +194,7 @@
     SkMatrix    lattice;
     lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0);
     lattice.postSkew(SK_Scalar1/3, 0, 0, 0);
-    p.setPathEffect(new Dot2DPathEffect(SK_Scalar1*2, lattice))->unref();
+    p.setPathEffect(sk_make_sp<Dot2DPathEffect>(SK_Scalar1*2, lattice));
     p.setXfermodeMode(SkXfermode::kClear_Mode);
     rastBuilder->addLayer(p);
 
@@ -211,7 +211,7 @@
     SkMatrix    lattice;
     lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0);
     lattice.postRotate(SkIntToScalar(30), 0, 0);
-    p.setPathEffect(SkLine2DPathEffect::Create(SK_Scalar1*2, lattice))->unref();
+    p.setPathEffect(SkLine2DPathEffect::Make(SK_Scalar1*2, lattice));
     p.setXfermodeMode(SkXfermode::kClear_Mode);
     rastBuilder->addLayer(p);
 
@@ -416,7 +416,7 @@
         canvas->translate(SkIntToScalar(50), 0);
         paint.setColor(SK_ColorYELLOW);
         paint.setShader(linear);
-        paint.setPathEffect(pathEffectTest())->unref();
+        paint.setPathEffect(pathEffectTest());
         canvas->drawRect(rect, paint);
         paint.setPathEffect(nullptr);
 
@@ -481,7 +481,7 @@
         return this->INHERITED::onFindClickHandler(x, y, modi);
     }
 
-    SkPathEffect* pathEffectTest() {
+    sk_sp<SkPathEffect> pathEffectTest() {
         static const int gXY[] = { 1, 0, 0, -1, 2, -1, 3, 0, 2, 1, 0, 1 };
         SkScalar gPhase = 0;
         SkPath path;
@@ -490,14 +490,11 @@
             path.lineTo(SkIntToScalar(gXY[i]), SkIntToScalar(gXY[i+1]));
         path.close();
         path.offset(SkIntToScalar(-6), 0);
-        SkPathEffect* outer = SkPath1DPathEffect::Create(path, SkIntToScalar(12),
+        auto outer = SkPath1DPathEffect::Make(path, SkIntToScalar(12),
             gPhase, SkPath1DPathEffect::kRotate_Style);
-        SkPathEffect* inner = SkDiscretePathEffect::Create(SkIntToScalar(2),
+        auto inner = SkDiscretePathEffect::Make(SkIntToScalar(2),
             SkIntToScalar(1)/10); // SkCornerPathEffect(SkIntToScalar(2));
-        SkPathEffect* result = SkComposePathEffect::Create(outer, inner);
-        outer->unref();
-        inner->unref();
-        return result;
+        return SkComposePathEffect::Make(outer, inner);
     }
 
     sk_sp<SkShader> shaderTest() {
diff --git a/samplecode/SampleFilterFuzz.cpp b/samplecode/SampleFilterFuzz.cpp
index 0dd01e9..fe2fb0b 100644
--- a/samplecode/SampleFilterFuzz.cpp
+++ b/samplecode/SampleFilterFuzz.cpp
@@ -422,22 +422,20 @@
     return path;
 }
 
-static SkPathEffect* make_path_effect(bool canBeNull = true) {
-    SkPathEffect* pathEffect = nullptr;
+static sk_sp<SkPathEffect> make_path_effect(bool canBeNull = true) {
+    sk_sp<SkPathEffect> pathEffect;
     if (canBeNull && (R(3) == 1)) { return pathEffect; }
 
     switch (R(9)) {
         case 0:
-            pathEffect = SkArcToPathEffect::Create(make_scalar(true));
+            pathEffect = SkArcToPathEffect::Make(make_scalar(true));
             break;
-        case 1: {
-            SkAutoTUnref<SkPathEffect> outer(make_path_effect(false));
-            SkAutoTUnref<SkPathEffect> inner(make_path_effect(false));
-            pathEffect = SkComposePathEffect::Create(outer, inner);
+        case 1:
+            pathEffect = SkComposePathEffect::Make(make_path_effect(false),
+                                                   make_path_effect(false));
             break;
-        }
         case 2:
-            pathEffect = SkCornerPathEffect::Create(make_scalar());
+            pathEffect = SkCornerPathEffect::Make(make_scalar());
             break;
         case 3: {
             int count = R(10);
@@ -445,28 +443,26 @@
             for (int i = 0; i < count; ++i) {
                 intervals[i] = make_scalar();
             }
-            pathEffect = SkDashPathEffect::Create(intervals, count, make_scalar());
+            pathEffect = SkDashPathEffect::Make(intervals, count, make_scalar());
             break;
         }
         case 4:
-            pathEffect = SkDiscretePathEffect::Create(make_scalar(), make_scalar());
+            pathEffect = SkDiscretePathEffect::Make(make_scalar(), make_scalar());
             break;
         case 5:
-            pathEffect = SkPath1DPathEffect::Create(make_path(),
-                                                    make_scalar(),
-                                                    make_scalar(),
-                                                    make_path_1d_path_effect_style());
+            pathEffect = SkPath1DPathEffect::Make(make_path(), make_scalar(), make_scalar(),
+                                                  make_path_1d_path_effect_style());
             break;
         case 6:
-            pathEffect = SkLine2DPathEffect::Create(make_scalar(), make_matrix());
+            pathEffect = SkLine2DPathEffect::Make(make_scalar(), make_matrix());
             break;
         case 7:
-            pathEffect = SkPath2DPathEffect::Create(make_matrix(), make_path());
+            pathEffect = SkPath2DPathEffect::Make(make_matrix(), make_path());
             break;
         case 8:
         default:
-            pathEffect = SkSumPathEffect::Create(make_path_effect(false),
-                                                 make_path_effect(false));
+            pathEffect = SkSumPathEffect::Make(make_path_effect(false),
+                                               make_path_effect(false));
             break;
     }
     return pathEffect;
diff --git a/samplecode/SamplePath.cpp b/samplecode/SamplePath.cpp
index c977ca0..9ef1c85 100644
--- a/samplecode/SamplePath.cpp
+++ b/samplecode/SamplePath.cpp
@@ -254,13 +254,13 @@
         fArcToPaint.setStyle(SkPaint::kStroke_Style);
         fArcToPaint.setStrokeWidth(9);
         fArcToPaint.setColor(0x800000FF);
-        fArcToPaint.setPathEffect(SkArcToPathEffect::Create(rad))->unref();
+        fArcToPaint.setPathEffect(SkArcToPathEffect::Make(rad));
 
         fCornerPaint.setAntiAlias(true);
         fCornerPaint.setStyle(SkPaint::kStroke_Style);
         fCornerPaint.setStrokeWidth(13);
         fCornerPaint.setColor(SK_ColorGREEN);
-        fCornerPaint.setPathEffect(SkCornerPathEffect::Create(rad*2))->unref();
+        fCornerPaint.setPathEffect(SkCornerPathEffect::Make(rad*2));
 
         fSkeletonPaint.setAntiAlias(true);
         fSkeletonPaint.setStyle(SkPaint::kStroke_Style);
diff --git a/samplecode/SamplePathEffects.cpp b/samplecode/SamplePathEffects.cpp
index a162cf3..10715f3 100644
--- a/samplecode/SamplePathEffects.cpp
+++ b/samplecode/SamplePathEffects.cpp
@@ -26,9 +26,10 @@
     4, 0, 0, -4, 8, -4, 12, 0, 8, 4, 0, 4
 };
 
-static SkPathEffect* make_pe(int flags, SkScalar phase) {
-    if (flags == 1)
-        return SkCornerPathEffect::Create(SkIntToScalar(CORNER_RADIUS));
+static sk_sp<SkPathEffect> make_pe(int flags, SkScalar phase) {
+    if (flags == 1) {
+        return SkCornerPathEffect::Make(SkIntToScalar(CORNER_RADIUS));
+    }
 
     SkPath  path;
     path.moveTo(SkIntToScalar(gXY[0]), SkIntToScalar(gXY[1]));
@@ -37,36 +38,30 @@
     path.close();
     path.offset(SkIntToScalar(-6), 0);
 
-    SkPathEffect* outer = SkPath1DPathEffect::Create(path, 12, phase,
-                                                     SkPath1DPathEffect::kRotate_Style);
+    auto outer = SkPath1DPathEffect::Make(path, 12, phase, SkPath1DPathEffect::kRotate_Style);
 
     if (flags == 2)
         return outer;
 
-    SkPathEffect* inner = SkCornerPathEffect::Create(SkIntToScalar(CORNER_RADIUS));
+    auto inner = SkCornerPathEffect::Make(SkIntToScalar(CORNER_RADIUS));
 
-    SkPathEffect* pe = SkComposePathEffect::Create(outer, inner);
-    outer->unref();
-    inner->unref();
-    return pe;
+    return SkComposePathEffect::Make(outer, inner);
 }
 
-static SkPathEffect* make_warp_pe(SkScalar phase) {
+static sk_sp<SkPathEffect> make_warp_pe(SkScalar phase) {
     SkPath  path;
     path.moveTo(SkIntToScalar(gXY[0]), SkIntToScalar(gXY[1]));
-    for (unsigned i = 2; i < SK_ARRAY_COUNT(gXY); i += 2)
+    for (unsigned i = 2; i < SK_ARRAY_COUNT(gXY); i += 2) {
         path.lineTo(SkIntToScalar(gXY[i]), SkIntToScalar(gXY[i+1]));
+    }
     path.close();
     path.offset(SkIntToScalar(-6), 0);
 
-    SkPathEffect* outer = SkPath1DPathEffect::Create(
+    auto outer = SkPath1DPathEffect::Make(
         path, 12, phase, SkPath1DPathEffect::kMorph_Style);
-    SkPathEffect* inner = SkCornerPathEffect::Create(SkIntToScalar(CORNER_RADIUS));
+    auto inner = SkCornerPathEffect::Make(SkIntToScalar(CORNER_RADIUS));
 
-    SkPathEffect* pe = SkComposePathEffect::Create(outer, inner);
-    outer->unref();
-    inner->unref();
-    return pe;
+    return SkComposePathEffect::Make(outer, inner);
 }
 
 ///////////////////////////////////////////////////////////
@@ -143,19 +138,19 @@
         canvas->translate(0, 50);
 
         paint.setColor(SK_ColorBLUE);
-        paint.setPathEffect(make_pe(2, fPhase))->unref();
+        paint.setPathEffect(make_pe(2, fPhase));
         canvas->drawPath(fPath, paint);
 
         canvas->translate(0, 50);
 
         paint.setARGB(0xFF, 0, 0xBB, 0);
-        paint.setPathEffect(make_pe(3, fPhase))->unref();
+        paint.setPathEffect(make_pe(3, fPhase));
         canvas->drawPath(fPath, paint);
 
         canvas->translate(0, 50);
 
         paint.setARGB(0xFF, 0, 0, 0);
-        paint.setPathEffect(make_warp_pe(fPhase))->unref();
+        paint.setPathEffect(make_warp_pe(fPhase));
         TestRastBuilder testRastBuilder;
         paint.setRasterizer(testRastBuilder.detachRasterizer())->unref();
         canvas->drawPath(fPath, paint);
diff --git a/samplecode/SampleSlides.cpp b/samplecode/SampleSlides.cpp
index c3cc2bb..38fd740 100644
--- a/samplecode/SampleSlides.cpp
+++ b/samplecode/SampleSlides.cpp
@@ -31,15 +31,14 @@
 
 static void compose_pe(SkPaint* paint) {
     SkPathEffect* pe = paint->getPathEffect();
-    SkPathEffect* corner = SkCornerPathEffect::Create(25);
-    SkPathEffect* compose;
+    sk_sp<SkPathEffect> corner = SkCornerPathEffect::Make(25);
+    sk_sp<SkPathEffect> compose;
     if (pe) {
-        compose = SkComposePathEffect::Create(pe, corner);
-        corner->unref();
+        compose = SkComposePathEffect::Make(sk_ref_sp(pe), corner);
     } else {
         compose = corner;
     }
-    paint->setPathEffect(compose)->unref();
+    paint->setPathEffect(compose);
 }
 
 static void hair_pe(SkPaint* paint) {
@@ -59,8 +58,7 @@
 static void dash_pe(SkPaint* paint) {
     SkScalar inter[] = { 20, 10, 10, 10 };
     paint->setStrokeWidth(12);
-    paint->setPathEffect(SkDashPathEffect::Create(inter, SK_ARRAY_COUNT(inter),
-                                                  0))->unref();
+    paint->setPathEffect(SkDashPathEffect::Make(inter, SK_ARRAY_COUNT(inter), 0));
     compose_pe(paint);
 }
 
@@ -83,8 +81,8 @@
     path.offset(SkIntToScalar(-6), 0);
     scale(&path, 1.5f);
 
-    paint->setPathEffect(SkPath1DPathEffect::Create(path, SkIntToScalar(21), 0,
-                                                    SkPath1DPathEffect::kRotate_Style))->unref();
+    paint->setPathEffect(SkPath1DPathEffect::Make(path, SkIntToScalar(21), 0,
+                                                  SkPath1DPathEffect::kRotate_Style));
     compose_pe(paint);
 }
 
@@ -97,21 +95,21 @@
 }
 
 static void discrete_pe(SkPaint* paint) {
-    paint->setPathEffect(SkDiscretePathEffect::Create(10, 4))->unref();
+    paint->setPathEffect(SkDiscretePathEffect::Make(10, 4));
 }
 
-static SkPathEffect* MakeTileEffect() {
+static sk_sp<SkPathEffect> MakeTileEffect() {
     SkMatrix m;
     m.setScale(SkIntToScalar(12), SkIntToScalar(12));
 
     SkPath path;
     path.addCircle(0, 0, SkIntToScalar(5));
 
-    return SkPath2DPathEffect::Create(m, path);
+    return SkPath2DPathEffect::Make(m, path);
 }
 
 static void tile_pe(SkPaint* paint) {
-    paint->setPathEffect(MakeTileEffect())->unref();
+    paint->setPathEffect(MakeTileEffect());
 }
 
 static const PE_Proc gPE2[] = { fill_pe, discrete_pe, tile_pe };
@@ -534,7 +532,7 @@
 {
     rastBuilder->addLayer(p);
 
-    p.setPathEffect(SkDiscretePathEffect::Create(SK_Scalar1*4, SK_Scalar1*3))->unref();
+    p.setPathEffect(SkDiscretePathEffect::Make(SK_Scalar1*4, SK_Scalar1*3));
     p.setXfermodeMode(SkXfermode::kSrcOut_Mode);
     rastBuilder->addLayer(p);
 }
@@ -553,10 +551,10 @@
 
 #include "Sk2DPathEffect.h"
 
-static SkPathEffect* MakeDotEffect(SkScalar radius, const SkMatrix& matrix) {
+static sk_sp<SkPathEffect> MakeDotEffect(SkScalar radius, const SkMatrix& matrix) {
     SkPath path;
     path.addCircle(0, 0, radius);
-    return SkPath2DPathEffect::Create(matrix, path);
+    return SkPath2DPathEffect::Make(matrix, path);
 }
 
 static void r7(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p)
@@ -564,7 +562,7 @@
     SkMatrix    lattice;
     lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0);
     lattice.postSkew(SK_Scalar1/3, 0, 0, 0);
-    p.setPathEffect(MakeDotEffect(SK_Scalar1*4, lattice))->unref();
+    p.setPathEffect(MakeDotEffect(SK_Scalar1*4, lattice));
     rastBuilder->addLayer(p);
 }
 
@@ -575,7 +573,7 @@
     SkMatrix    lattice;
     lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0);
     lattice.postSkew(SK_Scalar1/3, 0, 0, 0);
-    p.setPathEffect(MakeDotEffect(SK_Scalar1*2, lattice))->unref();
+    p.setPathEffect(MakeDotEffect(SK_Scalar1*2, lattice));
     p.setXfermodeMode(SkXfermode::kClear_Mode);
     rastBuilder->addLayer(p);
 
@@ -593,7 +591,7 @@
     SkMatrix    lattice;
     lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0);
     lattice.postRotate(SkIntToScalar(30), 0, 0);
-    p.setPathEffect(SkLine2DPathEffect::Create(SK_Scalar1*2, lattice))->unref();
+    p.setPathEffect(SkLine2DPathEffect::Make(SK_Scalar1*2, lattice));
     p.setXfermodeMode(SkXfermode::kClear_Mode);
     rastBuilder->addLayer(p);
 
diff --git a/src/animator/SkDrawPaint.cpp b/src/animator/SkDrawPaint.cpp
index d1af4f4..5f6efd8 100644
--- a/src/animator/SkDrawPaint.cpp
+++ b/src/animator/SkDrawPaint.cpp
@@ -233,7 +233,7 @@
     if (pathEffect == nullptr)
         paint->setPathEffect(nullptr);
     else if (pathEffect != (SkDrawPathEffect*) -1)
-        SkSafeUnref(paint->setPathEffect(pathEffect->getPathEffect()));
+        paint->setPathEffect(sk_ref_sp(pathEffect->getPathEffect()));
     if (shader == nullptr)
         paint->setShader(nullptr);
     else if (shader != (SkDrawShader*) -1)
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index c35247b..60db401 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -1615,7 +1615,7 @@
 
     // Now restore the original settings, so we "draw" with whatever style/stroking.
     paint.setStyle(origPaint.getStyle());
-    paint.setPathEffect(origPaint.getPathEffect());
+    paint.setPathEffect(sk_ref_sp(origPaint.getPathEffect()));
 
     while (text < stop) {
         const SkGlyph& glyph = glyphCacheProc(cache.get(), &text);
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp
index 5e813f7..331f779 100644
--- a/src/core/SkPaint.cpp
+++ b/src/core/SkPaint.cpp
@@ -375,7 +375,9 @@
 SET_PTR(Shader)
 SET_PTR(ColorFilter)
 SET_PTR(Xfermode)
+#ifdef SK_SUPPORT_LEGACY_PATHEFFECT_PTR
 SET_PTR(PathEffect)
+#endif
 SET_PTR(MaskFilter)
 #undef SET_PTR
 
@@ -1930,7 +1932,7 @@
     }
 
     if (flatFlags & kHasEffects_FlatFlag) {
-        SkSafeUnref(this->setPathEffect(buffer.readPathEffect()));
+        this->setPathEffect(buffer.readPathEffect());
         this->setShader(buffer.readShader());
         SkSafeUnref(this->setXfermode(buffer.readXfermode()));
         SkSafeUnref(this->setMaskFilter(buffer.readMaskFilter()));
@@ -2250,11 +2252,11 @@
     fCache = fPaint.detachCache(nullptr, SkPaint::FakeGamma::On, nullptr);
 
     SkPaint::Style  style = SkPaint::kFill_Style;
-    SkPathEffect*   pe = nullptr;
+    sk_sp<SkPathEffect> pe;
 
     if (!applyStrokeAndPathEffects) {
         style = paint.getStyle();   // restore
-        pe = paint.getPathEffect();     // restore
+        pe = sk_ref_sp(paint.getPathEffect());     // restore
     }
     fPaint.setStyle(style);
     fPaint.setPathEffect(pe);
diff --git a/src/core/SkPathEffect.cpp b/src/core/SkPathEffect.cpp
index 293bb53..b2e29bc 100644
--- a/src/core/SkPathEffect.cpp
+++ b/src/core/SkPathEffect.cpp
@@ -1,4 +1,3 @@
-
 /*
  * Copyright 2006 The Android Open Source Project
  *
@@ -28,25 +27,19 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
-SkPairPathEffect::SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1)
-        : fPE0(pe0), fPE1(pe1) {
-    SkASSERT(pe0);
-    SkASSERT(pe1);
-    fPE0->ref();
-    fPE1->ref();
-}
-
-SkPairPathEffect::~SkPairPathEffect() {
-    SkSafeUnref(fPE0);
-    SkSafeUnref(fPE1);
+SkPairPathEffect::SkPairPathEffect(sk_sp<SkPathEffect> pe0, sk_sp<SkPathEffect> pe1)
+    : fPE0(std::move(pe0)), fPE1(std::move(pe1))
+{
+    SkASSERT(fPE0.get());
+    SkASSERT(fPE1.get());
 }
 
 /*
     Format: [oe0-factory][pe1-factory][pe0-size][pe0-data][pe1-data]
 */
 void SkPairPathEffect::flatten(SkWriteBuffer& buffer) const {
-    buffer.writeFlattenable(fPE0);
-    buffer.writeFlattenable(fPE1);
+    buffer.writeFlattenable(fPE0.get());
+    buffer.writeFlattenable(fPE1.get());
 }
 
 #ifndef SK_IGNORE_TO_STRING
@@ -65,22 +58,13 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 SkFlattenable* SkComposePathEffect::CreateProc(SkReadBuffer& buffer) {
-    SkAutoTUnref<SkPathEffect> pe0(buffer.readPathEffect());
-    SkAutoTUnref<SkPathEffect> pe1(buffer.readPathEffect());
-    if (pe0 && pe1) {
-        return SkComposePathEffect::Create(pe0, pe1);
-    } else {
-        return nullptr;
-    }
+    sk_sp<SkPathEffect> pe0(buffer.readPathEffect());
+    sk_sp<SkPathEffect> pe1(buffer.readPathEffect());
+    return SkComposePathEffect::Make(std::move(pe0), std::move(pe1)).release();
 }
 
 bool SkComposePathEffect::filterPath(SkPath* dst, const SkPath& src,
                              SkStrokeRec* rec, const SkRect* cullRect) const {
-    // we may have failed to unflatten these, so we have to check
-    if (!fPE0 || !fPE1) {
-        return false;
-    }
-
     SkPath          tmp;
     const SkPath*   ptr = &src;
 
@@ -102,13 +86,9 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 SkFlattenable* SkSumPathEffect::CreateProc(SkReadBuffer& buffer) {
-    SkAutoTUnref<SkPathEffect> pe0(buffer.readPathEffect());
-    SkAutoTUnref<SkPathEffect> pe1(buffer.readPathEffect());
-    if (pe0 && pe1) {
-        return SkSumPathEffect::Create(pe0, pe1);
-    } else {
-        return nullptr;
-    }
+    sk_sp<SkPathEffect> pe0(buffer.readPathEffect());
+    sk_sp<SkPathEffect> pe1(buffer.readPathEffect());
+    return SkSumPathEffect::Make(pe0, pe1).release();
 }
 
 bool SkSumPathEffect::filterPath(SkPath* dst, const SkPath& src,
diff --git a/src/core/SkReadBuffer.h b/src/core/SkReadBuffer.h
index 7ce6d04..c7ac848 100644
--- a/src/core/SkReadBuffer.h
+++ b/src/core/SkReadBuffer.h
@@ -134,7 +134,9 @@
     SkDrawLooper*  readDrawLooper()  { return this->readFlattenable<SkDrawLooper>(); }
     SkImageFilter* readImageFilter() { return this->readFlattenable<SkImageFilter>(); }
     SkMaskFilter*  readMaskFilter()  { return this->readFlattenable<SkMaskFilter>(); }
-    SkPathEffect*  readPathEffect()  { return this->readFlattenable<SkPathEffect>(); }
+    sk_sp<SkPathEffect> readPathEffect()  {
+        return sk_sp<SkPathEffect>(this->readFlattenable<SkPathEffect>());
+    }
     SkRasterizer*  readRasterizer()  { return this->readFlattenable<SkRasterizer>(); }
     sk_sp<SkShader> readShader()     { return sk_sp<SkShader>(this->readFlattenable<SkShader>()); }
     SkXfermode*    readXfermode()    { return this->readFlattenable<SkXfermode>(); }
diff --git a/src/effects/Sk1DPathEffect.cpp b/src/effects/Sk1DPathEffect.cpp
index 4be6f97..1d147bd 100644
--- a/src/effects/Sk1DPathEffect.cpp
+++ b/src/effects/Sk1DPathEffect.cpp
@@ -153,7 +153,7 @@
         buffer.readPath(&path);
         SkScalar phase = buffer.readScalar();
         Style style = (Style)buffer.readUInt();
-        return SkPath1DPathEffect::Create(path, advance, phase, style);
+        return SkPath1DPathEffect::Make(path, advance, phase, style).release();
     }
     return nullptr;
 }
@@ -204,10 +204,10 @@
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-SkPathEffect* SkPath1DPathEffect::Create(const SkPath& path, SkScalar advance, SkScalar phase,
-                                         Style style) {
+sk_sp<SkPathEffect> SkPath1DPathEffect::Make(const SkPath& path, SkScalar advance, SkScalar phase,
+                                             Style style) {
     if (advance <= 0 || path.isEmpty()) {
         return nullptr;
     }
-    return new SkPath1DPathEffect(path, advance, phase, style);
+    return sk_sp<SkPathEffect>(new SkPath1DPathEffect(path, advance, phase, style));
 }
diff --git a/src/effects/Sk2DPathEffect.cpp b/src/effects/Sk2DPathEffect.cpp
index 7144526..a54f453 100644
--- a/src/effects/Sk2DPathEffect.cpp
+++ b/src/effects/Sk2DPathEffect.cpp
@@ -111,7 +111,7 @@
     SkMatrix matrix;
     buffer.readMatrix(&matrix);
     SkScalar width = buffer.readScalar();
-    return SkLine2DPathEffect::Create(width, matrix);
+    return SkLine2DPathEffect::Make(width, matrix).release();
 }
 
 void SkLine2DPathEffect::flatten(SkWriteBuffer &buffer) const {
@@ -140,7 +140,7 @@
     buffer.readMatrix(&matrix);
     SkPath path;
     buffer.readPath(&path);
-    return SkPath2DPathEffect::Create(matrix, path);
+    return SkPath2DPathEffect::Make(matrix, path).release();
 }
 
 void SkPath2DPathEffect::flatten(SkWriteBuffer& buffer) const {
diff --git a/src/effects/SkArcToPathEffect.cpp b/src/effects/SkArcToPathEffect.cpp
index 06cba96..c660de9 100644
--- a/src/effects/SkArcToPathEffect.cpp
+++ b/src/effects/SkArcToPathEffect.cpp
@@ -62,7 +62,7 @@
 }
 
 SkFlattenable* SkArcToPathEffect::CreateProc(SkReadBuffer& buffer) {
-    return SkArcToPathEffect::Create(buffer.readScalar());
+    return SkArcToPathEffect::Make(buffer.readScalar()).release();
 }
 
 void SkArcToPathEffect::flatten(SkWriteBuffer& buffer) const {
diff --git a/src/effects/SkCornerPathEffect.cpp b/src/effects/SkCornerPathEffect.cpp
index 4b81f26..325e2ca 100644
--- a/src/effects/SkCornerPathEffect.cpp
+++ b/src/effects/SkCornerPathEffect.cpp
@@ -140,7 +140,7 @@
 }
 
 SkFlattenable* SkCornerPathEffect::CreateProc(SkReadBuffer& buffer) {
-    return SkCornerPathEffect::Create(buffer.readScalar());
+    return SkCornerPathEffect::Make(buffer.readScalar()).release();
 }
 
 void SkCornerPathEffect::flatten(SkWriteBuffer& buffer) const {
diff --git a/src/effects/SkDashPathEffect.cpp b/src/effects/SkDashPathEffect.cpp
index 3816499..51bf548 100644
--- a/src/effects/SkDashPathEffect.cpp
+++ b/src/effects/SkDashPathEffect.cpp
@@ -365,7 +365,7 @@
     uint32_t count = buffer.getArrayCount();
     SkAutoSTArray<32, SkScalar> intervals(count);
     if (buffer.readScalarArray(intervals.get(), count)) {
-        return Create(intervals.get(), SkToInt(count), phase);
+        return Make(intervals.get(), SkToInt(count), phase).release();
     }
     return nullptr;
 }
@@ -386,9 +386,9 @@
 
 //////////////////////////////////////////////////////////////////////////////////////////////////
 
-SkPathEffect* SkDashPathEffect::Create(const SkScalar intervals[], int count, SkScalar phase) {
+sk_sp<SkPathEffect> SkDashPathEffect::Make(const SkScalar intervals[], int count, SkScalar phase) {
     if (!SkDashPath::ValidDashPath(phase, intervals, count)) {
         return nullptr;
     }
-    return new SkDashPathEffect(intervals, count, phase);
+    return sk_sp<SkPathEffect>(new SkDashPathEffect(intervals, count, phase));
 }
diff --git a/src/effects/SkDiscretePathEffect.cpp b/src/effects/SkDiscretePathEffect.cpp
index acde041..1989d9d 100644
--- a/src/effects/SkDiscretePathEffect.cpp
+++ b/src/effects/SkDiscretePathEffect.cpp
@@ -13,6 +13,11 @@
 #include "SkPathMeasure.h"
 #include "SkStrokeRec.h"
 
+sk_sp<SkPathEffect> SkDiscretePathEffect::Make(SkScalar segLength, SkScalar deviation,
+                                               uint32_t seedAssist) {
+    return sk_sp<SkPathEffect>(new SkDiscretePathEffect(segLength, deviation, seedAssist));
+}
+
 static void Perterb(SkPoint* p, const SkVector& tangent, SkScalar scale) {
     SkVector normal = tangent;
     normal.rotateCCW();
@@ -121,7 +126,7 @@
     SkScalar segLength = buffer.readScalar();
     SkScalar perterb = buffer.readScalar();
     uint32_t seed = buffer.readUInt();
-    return Create(segLength, perterb, seed);
+    return Make(segLength, perterb, seed).release();
 }
 
 void SkDiscretePathEffect::flatten(SkWriteBuffer& buffer) const {
diff --git a/src/effects/SkLayerDrawLooper.cpp b/src/effects/SkLayerDrawLooper.cpp
index bca65ef..83f21e5 100644
--- a/src/effects/SkLayerDrawLooper.cpp
+++ b/src/effects/SkLayerDrawLooper.cpp
@@ -93,7 +93,7 @@
     }
 
     if (bits & kPathEffect_Bit) {
-        dst->setPathEffect(src.getPathEffect());
+        dst->setPathEffect(sk_ref_sp(src.getPathEffect()));
     }
     if (bits & kMaskFilter_Bit) {
         dst->setMaskFilter(src.getMaskFilter());
diff --git a/src/gpu/text/GrTextUtils.cpp b/src/gpu/text/GrTextUtils.cpp
index c46ea73..edf813d 100644
--- a/src/gpu/text/GrTextUtils.cpp
+++ b/src/gpu/text/GrTextUtils.cpp
@@ -517,7 +517,7 @@
 
     // Now restore the original settings, so we "draw" with whatever style/stroking.
     paint.setStyle(origPaint.getStyle());
-    paint.setPathEffect(origPaint.getPathEffect());
+    paint.setPathEffect(sk_ref_sp(origPaint.getPathEffect()));
 
     while (text < stop) {
         const SkGlyph& glyph = glyphCacheProc(cache, &text);
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index 6e0dd4b..f5e341b 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -15,6 +15,7 @@
 #include "SkGlyphCache.h"
 #include "SkPaint.h"
 #include "SkPath.h"
+#include "SkPathEffect.h"
 #include "SkPathOps.h"
 #include "SkPDFBitmap.h"
 #include "SkPDFCanon.h"
diff --git a/src/xps/SkXPSDevice.cpp b/src/xps/SkXPSDevice.cpp
index 5d12c49..febd027 100644
--- a/src/xps/SkXPSDevice.cpp
+++ b/src/xps/SkXPSDevice.cpp
@@ -32,6 +32,7 @@
 #include "SkIStream.h"
 #include "SkMaskFilter.h"
 #include "SkPaint.h"
+#include "SkPathEffect.h"
 #include "SkPathOps.h"
 #include "SkPoint.h"
 #include "SkRasterizer.h"
diff --git a/tests/AsADashTest.cpp b/tests/AsADashTest.cpp
index fc4efec..2077b66 100644
--- a/tests/AsADashTest.cpp
+++ b/tests/AsADashTest.cpp
@@ -12,7 +12,7 @@
 #include "SkCornerPathEffect.h"
 
 DEF_TEST(AsADashTest_noneDash, reporter) {
-    SkAutoTUnref<SkPathEffect> pe(SkCornerPathEffect::Create(1.0));
+    sk_sp<SkPathEffect> pe(SkCornerPathEffect::Make(1.0));
     SkPathEffect::DashInfo info;
 
     SkPathEffect::DashType dashType = pe->asADash(&info);
@@ -22,7 +22,7 @@
 DEF_TEST(AsADashTest_nullInfo, reporter) {
     SkScalar inIntervals[] = { 4.0, 2.0, 1.0, 3.0 };
     const SkScalar phase = 2.0;
-    SkAutoTUnref<SkPathEffect> pe(SkDashPathEffect::Create(inIntervals, 4, phase));
+    sk_sp<SkPathEffect> pe(SkDashPathEffect::Make(inIntervals, 4, phase));
 
     SkPathEffect::DashType dashType = pe->asADash(nullptr);
     REPORTER_ASSERT(reporter, SkPathEffect::kDash_DashType == dashType);
@@ -33,7 +33,7 @@
     SkScalar totalIntSum = 10.0;
     const SkScalar phase = 2.0;
 
-    SkAutoTUnref<SkPathEffect> pe(SkDashPathEffect::Create(inIntervals, 4, phase));
+    sk_sp<SkPathEffect> pe(SkDashPathEffect::Make(inIntervals, 4, phase));
 
     SkPathEffect::DashInfo info;
 
diff --git a/tests/DashPathEffectTest.cpp b/tests/DashPathEffectTest.cpp
index fa2395e..7e832cd 100644
--- a/tests/DashPathEffectTest.cpp
+++ b/tests/DashPathEffectTest.cpp
@@ -18,7 +18,7 @@
     SkScalar intervals[] = { 1.76934361e+36f, 2.80259693e-45f };  // Values from bug.
     const int count = 2;
     SkScalar phase = SK_ScalarInfinity;  // Used to force a nonsense effect.
-    SkAutoTUnref<SkPathEffect> dash(SkDashPathEffect::Create(intervals, count, phase));
+    sk_sp<SkPathEffect> dash(SkDashPathEffect::Make(intervals, count, phase));
 
     REPORTER_ASSERT(r, dash == nullptr);
 }
@@ -28,7 +28,7 @@
 
     const SkScalar intervals[] = { 1.0f, 1.0f };
     const int count = 2;
-    SkAutoTUnref<SkPathEffect> dash(SkDashPathEffect::Create(intervals, count, 0.0f));
+    sk_sp<SkPathEffect> dash(SkDashPathEffect::Make(intervals, count, 0.0f));
 
     SkRect cull = SkRect::MakeWH(1.0f, 1.0f);
 
@@ -90,7 +90,7 @@
     path.close();
 
     SkScalar intervals[2] = { 1, 1 };
-    SkAutoTUnref<SkPathEffect> dash(SkDashPathEffect::Create(intervals, 2, 0));
+    sk_sp<SkPathEffect> dash(SkDashPathEffect::Make(intervals, 2, 0));
 
     SkPaint paint;
     paint.setStyle(SkPaint::kStroke_Style);
diff --git a/tests/DrawPathTest.cpp b/tests/DrawPathTest.cpp
index e9aa449..8c46b10 100644
--- a/tests/DrawPathTest.cpp
+++ b/tests/DrawPathTest.cpp
@@ -192,7 +192,7 @@
      */
 
     const SkScalar vals[] = { 27734, 35660, 2157846850.0f, 247 };
-    SkAutoTUnref<SkPathEffect> dontAssert(SkDashPathEffect::Create(vals, 4, -248.135982067f));
+    auto dontAssert = SkDashPathEffect::Make(vals, 4, -248.135982067f);
 }
 
 static void test_crbug_124652() {
@@ -202,7 +202,7 @@
         large values can "swamp" small ones.
      */
     SkScalar intervals[2] = {837099584, 33450};
-    SkAutoTUnref<SkPathEffect> dash(SkDashPathEffect::Create(intervals, 2, -10));
+    auto dontAssert = SkDashPathEffect::Make(intervals, 2, -10);
 }
 
 static void test_bigcubic() {
@@ -281,7 +281,7 @@
     path.lineTo(5000000, 0);
 
     SkScalar intervals[] = { 0.2f, 0.2f };
-    SkAutoTUnref<SkPathEffect> dash(SkDashPathEffect::Create(intervals, 2, 0));
+    sk_sp<SkPathEffect> dash(SkDashPathEffect::Make(intervals, 2, 0));
 
     SkPath filteredPath;
     SkPaint paint;
@@ -301,7 +301,7 @@
     path.lineTo(10000000, 0);
 
     SkScalar intervals[] = { 0.5f, 0.5f };
-    SkAutoTUnref<SkPathEffect> dash(SkDashPathEffect::Create(intervals, 2, 0));
+    sk_sp<SkPathEffect> dash(SkDashPathEffect::Make(intervals, 2, 0));
 
     SkPaint paint;
     paint.setStyle(SkPaint::kStroke_Style);
diff --git a/tests/GpuDrawPathTest.cpp b/tests/GpuDrawPathTest.cpp
index d454d9b..1f9361a 100644
--- a/tests/GpuDrawPathTest.cpp
+++ b/tests/GpuDrawPathTest.cpp
@@ -49,7 +49,7 @@
 }
 
 static void fill_and_stroke(SkCanvas* canvas, const SkPath& p1, const SkPath& p2,
-                            SkPathEffect* effect) {
+                            sk_sp<SkPathEffect> effect) {
     SkPaint paint;
     paint.setAntiAlias(true);
     paint.setPathEffect(effect);
@@ -73,8 +73,7 @@
     fill_and_stroke(canvas, oval1, oval2, nullptr);
 
     const SkScalar intervals[] = { 1, 1 };
-    SkAutoTUnref<SkPathEffect> dashEffect(SkDashPathEffect::Create(intervals, 2, 0));
-    fill_and_stroke(canvas, oval1, oval2, dashEffect);
+    fill_and_stroke(canvas, oval1, oval2, SkDashPathEffect::Make(intervals, 2, 0));
 }
 
 DEF_GPUTEST_FOR_ALL_CONTEXTS(GpuDrawPath, reporter, context) {
diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp
index 0ac50d9..58a08ec 100644
--- a/tests/PictureTest.cpp
+++ b/tests/PictureTest.cpp
@@ -144,7 +144,7 @@
         path.lineTo(50, 50);
 
         SkScalar intervals[] = { 1.0f, 1.0f };
-        SkAutoTUnref<SkPathEffect> dash(SkDashPathEffect::Create(intervals, 2, 0));
+        sk_sp<SkPathEffect> dash(SkDashPathEffect::Make(intervals, 2, 0));
 
         SkPaint paint;
         paint.setStyle(SkPaint::kStroke_Style);
@@ -233,8 +233,7 @@
     {
         SkPaint paint;
         SkScalar intervals [] = { 10, 20 };
-        SkPathEffect* pe = SkDashPathEffect::Create(intervals, 2, 25);
-        paint.setPathEffect(pe)->unref();
+        paint.setPathEffect(SkDashPathEffect::Make(intervals, 2, 25));
 
         SkPoint points [2] = { { 0, 0 }, { 100, 0 } };
 
@@ -250,8 +249,7 @@
     {
         SkPaint paint;
         SkScalar intervals [] = { 10, 20 };
-        SkPathEffect* pe = SkDashPathEffect::Create(intervals, 2, 25);
-        paint.setPathEffect(pe)->unref();
+        paint.setPathEffect(SkDashPathEffect::Make(intervals, 2, 25));
 
         for (int i = 0; i < 50; ++i) {
             canvas->drawRect(SkRect::MakeWH(10, 10), paint);
diff --git a/tools/debugger/SkDrawCommand.cpp b/tools/debugger/SkDrawCommand.cpp
index 847254a..ab9c9de 100644
--- a/tools/debugger/SkDrawCommand.cpp
+++ b/tools/debugger/SkDrawCommand.cpp
@@ -1106,10 +1106,10 @@
                                           SkPaint* target) {
     if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_PATHEFFECT)) {
         Json::Value jsonPathEffect = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_PATHEFFECT];
-        SkPathEffect* pathEffect = (SkPathEffect*) load_flattenable(jsonPathEffect, urlDataManager);
+        sk_sp<SkPathEffect> pathEffect((SkPathEffect*)load_flattenable(jsonPathEffect,
+                                                                       urlDataManager));
         if (pathEffect != nullptr) {
             target->setPathEffect(pathEffect);
-            pathEffect->unref();
         }
     }
 }
@@ -1329,7 +1329,7 @@
             intervals[i] = jsonIntervals[i].asFloat();
         }
         SkScalar phase = dash[SKDEBUGCANVAS_ATTRIBUTE_PHASE].asFloat();
-        target->setPathEffect(SkDashPathEffect::Create(intervals, count, phase));
+        target->setPathEffect(SkDashPathEffect::Make(intervals, count, phase));
         sk_free(intervals);
     }
 }