GrGeometryProcessor derives from GrNonAtomicRef not GrProgramElement.

It probably doesn't need to be ref counted at all and should be stored
in GrOpFlushState's arena but that's a larger change for another day.

Change-Id: I5f593fb426b8e7794f2ca81194f5a8d9e0f0a072
Reviewed-on: https://skia-review.googlesource.com/145332
Auto-Submit: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/bench/VertexColorSpaceBench.cpp b/bench/VertexColorSpaceBench.cpp
index 8af1db2..717a529 100644
--- a/bench/VertexColorSpaceBench.cpp
+++ b/bench/VertexColorSpaceBench.cpp
@@ -204,7 +204,7 @@
         mesh.setVertexData(vertexBuffer, firstVertex);
         auto pipe = target->makePipeline(0, GrProcessorSet::MakeEmptySet(),
                                          target->detachAppliedClip());
-        target->draw(gp.get(), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
+        target->draw(gp, pipe.fPipeline, pipe.fFixedDynamicState, mesh);
     }
 
     Mode fMode;
diff --git a/gm/beziereffects.cpp b/gm/beziereffects.cpp
index dbae869..a5b8f20 100644
--- a/gm/beziereffects.cpp
+++ b/gm/beziereffects.cpp
@@ -40,7 +40,8 @@
     }
 
 protected:
-    BezierTestOp(sk_sp<GrGeometryProcessor> gp, const SkRect& rect, GrColor color, int32_t classID)
+    BezierTestOp(sk_sp<const GrGeometryProcessor> gp, const SkRect& rect, GrColor color,
+                 int32_t classID)
             : INHERITED(classID)
             , fRect(rect)
             , fColor(color)
@@ -53,7 +54,7 @@
         return target->makePipeline(0, std::move(fProcessorSet), target->detachAppliedClip());
     }
 
-    const GrGeometryProcessor* gp() const { return fGeometryProcessor.get(); }
+    sk_sp<const GrGeometryProcessor> gp() const { return fGeometryProcessor; }
 
     const SkRect& rect() const { return fRect; }
     GrColor color() const { return fColor; }
@@ -63,7 +64,7 @@
 
     SkRect fRect;
     GrColor fColor;
-    sk_sp<GrGeometryProcessor> fGeometryProcessor;
+    sk_sp<const GrGeometryProcessor> fGeometryProcessor;
     GrProcessorSet fProcessorSet;
 
     typedef GrMeshDrawOp INHERITED;
