Remove GrRenderTarget from GrPipelineBuilder

This used to be "Declassify GrClipMaskManager and Remove GrRenderTarget and GrDrawTarget from GrPipelineBuilder"

but has been split into:
https://codereview.chromium.org/1993263002/ (Make GrAppliedClip friendless)
https://codereview.chromium.org/1997773002/ (Retract GrRenderTarget from GLProgramsTest)
https://codereview.chromium.org/1993403002/ (GrSWMaskHelper and GrSoftwarePathRenderer only need the textureProvider (not GrContext))
https://codereview.chromium.org/2004433002/ (Retract GrRenderTarget from GrTestTarget)
https://codereview.chromium.org/2015333002/ (Change parameters to GrPipelineBuilder's ctor)
https://codereview.chromium.org/2035823002/ (Make GrClipMaskManager stateless and push GrPipelineBuilder construction downstack)

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

Review-Url: https://codereview.chromium.org/1988923002
diff --git a/gm/beziereffects.cpp b/gm/beziereffects.cpp
index cfb84a5..1224c1a 100644
--- a/gm/beziereffects.cpp
+++ b/gm/beziereffects.cpp
@@ -192,7 +192,6 @@
                     GrPipelineBuilder pipelineBuilder;
                     pipelineBuilder.setXPFactory(
                         GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref();
-                    pipelineBuilder.setRenderTarget(drawContext->accessRenderTarget());
 
                     SkAutoTUnref<GrDrawBatch> batch(
                         new BezierCubicOrConicTestBatch(gp, bounds, color, klmEqs, klmSigns[c]));
@@ -325,7 +324,6 @@
                     GrPipelineBuilder pipelineBuilder;
                     pipelineBuilder.setXPFactory(
                         GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref();
-                    pipelineBuilder.setRenderTarget(drawContext->accessRenderTarget());
 
                     SkAutoTUnref<GrDrawBatch> batch(
                         new BezierCubicOrConicTestBatch(gp, bounds, color, klmEqs, 1.f));
@@ -533,7 +531,6 @@
                     GrPipelineBuilder pipelineBuilder;
                     pipelineBuilder.setXPFactory(
                         GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref();
-                    pipelineBuilder.setRenderTarget(drawContext->accessRenderTarget());
 
                     GrPathUtils::QuadUVMatrix DevToUV(pts);
 
diff --git a/gm/bigrrectaaeffect.cpp b/gm/bigrrectaaeffect.cpp
index b3f39a0..1036ed0 100644
--- a/gm/bigrrectaaeffect.cpp
+++ b/gm/bigrrectaaeffect.cpp
@@ -84,7 +84,6 @@
                 SkASSERT(fp);
                 if (fp) {
                     pipelineBuilder.addCoverageFragmentProcessor(fp);
-                    pipelineBuilder.setRenderTarget(drawContext->accessRenderTarget());
 
                     SkRect bounds = testBounds;
                     bounds.offset(SkIntToScalar(x), SkIntToScalar(y));
diff --git a/gm/constcolorprocessor.cpp b/gm/constcolorprocessor.cpp
index da7aa38..57f17b2 100644
--- a/gm/constcolorprocessor.cpp
+++ b/gm/constcolorprocessor.cpp
@@ -109,7 +109,6 @@
 
                     GrPipelineBuilder pipelineBuilder(grPaint,
                                                       drawContext->isUnifiedMultisampled());
-                    pipelineBuilder.setRenderTarget(drawContext->accessRenderTarget());
                     pipelineBuilder.addColorFragmentProcessor(fp);
 
                     SkAutoTUnref<GrDrawBatch> batch(
diff --git a/gm/convexpolyeffect.cpp b/gm/convexpolyeffect.cpp
index 5b27802..1365947 100644
--- a/gm/convexpolyeffect.cpp
+++ b/gm/convexpolyeffect.cpp
@@ -182,7 +182,6 @@
                 pipelineBuilder.setXPFactory(
                     GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref();
                 pipelineBuilder.addCoverageFragmentProcessor(fp);
-                pipelineBuilder.setRenderTarget(drawContext->accessRenderTarget());
 
                 SkAutoTUnref<GrDrawBatch> batch(new PolyBoundsBatch(p.getBounds(), 0xff000000));
 
@@ -223,7 +222,6 @@
                 pipelineBuilder.setXPFactory(
                     GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref();
                 pipelineBuilder.addCoverageFragmentProcessor(fp);
-                pipelineBuilder.setRenderTarget(drawContext->accessRenderTarget());
 
                 SkAutoTUnref<GrDrawBatch> batch(new PolyBoundsBatch(rect, 0xff000000));
 
diff --git a/gm/rrects.cpp b/gm/rrects.cpp
index 9f1c65d..5f28c9e 100644
--- a/gm/rrects.cpp
+++ b/gm/rrects.cpp
@@ -112,7 +112,6 @@
                                                                                    rrect));
                         if (fp) {
                             pipelineBuilder.addCoverageFragmentProcessor(fp);
-                            pipelineBuilder.setRenderTarget(drawContext->accessRenderTarget());
 
                             SkRect bounds = rrect.getBounds();
                             bounds.outset(2.f, 2.f);
diff --git a/gm/texturedomaineffect.cpp b/gm/texturedomaineffect.cpp
index 6607488..588ce97 100644
--- a/gm/texturedomaineffect.cpp
+++ b/gm/texturedomaineffect.cpp
@@ -124,7 +124,6 @@
                         continue;
                     }
                     const SkMatrix viewMatrix = SkMatrix::MakeTrans(x, y);
-                    pipelineBuilder.setRenderTarget(drawContext->accessRenderTarget());
                     pipelineBuilder.addColorFragmentProcessor(fp);
 
                     SkAutoTUnref<GrDrawBatch> batch(
diff --git a/gm/yuvtorgbeffect.cpp b/gm/yuvtorgbeffect.cpp
index 40a2f03..57e4f46 100644
--- a/gm/yuvtorgbeffect.cpp
+++ b/gm/yuvtorgbeffect.cpp
@@ -122,7 +122,6 @@
                 if (fp) {
                     SkMatrix viewMatrix;
                     viewMatrix.setTranslate(x, y);
-                    pipelineBuilder.setRenderTarget(drawContext->accessRenderTarget());
                     pipelineBuilder.addColorFragmentProcessor(fp);
                     SkAutoTUnref<GrDrawBatch> batch(
                             GrRectBatchFactory::CreateNonAAFill(GrColor_WHITE, viewMatrix,
diff --git a/include/gpu/GrDrawContext.h b/include/gpu/GrDrawContext.h
index 4dd331e..c4818e5 100644
--- a/include/gpu/GrDrawContext.h
+++ b/include/gpu/GrDrawContext.h
@@ -261,13 +261,13 @@
     bool isStencilBufferMultisampled() const {
         return fRenderTarget->isStencilBufferMultisampled();
     }
+    bool isUnifiedMultisampled() const { return fRenderTarget->isUnifiedMultisampled(); }
     bool hasMixedSamples() const { return fRenderTarget->hasMixedSamples(); }
 
     const GrSurfaceDesc& desc() const { return fRenderTarget->desc(); }
     int width() const { return fRenderTarget->width(); }
     int height() const { return fRenderTarget->height(); }
     GrPixelConfig config() const { return fRenderTarget->config(); }
-    bool isUnifiedMultisampled() const { return fRenderTarget->isUnifiedMultisampled(); }
     int numColorSamples() const { return fRenderTarget->numColorSamples(); }
     bool isGammaCorrect() const { return fSurfaceProps.isGammaCorrect(); }
     const SkSurfaceProps& surfaceProps() const { return fSurfaceProps; }
@@ -298,6 +298,7 @@
 private:
     friend class GrAtlasTextBlob; // for access to drawBatch
     friend class GrStencilAndCoverTextContext; // for access to drawBatch
+
     friend class GrDrawingManager; // for ctor
     friend class GrDrawContextPriv;
     friend class GrTestTarget;  // for access to getDrawTarget
diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp
index 280e632..263f0c8 100644
--- a/src/gpu/GrDrawContext.cpp
+++ b/src/gpu/GrDrawContext.cpp
@@ -241,7 +241,6 @@
                 GrRectBatchFactory::CreateNonAAFill(paint->getColor(), SkMatrix::I(), r, nullptr,
                                                     &localMatrix));
         GrPipelineBuilder pipelineBuilder(*paint, this->isUnifiedMultisampled());
-        pipelineBuilder.setRenderTarget(fRenderTarget.get());
         this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
     }
 }
@@ -357,8 +356,7 @@
     }
 
     if (batch) {
-        GrPipelineBuilder pipelineBuilder(paint,  this->isUnifiedMultisampled());
-        pipelineBuilder.setRenderTarget(fRenderTarget.get());
+        GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled());
 
         if (snapToPixelCenters) {
             pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixelCenters_Flag,
@@ -415,7 +413,6 @@
     SkASSERT(batch);
 
     GrPipelineBuilder pipelineBuilder(paint, fDrawContext->isUnifiedMultisampled());
-    pipelineBuilder.setRenderTarget(fDrawContext->accessRenderTarget());
     pipelineBuilder.setUserStencil(ss);
 
     fDrawContext->getDrawTarget()->drawBatch(pipelineBuilder, fDrawContext, clip, batch);
@@ -431,7 +428,7 @@
     ASSERT_SINGLE_OWNER_PRIV
     RETURN_FALSE_IF_ABANDONED_PRIV
     SkDEBUGCODE(fDrawContext->validate();)
-    GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::stencilRect");
+    GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::drawAndStencilRect");
 
     AutoCheckFlush acf(fDrawContext->fDrawingManager);
 
@@ -442,7 +439,6 @@
     SkAutoTUnref<GrDrawBatch> batch(fDrawContext->getFillRectBatch(paint, viewMatrix, rect));
     if (batch) {
         GrPipelineBuilder pipelineBuilder(paint, fDrawContext->isUnifiedMultisampled());
-        pipelineBuilder.setRenderTarget(fDrawContext->accessRenderTarget());
         pipelineBuilder.setUserStencil(ss);
 
         fDrawContext->getDrawTarget()->drawBatch(pipelineBuilder, fDrawContext, clip, batch);
@@ -479,7 +475,6 @@
 
     if (batch) {
         GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled());
-        pipelineBuilder.setRenderTarget(fRenderTarget.get());
         this->drawBatch(pipelineBuilder, clip, batch);
     }
 }
@@ -506,8 +501,7 @@
                                                         nullptr, &localMatrix));
     }
 
-    GrPipelineBuilder pipelineBuilder(paint,  this->isUnifiedMultisampled());
-    pipelineBuilder.setRenderTarget(fRenderTarget.get());
+    GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled());
     this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
 }
 
