Remove GrStagedProcessor, remove the word Stage as it applies to FPs

Committed: https://skia.googlesource.com/skia/+/24243446cdf7b7e4e132c2a0c387c7723777e0c7

Review URL: https://codereview.chromium.org/1307223004
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index 6013b58..ede386a 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -36,7 +36,7 @@
     matrix.setTranslate(-maskRect.fLeft, -maskRect.fTop);
     matrix.postIDiv(mask->width(), mask->height());
 
-    grp->addCoverageProcessor(GrSimpleTextureEffect::Create(grp->getProcessorDataManager(),
+    grp->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(grp->getProcessorDataManager(),
                                                             mask, matrix,
                                                             kDevice_GrCoordSet))->unref();
 
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index b58faaa..c9362fa 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -46,7 +46,7 @@
 
     SkIRect domainTexels = SkIRect::MakeWH(devBound.width(), devBound.height());
     // This could be a long-lived effect that is cached with the alpha-mask.
-    arfps->addCoverageProcessor(
+    arfps->addCoverageFragmentProcessor(
         GrTextureDomainEffect::Create(arfps->getProcessorDataManager(),
                                       result,
                                       mat,
@@ -200,7 +200,7 @@
                     break;
             }
             if (fp) {
-                arfps->addCoverageProcessor(fp);
+                arfps->addCoverageFragmentProcessor(fp);
             } else {
                 failed = true;
                 break;
@@ -488,7 +488,7 @@
     SkMatrix sampleM;
     sampleM.setIDiv(srcMask->width(), srcMask->height());
 
-    pipelineBuilder->addCoverageProcessor(
+    pipelineBuilder->addCoverageFragmentProcessor(
         GrTextureDomainEffect::Create(pipelineBuilder->getProcessorDataManager(),
                                       srcMask,
                                       sampleM,
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 3a1ca13..0e01313 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -427,7 +427,7 @@
             if (!drawContext) {
                 return false;
             }
-            paint.addColorProcessor(fp);
+            paint.addColorFragmentProcessor(fp);
             SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
             drawContext->drawRect(renderTarget, GrClip::WideOpen(), paint, matrix, rect, NULL);
 
@@ -532,7 +532,7 @@
                     GrConfigConversionEffect::kNone_PMConversion, textureMatrix));
             }
             if (fp) {
-                paint.addColorProcessor(fp);
+                paint.addColorFragmentProcessor(fp);
                 SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
                 GrDrawContext* drawContext = this->drawContext();
                 drawContext->drawRect(temp->asRenderTarget(), GrClip::WideOpen(), paint,
diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp
index 829f0ed..4847612 100644
--- a/src/gpu/GrOvalRenderer.cpp
+++ b/src/gpu/GrOvalRenderer.cpp
@@ -1419,7 +1419,7 @@
             return false;
         }
         arfps.set(&pipelineBuilder);
-        arfps.addCoverageProcessor(fp)->unref();
+        arfps.addCoverageFragmentProcessor(fp)->unref();
     }
 
     SkStrokeRec fillRec(SkStrokeRec::kFill_InitStyle);
@@ -1449,7 +1449,7 @@
         return false;
     }
 
-    arfps.addCoverageProcessor(effect)->unref();
+    arfps.addCoverageFragmentProcessor(effect)->unref();
     SkRect bounds = outer->getBounds();
     if (applyAA) {
         bounds.outset(SK_ScalarHalf, SK_ScalarHalf);
diff --git a/src/gpu/GrPaint.cpp b/src/gpu/GrPaint.cpp
index 1e57525f..dc1644b 100644
--- a/src/gpu/GrPaint.cpp
+++ b/src/gpu/GrPaint.cpp
@@ -24,32 +24,33 @@
 }
 
 void GrPaint::addColorTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
-    this->addColorProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
+    this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
                                                           matrix))->unref();
 }
 
 void GrPaint::addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
-    this->addCoverageProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
+    this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
                                                              matrix))->unref();
 }
 
 void GrPaint::addColorTextureProcessor(GrTexture* texture,
                                        const SkMatrix& matrix,
                                        const GrTextureParams& params) {
-    this->addColorProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture, matrix,
+    this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture, matrix,
                                                           params))->unref();
 }
 
 void GrPaint::addCoverageTextureProcessor(GrTexture* texture,
                                           const SkMatrix& matrix,
                                           const GrTextureParams& params) {
-    this->addCoverageProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture, matrix,
+    this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture, matrix,
                                                              params))->unref();
 }
 
 bool GrPaint::isConstantBlendedColor(GrColor* color) const {
     GrProcOptInfo colorProcInfo;
-    colorProcInfo.calcWithInitialValues(fColorStages.begin(), this->numColorStages(), fColor,
+    colorProcInfo.calcWithInitialValues(fColorFragmentProcessors.begin(),
+                                        this->numColorFragmentProcessors(), fColor,
                                         kRGBA_GrColorComponentFlags, false);
 
     GrXPFactory::InvariantBlendedColor blendedColor;
diff --git a/src/gpu/GrPendingFragmentStage.h b/src/gpu/GrPendingFragmentStage.h
deleted file mode 100644
index dfa5688..0000000
--- a/src/gpu/GrPendingFragmentStage.h
+++ /dev/null
@@ -1,27 +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 GrPendingFragmentStage_DEFINED
-#define GrPendingFragmentStage_DEFINED
-
-#include "GrStagedProcessor.h"
-#include "GrPendingProgramElement.h"
-
-/**
- * This a baked variant of GrFragmentStage, as recorded in GrPipeline
- */
-class GrPendingFragmentStage : public GrStagedProcessor<GrPendingProgramElement> {
-public:
-    GrPendingFragmentStage(const GrFragmentStage& stage) {
-        INHERITED::fProc.reset(stage.processor());
-    }
-
-private:
-    typedef GrStagedProcessor<GrPendingProgramElement> INHERITED;
-};
-
-#endif
diff --git a/src/gpu/GrPipeline.cpp b/src/gpu/GrPipeline.cpp
index 148ebb4..93647d6 100644
--- a/src/gpu/GrPipeline.cpp
+++ b/src/gpu/GrPipeline.cpp
@@ -29,8 +29,8 @@
     }
 
     GrColor overrideColor = GrColor_ILLEGAL;
-    if (args.fColorPOI.firstEffectiveStageIndex() != 0) {
-        overrideColor = args.fColorPOI.inputColorToEffectiveStage();
+    if (args.fColorPOI.firstEffectiveProcessorIndex() != 0) {
+        overrideColor = args.fColorPOI.inputColorToFirstEffectiveProccesor();
     }
 
     GrXferProcessor::OptFlags optFlags = GrXferProcessor::kNone_OptFlags;
@@ -73,31 +73,36 @@
         pipeline->fFlags |= kSnapVertices_Flag;
     }
 
-    int firstColorStageIdx = args.fColorPOI.firstEffectiveStageIndex();
+    int firstColorProcessorIdx = args.fColorPOI.firstEffectiveProcessorIndex();
 
-    // TODO: Once we can handle single or four channel input into coverage stages then we can use
-    // GrPipelineBuilder's coverageProcInfo (like color above) to set this initial information.
-    int firstCoverageStageIdx = 0;
+    // TODO: Once we can handle single or four channel input into coverage GrFragmentProcessors
+    // then we can use GrPipelineBuilder's coverageProcInfo (like color above) to set this initial
+    // information.
+    int firstCoverageProcessorIdx = 0;
 
     pipeline->adjustProgramFromOptimizations(builder, optFlags, args.fColorPOI, args.fCoveragePOI,
-                                             &firstColorStageIdx, &firstCoverageStageIdx);
+                                             &firstColorProcessorIdx, &firstCoverageProcessorIdx);
 
     bool usesLocalCoords = false;
 