@@ -76,7 +77,7 @@
     const char* name() const override { return "BezierCubicTestOp"; }
 
     static std::unique_ptr<GrDrawOp> Make(GrContext* context,
-                                          sk_sp<GrGeometryProcessor> gp,
+                                          sk_sp<const GrGeometryProcessor> gp,
                                           const SkRect& rect,
                                           GrColor color) {
         GrOpMemoryPool* pool = context->contextPriv().opMemoryPool();
@@ -87,7 +88,7 @@
 private:
     friend class ::GrOpMemoryPool; // for ctor
 
-    BezierCubicTestOp(sk_sp<GrGeometryProcessor> gp, const SkRect& rect, GrColor color)
+    BezierCubicTestOp(sk_sp<const GrGeometryProcessor> gp, const SkRect& rect, GrColor color)
             : INHERITED(std::move(gp), rect, color, ClassID()) {}
 
     void onPrepareDraws(Target* target) override {
@@ -261,7 +262,7 @@
     const char* name() const override { return "BezierConicTestOp"; }
 
     static std::unique_ptr<GrDrawOp> Make(GrContext* context,
-                                          sk_sp<GrGeometryProcessor> gp,
+                                          sk_sp<const GrGeometryProcessor> gp,
                                           const SkRect& rect,
                                           GrColor color,
                                           const SkMatrix& klm) {
@@ -273,7 +274,7 @@
 private:
     friend class ::GrOpMemoryPool; // for ctor
 
-    BezierConicTestOp(sk_sp<GrGeometryProcessor> gp, const SkRect& rect, GrColor color,
+    BezierConicTestOp(sk_sp<const GrGeometryProcessor> gp, const SkRect& rect, GrColor color,
                       const SkMatrix& klm)
             : INHERITED(std::move(gp), rect, color, ClassID()), fKLM(klm) {}
 
@@ -483,7 +484,7 @@
     const char* name() const override { return "BezierQuadTestOp"; }
 
     static std::unique_ptr<GrDrawOp> Make(GrContext* context,
-                                          sk_sp<GrGeometryProcessor> gp,
+                                          sk_sp<const GrGeometryProcessor> gp,
                                           const SkRect& rect,
                                           GrColor color,
                                           const GrPathUtils::QuadUVMatrix& devToUV) {
@@ -495,7 +496,7 @@
 private:
     friend class ::GrOpMemoryPool; // for ctor
 
-    BezierQuadTestOp(sk_sp<GrGeometryProcessor> gp, const SkRect& rect, GrColor color,
+    BezierQuadTestOp(sk_sp<const GrGeometryProcessor> gp, const SkRect& rect, GrColor color,
                      const GrPathUtils::QuadUVMatrix& devToUV)
             : INHERITED(std::move(gp), rect, color, ClassID()), fDevToUV(devToUV) {}
 
diff --git a/gm/convexpolyeffect.cpp b/gm/convexpolyeffect.cpp
index 41d53e6..3dcf35d 100644
--- a/gm/convexpolyeffect.cpp
+++ b/gm/convexpolyeffect.cpp
@@ -96,7 +96,7 @@
         SkPointPriv::SetRectTriStrip(verts, fRect, sizeof(SkPoint));
 
         auto pipe = target->makePipeline(0, std::move(fProcessors), target->detachAppliedClip());
-        helper.recordDraw(target, gp.get(), pipe.fPipeline, pipe.fFixedDynamicState);
+        helper.recordDraw(target, std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState);
     }
 
     bool onCombineIfPossible(GrOp* op, const GrCaps& caps) override { return false; }
diff --git a/gn/gpu.gni b/gn/gpu.gni
index 83d3c4e..e9b44cb 100644
--- a/gn/gpu.gni
+++ b/gn/gpu.gni
@@ -125,7 +125,6 @@
   "$_src/gpu/GrPathUtils.cpp",
   "$_src/gpu/GrPathUtils.h",
   "$_src/gpu/GrPendingIOResource.h",
-  "$_src/gpu/GrPendingProgramElement.h",
   "$_src/gpu/GrOnFlushResourceProvider.cpp",
   "$_src/gpu/GrOnFlushResourceProvider.h",
   "$_src/gpu/GrPipeline.cpp",
@@ -136,7 +135,6 @@
   "$_src/gpu/GrProcessorSet.h",
   "$_src/gpu/GrProgramDesc.cpp",
   "$_src/gpu/GrProgramDesc.h",
-  "$_src/gpu/GrProgramElement.h",
   "$_src/gpu/GrProcessor.cpp",
   "$_src/gpu/GrProcessor.h",
   "$_src/gpu/GrProcessorAnalysis.cpp",
diff --git a/include/private/GrProxyRef.h b/include/private/GrProxyRef.h
index 7af6ec4..9d4419f 100644
--- a/include/private/GrProxyRef.h
+++ b/include/private/GrProxyRef.h
@@ -80,8 +80,10 @@
         fProxy = nullptr;
     }
 
-    /** Called by owning GrProgramElement when the program element is first scheduled for
-        execution. It can only be called once. */
+    /**
+     * Called when transferring into an op list and therefore scheduled for an IO operation. It can
+     * only be called once.
+     */
     void markPendingIO() const {
         // This should only be called when the owning GrProgramElement gets its first
         // pendingExecution ref.
diff --git a/src/gpu/GrGpuCommandBuffer.cpp b/src/gpu/GrGpuCommandBuffer.cpp
index f4de5c6..d66f24c 100644
--- a/src/gpu/GrGpuCommandBuffer.cpp
+++ b/src/gpu/GrGpuCommandBuffer.cpp
@@ -44,7 +44,7 @@
 
     auto resourceProvider = this->gpu()->getContext()->contextPriv().resourceProvider();
 
-    if (pipeline.isBad() || !primProc.instantiate(resourceProvider)) {
+    if (pipeline.isBad()) {
         return false;
     }
     for (int i = 0; i < primProc.numTextureSamplers(); ++i) {
diff --git a/src/gpu/GrOpFlushState.cpp b/src/gpu/GrOpFlushState.cpp
index 128a98c..8709e78 100644
--- a/src/gpu/GrOpFlushState.cpp
+++ b/src/gpu/GrOpFlushState.cpp
@@ -104,7 +104,7 @@
     return fTokenTracker->nextTokenToFlush();
 }
 
-void GrOpFlushState::draw(const GrGeometryProcessor* gp, const GrPipeline* pipeline,
+void GrOpFlushState::draw(sk_sp<const GrGeometryProcessor> gp, const GrPipeline* pipeline,
                           const GrPipeline::FixedDynamicState* fixedDynamicState,
                           const GrMesh& mesh) {
     SkASSERT(fOpArgs);
@@ -132,7 +132,7 @@
     for (int i = 0; i < gp->numTextureSamplers(); ++i) {
         fixedDynamicState->fPrimitiveProcessorTextures[i]->addPendingRead();
     }
-    draw.fGeometryProcessor.reset(gp);
+    draw.fGeometryProcessor = std::move(gp);
     draw.fPipeline = pipeline;
     draw.fFixedDynamicState = fixedDynamicState;
     draw.fDynamicStateArrays = nullptr;
diff --git a/src/gpu/GrOpFlushState.h b/src/gpu/GrOpFlushState.h
index dcdcbeb..b9ec736 100644
--- a/src/gpu/GrOpFlushState.h
+++ b/src/gpu/GrOpFlushState.h
@@ -74,8 +74,8 @@
 
     /** Overrides of GrMeshDrawOp::Target. */
 
-    void draw(const GrGeometryProcessor*, const GrPipeline*, const GrPipeline::FixedDynamicState*,
-              const GrMesh&) final;
+    void draw(sk_sp<const GrGeometryProcessor>, const GrPipeline*,
+              const GrPipeline::FixedDynamicState*, const GrMesh&) final;
     void* makeVertexSpace(size_t vertexSize, int vertexCount, const GrBuffer**,
                           int* startVertex) final;
     uint16_t* makeIndexSpace(int indexCount, const GrBuffer**, int* startIndex) final;
@@ -124,7 +124,7 @@
             }
         }
         int fMeshCnt = 0;
-        GrPendingProgramElement<const GrGeometryProcessor> fGeometryProcessor;
+        sk_sp<const GrGeometryProcessor> fGeometryProcessor;
         const GrPipeline* fPipeline;
         const GrPipeline::FixedDynamicState* fFixedDynamicState;
         const GrPipeline::DynamicStateArrays* fDynamicStateArrays;
diff --git a/src/gpu/GrPendingProgramElement.h b/src/gpu/GrPendingProgramElement.h
deleted file mode 100644
index ab1f437..0000000
--- a/src/gpu/GrPendingProgramElement.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2014 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrPendingProgramElement_DEFINED
-#define GrPendingProgramElement_DEFINED
-
-#include "SkRefCnt.h"
-#include "GrTypes.h"
-
-/**
- * Helper for owning a pending execution on a GrProgramElement. Using this rather than ref allows
- * resources that are owned by the program element to be correctly tracked as having pending reads
- * and writes rather than refs.
- */
-template <typename T> class GrPendingProgramElement : SkNoncopyable {
-public:
-    GrPendingProgramElement() : fObj(nullptr) { }
-
-    // Adds a pending execution on obj.
-    explicit GrPendingProgramElement(T* obj) : fObj(obj)  {
-        if (obj) {
-            obj->addPendingExecution();
-        }
-    }
-
-    void reset(T* obj) {
-        if (obj) {
-            obj->addPendingExecution();
-        }
-        if (fObj) {
-            fObj->completedExecution();
-        }
-        fObj = obj;
-    }
-
-    T* get() const { return fObj; }
-    operator T*() { return fObj; }
-
-    T *operator->() const { return fObj; }
-
-    ~GrPendingProgramElement() {
-        if (fObj) {
-            fObj->completedExecution();
-        }
-    }
-
-private:
-    T*   fObj;
-
-    typedef SkNoncopyable INHERITED;
-};
-#endif
diff --git a/src/gpu/GrPipeline.h b/src/gpu/GrPipeline.h
index aaf36be..b2f6711 100644
--- a/src/gpu/GrPipeline.h
+++ b/src/gpu/GrPipeline.h
@@ -12,7 +12,6 @@
 #include "GrFragmentProcessor.h"
 #include "GrNonAtomicRef.h"
 #include "GrPendingIOResource.h"
-#include "GrPendingProgramElement.h"
 #include "GrProcessorSet.h"
 #include "GrProgramDesc.h"
 #include "GrRect.h"
diff --git a/src/gpu/GrPrimitiveProcessor.h b/src/gpu/GrPrimitiveProcessor.h
index 8c4d0aa..4becb54 100644
--- a/src/gpu/GrPrimitiveProcessor.h
+++ b/src/gpu/GrPrimitiveProcessor.h
@@ -9,6 +9,7 @@
 #define GrPrimitiveProcessor_DEFINED
 
 #include "GrColor.h"
+#include "GrNonAtomicRef.h"
 #include "GrProcessor.h"
 #include "GrProxyRef.h"
 #include "GrShaderVar.h"
@@ -41,9 +42,10 @@
  * GrPrimitiveProcessors must proivide seed color and coverage for the Ganesh color / coverage
  * pipelines, and they must provide some notion of equality
  *
- * TODO: Overrides of GrProgramElement virtuals don't do anything anymore. Remove this base class.
+ * TODO: This class does not really need to be ref counted. Instances should be allocated using
+ * GrOpFlushState's arena and destroyed when the arena is torn down.
  */
-class GrPrimitiveProcessor : public GrProcessor, public GrProgramElement {
+class GrPrimitiveProcessor : public GrProcessor, public GrNonAtomicRef<GrPrimitiveProcessor> {
 public:
     class TextureSampler;
 
@@ -138,8 +140,6 @@
 
     virtual float getSampleShading() const { return 0.0; }
 
-    bool instantiate(GrResourceProvider*) const { return true; }
-
 protected:
     void setVertexAttributeCnt(int cnt) {
         SkASSERT(cnt >= 0);
@@ -166,11 +166,6 @@
     inline static const TextureSampler& IthTextureSampler(int i);
 
 private:
-    void addPendingIOs() const final {}
-    void removeRefs() const final {}
-    void pendingIOComplete() const final {}
-    void notifyRefCntIsZero() const final {}
-
     virtual const Attribute& onVertexAttribute(int) const = 0;
     virtual const Attribute& onInstanceAttribute(int) const = 0;
     virtual const TextureSampler& onTextureSampler(int) const { return IthTextureSampler(0); }
diff --git a/src/gpu/GrProcessor.h b/src/gpu/GrProcessor.h
index 4afb246..3c6662c 100644
--- a/src/gpu/GrProcessor.h
+++ b/src/gpu/GrProcessor.h
@@ -12,7 +12,6 @@
 #include "GrBuffer.h"
 #include "GrColor.h"
 #include "GrProcessorUnitTest.h"
-#include "GrProgramElement.h"
 #include "GrSamplerState.h"
 #include "GrShaderVar.h"
 #include "GrSurfaceProxyPriv.h"
diff --git a/src/gpu/GrProgramElement.h b/src/gpu/GrProgramElement.h
deleted file mode 100644
index ef96738..0000000
--- a/src/gpu/GrProgramElement.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright 2014 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrProgramElement_DEFINED
-#define GrProgramElement_DEFINED
-
-#include "../private/SkTArray.h"
-#include "SkRefCnt.h"
-
-/**
- * Note: We are converting GrProcessor from ref counting to a single owner model using move
- * semantics. This class will be removed.
- *
- * This is used to track "refs" for two separate types GrProcessor ownership. A regular ref is owned
- * by any client that may continue to issue draws that use the GrProgramElement. A recorded op or
- * GrPipeline uses "pending executions" instead of refs. A pending execution is cleared after the
- * draw is executed (or aborted).
- *
- * While a GrProgramElement is ref'ed any resources it owns are also ref'ed. However, once it gets
- * into the state where it has pending executions AND no refs then it converts its ownership of
- * its GrGpuResources from refs to pending IOs. The pending IOs allow the cache to track when it is
- * safe to recycle a resource even though we still have buffered GrOps that read or write to the
- * the resource.
- *
- * To make this work the subclass GrProcessor implements addPendingIOs, removeRefs, and
- * pendingIOComplete. addPendingIOs adds pending reads/writes to GrGpuResources owned by the
- * processor as appropriate when the processor is recorded in a GrOpList. removeRefs is called when
- * the ref count reaches 0 and the GrProcessor is only owned by "pending executions".
- * pendingIOComplete occurs if the resource is still owned by a ref but all recorded draws have been
- * completed. Whenever pending executions and refs reach zero the processor is deleted.
- *
- * The GrProcessor may also implement notifyRefCntIsZero in order to change its ownership of child
- * processors from ref to pending execution when the processor is first owned exclusively in pending
- * execution mode.
- */
-class GrProgramElement : public SkNoncopyable {
-public:
-    virtual ~GrProgramElement() {
-        // fRefCnt can be one when an effect is created statically using GR_CREATE_STATIC_EFFECT
-        SkASSERT((0 == fRefCnt || 1 == fRefCnt) && 0 == fPendingExecutions);
-        // Set to invalid values.
-        SkDEBUGCODE(fRefCnt = fPendingExecutions = -10;)
-    }
-
-    void ref() const {
-        this->validate();
-        // Once the ref cnt reaches zero it should never be ref'ed again.
-        SkASSERT(fRefCnt > 0);
-        ++fRefCnt;
-        this->validate();
-    }
-
-    void unref() const {
-        this->validate();
-        --fRefCnt;
-        if (0 == fRefCnt) {
-            this->notifyRefCntIsZero();
-            if (0 == fPendingExecutions) {
-                delete this;
-                return;
-            } else {
-                this->removeRefs();
-            }
-        }
-        this->validate();
-    }
-
-    void validate() const {
-#ifdef SK_DEBUG
-        SkASSERT(fRefCnt >= 0);
-        SkASSERT(fPendingExecutions >= 0);
-        SkASSERT(fRefCnt + fPendingExecutions > 0);
-#endif
-    }
-
-protected:
-    GrProgramElement() : fRefCnt(1), fPendingExecutions(0) {}
-
-    void addPendingExecution() const {
-        this->validate();
-        if (0 == fPendingExecutions) {
-            this->addPendingIOs();
-        }
-        ++fPendingExecutions;
-        this->validate();
-    }
-
-    void completedExecution() const {
-        this->validate();
-        --fPendingExecutions;
-        if (0 == fPendingExecutions) {
-            if (0 == fRefCnt) {
-                delete this;
-                return;
-            } else {
-                this->pendingIOComplete();
-            }
-        }
-        this->validate();
-    }
-
-private:
-    virtual void addPendingIOs() const = 0;
-    virtual void removeRefs() const = 0;
-    virtual void pendingIOComplete() const = 0;
-
-    /** This will be called when the ref cnt is zero. The object may or may not have pending
-        executions. */
-    virtual void notifyRefCntIsZero() const = 0;
-
-    mutable int32_t fRefCnt;
-    // Count of deferred executions not yet issued to the 3D API.
-    mutable int32_t fPendingExecutions;
-
-    // Only these classes can access addPendingExecution() and completedExecution().
-    template <typename T> friend class GrPendingProgramElement;
-    friend class GrProcessorSet;
-
-    typedef SkNoncopyable INHERITED;
-};
-
-#endif
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index b60088d..ba290ac 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -33,11 +33,7 @@
                                                const GrPipeline& pipeline,
                                                GrProgramDesc* desc,
                                                GrGLGpu* gpu) {
-#ifdef SK_DEBUG
-    GrResourceProvider* resourceProvider = gpu->getContext()->contextPriv().resourceProvider();
-
-    SkASSERT(!pipeline.isBad() && primProc.instantiate(resourceProvider));
-#endif
+    SkASSERT(!pipeline.isBad());
 
     ATRACE_ANDROID_FRAMEWORK("Shader Compile");
     GrAutoLocaleSetter als("C");
diff --git a/src/gpu/ops/GrAAConvexPathRenderer.cpp b/src/gpu/ops/GrAAConvexPathRenderer.cpp
index 3d475b9..9831a11 100644
--- a/src/gpu/ops/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/ops/GrAAConvexPathRenderer.cpp
@@ -847,7 +847,7 @@
             mesh.setIndexed(indexBuffer, tess.numIndices(), firstIndex, 0, tess.numPts() - 1,
                             GrPrimitiveRestart::kNo);
             mesh.setVertexData(vertexBuffer, firstVertex);
-            target->draw(gp.get(), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
+            target->draw(gp, pipe.fPipeline, pipe.fFixedDynamicState, mesh);
         }
     }
 
@@ -935,7 +935,7 @@
                 mesh.setIndexed(indexBuffer, draw.fIndexCnt, firstIndex, 0, draw.fVertexCnt - 1,
                                 GrPrimitiveRestart::kNo);
                 mesh.setVertexData(vertexBuffer, firstVertex);
-                target->draw(quadProcessor.get(), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
+                target->draw(quadProcessor, pipe.fPipeline, pipe.fFixedDynamicState, mesh);
                 firstIndex += draw.fIndexCnt;
                 firstVertex += draw.fVertexCnt;
             }
diff --git a/src/gpu/ops/GrAAFillRectOp.cpp b/src/gpu/ops/GrAAFillRectOp.cpp
index 592c0b2..4b939bb 100644
--- a/src/gpu/ops/GrAAFillRectOp.cpp
+++ b/src/gpu/ops/GrAAFillRectOp.cpp
@@ -292,7 +292,7 @@
             info = this->next(info);
         }
         auto pipe = fHelper.makePipeline(target);
-        helper.recordDraw(target, gp.get(), pipe.fPipeline, pipe.fFixedDynamicState);
+        helper.recordDraw(target, std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState);
     }
 
     bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
diff --git a/src/gpu/ops/GrAAHairLinePathRenderer.cpp b/src/gpu/ops/GrAAHairLinePathRenderer.cpp
index 05f1fbd..b192474 100644
--- a/src/gpu/ops/GrAAHairLinePathRenderer.cpp
+++ b/src/gpu/ops/GrAAHairLinePathRenderer.cpp
@@ -979,7 +979,7 @@
         mesh.setIndexedPatterned(linesIndexBuffer.get(), kIdxsPerLineSeg, kLineSegNumVertices,
                                  lineCount, kLineSegsNumInIdxBuffer);
         mesh.setVertexData(vertexBuffer, firstVertex);
-        target->draw(lineGP.get(), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
+        target->draw(std::move(lineGP), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
     }
 
     if (quadCount || conicCount) {
@@ -1034,7 +1034,7 @@
             mesh.setIndexedPatterned(quadsIndexBuffer.get(), kIdxsPerQuad, kQuadNumVertices,
                                      quadCount, kQuadsNumInIdxBuffer);
             mesh.setVertexData(vertexBuffer, firstVertex);
-            target->draw(quadGP.get(), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
+            target->draw(std::move(quadGP), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
             firstVertex += quadCount * kQuadNumVertices;
         }
 
@@ -1043,7 +1043,7 @@
             mesh.setIndexedPatterned(quadsIndexBuffer.get(), kIdxsPerQuad, kQuadNumVertices,
                                      conicCount, kQuadsNumInIdxBuffer);
             mesh.setVertexData(vertexBuffer, firstVertex);
-            target->draw(conicGP.get(), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
+            target->draw(std::move(conicGP), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
         }
     }
 }
diff --git a/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp b/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp
index 75662d3..63aac85 100644
--- a/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp
+++ b/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp
@@ -210,7 +210,7 @@
     }
 
 private:
-    void draw(Target* target, const GrGeometryProcessor* gp, const GrPipeline* pipeline,
+    void draw(Target* target, sk_sp<const GrGeometryProcessor> gp, const GrPipeline* pipeline,
               const GrPipeline::FixedDynamicState* fixedDynamicState, int vertexCount,
               size_t vertexStride, void* vertices, int indexCount, uint16_t* indices) const {
         if (vertexCount == 0 || indexCount == 0) {
@@ -238,7 +238,7 @@
         mesh.setIndexed(indexBuffer, indexCount, firstIndex, 0, vertexCount - 1,
                         GrPrimitiveRestart::kNo);
         mesh.setVertexData(vertexBuffer, firstVertex);
-        target->draw(gp, pipeline, fixedDynamicState, mesh);
+        target->draw(std::move(gp), pipeline, fixedDynamicState, mesh);
     }
 
     void onPrepareDraws(Target* target) override {
@@ -279,7 +279,7 @@
             if (vertexCount + currentVertices > static_cast<int>(UINT16_MAX)) {
                 // if we added the current instance, we would overflow the indices we can store in a
                 // uint16_t. Draw what we've got so far and reset.
-                this->draw(target, gp.get(), pipe.fPipeline, pipe.fFixedDynamicState, vertexCount,
+                this->draw(target, gp, pipe.fPipeline, pipe.fFixedDynamicState, vertexCount,
                            vertexStride, vertices, indexCount, indices);
                 vertexCount = 0;
                 indexCount = 0;
@@ -311,7 +311,7 @@
             indexCount += currentIndices;
         }
         if (vertexCount <= SK_MaxS32 && indexCount <= SK_MaxS32) {
-            this->draw(target, gp.get(), pipe.fPipeline, pipe.fFixedDynamicState, vertexCount,
+            this->draw(target, std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState, vertexCount,
                        vertexStride, vertices, indexCount, indices);
         }
         sk_free(vertices);
diff --git a/src/gpu/ops/GrAAStrokeRectOp.cpp b/src/gpu/ops/GrAAStrokeRectOp.cpp
index 92d1c01..0645e64 100644
--- a/src/gpu/ops/GrAAStrokeRectOp.cpp
+++ b/src/gpu/ops/GrAAStrokeRectOp.cpp
@@ -308,7 +308,7 @@
                                            fHelper.compatibleWithAlphaAsCoverage());
     }
     auto pipe = fHelper.makePipeline(target);
-    helper.recordDraw(target, gp.get(), pipe.fPipeline, pipe.fFixedDynamicState);
+    helper.recordDraw(target, std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState);
 }
 
 sk_sp<const GrBuffer> AAStrokeRectOp::GetIndexBuffer(GrResourceProvider* resourceProvider,
diff --git a/src/gpu/ops/GrAtlasTextOp.cpp b/src/gpu/ops/GrAtlasTextOp.cpp
index a6e2bce..bd24ef6 100644
--- a/src/gpu/ops/GrAtlasTextOp.cpp
+++ b/src/gpu/ops/GrAtlasTextOp.cpp
@@ -431,8 +431,8 @@
     mesh.setIndexedPatterned(flushInfo->fIndexBuffer.get(), kIndicesPerGlyph, kVerticesPerGlyph,
                              flushInfo->fGlyphsToFlush, maxGlyphsPerDraw);
     mesh.setVertexData(flushInfo->fVertexBuffer.get(), flushInfo->fVertexOffset);
-    target->draw(flushInfo->fGeometryProcessor.get(), flushInfo->fPipeline,
-                 flushInfo->fFixedDynamicState, mesh);
+    target->draw(flushInfo->fGeometryProcessor, flushInfo->fPipeline, flushInfo->fFixedDynamicState,
+                 mesh);
     flushInfo->fVertexOffset += kVerticesPerGlyph * flushInfo->fGlyphsToFlush;
     flushInfo->fGlyphsToFlush = 0;
 }
diff --git a/src/gpu/ops/GrDashOp.cpp b/src/gpu/ops/GrDashOp.cpp
index 61fad24..29d9dcb 100644
--- a/src/gpu/ops/GrDashOp.cpp
+++ b/src/gpu/ops/GrDashOp.cpp
@@ -696,7 +696,7 @@
         }
         auto pipe = target->makePipeline(pipelineFlags, std::move(fProcessorSet),
                                          target->detachAppliedClip());
-        helper.recordDraw(target, gp.get(), pipe.fPipeline, pipe.fFixedDynamicState);
+        helper.recordDraw(target, std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState);
     }
 
     bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
diff --git a/src/gpu/ops/GrDefaultPathRenderer.cpp b/src/gpu/ops/GrDefaultPathRenderer.cpp
index 07e40f0..1e8e116 100644
--- a/src/gpu/ops/GrDefaultPathRenderer.cpp
+++ b/src/gpu/ops/GrDefaultPathRenderer.cpp
@@ -65,12 +65,12 @@
 class PathGeoBuilder {
 public:
     PathGeoBuilder(GrPrimitiveType primitiveType, GrMeshDrawOp::Target* target,
-                   GrGeometryProcessor* geometryProcessor, const GrPipeline* pipeline,
+                   sk_sp<const GrGeometryProcessor> geometryProcessor, const GrPipeline* pipeline,
                    const GrPipeline::FixedDynamicState* fixedDynamicState)
             : fMesh(primitiveType)
             , fTarget(target)
             , fVertexStride(sizeof(SkPoint))
-            , fGeometryProcessor(geometryProcessor)
+            , fGeometryProcessor(std::move(geometryProcessor))
             , fPipeline(pipeline)
             , fFixedDynamicState(fixedDynamicState)
             , fIndexBuffer(nullptr)
@@ -314,7 +314,7 @@
     GrMesh fMesh;
     GrMeshDrawOp::Target* fTarget;
     size_t fVertexStride;
-    GrGeometryProcessor* fGeometryProcessor;
+    sk_sp<const GrGeometryProcessor> fGeometryProcessor;
     const GrPipeline* fPipeline;
     const GrPipeline::FixedDynamicState* fFixedDynamicState;
 
@@ -428,7 +428,7 @@
             primitiveType = GrPrimitiveType::kTriangles;
         }
         auto pipe = fHelper.makePipeline(target);
-        PathGeoBuilder pathGeoBuilder(primitiveType, target, gp.get(), pipe.fPipeline,
+        PathGeoBuilder pathGeoBuilder(primitiveType, target, std::move(gp), pipe.fPipeline,
                                       pipe.fFixedDynamicState);
 
         // fill buffers
diff --git a/src/gpu/ops/GrDrawAtlasOp.cpp b/src/gpu/ops/GrDrawAtlasOp.cpp
index d280ad9..5e22416 100644
--- a/src/gpu/ops/GrDrawAtlasOp.cpp
+++ b/src/gpu/ops/GrDrawAtlasOp.cpp
@@ -147,7 +147,7 @@
         vertPtr += allocSize;
     }
     auto pipe = fHelper.makePipeline(target);
-    helper.recordDraw(target, gp.get(), pipe.fPipeline, pipe.fFixedDynamicState);
+    helper.recordDraw(target, std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState);
 }
 
 bool GrDrawAtlasOp::onCombineIfPossible(GrOp* t, const GrCaps& caps) {
diff --git a/src/gpu/ops/GrDrawVerticesOp.cpp b/src/gpu/ops/GrDrawVerticesOp.cpp
index d227920..b0cd3f7 100644
--- a/src/gpu/ops/GrDrawVerticesOp.cpp
+++ b/src/gpu/ops/GrDrawVerticesOp.cpp
@@ -261,7 +261,7 @@
                       indices);
 
     // Draw the vertices.
-    this->drawVertices(target, gp.get(), vertexBuffer, firstVertex, indexBuffer, firstIndex);
+    this->drawVertices(target, std::move(gp), vertexBuffer, firstVertex, indexBuffer, firstIndex);
 }
 
 void GrDrawVerticesOp::drawNonVolatile(Target* target) {
@@ -298,7 +298,7 @@
 
     // Draw using the cached buffers if possible.
     if (vertexBuffer && (!this->isIndexed() || indexBuffer)) {
-        this->drawVertices(target, gp.get(), vertexBuffer.get(), 0, indexBuffer.get(), 0);
+        this->drawVertices(target, std::move(gp), vertexBuffer.get(), 0, indexBuffer.get(), 0);
         return;
     }
 
@@ -353,7 +353,7 @@
     rp->assignUniqueKeyToResource(indexKey, indexBuffer.get());
 
     // Draw the vertices.
-    this->drawVertices(target, gp.get(), vertexBuffer.get(), 0, indexBuffer.get(), 0);
+    this->drawVertices(target, std::move(gp), vertexBuffer.get(), 0, indexBuffer.get(), 0);
 }
 
 void GrDrawVerticesOp::fillBuffers(bool hasColorAttribute,
@@ -465,7 +465,7 @@
 }
 
 void GrDrawVerticesOp::drawVertices(Target* target,
-                                    GrGeometryProcessor* gp,
+                                    sk_sp<const GrGeometryProcessor> gp,
                                     const GrBuffer* vertexBuffer,
                                     int firstVertex,
                                     const GrBuffer* indexBuffer,
@@ -480,7 +480,7 @@
     }
     mesh.setVertexData(vertexBuffer, firstVertex);
     auto pipe = fHelper.makePipeline(target);
-    target->draw(gp, pipe.fPipeline, pipe.fFixedDynamicState, mesh);
+    target->draw(std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
 }
 
 bool GrDrawVerticesOp::onCombineIfPossible(GrOp* t, const GrCaps& caps) {
diff --git a/src/gpu/ops/GrDrawVerticesOp.h b/src/gpu/ops/GrDrawVerticesOp.h
index 7695dd9..c23ec8b 100644
--- a/src/gpu/ops/GrDrawVerticesOp.h
+++ b/src/gpu/ops/GrDrawVerticesOp.h
@@ -80,7 +80,7 @@
                      uint16_t* indices) const;
 
     void drawVertices(Target*,
-                      GrGeometryProcessor*,
+                      sk_sp<const GrGeometryProcessor>,
                       const GrBuffer* vertexBuffer,
                       int firstVertex,
                       const GrBuffer* indexBuffer,
diff --git a/src/gpu/ops/GrLatticeOp.cpp b/src/gpu/ops/GrLatticeOp.cpp
index 0da289a..283754c 100644
--- a/src/gpu/ops/GrLatticeOp.cpp
+++ b/src/gpu/ops/GrLatticeOp.cpp
@@ -283,7 +283,7 @@
         }
         auto pipe = fHelper.makePipeline(target, 1);
         pipe.fFixedDynamicState->fPrimitiveProcessorTextures[0] = fProxy.get();
-        helper.recordDraw(target, gp.get(), pipe.fPipeline, pipe.fFixedDynamicState);
+        helper.recordDraw(target, std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState);
     }
 
     bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
diff --git a/src/gpu/ops/GrMeshDrawOp.cpp b/src/gpu/ops/GrMeshDrawOp.cpp
index 5450b11..ab1f364 100644
--- a/src/gpu/ops/GrMeshDrawOp.cpp
+++ b/src/gpu/ops/GrMeshDrawOp.cpp
@@ -41,9 +41,9 @@
 }
 
 void GrMeshDrawOp::PatternHelper::recordDraw(
-        Target* target, const GrGeometryProcessor* gp, const GrPipeline* pipeline,
+        Target* target, sk_sp<const GrGeometryProcessor> gp, const GrPipeline* pipeline,
         const GrPipeline::FixedDynamicState* fixedDynamicState) {
-    target->draw(gp, pipeline, fixedDynamicState, fMesh);
+    target->draw(std::move(gp), pipeline, fixedDynamicState, fMesh);
 }
 
 void* GrMeshDrawOp::QuadHelper::init(Target* target, size_t vertexStride, int quadsToDraw) {
diff --git a/src/gpu/ops/GrMeshDrawOp.h b/src/gpu/ops/GrMeshDrawOp.h
index 3cb5ffe..38b7bb4 100644
--- a/src/gpu/ops/GrMeshDrawOp.h
+++ b/src/gpu/ops/GrMeshDrawOp.h
@@ -12,7 +12,6 @@
 #include "GrDrawOp.h"
 #include "GrGeometryProcessor.h"
 #include "GrMesh.h"
-#include "GrPendingProgramElement.h"
 
 class GrAtlasManager;
 class GrCaps;
@@ -41,7 +40,7 @@
                    int indicesPerRepetition, int repeatCount);
 
         /** Call after init() to issue draws to the GrMeshDrawOp::Target.*/
-        void recordDraw(Target*, const GrGeometryProcessor*, const GrPipeline*,
+        void recordDraw(Target*, sk_sp<const GrGeometryProcessor>, const GrPipeline*,
                         const GrPipeline::FixedDynamicState*);
 
     private:
@@ -78,7 +77,7 @@
     virtual ~Target() {}
 
     /** Adds a draw of a mesh. */
-    virtual void draw(const GrGeometryProcessor*, const GrPipeline*,
+    virtual void draw(sk_sp<const GrGeometryProcessor>, const GrPipeline*,
                       const GrPipeline::FixedDynamicState*, const GrMesh&) = 0;
 
     /**
diff --git a/src/gpu/ops/GrNonAAFillRectOp.cpp b/src/gpu/ops/GrNonAAFillRectOp.cpp
index c554232..f7fea58 100644
--- a/src/gpu/ops/GrNonAAFillRectOp.cpp
+++ b/src/gpu/ops/GrNonAAFillRectOp.cpp
@@ -207,7 +207,7 @@
                       fRects[i].fRect, &fRects[i].fLocalQuad);
         }
         auto pipe = fHelper.makePipeline(target);
-        helper.recordDraw(target, gp.get(), pipe.fPipeline, pipe.fFixedDynamicState);
+        helper.recordDraw(target, std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState);
     }
 
     bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
@@ -345,7 +345,7 @@
             }
         }
         auto pipe = fHelper.makePipeline(target);
-        helper.recordDraw(target, gp.get(), pipe.fPipeline, pipe.fFixedDynamicState);
+        helper.recordDraw(target, std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState);
     }
 
     bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
diff --git a/src/gpu/ops/GrNonAAStrokeRectOp.cpp b/src/gpu/ops/GrNonAAStrokeRectOp.cpp
index 21636b2..cbeeb45 100644
--- a/src/gpu/ops/GrNonAAStrokeRectOp.cpp
+++ b/src/gpu/ops/GrNonAAStrokeRectOp.cpp
@@ -192,7 +192,7 @@
         mesh.setNonIndexedNonInstanced(vertexCount);
         mesh.setVertexData(vertexBuffer, firstVertex);
         auto pipe = fHelper.makePipeline(target);
-        target->draw(gp.get(), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
+        target->draw(std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
     }
 
     bool onCombineIfPossible(GrOp* t, const GrCaps&) override {
diff --git a/src/gpu/ops/GrOvalOpFactory.cpp b/src/gpu/ops/GrOvalOpFactory.cpp
index 3a11058..622fb7f 100644
--- a/src/gpu/ops/GrOvalOpFactory.cpp
+++ b/src/gpu/ops/GrOvalOpFactory.cpp
@@ -1475,7 +1475,7 @@
                         GrPrimitiveRestart::kNo);
         mesh.setVertexData(vertexBuffer, firstVertex);
         auto pipe = fHelper.makePipeline(target);
-        target->draw(gp.get(), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
+        target->draw(std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
     }
 
     bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
@@ -1791,7 +1791,7 @@
                         GrPrimitiveRestart::kNo);
         mesh.setVertexData(vertexBuffer, firstVertex);
         auto pipe = fHelper.makePipeline(target);
-        target->draw(gp.get(), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
+        target->draw(std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
     }
 
     bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
@@ -2040,7 +2040,7 @@
             verts += kVerticesPerQuad;
         }
         auto pipe = fHelper.makePipeline(target);
-        helper.recordDraw(target, gp.get(), pipe.fPipeline, pipe.fFixedDynamicState);
+        helper.recordDraw(target, std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState);
     }
 
     bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
@@ -2274,7 +2274,7 @@
             verts += kVerticesPerQuad;
         }
         auto pipe = fHelper.makePipeline(target);
-        helper.recordDraw(target, gp.get(), pipe.fPipeline, pipe.fFixedDynamicState);
+        helper.recordDraw(target, std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState);
     }
 
     bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
@@ -2730,7 +2730,7 @@
                         GrPrimitiveRestart::kNo);
         mesh.setVertexData(vertexBuffer, firstVertex);
         auto pipe = fHelper.makePipeline(target);
-        target->draw(gp.get(), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
+        target->draw(std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
     }
 
     bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
@@ -2997,7 +2997,7 @@
             }
         }
         auto pipe = fHelper.makePipeline(target);
-        helper.recordDraw(target, gp.get(), pipe.fPipeline, pipe.fFixedDynamicState);
+        helper.recordDraw(target, std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState);
     }
 
     bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
diff --git a/src/gpu/ops/GrRegionOp.cpp b/src/gpu/ops/GrRegionOp.cpp
index d0c24e6..238ad08 100644
--- a/src/gpu/ops/GrRegionOp.cpp
+++ b/src/gpu/ops/GrRegionOp.cpp
@@ -144,7 +144,7 @@
             verts += numRectsInRegion * kVertsPerInstance * kVertexStride;
         }
         auto pipe = fHelper.makePipeline(target);
-        helper.recordDraw(target, gp.get(), pipe.fPipeline, pipe.fFixedDynamicState);
+        helper.recordDraw(target, std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState);
     }
 
     bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
diff --git a/src/gpu/ops/GrShadowRRectOp.cpp b/src/gpu/ops/GrShadowRRectOp.cpp
index 09a2442..c437cb4 100644
--- a/src/gpu/ops/GrShadowRRectOp.cpp
+++ b/src/gpu/ops/GrShadowRRectOp.cpp
@@ -631,7 +631,7 @@
         mesh.setIndexed(indexBuffer, fIndexCount, firstIndex, 0, fVertCount - 1,
                         GrPrimitiveRestart::kNo);
         mesh.setVertexData(vertexBuffer, firstVertex);
-        target->draw(gp.get(), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
+        target->draw(std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
     }
 
     bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
diff --git a/src/gpu/ops/GrSmallPathRenderer.cpp b/src/gpu/ops/GrSmallPathRenderer.cpp
index 4bbff1d..20b6b64 100644
--- a/src/gpu/ops/GrSmallPathRenderer.cpp
+++ b/src/gpu/ops/GrSmallPathRenderer.cpp
@@ -840,7 +840,7 @@
                                      kVerticesPerQuad, flushInfo->fInstancesToFlush,
                                      maxInstancesPerDraw);
             mesh.setVertexData(flushInfo->fVertexBuffer.get(), flushInfo->fVertexOffset);
-            target->draw(flushInfo->fGeometryProcessor.get(), flushInfo->fPipeline,
+            target->draw(flushInfo->fGeometryProcessor, flushInfo->fPipeline,
                          flushInfo->fFixedDynamicState, mesh);
             flushInfo->fVertexOffset += kVerticesPerQuad * flushInfo->fInstancesToFlush;
             flushInfo->fInstancesToFlush = 0;
diff --git a/src/gpu/ops/GrTessellatingPathRenderer.cpp b/src/gpu/ops/GrTessellatingPathRenderer.cpp
index 2fea9cb..3eda75b 100644
--- a/src/gpu/ops/GrTessellatingPathRenderer.cpp
+++ b/src/gpu/ops/GrTessellatingPathRenderer.cpp
@@ -237,7 +237,7 @@
         return path;
     }
 
-    void draw(Target* target, const GrGeometryProcessor* gp, size_t vertexStride) {
+    void draw(Target* target, sk_sp<const GrGeometryProcessor> gp, size_t vertexStride) {
         SkASSERT(!fAntiAlias);
         GrResourceProvider* rp = target->resourceProvider();
         bool inverseFill = fShape.inverseFilled();
@@ -261,7 +261,7 @@
         SkScalar tol = GrPathUtils::kDefaultTolerance;
         tol = GrPathUtils::scaleToleranceToSrc(tol, fViewMatrix, fShape.bounds());
         if (cache_match(cachedVertexBuffer.get(), tol, &actualCount)) {
-            this->drawVertices(target, gp, cachedVertexBuffer.get(), 0, actualCount);
+            this->drawVertices(target, std::move(gp), cachedVertexBuffer.get(), 0, actualCount);
             return;
         }
 
@@ -280,7 +280,7 @@
         if (count == 0) {
             return;
         }
-        this->drawVertices(target, gp, allocator.vertexBuffer(), 0, count);
+        this->drawVertices(target, std::move(gp), allocator.vertexBuffer(), 0, count);
         TessInfo info;
         info.fTolerance = isLinear ? 0 : tol;
         info.fCount = count;
@@ -289,7 +289,7 @@
         fShape.addGenIDChangeListener(sk_make_sp<PathInvalidator>(key, target->contextUniqueID()));
     }
 
-    void drawAA(Target* target, const GrGeometryProcessor* gp, size_t vertexStride) {
+    void drawAA(Target* target, sk_sp<const GrGeometryProcessor> gp, size_t vertexStride) {
         SkASSERT(fAntiAlias);
         SkPath path = getPath();
         if (path.isEmpty()) {
@@ -306,7 +306,8 @@
         if (count == 0) {
             return;
         }
-        this->drawVertices(target, gp, allocator.vertexBuffer(), allocator.firstVertex(), count);
+        this->drawVertices(target, std::move(gp), allocator.vertexBuffer(), allocator.firstVertex(),
+                           count);
     }
 
     void onPrepareDraws(Target* target) override {
@@ -349,19 +350,19 @@
         }
         SkASSERT(vertexStride == gp->debugOnly_vertexStride());
         if (fAntiAlias) {
-            this->drawAA(target, gp.get(), vertexStride);
+            this->drawAA(target, std::move(gp), vertexStride);
         } else {
-            this->draw(target, gp.get(), vertexStride);
+            this->draw(target, std::move(gp), vertexStride);
         }
     }
 
-    void drawVertices(Target* target, const GrGeometryProcessor* gp, const GrBuffer* vb,
+    void drawVertices(Target* target, sk_sp<const GrGeometryProcessor> gp, const GrBuffer* vb,
                       int firstVertex, int count) {
         GrMesh mesh(TESSELLATOR_WIREFRAME ? GrPrimitiveType::kLines : GrPrimitiveType::kTriangles);
         mesh.setNonIndexedNonInstanced(count);
         mesh.setVertexData(vb, firstVertex);
         auto pipe = fHelper.makePipeline(target);
-        target->draw(gp, pipe.fPipeline, pipe.fFixedDynamicState, mesh);
+        target->draw(std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
     }
 
     bool onCombineIfPossible(GrOp*, const GrCaps&) override { return false; }
diff --git a/src/gpu/ops/GrTextureOp.cpp b/src/gpu/ops/GrTextureOp.cpp
index 7ba41c5..d9a4f71 100644
--- a/src/gpu/ops/GrTextureOp.cpp
+++ b/src/gpu/ops/GrTextureOp.cpp
@@ -871,7 +871,7 @@
             mesh.setNonIndexedNonInstanced(4);
         }
         mesh.setVertexData(vbuffer, vstart);
-        target->draw(gp.get(), pipeline, fixedDynamicState, mesh);
+        target->draw(std::move(gp), pipeline, fixedDynamicState, mesh);
     }
 
     bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
diff --git a/tests/OnFlushCallbackTest.cpp b/tests/OnFlushCallbackTest.cpp
index efbc43a..9d6aef7 100644
--- a/tests/OnFlushCallbackTest.cpp
+++ b/tests/OnFlushCallbackTest.cpp
@@ -164,7 +164,7 @@
         mesh.setVertexData(vertexBuffer, firstVertex);
 
         auto pipe = fHelper.makePipeline(target);
-        target->draw(gp.get(), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
+        target->draw(std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState, mesh);
     }
 
     Helper fHelper;
diff --git a/tests/PrimitiveProcessorTest.cpp b/tests/PrimitiveProcessorTest.cpp
index 661c1ce..0069fd3 100644
--- a/tests/PrimitiveProcessorTest.cpp
+++ b/tests/PrimitiveProcessorTest.cpp
@@ -112,7 +112,7 @@
         SkPointPriv::SetRectTriStrip(vertices, 0.f, 0.f, 1.f, 1.f, vertexStride);
         auto pipe = target->makePipeline(0, GrProcessorSet::MakeEmptySet(),
                                          target->detachAppliedClip());
-        helper.recordDraw(target, gp.get(), pipe.fPipeline, pipe.fFixedDynamicState);
+        helper.recordDraw(target, std::move(gp), pipe.fPipeline, pipe.fFixedDynamicState);
     }
 
     int fNumAttribs;