@@ -552,8 +546,7 @@
                                                                 indexCount, colors, texCoords,
                                                                 bounds));
 
-    GrPipelineBuilder pipelineBuilder(paint,  this->isUnifiedMultisampled());
-    pipelineBuilder.setRenderTarget(fRenderTarget.get());
+    GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled());
     this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
 }
 
@@ -578,8 +571,7 @@
     SkAutoTUnref<GrDrawBatch> batch(GrDrawAtlasBatch::Create(geometry, viewMatrix, spriteCount,
                                                              xform, texRect, colors));
 
-    GrPipelineBuilder pipelineBuilder(paint,  this->isUnifiedMultisampled());
-    pipelineBuilder.setRenderTarget(fRenderTarget.get());
+    GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled());
     this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
 }
 
@@ -612,8 +604,7 @@
                                                                          stroke,
                                                                          shaderCaps));
         if (batch) {
-            GrPipelineBuilder pipelineBuilder(paint,  this->isUnifiedMultisampled());
-            pipelineBuilder.setRenderTarget(fRenderTarget.get());
+            GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled());
             this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
             return;
         }
@@ -738,8 +729,7 @@
                                                                         stroke,
                                                                         shaderCaps));
         if (batch) {
-            GrPipelineBuilder pipelineBuilder(paint,  this->isUnifiedMultisampled());
-            pipelineBuilder.setRenderTarget(fRenderTarget.get());
+            GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled());
             this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
             return;
         }
