sk_sp for Ganesh.

Convert use of GrFragmentProcessor, GrGeometryProcessor, and
GrXPFactory to sk_sp. This clarifies ownership and should
reduce reference count churn by moving ownership.

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2041113004

Review-Url: https://codereview.chromium.org/2041113004
diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp
index e140f0f..972d731 100644
--- a/src/core/SkBitmapProcShader.cpp
+++ b/src/core/SkBitmapProcShader.cpp
@@ -410,7 +410,7 @@
 #include "SkGr.h"
 #include "effects/GrSimpleTextureEffect.h"
 
-const GrFragmentProcessor* SkBitmapProcShader::asFragmentProcessor(GrContext* context,
+sk_sp<GrFragmentProcessor> SkBitmapProcShader::asFragmentProcessor(GrContext* context,
                                              const SkMatrix& viewM, const SkMatrix* localMatrix,
                                              SkFilterQuality filterQuality,
                                              SkSourceGammaTreatment gammaTreatment) const {
@@ -453,17 +453,17 @@
         return nullptr;
     }
 
-    SkAutoTUnref<const GrFragmentProcessor> inner;
+    sk_sp<GrFragmentProcessor> inner;
     if (doBicubic) {
-        inner.reset(GrBicubicEffect::Create(texture, matrix, tm));
+        inner = GrBicubicEffect::Make(texture, matrix, tm);
     } else {
-        inner.reset(GrSimpleTextureEffect::Create(texture, matrix, params));
+        inner = GrSimpleTextureEffect::Make(texture, matrix, params);
     }
 
     if (kAlpha_8_SkColorType == fRawBitmap.colorType()) {
-        return GrFragmentProcessor::MulOutputByInputUnpremulColor(inner);
+        return GrFragmentProcessor::MulOutputByInputUnpremulColor(std::move(inner));
     }
-    return GrFragmentProcessor::MulOutputByInputAlpha(inner);
+    return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
 }
 
 #endif
diff --git a/src/core/SkBitmapProcShader.h b/src/core/SkBitmapProcShader.h
index dbd82a7..1d37433 100644
--- a/src/core/SkBitmapProcShader.h
+++ b/src/core/SkBitmapProcShader.h
@@ -25,7 +25,7 @@
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapProcShader)
 
 #if SK_SUPPORT_GPU
-    const GrFragmentProcessor* asFragmentProcessor(GrContext*, const SkMatrix& viewM,
+    sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*, const SkMatrix& viewM,
                                                    const SkMatrix*, SkFilterQuality,
                                                    SkSourceGammaTreatment) const override;
 #endif
diff --git a/src/core/SkColorFilter.cpp b/src/core/SkColorFilter.cpp
index e3d8957..9470766 100644
--- a/src/core/SkColorFilter.cpp
+++ b/src/core/SkColorFilter.cpp
@@ -31,6 +31,12 @@
     return false;
 }
 
