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/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp b/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp
index ab0c46c..b0c60f7 100644
--- a/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp
+++ b/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp
@@ -630,13 +630,14 @@
 
 class GrPerlinNoise2Effect : public GrFragmentProcessor {
 public:
-    static GrFragmentProcessor* Create(SkPerlinNoiseShader2::Type type,
-                                       int numOctaves, bool stitchTiles,
-                                       SkPerlinNoiseShader2::PaintingData* paintingData,
-                                       GrTexture* permutationsTexture, GrTexture* noiseTexture,
-                                       const SkMatrix& matrix) {
-        return new GrPerlinNoise2Effect(type, numOctaves, stitchTiles, paintingData,
-                                       permutationsTexture, noiseTexture, matrix);
+    static sk_sp<GrFragmentProcessor> Make(SkPerlinNoiseShader2::Type type,
+                                           int numOctaves, bool stitchTiles,
+                                           SkPerlinNoiseShader2::PaintingData* paintingData,
+                                           GrTexture* permutationsTexture, GrTexture* noiseTexture,
+                                           const SkMatrix& matrix) {
+        return sk_sp<GrFragmentProcessor>(
+            new GrPerlinNoise2Effect(type, numOctaves, stitchTiles, paintingData,
+                                     permutationsTexture, noiseTexture, matrix));
     }
 
     virtual ~GrPerlinNoise2Effect() { delete fPaintingData; }
@@ -709,7 +710,7 @@
 /////////////////////////////////////////////////////////////////////
 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrPerlinNoise2Effect);
 
-const GrFragmentProcessor* GrPerlinNoise2Effect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrPerlinNoise2Effect::TestCreate(GrProcessorTestData* d) {
     int      numOctaves = d->fRandom->nextRangeU(2, 10);
     bool     stitchTiles = d->fRandom->nextBool();
     SkScalar seed = SkIntToScalar(d->fRandom->nextU());
@@ -1050,12 +1051,14 @@
 
 class GrImprovedPerlinNoiseEffect : public GrFragmentProcessor {
 public:
-    static GrFragmentProcessor* Create(int octaves, SkScalar z, 
-                                       SkPerlinNoiseShader2::PaintingData* paintingData,
-                                       GrTexture* permutationsTexture, GrTexture* gradientTexture,
-                                       const SkMatrix& matrix) {
-        return new GrImprovedPerlinNoiseEffect(octaves, z, paintingData, permutationsTexture,
-                                               gradientTexture, matrix);
+    static sk_sp<GrFragmentProcessor> Make(int octaves, SkScalar z,
+                                           SkPerlinNoiseShader2::PaintingData* paintingData,
+                                           GrTexture* permutationsTexture,
+                                           GrTexture* gradientTexture,
+                                           const SkMatrix& matrix) {
+        return sk_sp<GrFragmentProcessor>(
+            new GrImprovedPerlinNoiseEffect(octaves, z, paintingData, permutationsTexture,
+                                            gradientTexture, matrix));
     }
 
     virtual ~GrImprovedPerlinNoiseEffect() { delete fPaintingData; }
@@ -1118,7 +1121,7 @@
 /////////////////////////////////////////////////////////////////////
 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrImprovedPerlinNoiseEffect);
 
-const GrFragmentProcessor* GrImprovedPerlinNoiseEffect::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrFragmentProcessor> GrImprovedPerlinNoiseEffect::TestCreate(GrProcessorTestData* d) {
     SkScalar baseFrequencyX = d->fRandom->nextRangeScalar(0.01f,
                                                           0.99f);
     SkScalar baseFrequencyY = d->fRandom->nextRangeScalar(0.01f,
@@ -1298,7 +1301,7 @@
 }
 
 /////////////////////////////////////////////////////////////////////
-const GrFragmentProcessor* SkPerlinNoiseShader2::asFragmentProcessor(
+sk_sp<GrFragmentProcessor> SkPerlinNoiseShader2::asFragmentProcessor(
                                                     GrContext* context,
                                                     const SkMatrix& viewM,
                                                     const SkMatrix* externalLocalMatrix,
@@ -1333,20 +1336,20 @@
         SkAutoTUnref<GrTexture> gradientTexture(
             GrRefCachedBitmapTexture(context, paintingData->getGradientBitmap(),
                                      textureParams, gammaTreatment));
-        return GrImprovedPerlinNoiseEffect::Create(fNumOctaves, fSeed, paintingData, 
+        return GrImprovedPerlinNoiseEffect::Make(fNumOctaves, fSeed, paintingData,
                                                    permutationsTexture, gradientTexture, m);
     }
 
     if (0 == fNumOctaves) {
         if (kFractalNoise_Type == fType) {
             // Extract the incoming alpha and emit rgba = (a/4, a/4, a/4, a/2)
-            SkAutoTUnref<const GrFragmentProcessor> inner(
-                GrConstColorProcessor::Create(0x80404040,
-                                              GrConstColorProcessor::kModulateRGBA_InputMode));
-            return GrFragmentProcessor::MulOutputByInputAlpha(inner);
+            sk_sp<GrFragmentProcessor> inner(
+                GrConstColorProcessor::Make(0x80404040,
+                                            GrConstColorProcessor::kModulateRGBA_InputMode));
+            return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
         }
         // Emit zero.
-        return GrConstColorProcessor::Create(0x0, GrConstColorProcessor::kIgnore_InputMode);
+        return GrConstColorProcessor::Make(0x0, GrConstColorProcessor::kIgnore_InputMode);
     }
 
     SkAutoTUnref<GrTexture> permutationsTexture(
@@ -1357,14 +1360,14 @@
                                  GrTextureParams::ClampNoFilter(), gammaTreatment));
 
     if ((permutationsTexture) && (noiseTexture)) {
-        SkAutoTUnref<GrFragmentProcessor> inner(
-            GrPerlinNoise2Effect::Create(fType,
-                                        fNumOctaves,
-                                        fStitchTiles,
-                                        paintingData,
-                                        permutationsTexture, noiseTexture,
-                                        m));
-        return GrFragmentProcessor::MulOutputByInputAlpha(inner);
+        sk_sp<GrFragmentProcessor> inner(
+            GrPerlinNoise2Effect::Make(fType,
+                                       fNumOctaves,
+                                       fStitchTiles,
+                                       paintingData,
+                                       permutationsTexture, noiseTexture,
+                                       m));
+        return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
     }
     delete paintingData;
     return nullptr;