@@ -769,8 +759,7 @@
                                                              imageWidth, imageHeight,
                                                              center, dst));
 
-    GrPipelineBuilder pipelineBuilder(paint,  this->isUnifiedMultisampled());
-    pipelineBuilder.setRenderTarget(fRenderTarget.get());
+    GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled());
     this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
 }
 
@@ -830,8 +819,7 @@
 
     AutoCheckFlush acf(fDrawingManager);
 
-    GrPipelineBuilder pipelineBuilder(paint,  this->isUnifiedMultisampled());
-    pipelineBuilder.setRenderTarget(fRenderTarget.get());
+    GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled());
     this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
 }
 
@@ -863,8 +851,7 @@
                 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateAAFillNestedRects(
                     paint.getColor(), viewMatrix, rects));
                 if (batch) {
-                    GrPipelineBuilder pipelineBuilder(paint,  this->isUnifiedMultisampled());
-                    pipelineBuilder.setRenderTarget(fRenderTarget.get());
+                    GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled());
                     this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
                 }
                 return;
@@ -881,8 +868,7 @@
                                                                             style.strokeRec(),
                                                                             shaderCaps));
             if (batch) {
-                GrPipelineBuilder pipelineBuilder(paint,  this->isUnifiedMultisampled());
-                pipelineBuilder.setRenderTarget(fRenderTarget.get());
+                GrPipelineBuilder pipelineBuilder(paint, this->isUnifiedMultisampled());
                 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
                 return;
             }
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index 6bbcc74..ac0c766 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -130,6 +130,7 @@
 #endif
 
 bool GrDrawTarget::setupDstReadIfNecessary(const GrPipelineBuilder& pipelineBuilder,
+                                           GrRenderTarget* rt,
                                            const GrClip& clip,
                                            const GrPipelineOptimizations& optimizations,
                                            GrXferProcessor::DstTexture* dstTexture,
@@ -141,8 +142,6 @@
         return true;
     }
 
