Start to propagate constness of GrPipelineBuilder up the stack

BUG=skia:

Review URL: https://codereview.chromium.org/1229143007
diff --git a/src/gpu/GrAAConvexPathRenderer.cpp b/src/gpu/GrAAConvexPathRenderer.cpp
index 2d4694c..fed6a7a 100644
--- a/src/gpu/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/GrAAConvexPathRenderer.cpp
@@ -1001,7 +1001,7 @@
     geometry.fPath = path;
 
     SkAutoTUnref<GrBatch> batch(AAConvexPathBatch::Create(geometry));
-    target->drawBatch(pipelineBuilder, batch);
+    target->drawBatch(*pipelineBuilder, batch);
 
     return true;
 
diff --git a/src/gpu/GrAADistanceFieldPathRenderer.cpp b/src/gpu/GrAADistanceFieldPathRenderer.cpp
index c11c641..ca0f4e3 100755
--- a/src/gpu/GrAADistanceFieldPathRenderer.cpp
+++ b/src/gpu/GrAADistanceFieldPathRenderer.cpp
@@ -583,7 +583,7 @@
 
     SkAutoTUnref<GrBatch> batch(AADistanceFieldPathBatch::Create(geometry, color, viewMatrix,
                                                                  fAtlas, &fPathCache, &fPathList));
-    target->drawBatch(pipelineBuilder, batch);
+    target->drawBatch(*pipelineBuilder, batch);
 
     return true;
 }
diff --git a/src/gpu/GrAAHairLinePathRenderer.cpp b/src/gpu/GrAAHairLinePathRenderer.cpp
index 14770b8..8a0c9a4 100644
--- a/src/gpu/GrAAHairLinePathRenderer.cpp
+++ b/src/gpu/GrAAHairLinePathRenderer.cpp
@@ -983,7 +983,7 @@
 
     SkAutoTUnref<GrBatch> batch(create_hairline_batch(color, viewMatrix, path, stroke,
                                                       devClipBounds));
-    target->drawBatch(pipelineBuilder, batch);
+    target->drawBatch(*pipelineBuilder, batch);
 
     return true;
 }
diff --git a/src/gpu/GrAALinearizingConvexPathRenderer.cpp b/src/gpu/GrAALinearizingConvexPathRenderer.cpp
index f9174ce..31d61a4 100644
--- a/src/gpu/GrAALinearizingConvexPathRenderer.cpp
+++ b/src/gpu/GrAALinearizingConvexPathRenderer.cpp
@@ -318,7 +318,7 @@
     geometry.fMiterLimit = stroke.getMiter();
 
     SkAutoTUnref<GrBatch> batch(AAFlatteningConvexPathBatch::Create(geometry));
-    target->drawBatch(pipelineBuilder, batch);
+    target->drawBatch(*pipelineBuilder, batch);
 
     return true;
 }