-    // Copy Stages from PipelineBuilder to Pipeline
-    for (int i = firstColorStageIdx; i < builder.numColorFragmentStages(); ++i) {
-        const GrFragmentStage& fps = builder.fColorStages[i];
-        const GrFragmentProcessor* fp = fps.processor();
-        SkNEW_APPEND_TO_TARRAY(&pipeline->fFragmentStages, GrPendingFragmentStage, (fps));
+    // Copy GrFragmentProcessors from GrPipelineBuilder to Pipeline
+    pipeline->fNumColorProcessors = builder.numColorFragmentProcessors() - firstColorProcessorIdx;
+    int numTotalProcessors = pipeline->fNumColorProcessors +
+                             builder.numCoverageFragmentProcessors() - firstCoverageProcessorIdx;
+    pipeline->fFragmentProcessors.reset(numTotalProcessors);
+    int currFPIdx = 0;
+    for (int i = firstColorProcessorIdx; i < builder.numColorFragmentProcessors();
+         ++i, ++currFPIdx) {
+        const GrFragmentProcessor* fp = builder.getColorFragmentProcessor(i);
+        pipeline->fFragmentProcessors[currFPIdx].reset(fp);
         usesLocalCoords = usesLocalCoords || fp->usesLocalCoords();
         fp->gatherCoordTransforms(&pipeline->fCoordTransforms);
     }
 
-    pipeline->fNumColorStages = pipeline->fFragmentStages.count();
-    for (int i = firstCoverageStageIdx; i < builder.numCoverageFragmentStages(); ++i) {
-        const GrFragmentStage& fps = builder.fCoverageStages[i];
-        const GrFragmentProcessor* fp = fps.processor();
-        SkNEW_APPEND_TO_TARRAY(&pipeline->fFragmentStages, GrPendingFragmentStage, (fps));
+    for (int i = firstCoverageProcessorIdx; i < builder.numCoverageFragmentProcessors();
+         ++i, ++currFPIdx) {
+        const GrFragmentProcessor* fp = builder.getCoverageFragmentProcessor(i);
+        pipeline->fFragmentProcessors[currFPIdx].reset(fp);
         usesLocalCoords = usesLocalCoords || fp->usesLocalCoords();
         fp->gatherCoordTransforms(&pipeline->fCoordTransforms);
     }
@@ -134,13 +139,13 @@
                                                 GrXferProcessor::OptFlags flags,
                                                 const GrProcOptInfo& colorPOI,
                                                 const GrProcOptInfo& coveragePOI,
-                                                int* firstColorStageIdx,
-                                                int* firstCoverageStageIdx) {
+                                                int* firstColorProcessorIdx,
+                                                int* firstCoverageProcessorIdx) {
     fReadsFragPosition = fXferProcessor->willReadFragmentPosition();
 
     if ((flags & GrXferProcessor::kIgnoreColor_OptFlag) ||
         (flags & GrXferProcessor::kOverrideColor_OptFlag)) {
-        *firstColorStageIdx = pipelineBuilder.numColorFragmentStages();
+        *firstColorProcessorIdx = pipelineBuilder.numColorFragmentProcessors();
     } else {
         if (coveragePOI.readsFragPosition()) {
             fReadsFragPosition = true;
@@ -148,7 +153,7 @@
     }
 
     if (flags & GrXferProcessor::kIgnoreCoverage_OptFlag) {
-        *firstCoverageStageIdx = pipelineBuilder.numCoverageFragmentStages();
+        *firstCoverageProcessorIdx = pipelineBuilder.numCoverageFragmentProcessors();
     } else {
         if (coveragePOI.readsFragPosition()) {
             fReadsFragPosition = true;
@@ -163,8 +168,8 @@
     SkASSERT(&a != &b);
 
     if (a.getRenderTarget() != b.getRenderTarget() ||
-        a.fFragmentStages.count() != b.fFragmentStages.count() ||
-        a.fNumColorStages != b.fNumColorStages ||
+        a.fFragmentProcessors.count() != b.fFragmentProcessors.count() ||
+        a.fNumColorProcessors != b.fNumColorProcessors ||
         a.fScissorState != b.fScissorState ||
         a.fFlags != b.fFlags ||
         a.fStencilSettings != b.fStencilSettings ||
@@ -176,9 +181,8 @@
         return false;
     }
 
-    for (int i = 0; i < a.numFragmentStages(); i++) {
-        if (!a.getFragmentStage(i).processor()->isEqual(*b.getFragmentStage(i).processor(),
-                                                            ignoreCoordTransforms)) {
+    for (int i = 0; i < a.numFragmentProcessors(); i++) {
+        if (!a.getFragmentProcessor(i).isEqual(b.getFragmentProcessor(i), ignoreCoordTransforms)) {
             return false;
         }
     }
diff --git a/src/gpu/GrPipeline.h b/src/gpu/GrPipeline.h
index ea2ea85..db14155 100644
--- a/src/gpu/GrPipeline.h
+++ b/src/gpu/GrPipeline.h
@@ -9,9 +9,10 @@
 #define GrPipeline_DEFINED
 
 #include "GrColor.h"
+#include "GrFragmentProcessor.h"
 #include "GrGpu.h"
 #include "GrNonAtomicRef.h"
-#include "GrPendingFragmentStage.h"
+#include "GrPendingProgramElement.h"
 #include "GrPrimitiveProcessor.h"
 #include "GrProgramDesc.h"
 #include "GrStencil.h"
@@ -84,22 +85,26 @@
     /// @name GrFragmentProcessors
 
 
-    int numColorFragmentStages() const { return fNumColorStages; }
-    int numCoverageFragmentStages() const { return fFragmentStages.count() - fNumColorStages; }
-    int numFragmentStages() const { return fFragmentStages.count(); }
+    int numColorFragmentProcessors() const { return fNumColorProcessors; }
+    int numCoverageFragmentProcessors() const {
+        return fFragmentProcessors.count() - fNumColorProcessors;
+    }
+    int numFragmentProcessors() const { return fFragmentProcessors.count(); }
 
     const GrXferProcessor* getXferProcessor() const { return fXferProcessor.get(); }
 
-    const GrPendingFragmentStage& getColorStage(int idx) const {
-        SkASSERT(idx < this->numColorFragmentStages());
-        return fFragmentStages[idx];
+    const GrFragmentProcessor& getColorFragmentProcessor(int idx) const {
+        SkASSERT(idx < this->numColorFragmentProcessors());
+        return *fFragmentProcessors[idx].get();
     }
-    const GrPendingFragmentStage& getCoverageStage(int idx) const {
-        SkASSERT(idx < this->numCoverageFragmentStages());
-        return fFragmentStages[fNumColorStages + idx];
+
+    const GrFragmentProcessor& getCoverageFragmentProcessor(int idx) const {
+        SkASSERT(idx < this->numCoverageFragmentProcessors());
+        return *fFragmentProcessors[fNumColorProcessors + idx].get();
     }
-    const GrPendingFragmentStage& getFragmentStage(int idx) const {
-        return fFragmentStages[idx];
+
+    const GrFragmentProcessor& getFragmentProcessor(int idx) const {
+        return *fFragmentProcessors[idx].get();
     }
 
     /// @}
@@ -149,8 +154,8 @@
                                         GrXferProcessor::OptFlags,
                                         const GrProcOptInfo& colorPOI,
                                         const GrProcOptInfo& coveragePOI,
-                                        int* firstColorStageIdx,
-                                        int* firstCoverageStageIdx);
+                                        int* firstColorProcessorIdx,
+                                        int* firstCoverageProcessorIdx);
 
     /**
      * Calculates the primary and secondary output types of the shader. For certain output types
@@ -167,7 +172,8 @@
     };
 
     typedef GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> RenderTarget;
-    typedef SkSTArray<8, GrPendingFragmentStage> FragmentStageArray;
+    typedef GrPendingProgramElement<const GrFragmentProcessor> PendingFragmentProcessor;
+    typedef SkAutoSTArray<8, PendingFragmentProcessor> FragmentProcessorArray;
     typedef GrPendingProgramElement<const GrXferProcessor> ProgramXferProcessor;
     RenderTarget                        fRenderTarget;
     GrScissorState                      fScissorState;
@@ -175,11 +181,11 @@
     GrPipelineBuilder::DrawFace         fDrawFace;
     uint32_t                            fFlags;
     ProgramXferProcessor                fXferProcessor;
-    FragmentStageArray                  fFragmentStages;
+    FragmentProcessorArray              fFragmentProcessors;
     bool                                fReadsFragPosition;
 
-    // This function is equivalent to the offset into fFragmentStages where coverage stages begin.
-    int                                 fNumColorStages;
+    // This value is also the index in fFragmentProcessors where coverage processors begin.
+    int                                 fNumColorProcessors;
 
     SkSTArray<8, const GrCoordTransform*, true> fCoordTransforms;
     GrProgramDesc                       fDesc;
diff --git a/src/gpu/GrPipelineBuilder.cpp b/src/gpu/GrPipelineBuilder.cpp
index d7db201..0af0eab 100644
--- a/src/gpu/GrPipelineBuilder.cpp
+++ b/src/gpu/GrPipelineBuilder.cpp
@@ -20,20 +20,6 @@
     SkDEBUGCODE(fBlockEffectRemovalCnt = 0;)
 }
 
-GrPipelineBuilder& GrPipelineBuilder::operator=(const GrPipelineBuilder& that) {
-    fProcDataManager.reset(new GrProcessorDataManager(*that.processorDataManager()));
-    fRenderTarget.reset(SkSafeRef(that.fRenderTarget.get()));
-    fFlags = that.fFlags;
-    fStencilSettings = that.fStencilSettings;
-    fDrawFace = that.fDrawFace;
-    fXPFactory.reset(SkRef(that.getXPFactory()));
-    fColorStages = that.fColorStages;
-    fCoverageStages = that.fCoverageStages;
-    fClip = that.fClip;
-
-    return *this;
-}
-
 GrPipelineBuilder::GrPipelineBuilder(const GrPaint& paint, GrRenderTarget* rt, const GrClip& clip) {
     SkDEBUGCODE(fBlockEffectRemovalCnt = 0;)
 
@@ -41,15 +27,12 @@
     fProcDataManager.reset(
          const_cast<GrProcessorDataManager*>(SkRef(paint.processorDataManager())));
 
-    fColorStages.reset();
-    fCoverageStages.reset();
-
-    for (int i = 0; i < paint.numColorStages(); ++i) {
-        fColorStages.push_back(paint.getColorStage(i));
+    for (int i = 0; i < paint.numColorFragmentProcessors(); ++i) {
+        fColorFragmentProcessors.push_back(SkRef(paint.getColorFragmentProcessor(i)));
     }
 
-    for (int i = 0; i < paint.numCoverageStages(); ++i) {
-        fCoverageStages.push_back(paint.getCoverageStage(i));
+    for (int i = 0; i < paint.numCoverageFragmentProcessors(); ++i) {
+        fCoverageFragmentProcessors.push_back(SkRef(paint.getCoverageFragmentProcessor(i)));
     }
 
     fXPFactory.reset(SkRef(paint.getXPFactory()));
@@ -80,21 +63,26 @@
 void GrPipelineBuilder::AutoRestoreFragmentProcessorState::set(
                                                          const GrPipelineBuilder* pipelineBuilder) {
     if (fPipelineBuilder) {
-        int m = fPipelineBuilder->numColorFragmentStages() - fColorEffectCnt;
+        int m = fPipelineBuilder->numColorFragmentProcessors() - fColorEffectCnt;
         SkASSERT(m >= 0);
-        fPipelineBuilder->fColorStages.pop_back_n(m);
+        for (int i = 0; i < m; ++i) {
+            fPipelineBuilder->fColorFragmentProcessors.fromBack(i)->unref();
+        }
+        fPipelineBuilder->fColorFragmentProcessors.pop_back_n(m);
 
-        int n = fPipelineBuilder->numCoverageFragmentStages() - fCoverageEffectCnt;
+        int n = fPipelineBuilder->numCoverageFragmentProcessors() - fCoverageEffectCnt;
         SkASSERT(n >= 0);
-        fPipelineBuilder->fCoverageStages.pop_back_n(n);
-
+        for (int i = 0; i < n; ++i) {
+            fPipelineBuilder->fCoverageFragmentProcessors.fromBack(i)->unref();
+        }
+        fPipelineBuilder->fCoverageFragmentProcessors.pop_back_n(n);
         SkDEBUGCODE(--fPipelineBuilder->fBlockEffectRemovalCnt;)
         fPipelineBuilder->getProcessorDataManager()->restoreToSaveMarker(/*fSaveMarker*/);
     }
     fPipelineBuilder = const_cast<GrPipelineBuilder*>(pipelineBuilder);
     if (NULL != pipelineBuilder) {
-        fColorEffectCnt = pipelineBuilder->numColorFragmentStages();
-        fCoverageEffectCnt = pipelineBuilder->numCoverageFragmentStages();
+        fColorEffectCnt = pipelineBuilder->numColorFragmentProcessors();
+        fCoverageEffectCnt = pipelineBuilder->numCoverageFragmentProcessors();
         SkDEBUGCODE(++pipelineBuilder->fBlockEffectRemovalCnt;)
         fSaveMarker = pipelineBuilder->processorDataManager()->currentSaveMarker();
     }
@@ -104,25 +92,33 @@
 
 GrPipelineBuilder::~GrPipelineBuilder() {
     SkASSERT(0 == fBlockEffectRemovalCnt);
+    for (int i = 0; i < fColorFragmentProcessors.count(); ++i) {
+        fColorFragmentProcessors[i]->unref();
+    }
+    for (int i = 0; i < fCoverageFragmentProcessors.count(); ++i) {
+        fCoverageFragmentProcessors[i]->unref();
+    }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
 void GrPipelineBuilder::calcColorInvariantOutput(const GrPrimitiveProcessor* pp) const {
-    fColorProcInfo.calcColorWithPrimProc(pp, fColorStages.begin(), this->numColorFragmentStages());
+    fColorProcInfo.calcColorWithPrimProc(pp, fColorFragmentProcessors.begin(),
+                                         this->numColorFragmentProcessors());
+
 }
 
 void GrPipelineBuilder::calcCoverageInvariantOutput(const GrPrimitiveProcessor* pp) const {
-    fCoverageProcInfo.calcCoverageWithPrimProc(pp, fCoverageStages.begin(),
-                                            this->numCoverageFragmentStages());
+    fCoverageProcInfo.calcCoverageWithPrimProc(pp, fCoverageFragmentProcessors.begin(),
+                                               this->numCoverageFragmentProcessors());
 }
 
 void GrPipelineBuilder::calcColorInvariantOutput(const GrDrawBatch* batch) const {
-    fColorProcInfo.calcColorWithBatch(batch, fColorStages.begin(), this->numColorFragmentStages());
+    fColorProcInfo.calcColorWithBatch(batch, fColorFragmentProcessors.begin(),
+                                      this->numColorFragmentProcessors());
 }
 
 void GrPipelineBuilder::calcCoverageInvariantOutput(const GrDrawBatch* batch) const {
-    fCoverageProcInfo.calcCoverageWithBatch(batch, fCoverageStages.begin(),
-                                            this->numCoverageFragmentStages());
+    fCoverageProcInfo.calcCoverageWithBatch(batch, fCoverageFragmentProcessors.begin(),
+                                            this->numCoverageFragmentProcessors());
 }
-
diff --git a/src/gpu/GrPipelineBuilder.h b/src/gpu/GrPipelineBuilder.h
index 1c6eb5f..47b996a 100644
--- a/src/gpu/GrPipelineBuilder.h
+++ b/src/gpu/GrPipelineBuilder.h
@@ -12,7 +12,6 @@
 #include "GrCaps.h"
 #include "GrClip.h"
 #include "GrGpuResourceRef.h"
-#include "GrStagedProcessor.h"
 #include "GrProcOptInfo.h"
 #include "GrProcessorDataManager.h"
 #include "GrRenderTarget.h"
@@ -29,15 +28,10 @@
 class GrPaint;
 class GrTexture;
 
-class GrPipelineBuilder {
+class GrPipelineBuilder : public SkNoncopyable {
 public:
     GrPipelineBuilder();
 
-    GrPipelineBuilder(const GrPipelineBuilder& pipelineBuilder) {
-        SkDEBUGCODE(fBlockEffectRemovalCnt = 0;)
-        *this = pipelineBuilder;
-    }
-
     /**
      * Initializes the GrPipelineBuilder based on a GrPaint, render target, and clip. Note
      * that GrPipelineBuilder encompasses more than GrPaint. Aspects of GrPipelineBuilder that have
@@ -58,51 +52,56 @@
     /// feed their output to the GrXferProcessor which controls blending.
     ////
 
-    int numColorFragmentStages() const { return fColorStages.count(); }
-    int numCoverageFragmentStages() const { return fCoverageStages.count(); }
-    int numFragmentStages() const { return this->numColorFragmentStages() +
-                                               this->numCoverageFragmentStages(); }
+    int numColorFragmentProcessors() const { return fColorFragmentProcessors.count(); }
+    int numCoverageFragmentProcessors() const { return fCoverageFragmentProcessors.count(); }
+    int numFragmentProcessors() const { return this->numColorFragmentProcessors() +
+                                               this->numCoverageFragmentProcessors(); }
 
-    const GrFragmentStage& getColorFragmentStage(int idx) const { return fColorStages[idx]; }
-    const GrFragmentStage& getCoverageFragmentStage(int idx) const { return fCoverageStages[idx]; }
-
-    const GrFragmentProcessor* addColorProcessor(const GrFragmentProcessor* effect) {
-        SkASSERT(effect);
-        SkNEW_APPEND_TO_TARRAY(&fColorStages, GrFragmentStage, (effect));
-        return effect;
+    const GrFragmentProcessor* getColorFragmentProcessor(int idx) const {
+        return fColorFragmentProcessors[idx];
+    }
+    const GrFragmentProcessor* getCoverageFragmentProcessor(int idx) const {
+        return fCoverageFragmentProcessors[idx];
     }
 
-    const GrFragmentProcessor* addCoverageProcessor(const GrFragmentProcessor* effect) {
-        SkASSERT(effect);
-        SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrFragmentStage, (effect));
-        return effect;
+    const GrFragmentProcessor* addColorFragmentProcessor(const GrFragmentProcessor* processor) {
+        SkASSERT(processor);
+        fColorFragmentProcessors.push_back(SkRef(processor));
+        return processor;
+    }
+
+    const GrFragmentProcessor* addCoverageFragmentProcessor(const GrFragmentProcessor* processor) {
+        SkASSERT(processor);
+        fCoverageFragmentProcessors.push_back(SkRef(processor));
+        return processor;
     }
 
     /**
      * Creates a GrSimpleTextureEffect that uses local coords as texture coordinates.
      */
     void addColorTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
-        this->addColorProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
-                                                              matrix))->unref();
+        this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
+                                                                      matrix))->unref();
     }
 
     void addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
-        this->addCoverageProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
-                                                                 matrix))->unref();
+        this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
+                                                                         matrix))->unref();
     }
 
     void addColorTextureProcessor(GrTexture* texture,
                                   const SkMatrix& matrix,
                                   const GrTextureParams& params) {
-        this->addColorProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture, matrix,
-                                                              params))->unref();
+        this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
+                                                                      matrix,
+                                                                      params))->unref();
     }
 
     void addCoverageTextureProcessor(GrTexture* texture,
                                      const SkMatrix& matrix,
                                      const GrTextureParams& params) {
-        this->addCoverageProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture, matrix,
-                                                                 params))->unref();
+        this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
+                                                                         matrix, params))->unref();
     }
 
     /**
@@ -139,9 +138,9 @@
             return fPipelineBuilder->getProcessorDataManager();
         }
 
-        const GrFragmentProcessor* addCoverageProcessor(const GrFragmentProcessor* processor) {
+        const GrFragmentProcessor* addCoverageFragmentProcessor(const GrFragmentProcessor* processor) {
             SkASSERT(this->isSet());
-            return fPipelineBuilder->addCoverageProcessor(processor);
+            return fPipelineBuilder->addCoverageFragmentProcessor(processor);
         }
 
     private:
@@ -385,8 +384,6 @@
 
     ///////////////////////////////////////////////////////////////////////////
 
-    GrPipelineBuilder& operator=(const GrPipelineBuilder& that);
-
     // TODO delete when we have Batch
     const GrProcOptInfo& colorProcInfo(const GrPrimitiveProcessor* pp) const {
         this->calcColorInvariantOutput(pp);
@@ -439,7 +436,7 @@
     // This is used to assert that this condition holds.
     SkDEBUGCODE(mutable int fBlockEffectRemovalCnt;)
 
-    typedef SkSTArray<4, GrFragmentStage> FragmentStageArray;
+    typedef SkSTArray<4, const GrFragmentProcessor*, true> FragmentProcessorArray;
 
     SkAutoTUnref<GrProcessorDataManager>    fProcDataManager;
     SkAutoTUnref<GrRenderTarget>            fRenderTarget;
@@ -447,8 +444,8 @@
     GrStencilSettings                       fStencilSettings;
     DrawFace                                fDrawFace;
     mutable SkAutoTUnref<const GrXPFactory> fXPFactory;
-    FragmentStageArray                      fColorStages;
-    FragmentStageArray                      fCoverageStages;
+    FragmentProcessorArray                  fColorFragmentProcessors;
+    FragmentProcessorArray                  fCoverageFragmentProcessors;
     GrClip                                  fClip;
 
     mutable GrProcOptInfo fColorProcInfo;
diff --git a/src/gpu/GrProcOptInfo.cpp b/src/gpu/GrProcOptInfo.cpp
index af6b81e..19302cc 100644
--- a/src/gpu/GrProcOptInfo.cpp
+++ b/src/gpu/GrProcOptInfo.cpp
@@ -12,43 +12,43 @@
 #include "batches/GrDrawBatch.h"
 
 void GrProcOptInfo::calcColorWithBatch(const GrDrawBatch* batch,
-                                       const GrFragmentStage* stages,
-                                       int stageCount) {
+                                       const GrFragmentProcessor* const processors[],
+                                       int cnt) {
     GrInitInvariantOutput out;
     batch->getInvariantOutputColor(&out);
     fInOut.reset(out);
-    this->internalCalc(stages, stageCount, batch->willReadFragmentPosition());
+    this->internalCalc(processors, cnt, batch->willReadFragmentPosition());
 }
 
 void GrProcOptInfo::calcCoverageWithBatch(const GrDrawBatch* batch,
-                                          const GrFragmentStage* stages,
-                                          int stageCount) {
+                                          const GrFragmentProcessor* const processors[],
+                                          int cnt) {
     GrInitInvariantOutput out;
     batch->getInvariantOutputCoverage(&out);
     fInOut.reset(out);
-    this->internalCalc(stages, stageCount, batch->willReadFragmentPosition());
+    this->internalCalc(processors, cnt, batch->willReadFragmentPosition());
 }
 
 void GrProcOptInfo::calcColorWithPrimProc(const GrPrimitiveProcessor* primProc,
-                                          const GrFragmentStage* stages,
-                                          int stageCount) {
+                                          const GrFragmentProcessor * const processors[],
+                                          int cnt) {
     GrInitInvariantOutput out;
     primProc->getInvariantOutputColor(&out);
     fInOut.reset(out);
-    this->internalCalc(stages, stageCount, primProc->willReadFragmentPosition());
+    this->internalCalc(processors, cnt, primProc->willReadFragmentPosition());
 }
 
 void GrProcOptInfo::calcCoverageWithPrimProc(const GrPrimitiveProcessor* primProc,
-                                             const GrFragmentStage* stages,
-                                             int stageCount) {
+                                             const GrFragmentProcessor * const processors[],
+                                             int cnt) {
     GrInitInvariantOutput out;
     primProc->getInvariantOutputCoverage(&out);
     fInOut.reset(out);
-    this->internalCalc(stages, stageCount, primProc->willReadFragmentPosition());
+    this->internalCalc(processors, cnt, primProc->willReadFragmentPosition());
 }
 
-void GrProcOptInfo::calcWithInitialValues(const GrFragmentStage* stages,
-                                          int stageCount,
+void GrProcOptInfo::calcWithInitialValues(const GrFragmentProcessor * const processors[],
+                                          int cnt,
                                           GrColor startColor,
                                           GrColorComponentFlags flags,
                                           bool areCoverageStages) {
@@ -57,24 +57,24 @@
     out.fColor = startColor;
     out.fValidFlags = flags;
     fInOut.reset(out);
-    this->internalCalc(stages, stageCount, false);
+    this->internalCalc(processors, cnt, false);
 }
 
-void GrProcOptInfo::internalCalc(const GrFragmentStage* stages,
-                                 int stageCount,
+void GrProcOptInfo::internalCalc(const GrFragmentProcessor* const processors[],
+                                 int cnt,
                                  bool initWillReadFragmentPosition) {
-    fFirstEffectStageIndex = 0;
+    fFirstEffectiveProcessorIndex = 0;
     fInputColorIsUsed = true;
     fInputColor = fInOut.color();
     fReadsFragPosition = initWillReadFragmentPosition;
 
-    for (int i = 0; i < stageCount; ++i) {
-        const GrFragmentProcessor* processor = stages[i].processor();
+    for (int i = 0; i < cnt; ++i) {
+        const GrFragmentProcessor* processor = processors[i];
         fInOut.resetWillUseInputColor();
         processor->computeInvariantOutput(&fInOut);
         SkDEBUGCODE(fInOut.validate());
         if (!fInOut.willUseInputColor()) {
-            fFirstEffectStageIndex = i;
+            fFirstEffectiveProcessorIndex = i;
             fInputColorIsUsed = false;
             // Reset these since we don't care if previous stages read these values
             fReadsFragPosition = initWillReadFragmentPosition;
@@ -83,7 +83,7 @@
             fReadsFragPosition = true;
         }
         if (kRGBA_GrColorComponentFlags == fInOut.validFlags()) {
-            fFirstEffectStageIndex = i + 1;
+            fFirstEffectiveProcessorIndex = i + 1;
             fInputColor = fInOut.color();
             fInputColorIsUsed = true;
             // Since we are clearing all previous color stages we are in a state where we have found
diff --git a/src/gpu/GrProcOptInfo.h b/src/gpu/GrProcOptInfo.h
index cf7e350..ad23614 100644
--- a/src/gpu/GrProcOptInfo.h
+++ b/src/gpu/GrProcOptInfo.h
@@ -10,7 +10,6 @@
 
 #include "GrColor.h"
 #include "GrInvariantOutput.h"
-#include "GrStagedProcessor.h"
 
 class GrDrawBatch;
 class GrFragmentProcessor;
@@ -26,21 +25,22 @@
 public:
     GrProcOptInfo()
         : fInOut(0, static_cast<GrColorComponentFlags>(0), false)
-        , fFirstEffectStageIndex(0)
+        , fFirstEffectiveProcessorIndex(0)
         , fInputColorIsUsed(true)
         , fInputColor(0)
         , fReadsFragPosition(false) {}
 
-    void calcWithInitialValues(const GrFragmentStage*, int stageCount, GrColor startColor,
-                               GrColorComponentFlags flags, bool areCoverageStages);
+    void calcWithInitialValues(const GrFragmentProcessor* const *, int cnt, GrColor startColor,
+                               GrColorComponentFlags, bool areCoverageStages);
 
-    void calcColorWithBatch(const GrDrawBatch*, const GrFragmentStage*, int stagecount);
-    void calcCoverageWithBatch(const GrDrawBatch*, const GrFragmentStage*, int stagecount);
+    void calcColorWithBatch(const GrDrawBatch*, const GrFragmentProcessor* const[], int cnt);
+    void calcCoverageWithBatch(const GrDrawBatch*, const GrFragmentProcessor* const[], int cnt);
 
     // TODO delete these when batch is everywhere
-    void calcColorWithPrimProc(const GrPrimitiveProcessor*, const GrFragmentStage*, int stagecount);
-    void calcCoverageWithPrimProc(const GrPrimitiveProcessor*, const GrFragmentStage*,
-                                  int stagecount);
+    void calcColorWithPrimProc(const GrPrimitiveProcessor*, const GrFragmentProcessor* const[],
+                               int cnt);
+    void calcCoverageWithPrimProc(const GrPrimitiveProcessor*, const GrFragmentProcessor* const[],
+                                  int cnt);
 
     bool isSolidWhite() const { return fInOut.isSolidWhite(); }
     bool isOpaque() const { return fInOut.isOpaque(); }
@@ -60,38 +60,38 @@
     }
 
     /**
-     * Returns the index of the first effective color stage. If an intermediate stage doesn't read
-     * its input or has a known output, then we can ignore all earlier stages since they will not
-     * affect the final output. Thus the first effective stage index is the index to the first stage
-     * that will have an effect on the final output.
+     * Returns the index of the first effective color processor. If an intermediate processor
+     * doesn't read its input or has a known output, then we can ignore all earlier processors
+     * since they will not affect the final output. Thus the first effective processors index is
+     * the index to the first processor that will have an effect on the final output.
      *
-     * If stages before the firstEffectiveStageIndex are removed, corresponding values from
-     * inputColorIsUsed(), inputColorToEffectiveStage(), removeVertexAttribs(), and readsDst() must
-     * be used when setting up the draw to ensure correct drawing.
+     * If processors before the firstEffectiveProcessorIndex() are removed, corresponding values
+     * from inputColorIsUsed(), inputColorToEffectiveProcessor(), removeVertexAttribs(), and
+     * readsDst() must be used when setting up the draw to ensure correct drawing.
      */