-    GrRenderTarget* rt = pipelineBuilder.getRenderTarget();
-
     if (this->caps()->textureBarrierSupport()) {
         if (GrTexture* rtTex = rt->asTexture()) {
             // The render target is a texture, so we can read from it directly in the shader. The XP
@@ -244,6 +243,7 @@
         return;
     }
 
+    // TODO: this is the only remaining usage of the AutoRestoreFragmentProcessorState - remove it
     GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps;
     if (appliedClip.clipCoverageFragmentProcessor()) {
         arfps.set(&pipelineBuilder);
@@ -252,11 +252,12 @@
 
     GrPipeline::CreateArgs args;
     args.fPipelineBuilder = &pipelineBuilder;
+    args.fDrawContext = drawContext;
     args.fCaps = this->caps();
     args.fScissor = &appliedClip.scissorState();
     args.fHasStencilClip = appliedClip.hasStencilClip();
     if (pipelineBuilder.hasUserStencilSettings() || appliedClip.hasStencilClip()) {
-        if (!fResourceProvider->attachStencilAttachment(pipelineBuilder.getRenderTarget())) {
+        if (!fResourceProvider->attachStencilAttachment(drawContext->accessRenderTarget())) {
             SkDebugf("ERROR creating stencil attachment. Draw skipped.\n");
             return;
         }
@@ -264,12 +265,11 @@
     batch->getPipelineOptimizations(&args.fOpts);
     GrScissorState finalScissor;
     if (args.fOpts.fOverrides.fUsePLSDstRead || fClipBatchToBounds) {
-        GrRenderTarget* rt = pipelineBuilder.getRenderTarget();
         GrGLIRect viewport;
         viewport.fLeft = 0;
         viewport.fBottom = 0;
-        viewport.fWidth = rt->width();
-        viewport.fHeight = rt->height();
+        viewport.fWidth = drawContext->width();
+        viewport.fHeight = drawContext->height();
         SkIRect ibounds;
         ibounds.fLeft = SkTPin(SkScalarFloorToInt(batch->bounds().fLeft), viewport.fLeft,
                               viewport.fWidth);
@@ -293,8 +293,9 @@
     args.fOpts.fCoveragePOI.completeCalculations(
                                                pipelineBuilder.fCoverageFragmentProcessors.begin(),
                                                pipelineBuilder.numCoverageFragmentProcessors());
-    if (!this->setupDstReadIfNecessary(pipelineBuilder, clip, args.fOpts, &args.fDstTexture,
-                                       batch->bounds())) {
+    if (!this->setupDstReadIfNecessary(pipelineBuilder, drawContext->accessRenderTarget(),
+                                       clip, args.fOpts,
+                                       &args.fDstTexture, batch->bounds())) {
         return;
     }
 
@@ -331,8 +332,8 @@
     // attempt this in a situation that would require coverage AA.
     SkASSERT(!appliedClip.clipCoverageFragmentProcessor());
 
-    GrRenderTarget* rt = pipelineBuilder.getRenderTarget();
-    GrStencilAttachment* stencilAttachment = fResourceProvider->attachStencilAttachment(rt);
+    GrStencilAttachment* stencilAttachment = fResourceProvider->attachStencilAttachment(
+                                                drawContext->accessRenderTarget());
     if (!stencilAttachment) {
         SkDebugf("ERROR creating stencil attachment. Draw skipped.\n");
         return;
@@ -344,7 +345,7 @@
                                                 appliedClip.hasStencilClip(),
                                                 stencilAttachment->bits(),
                                                 appliedClip.scissorState(),
-                                                pipelineBuilder.getRenderTarget(),
+                                                drawContext->accessRenderTarget(),
                                                 path);
     this->recordBatch(batch);
     batch->unref();
@@ -376,10 +377,10 @@
             drawContext->discard();
         }
 
+        // TODO: flip this into real draw!
         GrPipelineBuilder pipelineBuilder;
         pipelineBuilder.setXPFactory(
             GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref();
-        pipelineBuilder.setRenderTarget(drawContext->accessRenderTarget());
 
         SkRect scalarRect = SkRect::Make(*rect);
         SkAutoTUnref<GrDrawBatch> batch(
diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h
index 627472f..d43a930 100644
--- a/src/gpu/GrDrawTarget.h
+++ b/src/gpu/GrDrawTarget.h
@@ -117,9 +117,9 @@
                      const GrPath*, GrPathRendering::FillType);
 
     /**
-     * Clear the passed in render target. Ignores the GrPipelineBuilder and clip. Clears the whole
+     * Clear the passed in drawContext. Ignores the GrPipelineBuilder and clip. Clears the whole
      * thing if rect is nullptr, otherwise just the rect. If canIgnoreRect is set then the entire
-     * render target can be optionally cleared.
+     * drawContext can be optionally cleared.
      */
     void clear(const SkIRect* rect,
                GrColor color,
@@ -144,26 +144,6 @@
                      const SkIRect& srcRect,
                      const SkIPoint& dstPoint);
 
-    /** Provides access to internal functions to GrClipMaskManager without friending all of
-        GrDrawTarget to CMM. */
-    class CMMAccess {
-    public:
-        CMMAccess(GrDrawTarget* drawTarget) : fDrawTarget(drawTarget) {}
-    private:
-        void clearStencilClip(const SkIRect& rect, bool insideClip, GrRenderTarget* rt) const {
-            fDrawTarget->clearStencilClip(rect, insideClip, rt);
-        }
-
-        GrContext* context() const { return fDrawTarget->fContext; }
-        GrResourceProvider* resourceProvider() const { return fDrawTarget->fResourceProvider; }
-        GrDrawTarget* fDrawTarget;
-        friend class GrClipMaskManager;
-    };
-
-    const CMMAccess cmmAccess() { return CMMAccess(this); }
-
-    GrAuditTrail* getAuditTrail() const { return fAuditTrail; }
-
 private:
     friend class GrDrawingManager; // for resetFlag & TopoSortTraits
     friend class GrDrawContextPriv; // for clearStencilClip
@@ -218,14 +198,15 @@
     // but couldn't be made. Otherwise, returns true.  This method needs to be protected because it
     // needs to be accessed by GLPrograms to setup a correct drawstate
     bool setupDstReadIfNecessary(const GrPipelineBuilder&,
-        const GrClip&,
-        const GrPipelineOptimizations& optimizations,
-        GrXferProcessor::DstTexture*,
-        const SkRect& batchBounds);
+                                 GrRenderTarget*,
+                                 const GrClip&,
+                                 const GrPipelineOptimizations& optimizations,
+                                 GrXferProcessor::DstTexture*,
+                                 const SkRect& batchBounds);
 
     void addDependency(GrDrawTarget* dependedOn);
 
-    // Used only by CMM.
+    // Used only by drawContextPriv.
     void clearStencilClip(const SkIRect&, bool insideClip, GrRenderTarget*);
 
     SkSTArray<256, SkAutoTUnref<GrBatch>, true> fBatches;
diff --git a/src/gpu/GrPipeline.cpp b/src/gpu/GrPipeline.cpp
index d52e811..20089a6 100644
--- a/src/gpu/GrPipeline.cpp
+++ b/src/gpu/GrPipeline.cpp
@@ -8,6 +8,7 @@
 #include "GrPipeline.h"
 
 #include "GrCaps.h"
+#include "GrDrawContext.h"
 #include "GrDrawTarget.h"
 #include "GrGpu.h"
 #include "GrPipelineBuilder.h"
@@ -22,11 +23,12 @@
     const GrPipelineBuilder& builder = *args.fPipelineBuilder;
 
     GrPipeline* pipeline = new (memory) GrPipeline;
-    pipeline->fRenderTarget.reset(builder.fRenderTarget.get());
+    GrRenderTarget* rt = args.fDrawContext->accessRenderTarget();
+    pipeline->fRenderTarget.reset(rt);
     SkASSERT(pipeline->fRenderTarget);
     pipeline->fScissorState = *args.fScissor;
     if (builder.hasUserStencilSettings() || args.fHasStencilClip) {
-        const GrRenderTargetPriv& rtPriv = builder.getRenderTarget()->renderTargetPriv();
+        const GrRenderTargetPriv& rtPriv = rt->renderTargetPriv();
         pipeline->fStencilSettings.reset(*builder.getUserStencil(), args.fHasStencilClip,
                                          rtPriv.numStencilBits());
         SkASSERT(!pipeline->fStencilSettings.usesWrapOp() || args.fCaps->stencilWrapOpsSupport());
@@ -51,7 +53,7 @@
     }
 
     // Create XferProcessor from DS's XPFactory
-    bool hasMixedSamples = builder.getRenderTarget()->hasMixedSamples() &&
+    bool hasMixedSamples = args.fDrawContext->hasMixedSamples() &&
                            (builder.isHWAntialias() || !pipeline->fStencilSettings.isDisabled());
     const GrXPFactory* xpFactory = builder.getXPFactory();
     SkAutoTUnref<GrXferProcessor> xferProcessor;
diff --git a/src/gpu/GrPipeline.h b/src/gpu/GrPipeline.h
index 60e1631..3fd70a3 100644
--- a/src/gpu/GrPipeline.h
+++ b/src/gpu/GrPipeline.h
@@ -21,6 +21,7 @@
 #include "SkRefCnt.h"
 
 class GrBatch;
+class GrDrawContext;
 class GrDeviceCoordTexture;
 class GrPipelineBuilder;
 
@@ -48,6 +49,7 @@
 
     struct CreateArgs {
         const GrPipelineBuilder*    fPipelineBuilder;
+        GrDrawContext*              fDrawContext;
         const GrCaps*               fCaps;
         GrPipelineOptimizations     fOpts;
         const GrScissorState*       fScissor;
diff --git a/src/gpu/GrPipelineBuilder.h b/src/gpu/GrPipelineBuilder.h
index 11b427b..68e70ac 100644
--- a/src/gpu/GrPipelineBuilder.h
+++ b/src/gpu/GrPipelineBuilder.h
@@ -31,7 +31,7 @@
     GrPipelineBuilder();
 
     /**
-     * Initializes the GrPipelineBuilder based on a GrPaint, MSAA availability. Note
+     * Initializes the GrPipelineBuilder based on a GrPaint and MSAA availability. Note
      * that GrPipelineBuilder encompasses more than GrPaint. Aspects of GrPipelineBuilder that have
      * no GrPaint equivalents are set to default values with the exception of vertex attribute state
      * which is unmodified by this function and clipping which will be enabled.
@@ -175,26 +175,6 @@
 
 
     ///////////////////////////////////////////////////////////////////////////
-    /// @name Render Target
-    ////
-
-    /**
-     * Retrieves the currently set render-target.
-     *
-     * @return    The currently set render target.
-     */
-    GrRenderTarget* getRenderTarget() const { return fRenderTarget.get(); }
-
-    /**
-     * Sets the render-target used at the next drawing call
-     *
-     * @param target  The render target to set.
-     */
-    void setRenderTarget(GrRenderTarget* target) { fRenderTarget.reset(SkSafeRef(target)); }
-
-    /// @}
-
-    ///////////////////////////////////////////////////////////////////////////
     /// @name Stencil
     ////
 
@@ -326,7 +306,6 @@
 
     typedef SkSTArray<4, const GrFragmentProcessor*, true> FragmentProcessorArray;
 
-    SkAutoTUnref<GrRenderTarget>            fRenderTarget;
     uint32_t                                fFlags;
     const GrUserStencilSettings*            fUserStencilSettings;
     DrawFace                                fDrawFace;
diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp
index 6e99f07..a0ab7ad 100644
--- a/src/gpu/GrSWMaskHelper.cpp
+++ b/src/gpu/GrSWMaskHelper.cpp
@@ -186,7 +186,6 @@
     maskMatrix.preTranslate(SkIntToScalar(-rect.fLeft), SkIntToScalar(-rect.fTop));
 
     GrPipelineBuilder pipelineBuilder(*paint, drawContext->isUnifiedMultisampled());
-    pipelineBuilder.setRenderTarget(drawContext->accessRenderTarget());
     pipelineBuilder.setUserStencil(userStencilSettings);
 
     pipelineBuilder.addCoverageFragmentProcessor(
diff --git a/src/gpu/GrSoftwarePathRenderer.cpp b/src/gpu/GrSoftwarePathRenderer.cpp
index dc0c6c0..4bc592d 100644
--- a/src/gpu/GrSoftwarePathRenderer.cpp
+++ b/src/gpu/GrSoftwarePathRenderer.cpp
@@ -71,7 +71,6 @@
                                                                         nullptr, &localMatrix));
 
     GrPipelineBuilder pipelineBuilder(*paint, drawContext->isUnifiedMultisampled());
-    pipelineBuilder.setRenderTarget(drawContext->accessRenderTarget());
     pipelineBuilder.setUserStencil(userStencilSettings);
 
     drawContext->drawBatch(pipelineBuilder, clip, batch);
diff --git a/src/gpu/GrStencilAttachment.h b/src/gpu/GrStencilAttachment.h
index 5b7ae63..7573d23 100644
--- a/src/gpu/GrStencilAttachment.h
+++ b/src/gpu/GrStencilAttachment.h
@@ -52,8 +52,7 @@
                                                   GrUniqueKey* key);
 
 protected:
-    GrStencilAttachment(GrGpu* gpu, int width, int height, int bits,
-                        int sampleCnt)
+    GrStencilAttachment(GrGpu* gpu, int width, int height, int bits, int sampleCnt)
         : GrGpuResource(gpu)
         , fWidth(width)
         , fHeight(height)
diff --git a/src/gpu/batches/GrAAConvexPathRenderer.cpp b/src/gpu/batches/GrAAConvexPathRenderer.cpp
index 191c081..ef6c0ae 100644
--- a/src/gpu/batches/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/batches/GrAAConvexPathRenderer.cpp
@@ -1009,7 +1009,6 @@
     SkAutoTUnref<GrDrawBatch> batch(AAConvexPathBatch::Create(geometry));
 
     GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fDrawContext->isUnifiedMultisampled());
-    pipelineBuilder.setRenderTarget(args.fDrawContext->accessRenderTarget());
     pipelineBuilder.setUserStencil(args.fUserStencilSettings);
 
     args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch);
diff --git a/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp b/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
index e506e53..9a5eada 100644
--- a/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
+++ b/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
@@ -566,7 +566,6 @@
                                                                      args.fGammaCorrect));
 
     GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fDrawContext->isUnifiedMultisampled());