+#if SK_SUPPORT_GPU
+sk_sp<GrFragmentProcessor> SkColorFilter::asFragmentProcessor(GrContext*) const {
+    return nullptr;
+}
+#endif
+
 void SkColorFilter::filterSpan4f(const SkPM4f[], int count, SkPM4f span[]) const {
     const int N = 128;
     SkPMColor tmp[N];
@@ -99,13 +105,13 @@
 #endif
 
 #if SK_SUPPORT_GPU
-    const GrFragmentProcessor* asFragmentProcessor(GrContext* context) const override {
-        SkAutoTUnref<const GrFragmentProcessor> innerFP(fInner->asFragmentProcessor(context));
-        SkAutoTUnref<const GrFragmentProcessor> outerFP(fOuter->asFragmentProcessor(context));
+    sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext* context) const override {
+        sk_sp<GrFragmentProcessor> innerFP(fInner->asFragmentProcessor(context));
+        sk_sp<GrFragmentProcessor> outerFP(fOuter->asFragmentProcessor(context));
         if (!innerFP || !outerFP) {
             return nullptr;
         }
-        const GrFragmentProcessor* series[] = { innerFP, outerFP };
+        sk_sp<GrFragmentProcessor> series[] = { std::move(innerFP), std::move(outerFP) };
         return GrFragmentProcessor::RunInSeries(series, 2);
     }
 #endif
diff --git a/src/core/SkColorFilterShader.cpp b/src/core/SkColorFilterShader.cpp
index 4ab232a..6f9fc97 100644
--- a/src/core/SkColorFilterShader.cpp
+++ b/src/core/SkColorFilterShader.cpp
@@ -97,27 +97,25 @@
 #if SK_SUPPORT_GPU
 /////////////////////////////////////////////////////////////////////
 
-const GrFragmentProcessor* SkColorFilterShader::asFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkColorFilterShader::asFragmentProcessor(
                                                      GrContext* context,
                                                      const SkMatrix& viewM,
                                                      const SkMatrix* localMatrix,
                                                      SkFilterQuality fq,
                                                      SkSourceGammaTreatment gammaTreatment) const {
 
-    SkAutoTUnref<const GrFragmentProcessor> fp1(fShader->asFragmentProcessor(context, viewM,
-                                                                             localMatrix, fq,
-                                                                             gammaTreatment));
-    if (!fp1.get()) {
+    sk_sp<GrFragmentProcessor> fp1(fShader->asFragmentProcessor(context, viewM, localMatrix, fq,
+                                                                gammaTreatment));
+    if (!fp1) {
         return nullptr;
     }
 
-    SkAutoTUnref<const GrFragmentProcessor> fp2(fFilter->asFragmentProcessor(context));
-    if (!fp2.get()) {
-        return fp1.release();
+    sk_sp<GrFragmentProcessor> fp2(fFilter->asFragmentProcessor(context));
+    if (!fp2) {
+        return fp1;
     }
 
-    const GrFragmentProcessor* fpSeries[] = { fp1.get(), fp2.get() };
-
+    sk_sp<GrFragmentProcessor> fpSeries[] = { std::move(fp1), std::move(fp2) };
     return GrFragmentProcessor::RunInSeries(fpSeries, 2);
 }
 #endif
diff --git a/src/core/SkColorFilterShader.h b/src/core/SkColorFilterShader.h
index 01a03f8..39a62ab 100644
--- a/src/core/SkColorFilterShader.h
+++ b/src/core/SkColorFilterShader.h
@@ -16,7 +16,7 @@
     SkColorFilterShader(sk_sp<SkShader> shader, sk_sp<SkColorFilter> filter);
 
 #if SK_SUPPORT_GPU
-    const GrFragmentProcessor* asFragmentProcessor(GrContext*,
+    sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
                                                    const SkMatrix& viewM,
                                                    const SkMatrix* localMatrix,
                                                    SkFilterQuality,
diff --git a/src/core/SkColorMatrixFilterRowMajor255.cpp b/src/core/SkColorMatrixFilterRowMajor255.cpp
index c158a79..cdfd1df 100644
--- a/src/core/SkColorMatrixFilterRowMajor255.cpp
+++ b/src/core/SkColorMatrixFilterRowMajor255.cpp
@@ -8,11 +8,12 @@
 #include "SkColorMatrixFilterRowMajor255.h"
 #include "SkColorPriv.h"
 #include "SkNx.h"
-#include "SkReadBuffer.h"
-#include "SkWriteBuffer.h"
-#include "SkUnPreMultiply.h"
-#include "SkString.h"
 #include "SkPM4fPriv.h"
+#include "SkReadBuffer.h"
+#include "SkRefCnt.h"
+#include "SkString.h"
+#include "SkUnPreMultiply.h"
+#include "SkWriteBuffer.h"
 
 static void transpose(float dst[20], const float src[20]) {
     const float* srcR = src + 0;
@@ -247,8 +248,8 @@
 
 class ColorMatrixEffect : public GrFragmentProcessor {
 public:
-    static const GrFragmentProcessor* Create(const SkScalar matrix[20]) {
-        return new ColorMatrixEffect(matrix);
+    static sk_sp<GrFragmentProcessor> Make(const SkScalar matrix[20]) {
+        return sk_sp<GrFragmentProcessor>(new ColorMatrixEffect(matrix));
     }
 
     const char* name() const override { return "Color Matrix"; }
@@ -387,16 +388,16 @@
 
 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ColorMatrixEffect);
 
-const GrFragmentProcessor* ColorMatrixEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> ColorMatrixEffect::TestCreate(GrProcessorTestData* d) {
     SkScalar colorMatrix[20];
     for (size_t i = 0; i < SK_ARRAY_COUNT(colorMatrix); ++i) {
         colorMatrix[i] = d->fRandom->nextSScalar1();
     }
-    return ColorMatrixEffect::Create(colorMatrix);
+    return ColorMatrixEffect::Make(colorMatrix);
 }
 
-const GrFragmentProcessor* SkColorMatrixFilterRowMajor255::asFragmentProcessor(GrContext*) const {
-    return ColorMatrixEffect::Create(fMatrix);
+sk_sp<GrFragmentProcessor> SkColorMatrixFilterRowMajor255::asFragmentProcessor(GrContext*) const {
+    return ColorMatrixEffect::Make(fMatrix);
 }
 
 #endif
diff --git a/src/core/SkColorMatrixFilterRowMajor255.h b/src/core/SkColorMatrixFilterRowMajor255.h
index 0ad64fa..79709b3 100644
--- a/src/core/SkColorMatrixFilterRowMajor255.h
+++ b/src/core/SkColorMatrixFilterRowMajor255.h
@@ -25,7 +25,7 @@
     sk_sp<SkColorFilter> makeComposed(sk_sp<SkColorFilter>) const override;
 
 #if SK_SUPPORT_GPU
-    const GrFragmentProcessor* asFragmentProcessor(GrContext*) const override;
+    sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*) const override;
 #endif
 
     SK_TO_STRING_OVERRIDE()
diff --git a/src/core/SkColorShader.cpp b/src/core/SkColorShader.cpp
index 2c7ee8b..83fd239 100644
--- a/src/core/SkColorShader.cpp
+++ b/src/core/SkColorShader.cpp
@@ -89,12 +89,12 @@
 
 #include "SkGr.h"
 #include "effects/GrConstColorProcessor.h"
-const GrFragmentProcessor* SkColorShader::asFragmentProcessor(GrContext*, const SkMatrix&,
+sk_sp<GrFragmentProcessor> SkColorShader::asFragmentProcessor(GrContext*, const SkMatrix&,
                                                               const SkMatrix*,
                                                               SkFilterQuality,
                                                               SkSourceGammaTreatment) const {
     GrColor color = SkColorToPremulGrColor(fColor);
-    return GrConstColorProcessor::Create(color, GrConstColorProcessor::kModulateA_InputMode);
+    return GrConstColorProcessor::Make(color, GrConstColorProcessor::kModulateA_InputMode);
 }
 
 #endif
@@ -217,13 +217,13 @@
 
 #include "SkGr.h"
 #include "effects/GrConstColorProcessor.h"
-const GrFragmentProcessor* SkColor4Shader::asFragmentProcessor(GrContext*, const SkMatrix&,
+sk_sp<GrFragmentProcessor> SkColor4Shader::asFragmentProcessor(GrContext*, const SkMatrix&,
                                                                const SkMatrix*,
                                                                SkFilterQuality,
                                                                SkSourceGammaTreatment) const {
     // TODO: how to communicate color4f to Gr
     GrColor color = SkColorToPremulGrColor(fCachedByteColor);
-    return GrConstColorProcessor::Create(color, GrConstColorProcessor::kModulateA_InputMode);
+    return GrConstColorProcessor::Make(color, GrConstColorProcessor::kModulateA_InputMode);
 }
 
 #endif
diff --git a/src/core/SkColorShader.h b/src/core/SkColorShader.h
index 8419742..9e0c542 100644
--- a/src/core/SkColorShader.h
+++ b/src/core/SkColorShader.h
@@ -49,7 +49,7 @@
     GradientType asAGradient(GradientInfo* info) const override;
 
 #if SK_SUPPORT_GPU
-    const GrFragmentProcessor* asFragmentProcessor(GrContext*, const SkMatrix& viewM,
+    sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*, const SkMatrix& viewM,
                                                    const SkMatrix*, SkFilterQuality,
                                                    SkSourceGammaTreatment) const override;
 #endif
@@ -104,7 +104,7 @@
     GradientType asAGradient(GradientInfo* info) const override;
 
 #if SK_SUPPORT_GPU
-    const GrFragmentProcessor* asFragmentProcessor(GrContext*, const SkMatrix& viewM,
+    sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*, const SkMatrix& viewM,
                                                    const SkMatrix*, SkFilterQuality,
                                                    SkSourceGammaTreatment) const override;
 #endif
diff --git a/src/core/SkComposeShader.cpp b/src/core/SkComposeShader.cpp
index 13569f1..e9f3f4c 100644
--- a/src/core/SkComposeShader.cpp
+++ b/src/core/SkComposeShader.cpp
@@ -183,7 +183,7 @@
 
 /////////////////////////////////////////////////////////////////////
 
-const GrFragmentProcessor* SkComposeShader::asFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkComposeShader::asFragmentProcessor(
                                                      GrContext* context,
                                                      const SkMatrix& viewM,
                                                      const SkMatrix* localMatrix,
@@ -197,8 +197,8 @@
 
     switch (mode) {
         case SkXfermode::kClear_Mode:
-            return GrConstColorProcessor::Create(GrColor_TRANSPARENT_BLACK,
-                                                 GrConstColorProcessor::kIgnore_InputMode);
+            return GrConstColorProcessor::Make(GrColor_TRANSPARENT_BLACK,
+                                               GrConstColorProcessor::kIgnore_InputMode);
             break;
         case SkXfermode::kSrc_Mode:
             return fShaderB->asFragmentProcessor(context, viewM, localMatrix, fq, gammaTreatment);
@@ -207,17 +207,18 @@
             return fShaderA->asFragmentProcessor(context, viewM, localMatrix, fq, gammaTreatment);
             break;
         default:
-            SkAutoTUnref<const GrFragmentProcessor> fpA(fShaderA->asFragmentProcessor(context,
-                                                        viewM, localMatrix, fq, gammaTreatment));
-            if (!fpA.get()) {
+            sk_sp<GrFragmentProcessor> fpA(fShaderA->asFragmentProcessor(context,
+                                           viewM, localMatrix, fq, gammaTreatment));
+            if (!fpA) {
                 return nullptr;
             }
-            SkAutoTUnref<const GrFragmentProcessor> fpB(fShaderB->asFragmentProcessor(context,
-                                                        viewM, localMatrix, fq, gammaTreatment));
-            if (!fpB.get()) {
+            sk_sp<GrFragmentProcessor> fpB(fShaderB->asFragmentProcessor(context,
+                                           viewM, localMatrix, fq, gammaTreatment));
+            if (!fpB) {
                 return nullptr;
             }
-            return GrXfermodeFragmentProcessor::CreateFromTwoProcessors(fpB, fpA, mode);
+            return GrXfermodeFragmentProcessor::MakeFromTwoProcessors(std::move(fpB),
+                                                                      std::move(fpA), mode);
     }
 }
 #endif
diff --git a/src/core/SkComposeShader.h b/src/core/SkComposeShader.h
index ed89b88..dcd43d3 100644
--- a/src/core/SkComposeShader.h
+++ b/src/core/SkComposeShader.h
@@ -35,11 +35,11 @@
     {}
 
 #if SK_SUPPORT_GPU
-    const GrFragmentProcessor*  asFragmentProcessor(GrContext*,
-                                                    const SkMatrix& viewM,
-                                                    const SkMatrix* localMatrix,
-                                                    SkFilterQuality,
-                                                    SkSourceGammaTreatment) const override;
+    sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
+                                                   const SkMatrix& viewM,
+                                                   const SkMatrix* localMatrix,
+                                                   SkFilterQuality,
+                                                   SkSourceGammaTreatment) const override;
 #endif
 
     class ComposeShaderContext : public SkShader::Context {
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index c7a5701..9e21525 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -277,7 +277,7 @@
                                                 sk_sp<GrFragmentProcessor> fp,
                                                 const SkIRect& bounds) {
     GrPaint paint;
-    paint.addColorFragmentProcessor(fp.get());
+    paint.addColorFragmentProcessor(std::move(fp));
     paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
 
     sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kApprox,
diff --git a/src/core/SkLightingShader.cpp b/src/core/SkLightingShader.cpp
index 542d0f3..a2ce52f 100644
--- a/src/core/SkLightingShader.cpp
+++ b/src/core/SkLightingShader.cpp
@@ -72,7 +72,7 @@
     bool isOpaque() const override;
 
 #if SK_SUPPORT_GPU
-    const GrFragmentProcessor* asFragmentProcessor(GrContext*,
+    sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
                                                    const SkMatrix& viewM,
                                                    const SkMatrix* localMatrix,
                                                    SkFilterQuality,
@@ -350,7 +350,7 @@
     return true;
 }
 
-const GrFragmentProcessor* SkLightingShaderImpl::asFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkLightingShaderImpl::asFragmentProcessor(
                                                      GrContext* context,
                                                      const SkMatrix& viewM,
                                                      const SkMatrix* localMatrix,
@@ -404,10 +404,10 @@
         return nullptr;
     }
 
-    SkAutoTUnref<const GrFragmentProcessor> inner (
+    sk_sp<GrFragmentProcessor> inner (
         new LightingFP(diffuseTexture, normalTexture, diffM, normM, diffParams, normParams, fLights,
                        fInvNormRotation));
-    return GrFragmentProcessor::MulOutputByInputAlpha(inner);
+    return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
 }
 
 #endif
diff --git a/src/core/SkLocalMatrixShader.cpp b/src/core/SkLocalMatrixShader.cpp
index ea4db53..cb85019 100644
--- a/src/core/SkLocalMatrixShader.cpp
+++ b/src/core/SkLocalMatrixShader.cpp
@@ -7,6 +7,23 @@
 
 #include "SkLocalMatrixShader.h"
 
+#if SK_SUPPORT_GPU
+#include "GrFragmentProcessor.h"
+#endif
+
+#if SK_SUPPORT_GPU
+sk_sp<GrFragmentProcessor> SkLocalMatrixShader::asFragmentProcessor(
+                                        GrContext* context, const SkMatrix& viewM,
+                                        const SkMatrix* localMatrix, SkFilterQuality fq,
+                                        SkSourceGammaTreatment gammaTreatment) const {
+    SkMatrix tmp = this->getLocalMatrix();
+    if (localMatrix) {
+        tmp.preConcat(*localMatrix);
+    }
+    return fProxyShader->asFragmentProcessor(context, viewM, &tmp, fq, gammaTreatment);
+}
+#endif
+
 sk_sp<SkFlattenable> SkLocalMatrixShader::CreateProc(SkReadBuffer& buffer) {
     SkMatrix lm;
     buffer.readMatrix(&lm);
diff --git a/src/core/SkLocalMatrixShader.h b/src/core/SkLocalMatrixShader.h
index 3d590e4..ea78419 100644
--- a/src/core/SkLocalMatrixShader.h
+++ b/src/core/SkLocalMatrixShader.h
@@ -12,6 +12,8 @@
 #include "SkReadBuffer.h"
 #include "SkWriteBuffer.h"
 
+class GrFragmentProcessor;
+
 class SkLocalMatrixShader : public SkShader {
 public:
     SkLocalMatrixShader(SkShader* proxy, const SkMatrix& localMatrix)
@@ -24,16 +26,10 @@
     }
 
 #if SK_SUPPORT_GPU
-    const GrFragmentProcessor* asFragmentProcessor(
+    sk_sp<GrFragmentProcessor> asFragmentProcessor(
                                             GrContext* context, const SkMatrix& viewM,
                                             const SkMatrix* localMatrix, SkFilterQuality fq,
-                                            SkSourceGammaTreatment gammaTreatment) const override {
-        SkMatrix tmp = this->getLocalMatrix();
-        if (localMatrix) {
-            tmp.preConcat(*localMatrix);
-        }
-        return fProxyShader->asFragmentProcessor(context, viewM, &tmp, fq, gammaTreatment);
-    }
+                                            SkSourceGammaTreatment gammaTreatment) const override;
 #endif
 
     SkShader* refAsALocalMatrixShader(SkMatrix* localMatrix) const override {
diff --git a/src/core/SkModeColorFilter.cpp b/src/core/SkModeColorFilter.cpp
index eacd261..ba3b50d 100644
--- a/src/core/SkModeColorFilter.cpp
+++ b/src/core/SkModeColorFilter.cpp
@@ -91,16 +91,16 @@
 #include "effects/GrConstColorProcessor.h"
 #include "SkGr.h"
 
-const GrFragmentProcessor* SkModeColorFilter::asFragmentProcessor(GrContext*) const {
+sk_sp<GrFragmentProcessor> SkModeColorFilter::asFragmentProcessor(GrContext*) const {
     if (SkXfermode::kDst_Mode == fMode) {
         return nullptr;
     }
 
-    SkAutoTUnref<const GrFragmentProcessor> constFP(
-        GrConstColorProcessor::Create(SkColorToPremulGrColor(fColor),
-                                        GrConstColorProcessor::kIgnore_InputMode));
-    const GrFragmentProcessor* fp =
-        GrXfermodeFragmentProcessor::CreateFromSrcProcessor(constFP, fMode);
+    sk_sp<GrFragmentProcessor> constFP(
+        GrConstColorProcessor::Make(SkColorToPremulGrColor(fColor),
+                                    GrConstColorProcessor::kIgnore_InputMode));
+    sk_sp<GrFragmentProcessor> fp(
+        GrXfermodeFragmentProcessor::MakeFromSrcProcessor(std::move(constFP), fMode));
     if (!fp) {
         return nullptr;
     }
diff --git a/src/core/SkModeColorFilter.h b/src/core/SkModeColorFilter.h
index d73cab7..01d1eaa 100644
--- a/src/core/SkModeColorFilter.h
+++ b/src/core/SkModeColorFilter.h
@@ -36,7 +36,7 @@
 #endif
 
 #if SK_SUPPORT_GPU
-    const GrFragmentProcessor* asFragmentProcessor(GrContext*) const override;
+    sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*) const override;
 #endif
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkModeColorFilter)
 
diff --git a/src/core/SkPictureShader.cpp b/src/core/SkPictureShader.cpp
index a880db3..a6186e6 100644
--- a/src/core/SkPictureShader.cpp
+++ b/src/core/SkPictureShader.cpp
@@ -318,7 +318,7 @@
 #endif
 
 #if SK_SUPPORT_GPU
-const GrFragmentProcessor* SkPictureShader::asFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkPictureShader::asFragmentProcessor(
                                                      GrContext* context, const SkMatrix& viewM,
                                                      const SkMatrix* localMatrix,
                                                      SkFilterQuality fq,
diff --git a/src/core/SkPictureShader.h b/src/core/SkPictureShader.h
index 01a66ec..11bec1a 100644
--- a/src/core/SkPictureShader.h
+++ b/src/core/SkPictureShader.h
@@ -28,7 +28,7 @@
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureShader)
 
 #if SK_SUPPORT_GPU
-    const GrFragmentProcessor* asFragmentProcessor(GrContext*,
+    sk_sp<GrFragmentProcessor> asFragmentProcessor(GrContext*,
                                                    const SkMatrix& viewM,
                                                    const SkMatrix*,
                                                    SkFilterQuality,
diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp
index 2ec3b0b..1ab4ea7 100644
--- a/src/core/SkShader.cpp
+++ b/src/core/SkShader.cpp
@@ -18,6 +18,10 @@
 #include "SkShader.h"
 #include "SkWriteBuffer.h"
 
+#if SK_SUPPORT_GPU
+#include "GrFragmentProcessor.h"
+#endif
+
 //#define SK_TRACK_SHADER_LIFETIME
 
 #ifdef SK_TRACK_SHADER_LIFETIME
@@ -220,11 +224,13 @@
     return kNone_GradientType;
 }
 
-const GrFragmentProcessor* SkShader::asFragmentProcessor(GrContext*, const SkMatrix&,
+#if SK_SUPPORT_GPU
+sk_sp<GrFragmentProcessor> SkShader::asFragmentProcessor(GrContext*, const SkMatrix&,
                                                          const SkMatrix*, SkFilterQuality,
-                                                         SkSourceGammaTreatment)  const {
+                                                         SkSourceGammaTreatment) const {
     return nullptr;
 }
+#endif
 
 SkShader* SkShader::refAsALocalMatrixShader(SkMatrix*) const {
     return nullptr;
diff --git a/src/core/SkXfermode.cpp b/src/core/SkXfermode.cpp
index b6d2388..e91f53a 100644
--- a/src/core/SkXfermode.cpp
+++ b/src/core/SkXfermode.cpp
@@ -16,6 +16,13 @@
 #include "SkWriteBuffer.h"
 #include "SkPM4f.h"
 
+#if SK_SUPPORT_GPU
+#include "GrFragmentProcessor.h"
+#include "effects/GrCustomXfermode.h"
+#include "effects/GrPorterDuffXferProcessor.h"
+#include "effects/GrXfermodeFragmentProcessor.h"
+#endif
+
 #define SkAlphaMulAlpha(a, b)   SkMulDiv255Round(a, b)
 
 static inline unsigned saturated_add(unsigned a, unsigned b) {
@@ -985,15 +992,15 @@
 }
 
 #if SK_SUPPORT_GPU
-const GrFragmentProcessor* SkXfermode::getFragmentProcessorForImageFilter(
-                                                                const GrFragmentProcessor*) const {
+sk_sp<GrFragmentProcessor> SkXfermode::makeFragmentProcessorForImageFilter(
+                                                                sk_sp<GrFragmentProcessor>) const {
     // This should never be called.
     // TODO: make pure virtual in SkXfermode once Android update lands
     SkASSERT(0);
     return nullptr;
 }
 
-GrXPFactory* SkXfermode::asXPFactory() const {
+sk_sp<GrXPFactory> SkXfermode::asXPFactory() const {
     // This should never be called.
     // TODO: make pure virtual in SkXfermode once Android update lands
     SkASSERT(0);
@@ -1240,25 +1247,21 @@
 }
 
 #if SK_SUPPORT_GPU
-#include "effects/GrCustomXfermode.h"
-#include "effects/GrPorterDuffXferProcessor.h"
-#include "effects/GrXfermodeFragmentProcessor.h"
-
-const GrFragmentProcessor* SkProcCoeffXfermode::getFragmentProcessorForImageFilter(
-                                                            const GrFragmentProcessor* dst) const {
+sk_sp<GrFragmentProcessor> SkProcCoeffXfermode::makeFragmentProcessorForImageFilter(
+                                                            sk_sp<GrFragmentProcessor> dst) const {
     SkASSERT(dst);
-    return GrXfermodeFragmentProcessor::CreateFromDstProcessor(dst, fMode);
+    return GrXfermodeFragmentProcessor::MakeFromDstProcessor(std::move(dst), fMode);
 }
 
-GrXPFactory* SkProcCoeffXfermode::asXPFactory() const {
+sk_sp<GrXPFactory> SkProcCoeffXfermode::asXPFactory() const {
     if (CANNOT_USE_COEFF != fSrcCoeff) {
-        GrXPFactory* result = GrPorterDuffXPFactory::Create(fMode);
+        sk_sp<GrXPFactory> result(GrPorterDuffXPFactory::Make(fMode));
         SkASSERT(result);
         return result;
     }
 
     SkASSERT(GrCustomXfermode::IsSupportedMode(fMode));
-    return GrCustomXfermode::CreateXPFactory(fMode);
+    return GrCustomXfermode::MakeXPFactory(fMode);
 }
 #endif
 
diff --git a/src/core/SkXfermode_proccoeff.h b/src/core/SkXfermode_proccoeff.h
index 3b45594..357de43 100644
--- a/src/core/SkXfermode_proccoeff.h
+++ b/src/core/SkXfermode_proccoeff.h
@@ -45,9 +45,9 @@
     bool isOpaque(SkXfermode::SrcColorOpacity opacityType) const override;
 
 #if SK_SUPPORT_GPU
-    const GrFragmentProcessor* getFragmentProcessorForImageFilter(
-                                                        const GrFragmentProcessor*) const override;
-    GrXPFactory* asXPFactory() const override;
+    sk_sp<GrFragmentProcessor> makeFragmentProcessorForImageFilter(
+                                                        sk_sp<GrFragmentProcessor>) const override;
+    sk_sp<GrXPFactory> asXPFactory() const override;
 #endif
 
     SK_TO_STRING_OVERRIDE()