-    int firstEffectiveStageIndex() const { return fFirstEffectStageIndex; }
+    int firstEffectiveProcessorIndex() const { return fFirstEffectiveProcessorIndex; }
 
     /**
-     * True if the first effective stage reads its input, false otherwise.
+     * True if the first effective processor reads its input, false otherwise.
      */
     bool inputColorIsUsed() const { return fInputColorIsUsed; }
 
     /**
      * If input color is used and per-vertex colors are not used, this is the input color to the
-     * first effective stage.
+     * first effective processor.
      */
-    GrColor inputColorToEffectiveStage() const { return fInputColor; }
+    GrColor inputColorToFirstEffectiveProccesor() const { return fInputColor; }
 
     /**
-     * Returns true if any of the stages preserved by GrProcOptInfo read the frag position.
+     * Returns true if any of the processor preserved by GrProcOptInfo read the frag position.
      */
     bool readsFragPosition() const { return fReadsFragPosition; }
 
 private:
-    void internalCalc(const GrFragmentStage*, int stagecount, bool initWillReadFragPosition);
+    void internalCalc(const GrFragmentProcessor* const[], int cnt, bool initWillReadFragPosition);
 
     GrInvariantOutput fInOut;
-    int fFirstEffectStageIndex;
+    int fFirstEffectiveProcessorIndex;
     bool fInputColorIsUsed;
     GrColor fInputColor;
     bool fReadsFragPosition;