-    pipelineBuilder.setRenderTarget(args.fDrawContext->accessRenderTarget());
     pipelineBuilder.setUserStencil(args.fUserStencilSettings);
 
     args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch);
diff --git a/src/gpu/batches/GrAAHairLinePathRenderer.cpp b/src/gpu/batches/GrAAHairLinePathRenderer.cpp
index a163138..750c1f1 100644
--- a/src/gpu/batches/GrAAHairLinePathRenderer.cpp
+++ b/src/gpu/batches/GrAAHairLinePathRenderer.cpp
@@ -974,7 +974,6 @@
 
     GrPipelineBuilder pipelineBuilder(*args.fPaint,
                                       args.fDrawContext->isStencilBufferMultisampled());
-    pipelineBuilder.setRenderTarget(args.fDrawContext->accessRenderTarget());
     pipelineBuilder.setUserStencil(args.fUserStencilSettings);
 
     args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch);
diff --git a/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp b/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp
index ee5a7af..a3e00d1 100644
--- a/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp
+++ b/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp
@@ -337,7 +337,6 @@
     SkAutoTUnref<GrDrawBatch> batch(AAFlatteningConvexPathBatch::Create(geometry));
 
     GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fDrawContext->isUnifiedMultisampled());
-    pipelineBuilder.setRenderTarget(args.fDrawContext->accessRenderTarget());
     pipelineBuilder.setUserStencil(args.fUserStencilSettings);
 
     args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch);