diff --git a/src/gpu/GrAARectRenderer.cpp b/src/gpu/GrAARectRenderer.cpp
index 64f587f..f59b611 100644
--- a/src/gpu/GrAARectRenderer.cpp
+++ b/src/gpu/GrAARectRenderer.cpp
@@ -314,7 +314,7 @@
 }
 
 void GrAARectRenderer::GeometryFillAARect(GrDrawTarget* target,
-                                          GrPipelineBuilder* pipelineBuilder,
+                                          const GrPipelineBuilder& pipelineBuilder,
                                           GrColor color,
                                           const SkMatrix& viewMatrix,
                                           const SkRect& rect,
@@ -331,7 +331,7 @@
 }
 
 void GrAARectRenderer::StrokeAARect(GrDrawTarget* target,
-                                    GrPipelineBuilder* pipelineBuilder,
+                                    const GrPipelineBuilder& pipelineBuilder,
                                     GrColor color,
                                     const SkMatrix& viewMatrix,
                                     const SkRect& rect,
@@ -773,7 +773,7 @@
 };
 
 void GrAARectRenderer::GeometryStrokeAARect(GrDrawTarget* target,
-                                            GrPipelineBuilder* pipelineBuilder,
+                                            const GrPipelineBuilder& pipelineBuilder,
                                             GrColor color,
                                             const SkMatrix& viewMatrix,
                                             const SkRect& devOutside,
@@ -792,7 +792,7 @@
 }
 
 void GrAARectRenderer::FillAANestedRects(GrDrawTarget* target,
-                                         GrPipelineBuilder* pipelineBuilder,
+                                         const GrPipelineBuilder& pipelineBuilder,
                                          GrColor color,
                                          const SkMatrix& viewMatrix,
                                          const SkRect rects[2]) {
diff --git a/src/gpu/GrAARectRenderer.h b/src/gpu/GrAARectRenderer.h
index 8f42671..6115439 100644
--- a/src/gpu/GrAARectRenderer.h
+++ b/src/gpu/GrAARectRenderer.h
@@ -27,7 +27,7 @@
     // between them by passing in stroke (==NULL means fill).
 
     static void FillAARect(GrDrawTarget* target,
-                           GrPipelineBuilder* pipelineBuilder,
+                           const GrPipelineBuilder& pipelineBuilder,
                            GrColor color,
                            const SkMatrix& viewMatrix,
                            const SkRect& rect,
@@ -36,7 +36,7 @@
     }
 
     static void StrokeAARect(GrDrawTarget*,
-                             GrPipelineBuilder*,
+                             const GrPipelineBuilder&,
                              GrColor,
                              const SkMatrix& viewMatrix,
                              const SkRect& rect,
@@ -45,7 +45,7 @@
 
     // First rect is outer; second rect is inner
     static void FillAANestedRects(GrDrawTarget*,
-                                  GrPipelineBuilder*,
+                                  const GrPipelineBuilder&,
                                   GrColor,
                                   const SkMatrix& viewMatrix,
                                   const SkRect rects[2]);
@@ -54,14 +54,14 @@
     GrAARectRenderer();
 
     static void GeometryFillAARect(GrDrawTarget*,
-                                   GrPipelineBuilder*,
+                                   const GrPipelineBuilder&,
                                    GrColor,
                                    const SkMatrix& viewMatrix,
                                    const SkRect& rect,
                                    const SkRect& devRect);
 
     static void GeometryStrokeAARect(GrDrawTarget*,
-                                     GrPipelineBuilder*,
+                                     const GrPipelineBuilder&,
                                      GrColor,
                                      const SkMatrix& viewMatrix,
                                      const SkRect& devOutside,
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index 208581e..d7501c3 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -409,10 +409,10 @@
                 SkRect devRect = element->getRect();
                 viewMatrix.mapRect(&devRect);
 
-                fClipTarget->drawAARect(pipelineBuilder, color, viewMatrix,
+                fClipTarget->drawAARect(*pipelineBuilder, color, viewMatrix,
                                         element->getRect(), devRect);
             } else {
-                fClipTarget->drawSimpleRect(pipelineBuilder, color, viewMatrix,
+                fClipTarget->drawSimpleRect(*pipelineBuilder, color, viewMatrix,
                                             element->getRect());
             }
             return true;
@@ -492,7 +492,7 @@
                                       GrTextureParams::kNone_FilterMode))->unref();
 
     // The color passed in here does not matter since the coverageSetOpXP won't read it.
-    fClipTarget->drawSimpleRect(pipelineBuilder,
+    fClipTarget->drawSimpleRect(*pipelineBuilder,
                                 GrColor_WHITE,
                                 SkMatrix::I(),
                                 SkRect::Make(dstBound));
@@ -686,7 +686,7 @@
                 backgroundPipelineBuilder.setStencil(kDrawOutsideElement);
 
                 // The color passed in here does not matter since the coverageSetOpXP won't read it.
-                fClipTarget->drawSimpleRect(&backgroundPipelineBuilder, GrColor_WHITE, translate,
+                fClipTarget->drawSimpleRect(backgroundPipelineBuilder, GrColor_WHITE, translate,
                                             clipSpaceIBounds);
             }
         } else {
@@ -823,7 +823,7 @@
                     *pipelineBuilder.stencil() = gDrawToStencil;
 
                     // We need this AGP until everything is in GrBatch
-                    fClipTarget->drawSimpleRect(&pipelineBuilder,
+                    fClipTarget->drawSimpleRect(pipelineBuilder,
                                                 GrColor_WHITE,
                                                 viewMatrix,
                                                 element->getRect());
@@ -850,7 +850,7 @@
                 if (canDrawDirectToClip) {
                     if (Element::kRect_Type == element->getType()) {
                         // We need this AGP until everything is in GrBatch
-                        fClipTarget->drawSimpleRect(&pipelineBuilder,
+                        fClipTarget->drawSimpleRect(pipelineBuilder,
                                                     GrColor_WHITE,
                                                     viewMatrix,
                                                     element->getRect());
@@ -861,7 +861,7 @@
                 } else {
                     // The view matrix is setup to do clip space -> stencil space translation, so
                     // draw rect in clip space.
-                    fClipTarget->drawSimpleRect(&pipelineBuilder,
+                    fClipTarget->drawSimpleRect(pipelineBuilder,
                                                 GrColor_WHITE,
                                                 viewMatrix,
                                                 SkRect::Make(clipSpaceIBounds));
diff --git a/src/gpu/GrDashLinePathRenderer.cpp b/src/gpu/GrDashLinePathRenderer.cpp
index c27e61b..17c1890 100644
--- a/src/gpu/GrDashLinePathRenderer.cpp
+++ b/src/gpu/GrDashLinePathRenderer.cpp
@@ -32,6 +32,6 @@
                                         bool useAA) {
     SkPoint pts[2];
     SkAssertResult(path.isLine(pts));
-    return GrDashingEffect::DrawDashLine(target, pipelineBuilder, color,
+    return GrDashingEffect::DrawDashLine(target, *pipelineBuilder, color,
                                          viewMatrix, pts, useAA, stroke);
 }
diff --git a/src/gpu/GrDefaultPathRenderer.cpp b/src/gpu/GrDefaultPathRenderer.cpp
index 2431696..e02e082 100644
--- a/src/gpu/GrDefaultPathRenderer.cpp
+++ b/src/gpu/GrDefaultPathRenderer.cpp
@@ -678,7 +678,7 @@
             }
             const SkMatrix& viewM = (reverse && viewMatrix.hasPerspective()) ? SkMatrix::I() :
                                                                                viewMatrix;
-            target->drawBWRect(pipelineBuilder, color, viewM, bounds, NULL, &localMatrix);
+            target->drawBWRect(*pipelineBuilder, color, viewM, bounds, NULL, &localMatrix);
         } else {
             if (passCount > 1) {
                 pipelineBuilder->setDisableColorXPFactory();
@@ -692,7 +692,7 @@
             SkAutoTUnref<GrBatch> batch(DefaultPathBatch::Create(geometry, newCoverage, viewMatrix,
                                                                  isHairline, devBounds));
 
-            target->drawBatch(pipelineBuilder, batch);
+            target->drawBatch(*pipelineBuilder, batch);
         }
     }
     return true;
diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp
index 0c00b32..2f04a02 100644
--- a/src/gpu/GrDrawContext.cpp
+++ b/src/gpu/GrDrawContext.cpp
@@ -116,7 +116,7 @@
                               int /*GrDrawTarget::PathTransformType*/ transformType,
                               int count,
                               int /*GrPathRendering::FillType*/ fill) {
-    fDrawTarget->drawPaths(pipelineBuilder, pathProc, pathRange,
+    fDrawTarget->drawPaths(*pipelineBuilder, pathProc, pathRange,
                            indices, (GrDrawTarget::PathIndexType) indexType,
                            transformValues,
                            (GrDrawTarget::PathTransformType) transformType,
@@ -192,7 +192,7 @@
         }
 
         GrPipelineBuilder pipelineBuilder(*paint, rt, clip);
-        fDrawTarget->drawBWRect(&pipelineBuilder,
+        fDrawTarget->drawBWRect(pipelineBuilder,
                                 paint->getColor(),
                                 SkMatrix::I(),
                                 r,
@@ -487,7 +487,7 @@
     if (doAA) {
         if (width >= 0) {
             GrAARectRenderer::StrokeAARect(fDrawTarget,
-                                           &pipelineBuilder,
+                                           pipelineBuilder,
                                            color,
                                            viewMatrix,
                                            rect,
@@ -496,7 +496,7 @@
         } else {
             // filled AA rect
             GrAARectRenderer::FillAARect(fDrawTarget,
-                                         &pipelineBuilder,
+                                         pipelineBuilder,
                                          color,
                                          viewMatrix,
                                          rect,
@@ -521,10 +521,10 @@
         // is enabled because it can cause ugly artifacts.
         pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixelCenters_Flag,
                                  snapToPixelCenters);
-        fDrawTarget->drawBatch(&pipelineBuilder, batch);
+        fDrawTarget->drawBatch(pipelineBuilder, batch);
     } else {
         // filled BW rect
-        fDrawTarget->drawSimpleRect(&pipelineBuilder, color, viewMatrix, rect);
+        fDrawTarget->drawSimpleRect(pipelineBuilder, color, viewMatrix, rect);
     }
 }
 
@@ -542,7 +542,7 @@
     }
 
     GrPipelineBuilder pipelineBuilder(paint, rt, clip);
-    fDrawTarget->drawBWRect(&pipelineBuilder,
+    fDrawTarget->drawBWRect(pipelineBuilder,
                             paint.getColor(),
                             viewMatrix,
                             rectToDraw,
@@ -861,7 +861,7 @@
                                                           indexCount, colors, texCoords,
                                                           bounds));
 
-    fDrawTarget->drawBatch(&pipelineBuilder, batch);
+    fDrawTarget->drawBatch(pipelineBuilder, batch);
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -1075,7 +1075,7 @@
             SkRect rects[2];
 
             if (is_nested_rects(viewMatrix, path, strokeInfo, rects)) {
-                GrAARectRenderer::FillAANestedRects(fDrawTarget, &pipelineBuilder, color,
+                GrAARectRenderer::FillAANestedRects(fDrawTarget, pipelineBuilder, color,
                                                     viewMatrix, rects);
                 return;
             }
@@ -1188,7 +1188,7 @@
 }
 
 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrBatch* batch) {
-    fDrawTarget->drawBatch(pipelineBuilder, batch);
+    fDrawTarget->drawBatch(*pipelineBuilder, batch);
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index 4763ca7..ba06c66 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -126,9 +126,7 @@
     this->reset();
 }
 
-void GrDrawTarget::drawBatch(GrPipelineBuilder* pipelineBuilder,
-                             GrBatch* batch) {
-    SkASSERT(pipelineBuilder);
+void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, GrBatch* batch) {
     // TODO some kind of checkdraw, but not at this level
 
     // Setup clip
@@ -189,14 +187,13 @@
     this->clipMaskManager()->adjustPathStencilParams(sb, outStencilSettings);
 }
 
-void GrDrawTarget::stencilPath(GrPipelineBuilder* pipelineBuilder,
+void GrDrawTarget::stencilPath(const GrPipelineBuilder& pipelineBuilder,
                                const GrPathProcessor* pathProc,
                                const GrPath* path,
                                GrPathRendering::FillType fill) {
     // TODO: extract portions of checkDraw that are relevant to path stenciling.
     SkASSERT(path);
     SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport());
-    SkASSERT(pipelineBuilder);
 
     // Setup clip
     GrScissorState scissorState;
@@ -209,21 +206,20 @@
 
     // set stencil settings for path
     GrStencilSettings stencilSettings;
-    GrRenderTarget* rt = pipelineBuilder->getRenderTarget();
+    GrRenderTarget* rt = pipelineBuilder.getRenderTarget();
     GrStencilAttachment* sb = rt->renderTargetPriv().attachStencilAttachment();
     this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings);
 
-    this->onStencilPath(*pipelineBuilder, pathProc, path, scissorState, stencilSettings);
+    this->onStencilPath(pipelineBuilder, pathProc, path, scissorState, stencilSettings);
 }
 
-void GrDrawTarget::drawPath(GrPipelineBuilder* pipelineBuilder,
+void GrDrawTarget::drawPath(const GrPipelineBuilder& pipelineBuilder,
                             const GrPathProcessor* pathProc,
                             const GrPath* path,
                             GrPathRendering::FillType fill) {
     // TODO: extract portions of checkDraw that are relevant to path rendering.
     SkASSERT(path);
     SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport());
-    SkASSERT(pipelineBuilder);
 
     SkRect devBounds = path->getBounds();
     pathProc->viewMatrix().mapRect(&devBounds);
@@ -239,7 +235,7 @@
 
     // set stencil settings for path
     GrStencilSettings stencilSettings;
-    GrRenderTarget* rt = pipelineBuilder->getRenderTarget();
+    GrRenderTarget* rt = pipelineBuilder.getRenderTarget();
     GrStencilAttachment* sb = rt->renderTargetPriv().attachStencilAttachment();
     this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings);
 
@@ -252,7 +248,7 @@
     this->onDrawPath(pathProc, path, stencilSettings, pipelineInfo);
 }
 
-void GrDrawTarget::drawPaths(GrPipelineBuilder* pipelineBuilder,
+void GrDrawTarget::drawPaths(const GrPipelineBuilder& pipelineBuilder,
                              const GrPathProcessor* pathProc,
                              const GrPathRange* pathRange,
                              const void* indices,
@@ -266,7 +262,6 @@
     SkASSERT(indices);
     SkASSERT(0 == reinterpret_cast<long>(indices) % GrPathRange::PathIndexSizeInBytes(indexType));
     SkASSERT(transformValues);
-    SkASSERT(pipelineBuilder);
 
     // Setup clip
     GrScissorState scissorState;
@@ -279,7 +274,7 @@
 
     // set stencil settings for path
     GrStencilSettings stencilSettings;
-    GrRenderTarget* rt = pipelineBuilder->getRenderTarget();
+    GrRenderTarget* rt = pipelineBuilder.getRenderTarget();
     GrStencilAttachment* sb = rt->renderTargetPriv().attachStencilAttachment();
     this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings);
 
@@ -296,18 +291,18 @@
                       transformType, count, stencilSettings, pipelineInfo);
 }
 
-void GrDrawTarget::drawBWRect(GrPipelineBuilder* pipelineBuilder,
-                            GrColor color,
-                            const SkMatrix& viewMatrix,
-                            const SkRect& rect,
-                            const SkRect* localRect,
-                            const SkMatrix* localMatrix) {
+void GrDrawTarget::drawBWRect(const GrPipelineBuilder& pipelineBuilder,
+                              GrColor color,
+                              const SkMatrix& viewMatrix,
+                              const SkRect& rect,
+                              const SkRect* localRect,
+                              const SkMatrix* localMatrix) {
    SkAutoTUnref<GrBatch> batch(GrRectBatch::Create(color, viewMatrix, rect, localRect,
                                                    localMatrix));
    this->drawBatch(pipelineBuilder, batch);
 }
 
-void GrDrawTarget::drawAARect(GrPipelineBuilder* pipelineBuilder,
+void GrDrawTarget::drawAARect(const GrPipelineBuilder& pipelineBuilder,
                               GrColor color,
                               const SkMatrix& viewMatrix,
                               const SkRect& rect,
@@ -333,7 +328,7 @@
         GrPipelineBuilder pipelineBuilder;
         pipelineBuilder.setRenderTarget(renderTarget);
 
-        this->drawSimpleRect(&pipelineBuilder, color, SkMatrix::I(), *rect);
+        this->drawSimpleRect(pipelineBuilder, color, SkMatrix::I(), *rect);
     } else {       
         this->onClear(rect, color, canIgnoreRect, renderTarget);
     }
@@ -466,12 +461,12 @@
 }
 ///////////////////////////////////////////////////////////////////////////////
 
-GrDrawTarget::PipelineInfo::PipelineInfo(GrPipelineBuilder* pipelineBuilder,
+GrDrawTarget::PipelineInfo::PipelineInfo(const GrPipelineBuilder& pipelineBuilder,
                                          GrScissorState* scissor,
                                          const GrPrimitiveProcessor* primProc,
                                          const SkRect* devBounds,
                                          GrDrawTarget* target)
-    : fPipelineBuilder(pipelineBuilder)
+    : fPipelineBuilder(&pipelineBuilder)
     , fScissor(scissor) {
     fColorPOI = fPipelineBuilder->colorProcInfo(primProc);
     fCoveragePOI = fPipelineBuilder->coverageProcInfo(primProc);
@@ -481,12 +476,12 @@
     }
 }
 
-GrDrawTarget::PipelineInfo::PipelineInfo(GrPipelineBuilder* pipelineBuilder,
+GrDrawTarget::PipelineInfo::PipelineInfo(const GrPipelineBuilder& pipelineBuilder,
                                          GrScissorState* scissor,
                                          const GrBatch* batch,
                                          const SkRect* devBounds,
                                          GrDrawTarget* target)
-    : fPipelineBuilder(pipelineBuilder)
+    : fPipelineBuilder(&pipelineBuilder)
     , fScissor(scissor) {
     fColorPOI = fPipelineBuilder->colorProcInfo(batch);
     fCoveragePOI = fPipelineBuilder->coverageProcInfo(batch);
@@ -504,13 +499,13 @@
 }
 
 
-bool GrClipTarget::setupClip(GrPipelineBuilder* pipelineBuilder,
+bool GrClipTarget::setupClip(const GrPipelineBuilder& pipelineBuilder,
                              GrPipelineBuilder::AutoRestoreFragmentProcessors* arfp,
                              GrPipelineBuilder::AutoRestoreStencil* ars,
                              GrPipelineBuilder::AutoRestoreProcessorDataManager* arpdm,
                              GrScissorState* scissorState,
                              const SkRect* devBounds) {
-    return fClipMaskManager->setupClipping(*pipelineBuilder,
+    return fClipMaskManager->setupClipping(pipelineBuilder,
                                            arfp,
                                            ars,
                                            arpdm,
diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h
index 634a492..2265f61 100644
--- a/src/gpu/GrDrawTarget.h
+++ b/src/gpu/GrDrawTarget.h
@@ -66,7 +66,7 @@
      */
     const GrCaps* caps() const { return fCaps; }
 
-    void drawBatch(GrPipelineBuilder*, GrBatch*);
+    void drawBatch(const GrPipelineBuilder&, GrBatch*);
 
     /**
      * Draws path into the stencil buffer. The fill must be either even/odd or
@@ -74,14 +74,14 @@
      * on the GrPipelineBuilder (if possible in the 3D API).  Note, we will never have an inverse
      * fill with stencil path
      */
-    void stencilPath(GrPipelineBuilder*, const GrPathProcessor*, const GrPath*,
+    void stencilPath(const GrPipelineBuilder&, const GrPathProcessor*, const GrPath*,
                      GrPathRendering::FillType);
 
     /**
      * Draws a path. Fill must not be a hairline. It will respect the HW
      * antialias flag on the GrPipelineBuilder (if possible in the 3D API).
      */
-    void drawPath(GrPipelineBuilder*, const GrPathProcessor*, const GrPath*,
+    void drawPath(const GrPipelineBuilder&, const GrPathProcessor*, const GrPath*,
                   GrPathRendering::FillType);
 
     /**
@@ -97,7 +97,7 @@
      * @param count           Number of paths to draw
      * @param fill            Fill type for drawing all the paths
      */
-    void drawPaths(GrPipelineBuilder*,
+    void drawPaths(const GrPipelineBuilder&,
                    const GrPathProcessor*,
                    const GrPathRange* pathRange,
                    const void* indices,
@@ -118,7 +118,7 @@
      *                    that rectangle before it is input to GrCoordTransforms that read local
      *                    coordinates
      */
-    void drawBWRect(GrPipelineBuilder* pipelineBuilder,
+    void drawBWRect(const GrPipelineBuilder& pipelineBuilder,
                     GrColor color,
                     const SkMatrix& viewMatrix,
                     const SkRect& rect,
@@ -128,17 +128,17 @@
     /**
      * Helper for drawRect when the caller doesn't need separate local rects or matrices.
      */
-    void drawSimpleRect(GrPipelineBuilder* ds, GrColor color, const SkMatrix& viewM,
+    void drawSimpleRect(const GrPipelineBuilder& ds, GrColor color, const SkMatrix& viewM,
                         const SkRect& rect) {
         this->drawBWRect(ds, color, viewM, rect, NULL, NULL);
     }
-    void drawSimpleRect(GrPipelineBuilder* ds, GrColor color, const SkMatrix& viewM,
+    void drawSimpleRect(const GrPipelineBuilder& ds, GrColor color, const SkMatrix& viewM,
                         const SkIRect& irect) {
         SkRect rect = SkRect::Make(irect);
         this->drawBWRect(ds, color, viewM, rect, NULL, NULL);
     }
 
-    void drawAARect(GrPipelineBuilder* pipelineBuilder,
+    void drawAARect(const GrPipelineBuilder& pipelineBuilder,
                     GrColor color,
                     const SkMatrix& viewMatrix,
                     const SkRect& rect,
@@ -221,11 +221,11 @@
                                  const SkRect* drawBounds);
 
     struct PipelineInfo {
-        PipelineInfo(GrPipelineBuilder* pipelineBuilder, GrScissorState* scissor,
+        PipelineInfo(const GrPipelineBuilder& pipelineBuilder, GrScissorState* scissor,
                      const GrPrimitiveProcessor* primProc,
                      const SkRect* devBounds, GrDrawTarget* target);
 
-        PipelineInfo(GrPipelineBuilder* pipelineBuilder, GrScissorState* scissor,
+        PipelineInfo(const GrPipelineBuilder& pipelineBuilder, GrScissorState* scissor,
                      const GrBatch* batch, const SkRect* devBounds,
                      GrDrawTarget* target);
 
@@ -237,7 +237,7 @@
 
         bool mustSkipDraw() const { return (NULL == fPipelineBuilder); }
 
-        GrPipelineBuilder*          fPipelineBuilder;
+        const GrPipelineBuilder*    fPipelineBuilder;
         GrScissorState*             fScissor;
         GrProcOptInfo               fColorPOI; 
         GrProcOptInfo               fCoveragePOI; 
@@ -287,7 +287,7 @@
                                            const GrStencilAttachment*,
                                            GrStencilSettings*);
     virtual GrClipMaskManager* clipMaskManager() = 0;
-    virtual bool setupClip(GrPipelineBuilder*,
+    virtual bool setupClip(const GrPipelineBuilder&,
                            GrPipelineBuilder::AutoRestoreFragmentProcessors*,
                            GrPipelineBuilder::AutoRestoreStencil*,
                            GrPipelineBuilder::AutoRestoreProcessorDataManager*,
@@ -340,7 +340,7 @@
 private:
     GrClipMaskManager* clipMaskManager() override { return fClipMaskManager; }
 
-    bool setupClip(GrPipelineBuilder*,
+    bool setupClip(const GrPipelineBuilder&,
                    GrPipelineBuilder::AutoRestoreFragmentProcessors*,
                    GrPipelineBuilder::AutoRestoreStencil*,
                    GrPipelineBuilder::AutoRestoreProcessorDataManager*,
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index 0ce6bea..b8bec3a 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -245,7 +245,7 @@
      * efficiently succeed. It should only succeed if it can allow copySurface to perform a copy
      * that would be more effecient than drawing the src to a dst render target.
      */
-    virtual bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) = 0;
+    virtual bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) const = 0;
 
     // After the client interacts directly with the 3D context state the GrGpu
     // must resync its internal state and assumptions about 3D context state.
diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp
index 0d7da2e..a34027c 100644
--- a/src/gpu/GrOvalRenderer.cpp
+++ b/src/gpu/GrOvalRenderer.cpp
@@ -832,7 +832,7 @@
                                 const SkStrokeRec& stroke) {
     SkAutoTUnref<GrBatch> batch(create_circle_batch(color, viewMatrix, useCoverageAA, circle,
                                                     stroke));
-    target->drawBatch(pipelineBuilder, batch);
+    target->drawBatch(*pipelineBuilder, batch);
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -1092,7 +1092,7 @@
         return false;
     }
 
-    target->drawBatch(pipelineBuilder, batch);
+    target->drawBatch(*pipelineBuilder, batch);
     return true;
 }
 
@@ -1336,7 +1336,7 @@
     if (!batch) {
         return false;
     }
-    target->drawBatch(pipelineBuilder, batch);
+    target->drawBatch(*pipelineBuilder, batch);
     return true;
 }
 
@@ -1444,7 +1444,7 @@
     if (applyAA) {
         bounds.outset(SK_ScalarHalf, SK_ScalarHalf);
     }
-    target->drawBWRect(pipelineBuilder, color, SkMatrix::I(), bounds, NULL, &invert);
+    target->drawBWRect(*pipelineBuilder, color, SkMatrix::I(), bounds, NULL, &invert);
     return true;
 }
 
@@ -1979,7 +1979,7 @@
         return false;
     }
 
-    target->drawBatch(pipelineBuilder, batch);
+    target->drawBatch(*pipelineBuilder, batch);
     return true;
 }
 
diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp
index 28071d2..0e0a541 100644
--- a/src/gpu/GrSWMaskHelper.cpp
+++ b/src/gpu/GrSWMaskHelper.cpp
@@ -374,5 +374,5 @@
                                                        GrTextureParams::kNone_FilterMode,
                                                        kDevice_GrCoordSet))->unref();
 
-    target->drawBWRect(pipelineBuilder, color, SkMatrix::I(), dstRect, NULL, &invert);
+    target->drawBWRect(*pipelineBuilder, color, SkMatrix::I(), dstRect, NULL, &invert);
 }
diff --git a/src/gpu/GrSoftwarePathRenderer.cpp b/src/gpu/GrSoftwarePathRenderer.cpp
index 3d5bc3e..5389a9b 100644
--- a/src/gpu/GrSoftwarePathRenderer.cpp
+++ b/src/gpu/GrSoftwarePathRenderer.cpp
@@ -94,22 +94,22 @@
     if (devClipBounds.fTop < devPathBounds.fTop) {
         rect.iset(devClipBounds.fLeft, devClipBounds.fTop,
                   devClipBounds.fRight, devPathBounds.fTop);
-        target->drawBWRect(pipelineBuilder, color, SkMatrix::I(), rect, NULL, &invert);
+        target->drawBWRect(*pipelineBuilder, color, SkMatrix::I(), rect, NULL, &invert);
     }
     if (devClipBounds.fLeft < devPathBounds.fLeft) {
         rect.iset(devClipBounds.fLeft, devPathBounds.fTop,
                   devPathBounds.fLeft, devPathBounds.fBottom);
-        target->drawBWRect(pipelineBuilder, color, SkMatrix::I(), rect, NULL, &invert);
+        target->drawBWRect(*pipelineBuilder, color, SkMatrix::I(), rect, NULL, &invert);
     }
     if (devClipBounds.fRight > devPathBounds.fRight) {
         rect.iset(devPathBounds.fRight, devPathBounds.fTop,
                   devClipBounds.fRight, devPathBounds.fBottom);
-        target->drawBWRect(pipelineBuilder, color, SkMatrix::I(), rect, NULL, &invert);
+        target->drawBWRect(*pipelineBuilder, color, SkMatrix::I(), rect, NULL, &invert);
     }
     if (devClipBounds.fBottom > devPathBounds.fBottom) {
         rect.iset(devClipBounds.fLeft, devPathBounds.fBottom,
                   devClipBounds.fRight, devClipBounds.fBottom);
-        target->drawBWRect(pipelineBuilder, color, SkMatrix::I(), rect, NULL, &invert);
+        target->drawBWRect(*pipelineBuilder, color, SkMatrix::I(), rect, NULL, &invert);
     }
 }
 
diff --git a/src/gpu/GrStencilAndCoverPathRenderer.cpp b/src/gpu/GrStencilAndCoverPathRenderer.cpp
index 248730b..fb37360 100644
--- a/src/gpu/GrStencilAndCoverPathRenderer.cpp
+++ b/src/gpu/GrStencilAndCoverPathRenderer.cpp
@@ -98,7 +98,7 @@
     SkASSERT(!path.isInverseFillType());
     SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(GrColor_WHITE, viewMatrix));
     SkAutoTUnref<GrPath> p(get_gr_path(fResourceProvider, path, stroke));
-    target->stencilPath(pipelineBuilder, pp, p, convert_skpath_filltype(path.getFillType()));
+    target->stencilPath(*pipelineBuilder, pp, p, convert_skpath_filltype(path.getFillType()));
 }
 
 bool GrStencilAndCoverPathRenderer::onDrawPath(GrDrawTarget* target,
@@ -134,7 +134,7 @@
 
         // fake inverse with a stencil and cover
         SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(GrColor_WHITE, viewMatrix));
-        target->stencilPath(pipelineBuilder, pp, p, convert_skpath_filltype(path.getFillType()));
+        target->stencilPath(*pipelineBuilder, pp, p, convert_skpath_filltype(path.getFillType()));
 
         SkMatrix invert = SkMatrix::I();
         SkRect bounds =
@@ -154,7 +154,7 @@
             }
         }
         const SkMatrix& viewM = viewMatrix.hasPerspective() ? SkMatrix::I() : viewMatrix;
-        target->drawBWRect(pipelineBuilder, color, viewM, bounds, NULL, &invert);
+        target->drawBWRect(*pipelineBuilder, color, viewM, bounds, NULL, &invert);
     } else {
         GR_STATIC_CONST_SAME_STENCIL(kStencilPass,
             kZero_StencilOp,
@@ -166,7 +166,7 @@
 
         pipelineBuilder->setStencil(kStencilPass);
         SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(color, viewMatrix));
-        target->drawPath(pipelineBuilder, pp, p, convert_skpath_filltype(path.getFillType()));
+        target->drawPath(*pipelineBuilder, pp, p, convert_skpath_filltype(path.getFillType()));
     }
 
     pipelineBuilder->stencil()->setDisabled();
diff --git a/src/gpu/GrTessellatingPathRenderer.cpp b/src/gpu/GrTessellatingPathRenderer.cpp
index de5dcab..f420372 100644
--- a/src/gpu/GrTessellatingPathRenderer.cpp
+++ b/src/gpu/GrTessellatingPathRenderer.cpp
@@ -1511,7 +1511,7 @@
     }
     vmi.mapRect(&clipBounds);
     SkAutoTUnref<GrBatch> batch(TessellatingPathBatch::Create(color, path, viewM, clipBounds));
-    target->drawBatch(pipelineBuilder, batch);
+    target->drawBatch(*pipelineBuilder, batch);
 
     return true;
 }
diff --git a/src/gpu/GrTest.cpp b/src/gpu/GrTest.cpp
index 5a3c014..b070d84 100644
--- a/src/gpu/GrTest.cpp
+++ b/src/gpu/GrTest.cpp
@@ -166,7 +166,7 @@
                      const SkIRect& srcRect,
                      const SkIPoint& dstPoint) override { return false; };
 
-    bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) override {
+    bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) const override {
         return false;
     }
 
diff --git a/src/gpu/effects/GrDashingEffect.cpp b/src/gpu/effects/GrDashingEffect.cpp
index 26a2506..18cd3d1 100644
--- a/src/gpu/effects/GrDashingEffect.cpp
+++ b/src/gpu/effects/GrDashingEffect.cpp
@@ -728,11 +728,12 @@
 }
 
 bool GrDashingEffect::DrawDashLine(GrDrawTarget* target,
-                                   GrPipelineBuilder* pipelineBuilder, GrColor color,
+                                   const GrPipelineBuilder& pipelineBuilder, GrColor color,
                                    const SkMatrix& viewMatrix, const SkPoint pts[2],
                                    bool useAA, const GrStrokeInfo& strokeInfo) {
-    SkAutoTUnref<GrBatch> batch(create_batch(color, viewMatrix, pts, useAA, strokeInfo,
-                                    pipelineBuilder->getRenderTarget()->isUnifiedMultisampled()));
+    SkAutoTUnref<GrBatch> batch(
+            create_batch(color, viewMatrix, pts, useAA, strokeInfo,
+                         pipelineBuilder.getRenderTarget()->isUnifiedMultisampled()));
     if (!batch) {
         return false;
     }
diff --git a/src/gpu/effects/GrDashingEffect.h b/src/gpu/effects/GrDashingEffect.h
index 05b1c90..7d0d006 100644
--- a/src/gpu/effects/GrDashingEffect.h
+++ b/src/gpu/effects/GrDashingEffect.h
@@ -20,7 +20,7 @@
 class GrStrokeInfo;
 
 namespace GrDashingEffect {
-    bool DrawDashLine(GrDrawTarget*, GrPipelineBuilder*, GrColor,
+    bool DrawDashLine(GrDrawTarget*, const GrPipelineBuilder&, GrColor,
                       const SkMatrix& viewMatrix, const SkPoint pts[2], bool useAA,
                       const GrStrokeInfo& strokeInfo);
     bool CanDrawDashLine(const SkPoint pts[2], const GrStrokeInfo& strokeInfo,
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index e185ef0..7320d2e 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -2676,7 +2676,7 @@
                                                          0));
 }
 
-bool GrGLGpu::initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) {
+bool GrGLGpu::initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) const {
     // If the src is a texture, we can implement the blit as a draw assuming the config is
     // renderable.
     if (src->asTexture() && this->caps()->isConfigRenderable(src->config(), false)) {
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index 368bda1..baafea3 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -70,7 +70,7 @@
                                    size_t rowBytes) const override;
     bool fullReadPixelsIsFasterThanPartial() const override;
 
-    bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) override;
+    bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) const override;
 
     // These functions should be used to bind GL objects. They track the GL state and skip redundant
     // bindings. Making the equivalent glBind calls directly will confuse the state tracking.