diff --git a/src/gpu/GrProcessor.cpp b/src/gpu/GrProcessor.cpp
index db1e2d9..3cbf777 100644
--- a/src/gpu/GrProcessor.cpp
+++ b/src/gpu/GrProcessor.cpp
@@ -130,6 +130,12 @@
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
+GrFragmentProcessor::~GrFragmentProcessor() {
+    for (int i = 0; i < fChildProcessors.count(); ++i) {
+        fChildProcessors[i]->unref();
+    }
+}
+
 bool GrFragmentProcessor::isEqual(const GrFragmentProcessor& that,
                                   bool ignoreCoordTransforms) const {
     if (this->classID() != that.classID() ||
@@ -161,7 +167,7 @@
     GrGLFragmentProcessor* glFragProc = this->onCreateGLInstance();
     glFragProc->fChildProcessors.push_back_n(fChildProcessors.count());
     for (int i = 0; i < fChildProcessors.count(); ++i) {
-        glFragProc->fChildProcessors[i] = fChildProcessors[i].processor()->createGLInstance();
+        glFragProc->fChildProcessors[i] = fChildProcessors[i]->createGLInstance();
     }
     return glFragProc;
 }
@@ -199,7 +205,7 @@
     }
 
     int index = fChildProcessors.count();
-    fChildProcessors.push_back(GrFragmentStage(child));
+    fChildProcessors.push_back(SkRef(child));
 
     if (child->willReadFragmentPosition()) {
         this->setWillReadFragmentPosition();
diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp
index f421b81..ce00ad9 100644
--- a/src/gpu/GrSWMaskHelper.cpp
+++ b/src/gpu/GrSWMaskHelper.cpp
@@ -366,7 +366,7 @@
     maskMatrix.setIDiv(texture->width(), texture->height());
     maskMatrix.preTranslate(SkIntToScalar(-rect.fLeft), SkIntToScalar(-rect.fTop));
 
-    pipelineBuilder->addCoverageProcessor(
+    pipelineBuilder->addCoverageFragmentProcessor(
                          GrSimpleTextureEffect::Create(pipelineBuilder->getProcessorDataManager(),
                                                        texture,
                                                        maskMatrix,
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index aefa389..722f744 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -963,7 +963,7 @@
     }
 
     // The bitmap read has to be first
-    grPaint.addColorProcessor(fp);
+    grPaint.addColorFragmentProcessor(fp);
     if (!SkPaint2GrPaintNoShader(context, renderTarget, paint, SkColor2GrColor(paint.getColor()),
                                  false, &grPaint)) {
         return;
@@ -1305,7 +1305,7 @@
                                                SkMatrix::I(), params));
     }
 
-    grPaint.addColorProcessor(fp);
+    grPaint.addColorFragmentProcessor(fp);
     bool alphaOnly = !(kAlpha_8_SkColorType == bitmap.colorType());
     GrColor paintColor = (alphaOnly) ? SkColor2GrColorJustAlpha(paint.getColor()) :
                                        SkColor2GrColor(paint.getColor());
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index ef8460b..f55aa6a 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -469,7 +469,7 @@
         yuvToRgbProcessor(GrYUVtoRGBEffect::Create(paint.getProcessorDataManager(), yuvTextures[0],
                                                    yuvTextures[1], yuvTextures[2],
                                                    yuvInfo.fSize, yuvInfo.fColorSpace));
-    paint.addColorProcessor(yuvToRgbProcessor);
+    paint.addColorFragmentProcessor(yuvToRgbProcessor);
     SkRect r = SkRect::MakeWH(SkIntToScalar(yuvInfo.fSize[0].fWidth),
                               SkIntToScalar(yuvInfo.fSize[0].fHeight));
 
@@ -810,7 +810,7 @@
             if (colorFilter->asFragmentProcessors(context, grPaint->getProcessorDataManager(),
                                                   &array)) {
                 for (int i = 0; i < array.count(); ++i) {
-                    grPaint->addColorProcessor(array[i]);
+                    grPaint->addColorFragmentProcessor(array[i]);
                     array[i]->unref();
                 }
             }
@@ -820,7 +820,7 @@
 #ifndef SK_IGNORE_GPU_DITHER
     // If the dither flag is set, then we need to see if the underlying context
     // supports it. If not, then install a dither effect.
-    if (skPaint.isDither() && grPaint->numColorStages() > 0) {
+    if (skPaint.isDither() && grPaint->numColorFragmentProcessors() > 0) {
         // What are we rendering into?
         SkASSERT(rt);
 
@@ -832,7 +832,7 @@
             // not going to be dithered by the GPU.
             SkAutoTUnref<GrFragmentProcessor> fp(GrDitherEffect::Create());
             if (fp.get()) {
-                grPaint->addColorProcessor(fp);
+                grPaint->addColorFragmentProcessor(fp);
                 grPaint->setDither(false);
             }
         }
@@ -863,7 +863,7 @@
             return false;
         }
         if (fp) {
-            grPaint->addColorProcessor(fp)->unref();
+            grPaint->addColorFragmentProcessor(fp)->unref();
             constantColor = false;
         }
     }
diff --git a/src/gpu/batches/GrDrawBatch.h b/src/gpu/batches/GrDrawBatch.h
index ed33816..f7c206d 100644
--- a/src/gpu/batches/GrDrawBatch.h
+++ b/src/gpu/batches/GrDrawBatch.h
@@ -64,12 +64,12 @@
     SkString dumpInfo() const override {
         SkString string;
         string.append("ColorStages:\n");
-        for (int i = 0; i < this->pipeline()->numColorFragmentStages(); i++) {
-            string.appendf("\t\t%s\n", this->pipeline()->getColorStage(i).processor()->name());
+        for (int i = 0; i < this->pipeline()->numColorFragmentProcessors(); i++) {
+            string.appendf("\t\t%s\n", this->pipeline()->getColorFragmentProcessor(i).name());
         }
         string.append("CoverageStages:\n");
-        for (int i = 0; i < this->pipeline()->numCoverageFragmentStages(); i++) {
-            string.appendf("\t%s\n", this->pipeline()->getCoverageStage(i).processor()->name());
+        for (int i = 0; i < this->pipeline()->numCoverageFragmentProcessors(); i++) {
+            string.appendf("\t%s\n", this->pipeline()->getCoverageFragmentProcessor(i).name());
         }
         string.appendf("XP: %s\n", this->pipeline()->getXferProcessor()->name());
         return string;
diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp
index 06b2d8d..cee0f2f 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -223,7 +223,7 @@
         SkAutoTUnref<GrFragmentProcessor> pmToUPM2(new GrConfigConversionEffect(
                 paint3.getProcessorDataManager(), tempTex, false, *pmToUPMRule, SkMatrix::I()));
 
-        paint1.addColorProcessor(pmToUPM1);
+        paint1.addColorFragmentProcessor(pmToUPM1);
 
 
         GrDrawContext* readDrawContext = context->drawContext();
@@ -241,7 +241,7 @@
 
         readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, firstRead);
 
-        paint2.addColorProcessor(upmToPM);
+        paint2.addColorFragmentProcessor(upmToPM);
 
         GrDrawContext* tempDrawContext = context->drawContext();
         if (!tempDrawContext) {
@@ -255,7 +255,7 @@
                                              kDstRect,
                                              kSrcRect);
 
-        paint3.addColorProcessor(pmToUPM2);
+        paint3.addColorFragmentProcessor(pmToUPM2);
 
         readDrawContext = context->drawContext();
         if (!readDrawContext) {
diff --git a/src/gpu/gl/GrGLPathProgram.cpp b/src/gpu/gl/GrGLPathProgram.cpp
index 4b31f02..5bcadfe 100644
--- a/src/gpu/gl/GrGLPathProgram.cpp
+++ b/src/gpu/gl/GrGLPathProgram.cpp
@@ -31,13 +31,13 @@
 }
 
 void GrGLPathProgram::setTransformData(const GrPrimitiveProcessor& primProc,
-                                       const GrPendingFragmentStage& proc,
+                                       const GrFragmentProcessor& processor,
                                        int index,
                                        GrGLInstalledFragProc* ip) {
     GrGLPathProcessor* pathProc =
             static_cast<GrGLPathProcessor*>(fGeometryProcessor.get()->fGLProc.get());
     pathProc->setTransformData(primProc, fPathProgramDataManager, index,
-                               proc.processor()->coordTransforms());
+                               processor.coordTransforms());
 }
 
 void GrGLPathProgram::onSetRenderTargetState(const GrPrimitiveProcessor& primProc,
diff --git a/src/gpu/gl/GrGLPathProgram.h b/src/gpu/gl/GrGLPathProgram.h
index c7ca3dc..74f43e5 100644
--- a/src/gpu/gl/GrGLPathProgram.h
+++ b/src/gpu/gl/GrGLPathProgram.h
@@ -34,7 +34,7 @@
 private:
     void didSetData() override;
     virtual void setTransformData(const GrPrimitiveProcessor&,
-                                  const GrPendingFragmentStage&,
+                                  const GrFragmentProcessor&,
                                   int index,
                                   GrGLInstalledFragProc*) override;
     void onSetRenderTargetState(const GrPrimitiveProcessor&, const GrPipeline&) override;
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index 5af84e0..3aaa7ea 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -105,25 +105,24 @@
                                   const GrPipeline& pipeline,
                                   SkTArray<const GrTextureAccess*>* textureBindings) {
     int numProcessors = fFragmentProcessors->fProcs.count();
-    for (int e = 0; e < numProcessors; ++e) {
-        const GrPendingFragmentStage& stage = pipeline.getFragmentStage(e);
-        const GrFragmentProcessor& processor = *stage.processor();
-        fFragmentProcessors->fProcs[e]->fGLProc->setData(fProgramDataManager, processor);
+    for (int i = 0; i < numProcessors; ++i) {
+        const GrFragmentProcessor& processor = pipeline.getFragmentProcessor(i);
+        fFragmentProcessors->fProcs[i]->fGLProc->setData(fProgramDataManager, processor);
         this->setTransformData(primProc,
-                               stage,
-                               e,
-                               fFragmentProcessors->fProcs[e]);
-        append_texture_bindings(fFragmentProcessors->fProcs[e], processor, textureBindings);
+                               processor,
+                               i,
+                               fFragmentProcessors->fProcs[i]);
+        append_texture_bindings(fFragmentProcessors->fProcs[i], processor, textureBindings);
     }
 }
 void GrGLProgram::setTransformData(const GrPrimitiveProcessor& primProc,
-                                   const GrPendingFragmentStage& processor,
+                                   const GrFragmentProcessor& processor,
                                    int index,
                                    GrGLInstalledFragProc* ip) {
     GrGLGeometryProcessor* gp =
             static_cast<GrGLGeometryProcessor*>(fGeometryProcessor.get()->fGLProc.get());
     gp->setTransformData(primProc, fProgramDataManager, index,
-                         processor.processor()->coordTransforms());
+                         processor.coordTransforms());
 }
 
 void GrGLProgram::setRenderTargetState(const GrPrimitiveProcessor& primProc,
diff --git a/src/gpu/gl/GrGLProgram.h b/src/gpu/gl/GrGLProgram.h
index c8fa1b1..fee6277 100644
--- a/src/gpu/gl/GrGLProgram.h
+++ b/src/gpu/gl/GrGLProgram.h
@@ -115,7 +115,7 @@
     void setFragmentData(const GrPrimitiveProcessor&, const GrPipeline&,
                          SkTArray<const GrTextureAccess*>* textureBindings);
     virtual void setTransformData(const GrPrimitiveProcessor&,
-                                  const GrPendingFragmentStage&,
+                                  const GrFragmentProcessor&,
                                   int index,
                                   GrGLInstalledFragProc*);
 
diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp
index 5365ffb..6b38cc6 100644
--- a/src/gpu/gl/GrGLProgramDesc.cpp
+++ b/src/gpu/gl/GrGLProgramDesc.cpp
@@ -134,9 +134,8 @@
         return false;
     }
 
-    for (int s = 0; s < pipeline.numFragmentStages(); ++s) {
-        const GrPendingFragmentStage& fps = pipeline.getFragmentStage(s);
-        const GrFragmentProcessor& fp = *fps.processor();
+    for (int i = 0; i < pipeline.numFragmentProcessors(); ++i) {
+        const GrFragmentProcessor& fp = pipeline.getFragmentProcessor(i);
         if (!get_frag_proc_and_meta_keys(primProc, fp, gpu->glCaps(), &b)) {
             glDesc->key().reset();
             return false;
@@ -167,8 +166,8 @@
         header->fFragPosKey = 0;
     }
     header->fSnapVerticesToPixelCenters = pipeline.snapVerticesToPixelCenters();
-    header->fColorEffectCnt = pipeline.numColorFragmentStages();
-    header->fCoverageEffectCnt = pipeline.numCoverageFragmentStages();
+    header->fColorEffectCnt = pipeline.numColorFragmentProcessors();
+    header->fCoverageEffectCnt = pipeline.numCoverageFragmentProcessors();
     glDesc->finalize();
     return true;
 }
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index 39d8ec5..d0eb4d4 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -186,15 +186,15 @@
     int totalTextures = primProc.numTextures();
     const int maxTextureUnits = fGpu->glCaps().maxFragmentTextureUnits();
 
-    for (int i = 0; i < this->pipeline().numFragmentStages(); i++) {
-        const GrFragmentProcessor* processor = this->pipeline().getFragmentStage(i).processor();
+    for (int i = 0; i < this->pipeline().numFragmentProcessors(); i++) {
+        const GrFragmentProcessor& processor = this->pipeline().getFragmentProcessor(i);
 
         if (!primProc.hasTransformedLocalCoords()) {
-            SkSTArray<2, const GrCoordTransform*, true>& procCoords = fCoordTransforms.push_back();
-            processor->gatherCoordTransforms(&procCoords);
+            SkTArray<const GrCoordTransform*, true>& procCoords = fCoordTransforms.push_back();
+            processor.gatherCoordTransforms(&procCoords);
         }
 
-        totalTextures += processor->numTextures();
+        totalTextures += processor.numTextures();
         if (totalTextures >= maxTextureUnits) {
             GrCapsDebugf(fGpu->caps(), "Program would use too many texture units\n");
             return false;
@@ -204,9 +204,9 @@
     this->emitAndInstallProc(primProc, inputColor, inputCoverage);
 
     fFragmentProcessors.reset(new GrGLInstalledFragProcs);
-    int numProcs = this->pipeline().numFragmentStages();
-    this->emitAndInstallFragProcs(0, this->pipeline().numColorFragmentStages(), inputColor);
-    this->emitAndInstallFragProcs(this->pipeline().numColorFragmentStages(), numProcs,
+    int numProcs = this->pipeline().numFragmentProcessors();
+    this->emitAndInstallFragProcs(0, this->pipeline().numColorFragmentProcessors(), inputColor);
+    this->emitAndInstallFragProcs(this->pipeline().numColorFragmentProcessors(), numProcs,
                                   inputCoverage);
     this->emitAndInstallXferProc(*this->pipeline().getXferProcessor(), *inputColor, *inputCoverage);
     return true;
@@ -215,10 +215,10 @@
 void GrGLProgramBuilder::emitAndInstallFragProcs(int procOffset,
                                                  int numProcs,
                                                  GrGLSLExpr4* inOut) {
-    for (int e = procOffset; e < numProcs; ++e) {
+    for (int i = procOffset; i < numProcs; ++i) {
         GrGLSLExpr4 output;
-        const GrPendingFragmentStage& stage = this->pipeline().getFragmentStage(e);
-        this->emitAndInstallProc(stage, e, *inOut, &output);
+        const GrFragmentProcessor& fp = this->pipeline().getFragmentProcessor(i);
+        this->emitAndInstallProc(fp, i, *inOut, &output);
         *inOut = output;
     }
 }
@@ -239,7 +239,7 @@
 
 // TODO Processors cannot output zeros because an empty string is all 1s
 // the fix is to allow effects to take the GrGLSLExpr4 directly
-void GrGLProgramBuilder::emitAndInstallProc(const GrPendingFragmentStage& proc,
+void GrGLProgramBuilder::emitAndInstallProc(const GrFragmentProcessor& fp,
                                             int index,
                                             const GrGLSLExpr4& input,
                                             GrGLSLExpr4* output) {
@@ -249,10 +249,10 @@
 
     // Enclose custom code in a block to avoid namespace conflicts
     SkString openBrace;
-    openBrace.printf("{ // Stage %d, %s\n", fStageIndex, proc.name());
+    openBrace.printf("{ // Stage %d, %s\n", fStageIndex, fp.name());
     fFS.codeAppend(openBrace.c_str());
 
-    this->emitAndInstallProc(proc, index, output->c_str(), input.isOnes() ? NULL : input.c_str());
+    this->emitAndInstallProc(fp, index, output->c_str(), input.isOnes() ? NULL : input.c_str());
 
     fFS.codeAppend("}");
 }
@@ -276,13 +276,12 @@
     fFS.codeAppend("}");
 }
 
-void GrGLProgramBuilder::emitAndInstallProc(const GrPendingFragmentStage& fs,
+void GrGLProgramBuilder::emitAndInstallProc(const GrFragmentProcessor& fp,
                                             int index,
                                             const char* outColor,
                                             const char* inColor) {
     GrGLInstalledFragProc* ifp = new GrGLInstalledFragProc;
 
-    const GrFragmentProcessor& fp = *fs.processor();
     ifp->fGLProc.reset(fp.createGLInstance());
 
     SkSTArray<4, GrGLProcessor::TextureSampler> samplers(fp.numTextures());
@@ -501,7 +500,7 @@
 
 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() {
     int numProcs = fProcs.count();
-    for (int e = 0; e < numProcs; ++e) {
-        delete fProcs[e];
+    for (int i = 0; i < numProcs; ++i) {
+        delete fProcs[i];
     }
 }
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.h b/src/gpu/gl/builders/GrGLProgramBuilder.h
index bdd96d2..06d0fa0 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.h
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.h
@@ -16,9 +16,10 @@
 #include "../GrGLUniformHandle.h"
 #include "../GrGLPrimitiveProcessor.h"
 #include "../GrGLXferProcessor.h"
-#include "../../GrPendingFragmentStage.h"
 #include "../../GrPipeline.h"
 
+class GrFragmentProcessor;
+
 // Enough precision to represent 1 / 2048 accurately in printf
 #define GR_SIGNIFICANT_POW2_DECIMAL_DIG 11
 
@@ -301,7 +302,7 @@
     void nameExpression(GrGLSLExpr4*, const char* baseName);
     bool emitAndInstallProcs(GrGLSLExpr4* inputColor, GrGLSLExpr4* inputCoverage);
     void emitAndInstallFragProcs(int procOffset, int numProcs, GrGLSLExpr4* inOut);
-    void emitAndInstallProc(const GrPendingFragmentStage&,
+    void emitAndInstallProc(const GrFragmentProcessor&,
                             int index,
                             const GrGLSLExpr4& input,
                             GrGLSLExpr4* output);
@@ -311,7 +312,7 @@
                             GrGLSLExpr4* outputCoverage);
 
     // these emit functions help to keep the createAndEmitProcessors template general
-    void emitAndInstallProc(const GrPendingFragmentStage&,
+    void emitAndInstallProc(const GrFragmentProcessor&,
                             int index,
                             const char* outColor,
                             const char* inColor);