diff --git a/src/gpu/batches/GrDashLinePathRenderer.cpp b/src/gpu/batches/GrDashLinePathRenderer.cpp
index 1763f95..6a05458 100644
--- a/src/gpu/batches/GrDashLinePathRenderer.cpp
+++ b/src/gpu/batches/GrDashLinePathRenderer.cpp
@@ -36,7 +36,6 @@
     }
 
     GrPipelineBuilder pipelineBuilder(*args.fPaint, msaaIsEnabled);
-    pipelineBuilder.setRenderTarget(args.fDrawContext->accessRenderTarget());
     pipelineBuilder.setUserStencil(args.fUserStencilSettings);
 
     args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch);
diff --git a/src/gpu/batches/GrDefaultPathRenderer.cpp b/src/gpu/batches/GrDefaultPathRenderer.cpp
index 1bcfc2d..bab39ee 100644
--- a/src/gpu/batches/GrDefaultPathRenderer.cpp
+++ b/src/gpu/batches/GrDefaultPathRenderer.cpp
@@ -563,7 +563,6 @@
                                                         &localMatrix));
 
             GrPipelineBuilder pipelineBuilder(paint, drawContext->isUnifiedMultisampled());
-            pipelineBuilder.setRenderTarget(drawContext->accessRenderTarget());
             pipelineBuilder.setDrawFace(drawFace[p]);
             if (passes[p]) {
                 pipelineBuilder.setUserStencil(passes[p]);
@@ -583,7 +582,6 @@
                                                                      devBounds));
 
             GrPipelineBuilder pipelineBuilder(paint, drawContext->isUnifiedMultisampled());
-            pipelineBuilder.setRenderTarget(drawContext->accessRenderTarget());
             pipelineBuilder.setDrawFace(drawFace[p]);
             if (passes[p]) {
                 pipelineBuilder.setUserStencil(passes[p]);
diff --git a/src/gpu/batches/GrMSAAPathRenderer.cpp b/src/gpu/batches/GrMSAAPathRenderer.cpp
index 2983f58..45971f5 100644
--- a/src/gpu/batches/GrMSAAPathRenderer.cpp
+++ b/src/gpu/batches/GrMSAAPathRenderer.cpp
@@ -668,7 +668,6 @@
                                                         &localMatrix));
 
             GrPipelineBuilder pipelineBuilder(paint, drawContext->isUnifiedMultisampled());
-            pipelineBuilder.setRenderTarget(drawContext->accessRenderTarget());
             pipelineBuilder.setDrawFace(drawFace[p]);
             if (passes[p]) {
                 pipelineBuilder.setUserStencil(passes[p]);
@@ -690,7 +689,6 @@
             }
 
             GrPipelineBuilder pipelineBuilder(paint, drawContext->isUnifiedMultisampled());
-            pipelineBuilder.setRenderTarget(drawContext->accessRenderTarget());
             pipelineBuilder.setDrawFace(drawFace[p]);
             if (passes[p]) {
                 pipelineBuilder.setUserStencil(passes[p]);
diff --git a/src/gpu/batches/GrPLSPathRenderer.cpp b/src/gpu/batches/GrPLSPathRenderer.cpp
index e84bd4d..79da83c 100644
--- a/src/gpu/batches/GrPLSPathRenderer.cpp
+++ b/src/gpu/batches/GrPLSPathRenderer.cpp
@@ -987,7 +987,6 @@
     SkAutoTUnref<GrDrawBatch> batch(PLSPathBatch::Create(geometry));
 
     GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fDrawContext->isUnifiedMultisampled());
-    pipelineBuilder.setRenderTarget(args.fDrawContext->accessRenderTarget());
     pipelineBuilder.setUserStencil(args.fUserStencilSettings);
 
     args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch);
diff --git a/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp b/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp
index 314e6c2..296343d 100644
--- a/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp
+++ b/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp
@@ -74,8 +74,7 @@
     SkSafeUnref(paint.setXPFactory(GrDisableColorXPFactory::Create()));
     paint.setAntiAlias(args.fIsAA);
 
-    GrPipelineBuilder pipelineBuilder(paint, args.fDrawContext->isUnifiedMultisampled());    
-    pipelineBuilder.setRenderTarget(args.fDrawContext->accessRenderTarget());
+    const GrPipelineBuilder pipelineBuilder(paint, args.fDrawContext->isUnifiedMultisampled());
 
     SkASSERT(!args.fPath->isInverseFillType());
     SkAutoTUnref<GrPath> path(get_gr_path(fResourceProvider, *args.fPath, GrStyle::SimpleFill()));
@@ -113,7 +112,6 @@
         {
             GrPipelineBuilder pipelineBuilder(*args.fPaint,
                                               args.fDrawContext->isUnifiedMultisampled());
-            pipelineBuilder.setRenderTarget(args.fDrawContext->accessRenderTarget());
             pipelineBuilder.setUserStencil(&kInvertedCoverPass);
             if (args.fAntiAlias) {
                 SkASSERT(args.fDrawContext->isStencilBufferMultisampled());
@@ -151,7 +149,6 @@
         {
             GrPipelineBuilder pipelineBuilder(*args.fPaint,
                                               args.fDrawContext->isUnifiedMultisampled());
-            pipelineBuilder.setRenderTarget(args.fDrawContext->accessRenderTarget());
             pipelineBuilder.setUserStencil(&kInvertedCoverPass);
             if (args.fAntiAlias) {
                 SkASSERT(args.fDrawContext->isStencilBufferMultisampled());
@@ -179,7 +176,6 @@
 
         GrPipelineBuilder pipelineBuilder(*args.fPaint,
                                           args.fDrawContext->isUnifiedMultisampled());
-        pipelineBuilder.setRenderTarget(args.fDrawContext->accessRenderTarget());
         pipelineBuilder.setUserStencil(&kCoverPass);
         if (args.fAntiAlias) {
             SkASSERT(args.fDrawContext->isStencilBufferMultisampled());
diff --git a/src/gpu/batches/GrTessellatingPathRenderer.cpp b/src/gpu/batches/GrTessellatingPathRenderer.cpp
index e025435..6d05250 100644
--- a/src/gpu/batches/GrTessellatingPathRenderer.cpp
+++ b/src/gpu/batches/GrTessellatingPathRenderer.cpp
@@ -298,7 +298,6 @@
                                                                   clipBounds));
 
     GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fDrawContext->isUnifiedMultisampled());
-    pipelineBuilder.setRenderTarget(args.fDrawContext->accessRenderTarget());
     pipelineBuilder.setUserStencil(args.fUserStencilSettings);
 
     args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch);
diff --git a/src/gpu/text/GrAtlasTextBlob.cpp b/src/gpu/text/GrAtlasTextBlob.cpp
index 72193dc..e4fa349 100644
--- a/src/gpu/text/GrAtlasTextBlob.cpp
+++ b/src/gpu/text/GrAtlasTextBlob.cpp
@@ -419,8 +419,7 @@
                                   SkScalar x, SkScalar y) {
     // We loop through the runs of the blob, flushing each.  If any run is too large, then we flush
     // it as paths
-    GrPipelineBuilder pipelineBuilder(grPaint,  dc->isUnifiedMultisampled());
-    pipelineBuilder.setRenderTarget(dc->accessRenderTarget());
+    GrPipelineBuilder pipelineBuilder(grPaint, dc->isUnifiedMultisampled());
 
     GrColor color = grPaint.getColor();
 
@@ -449,8 +448,7 @@
                                      const SkMatrix& viewMatrix,
                                      const SkIRect& clipBounds,
                                      SkScalar x, SkScalar y) {
-    GrPipelineBuilder pipelineBuilder(grPaint,  dc->isUnifiedMultisampled());
-    pipelineBuilder.setRenderTarget(dc->accessRenderTarget());
+    GrPipelineBuilder pipelineBuilder(grPaint, dc->isUnifiedMultisampled());
 
     GrColor color = grPaint.getColor();
     for (int run = 0; run < fRunCount; run++) {
diff --git a/src/gpu/text/GrAtlasTextContext.h b/src/gpu/text/GrAtlasTextContext.h
index 928ce0a..5bf7662 100644
--- a/src/gpu/text/GrAtlasTextContext.h
+++ b/src/gpu/text/GrAtlasTextContext.h
@@ -19,7 +19,6 @@
 
 class GrDrawBatch;
 class GrDrawContext;
-class GrDrawTarget;
 class GrPipelineBuilder;
 class GrTextBlobCache;
 class SkGlyph;
diff --git a/src/gpu/text/GrStencilAndCoverTextContext.cpp b/src/gpu/text/GrStencilAndCoverTextContext.cpp
index 00ec451..5673c39 100644
--- a/src/gpu/text/GrStencilAndCoverTextContext.cpp
+++ b/src/gpu/text/GrStencilAndCoverTextContext.cpp
@@ -82,8 +82,7 @@
     } else if (this->canDraw(skPaint, viewMatrix)) {
         if (skPaint.getTextSize() > 0) {
             TextRun run(skPaint);
-            GrPipelineBuilder pipelineBuilder(paint,  dc->isUnifiedMultisampled());
-            pipelineBuilder.setRenderTarget(dc->accessRenderTarget());
+            GrPipelineBuilder pipelineBuilder(paint, dc->isUnifiedMultisampled());
             run.setText(text, byteLength, x, y);
             run.draw(context, dc, &pipelineBuilder, clip, paint.getColor(), viewMatrix, props, 0, 0,
                      clipBounds, fFallbackTextContext, skPaint);
@@ -118,8 +117,7 @@
     } else if (this->canDraw(skPaint, viewMatrix)) {
         if (skPaint.getTextSize() > 0) {
             TextRun run(skPaint);
-            GrPipelineBuilder pipelineBuilder(paint,  dc->isUnifiedMultisampled());
-            pipelineBuilder.setRenderTarget(dc->accessRenderTarget());
+            GrPipelineBuilder pipelineBuilder(paint, dc->isUnifiedMultisampled());
             run.setPosText(text, byteLength, pos, scalarsPerPosition, offset);
             run.draw(context, dc, &pipelineBuilder, clip, paint.getColor(), viewMatrix, props, 0, 0,
                      clipBounds, fFallbackTextContext, skPaint);
@@ -227,8 +225,7 @@
     }
 
     const TextBlob& blob = this->findOrCreateTextBlob(skBlob, skPaint);
-    GrPipelineBuilder pipelineBuilder(paint,  dc->isUnifiedMultisampled());
-    pipelineBuilder.setRenderTarget(dc->accessRenderTarget());
+    GrPipelineBuilder pipelineBuilder(paint, dc->isUnifiedMultisampled());
 
     TextBlob::Iter iter(blob);
     for (TextRun* run = iter.get(); run; run = iter.next()) {
@@ -598,7 +595,7 @@
 }
 
 void GrStencilAndCoverTextContext::TextRun::draw(GrContext* ctx,
-                                                 GrDrawContext* dc,
+                                                 GrDrawContext* drawContext,
                                                  GrPipelineBuilder* pipelineBuilder,
                                                  const GrClip& clip,
                                                  GrColor color,
@@ -609,7 +606,7 @@
                                                  GrAtlasTextContext* fallbackTextContext,
                                                  const SkPaint& originalSkPaint) const {
     SkASSERT(fInstanceData);
-    SkASSERT(dc->accessRenderTarget()->isStencilBufferMultisampled() || !fFont.isAntiAlias());
+    SkASSERT(drawContext->isStencilBufferMultisampled() || !fFont.isAntiAlias());
 
     if (fInstanceData->count()) {
         pipelineBuilder->setState(GrPipelineBuilder::kHWAntialias_Flag, fFont.isAntiAlias());
@@ -638,8 +635,7 @@
         // NV_path_rendering will also support NV_blend_equation_advanced.
         // For clipping we'll just skip any optimizations based on the bounds. This does, however,
         // hurt batching.
-        SkRect bounds = SkRect::MakeIWH(pipelineBuilder->getRenderTarget()->width(),
-                                        pipelineBuilder->getRenderTarget()->height());
+        const SkRect bounds = SkRect::MakeIWH(drawContext->width(), drawContext->height());
 
         SkAutoTUnref<GrDrawBatch> batch(
             GrDrawPathRangeBatch::Create(viewMatrix, fTextRatio, fTextInverseRatio * x,
@@ -647,7 +643,7 @@
                                          GrPathRendering::kWinding_FillType, glyphs, fInstanceData,
                                          bounds));
 
-        dc->drawBatch(*pipelineBuilder, clip, batch);
+        drawContext->drawBatch(*pipelineBuilder, clip, batch);
     }
 
     if (fFallbackTextBlob) {
@@ -657,8 +653,8 @@
             fallbackSkPaint.setStrokeWidth(fStyle.strokeRec().getWidth() * fTextRatio);
         }
 
-        fallbackTextContext->drawTextBlob(ctx, dc, clip, fallbackSkPaint, viewMatrix, props,
-                                          fFallbackTextBlob, x, y, nullptr, clipBounds);
+        fallbackTextContext->drawTextBlob(ctx, drawContext, clip, fallbackSkPaint, viewMatrix,
+                                          props, fFallbackTextBlob, x, y, nullptr, clipBounds);
     }
 }
 
diff --git a/src/gpu/vk/GrVkStencilAttachment.cpp b/src/gpu/vk/GrVkStencilAttachment.cpp
index 0343504..8e5940d 100644
--- a/src/gpu/vk/GrVkStencilAttachment.cpp
+++ b/src/gpu/vk/GrVkStencilAttachment.cpp
@@ -18,8 +18,7 @@
                                              const GrVkImage::ImageDesc& desc,
                                              const GrVkImageInfo& info,
                                              const GrVkImageView* stencilView)
-    : GrStencilAttachment(gpu, desc.fWidth, desc.fHeight,
-                          format.fStencilBits, desc.fSamples)
+    : GrStencilAttachment(gpu, desc.fWidth, desc.fHeight, format.fStencilBits, desc.fSamples)
     , GrVkImage(info, GrVkImage::kNot_Wrapped)
     , fFormat(format)
     , fStencilView(stencilView) {
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index 7fabf32..2470061 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -350,7 +350,6 @@
         }
 
         GrPipelineBuilder pipelineBuilder;
-        pipelineBuilder.setRenderTarget(drawContext->accessRenderTarget());
 
         SkAutoTUnref<GrDrawBatch> batch(GrRandomDrawBatch(&random, context));
         SkASSERT(batch);
@@ -387,7 +386,6 @@
                                     drawContext.get(), dummyTextures);
             GrPipelineBuilder builder;
             builder.setXPFactory(GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref();
-            builder.setRenderTarget(drawContext->accessRenderTarget());
 
             SkAutoTUnref<const GrFragmentProcessor> fp(
                 GrProcessorTestFactory<GrFragmentProcessor>::CreateIdx(i, &ptd));
diff --git a/tests/PrimitiveProcessorTest.cpp b/tests/PrimitiveProcessorTest.cpp
index c2ab05c..5ef4994 100644
--- a/tests/PrimitiveProcessorTest.cpp
+++ b/tests/PrimitiveProcessorTest.cpp
@@ -104,9 +104,9 @@
 DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(VertexAttributeCount, reporter, ctxInfo) {
     GrContext* context = ctxInfo.grContext();
 
-    sk_sp<GrDrawContext> dc(context->newDrawContext(SkBackingFit::kApprox,
-                                                    1, 1, kRGBA_8888_GrPixelConfig));
-    if (!dc) {
+    sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kApprox,
+                                                             1, 1, kRGBA_8888_GrPixelConfig));
+    if (!drawContext) {
         ERRORF(reporter, "Could not create draw context.");
         return;
     }
@@ -123,10 +123,9 @@
 #endif
     SkAutoTUnref<GrDrawBatch> batch;
     GrPipelineBuilder pb;
-    pb.setRenderTarget(dc->accessRenderTarget());
     // This one should succeed.
     batch.reset(new Batch(attribCnt));
-    dc->drawContextPriv().testingOnly_drawBatch(pb, batch);
+    drawContext->drawContextPriv().testingOnly_drawBatch(pb, batch);
     context->flush();
 #if GR_GPU_STATS
     REPORTER_ASSERT(reporter, context->getGpu()->stats()->numDraws() == 1);
@@ -135,7 +134,7 @@
     context->resetGpuStats();
     // This one should fail.
     batch.reset(new Batch(attribCnt+1));
-    dc->drawContextPriv().testingOnly_drawBatch(pb, batch);
+    drawContext->drawContextPriv().testingOnly_drawBatch(pb, batch);
     context->flush();
 #if GR_GPU_STATS
     REPORTER_ASSERT(reporter, context->getGpu()->stats()->numDraws() == 0);
diff --git a/tools/gpu/GrTest.h b/tools/gpu/GrTest.h
index 217efe6..7c94c9f 100644
--- a/tools/gpu/GrTest.h
+++ b/tools/gpu/GrTest.h
@@ -29,7 +29,6 @@
 
     void init(GrContext*, sk_sp<GrDrawContext>);
 
-    GrDrawTarget* target() { return fDrawContext->getDrawTarget(); }
     GrResourceProvider* resourceProvider() { return fContext->resourceProvider(); }
 
 private: