Another trivial cleanup

TBR=bsalomon@google.com
BUG=skia:

Review URL: https://codereview.chromium.org/1229303003
diff --git a/gyp/gpu.gypi b/gyp/gpu.gypi
index b9cd795..7911353 100644
--- a/gyp/gpu.gypi
+++ b/gyp/gpu.gypi
@@ -22,7 +22,6 @@
       '<(skia_include_path)/gpu/GrCoordTransform.h',
       '<(skia_include_path)/gpu/GrDrawContext.h',
       '<(skia_include_path)/gpu/GrFragmentProcessor.h',
-      '<(skia_include_path)/gpu/GrFragmentStage.h',
       '<(skia_include_path)/gpu/GrGpuResource.h',
       '<(skia_include_path)/gpu/GrInvariantOutput.h',
       '<(skia_include_path)/gpu/GrPaint.h',
@@ -35,8 +34,9 @@
       '<(skia_include_path)/gpu/GrRect.h',
       '<(skia_include_path)/gpu/GrRenderTarget.h',
       '<(skia_include_path)/gpu/GrResourceKey.h',
-      '<(skia_include_path)/gpu/GrSurface.h',
       '<(skia_include_path)/gpu/GrShaderVar.h',
+      '<(skia_include_path)/gpu/GrStagedProcessor.h',
+      '<(skia_include_path)/gpu/GrSurface.h',
       '<(skia_include_path)/gpu/GrTexture.h',
       '<(skia_include_path)/gpu/GrTextureProvider.h',
       '<(skia_include_path)/gpu/GrTextureAccess.h',
@@ -153,7 +153,6 @@
       '<(skia_src_path)/gpu/GrPathUtils.cpp',
       '<(skia_src_path)/gpu/GrPathUtils.h',
       '<(skia_src_path)/gpu/GrPendingProgramElement.h',
-      '<(skia_src_path)/gpu/GrPendingFragmentStage.h',
       '<(skia_src_path)/gpu/GrPipeline.cpp',
       '<(skia_src_path)/gpu/GrPipeline.h',
       '<(skia_src_path)/gpu/GrPipelineBuilder.cpp',
diff --git a/include/gpu/GrFragmentStage.h b/include/gpu/GrFragmentStage.h
deleted file mode 100644
index ca3be8a..0000000
--- a/include/gpu/GrFragmentStage.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2010 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrFragmentStage_DEFINED
-#define GrFragmentStage_DEFINED
-
-#include "GrFragmentProcessor.h"
-
-/**
- * Wraps a GrFragmentProcessor, basically a copyable SkAutoTUnref
- */
-class GrFragmentStage {
-public:
-    explicit GrFragmentStage(const GrFragmentProcessor* proc) : fProc(SkRef(proc)) {}
-
-    GrFragmentStage(const GrFragmentStage& other) { fProc.reset(SkRef(other.fProc.get())); }
-
-    const GrFragmentProcessor* processor() const { return fProc.get(); }
-
-    bool operator==(const GrFragmentStage& that) const {
-        return this->processor() == that.processor();
-    }
-
-    bool operator!=(const GrFragmentStage& that) const { return !(*this == that); }
-
-protected:
-    SkAutoTUnref<const GrFragmentProcessor> fProc;
-};
-
-#endif
diff --git a/include/gpu/GrPaint.h b/include/gpu/GrPaint.h
index 22951f9..efb3010 100644
--- a/include/gpu/GrPaint.h
+++ b/include/gpu/GrPaint.h
@@ -11,7 +11,7 @@
 #define GrPaint_DEFINED
 
 #include "GrColor.h"
-#include "GrFragmentStage.h"
+#include "GrStagedProcessor.h"
 #include "GrProcessorDataManager.h"
 #include "GrXferProcessor.h"
 #include "effects/GrPorterDuffXferProcessor.h"
diff --git a/include/gpu/GrStagedProcessor.h b/include/gpu/GrStagedProcessor.h
new file mode 100644
index 0000000..fcbc5b2
--- /dev/null
+++ b/include/gpu/GrStagedProcessor.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrStagedProcessorStage_DEFINED
+#define GrStagedProcessorStage_DEFINED
+
+#include "GrFragmentProcessor.h"
+#include "SkRefCnt.h"
+
+/**
+ * Wraps a GrFragmentProcessor, basically a copyable SkAutoTUnref
+ * Templatized based on the ref type so backends can use the same wrapper
+ */
+template<template<typename> class T>
+class GrStagedProcessor {
+public:
+    explicit GrStagedProcessor(const GrFragmentProcessor* proc) : fProc(SkRef(proc)) {}
+
+    GrStagedProcessor(const GrStagedProcessor& other) { fProc.reset(SkRef(other.fProc.get())); }
+
+    const GrFragmentProcessor* processor() const { return fProc.get(); }
+
+    bool operator==(const GrStagedProcessor& that) const {
+        return this->processor() == that.processor();
+    }
+
+    bool operator!=(const GrStagedProcessor& that) const { return !(*this == that); }
+
+    const char* name() const { return fProc->name(); }
+
+protected:
+    T<const GrFragmentProcessor> fProc;
+};
+
+typedef GrStagedProcessor<SkAutoTUnref> GrFragmentStage;
+
+#endif
diff --git a/src/effects/gradients/SkGradientShaderPriv.h b/src/effects/gradients/SkGradientShaderPriv.h
index 9dc6b66..cb882b2 100644
--- a/src/effects/gradients/SkGradientShaderPriv.h
+++ b/src/effects/gradients/SkGradientShaderPriv.h
@@ -296,7 +296,6 @@
 #include "GrFragmentProcessor.h"
 #include "gl/GrGLProcessor.h"
 
-class GrFragmentStage;
 class GrInvariantOutput;
 
 /*
diff --git a/src/gpu/GrPendingFragmentStage.h b/src/gpu/GrPendingFragmentStage.h
deleted file mode 100644
index 0bf984a..0000000
--- a/src/gpu/GrPendingFragmentStage.h
+++ /dev/null
@@ -1,53 +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 GrPendingProcessorStage_DEFINED
-#define GrPendingProcessorStage_DEFINED
-
-#include "GrFragmentStage.h"
-#include "GrCoordTransform.h"
-#include "GrFragmentProcessor.h"
-#include "GrPendingProgramElement.h"
-
-/**
- * This a baked variant of GrFragmentStage, as recorded in GrOptDrawState.
- */
-class GrPendingFragmentStage {
-public:
-    GrPendingFragmentStage(const GrFragmentStage& stage) : fProc(stage.processor()) {}
-
-    GrPendingFragmentStage(const GrPendingFragmentStage& that) { *this = that; }
-
-    GrPendingFragmentStage& operator=(const GrPendingFragmentStage& that) {
-        fProc.reset(that.fProc.get());
-        return *this;
-    }
-
-    bool operator==(const GrPendingFragmentStage& that) const {
-        return this->processor()->isEqual(*that.processor());
-    }
-
-    bool operator!=(const GrPendingFragmentStage& that) const { return !(*this == that); }
-
-    /**
-     * For a coord transform on the fragment processor, does it or the coord change matrix (if
-     * relevant) contain perspective?
-     */
-    bool isPerspectiveCoordTransform(int matrixIndex) const {
-        const GrCoordTransform& coordTransform = this->processor()->coordTransform(matrixIndex);
-        uint32_t type = coordTransform.getMatrix().getType();
-        return SkToBool(SkMatrix::kPerspective_Mask & type);
-    }
-
-    const char* name() const { return fProc->name(); }
-
-    const GrFragmentProcessor* processor() const { return fProc.get(); }
-
-protected:
-    GrPendingProgramElement<const GrFragmentProcessor>  fProc;
-};
-#endif
diff --git a/src/gpu/GrPipeline.cpp b/src/gpu/GrPipeline.cpp
index 8c40438..2c3422a 100644
--- a/src/gpu/GrPipeline.cpp
+++ b/src/gpu/GrPipeline.cpp
@@ -87,20 +87,16 @@
 
     // Copy Stages from PipelineBuilder to Pipeline
     for (int i = firstColorStageIdx; i < pipelineBuilder.numColorFragmentStages(); ++i) {
-        SkNEW_APPEND_TO_TARRAY(&fFragmentStages,
-                               GrPendingFragmentStage,
-                               (pipelineBuilder.fColorStages[i]));
-        usesLocalCoords = usesLocalCoords ||
-                          pipelineBuilder.fColorStages[i].processor()->usesLocalCoords();
+        const GrFragmentProcessor* fp = pipelineBuilder.fColorStages[i].processor();
+        SkNEW_APPEND_TO_TARRAY(&fFragmentStages, GrPendingFragmentStage, (fp));
+        usesLocalCoords = usesLocalCoords || fp->usesLocalCoords();
     }
 
     fNumColorStages = fFragmentStages.count();
     for (int i = firstCoverageStageIdx; i < pipelineBuilder.numCoverageFragmentStages(); ++i) {
-        SkNEW_APPEND_TO_TARRAY(&fFragmentStages,
-                               GrPendingFragmentStage,
-                               (pipelineBuilder.fCoverageStages[i]));
-        usesLocalCoords = usesLocalCoords ||
-                          pipelineBuilder.fCoverageStages[i].processor()->usesLocalCoords();
+        const GrFragmentProcessor* fp = pipelineBuilder.fCoverageStages[i].processor();
+        SkNEW_APPEND_TO_TARRAY(&fFragmentStages, GrPendingFragmentStage, (fp));
+        usesLocalCoords = usesLocalCoords || fp->usesLocalCoords();
     }
 
     // Setup info we need to pass to GrPrimitiveProcessors that are used with this GrPipeline.
diff --git a/src/gpu/GrPipeline.h b/src/gpu/GrPipeline.h
index bf8ca8a..fb90d47 100644
--- a/src/gpu/GrPipeline.h
+++ b/src/gpu/GrPipeline.h
@@ -10,7 +10,8 @@
 
 #include "GrColor.h"
 #include "GrGpu.h"
-#include "GrPendingFragmentStage.h"
+#include "GrStagedProcessor.h"
+#include "GrPendingProgramElement.h"
 #include "GrPrimitiveProcessor.h"
 #include "GrProgramDesc.h"
 #include "GrStencil.h"
@@ -22,6 +23,8 @@
 class GrDeviceCoordTexture;
 class GrPipelineBuilder;
 
+typedef GrStagedProcessor<GrPendingProgramElement> GrPendingFragmentStage;
+
 /**
  * Class that holds an optimized version of a GrPipelineBuilder. It is meant to be an immutable
  * class, and contains all data needed to set the state for a gpu draw.
diff --git a/src/gpu/GrPipelineBuilder.h b/src/gpu/GrPipelineBuilder.h
index dd3db6e..2098454 100644
--- a/src/gpu/GrPipelineBuilder.h
+++ b/src/gpu/GrPipelineBuilder.h
@@ -12,7 +12,7 @@
 #include "GrCaps.h"
 #include "GrClip.h"
 #include "GrGpuResourceRef.h"
-#include "GrFragmentStage.h"
+#include "GrStagedProcessor.h"
 #include "GrProcOptInfo.h"
 #include "GrProcessorDataManager.h"
 #include "GrRenderTarget.h"
diff --git a/src/gpu/GrProcOptInfo.cpp b/src/gpu/GrProcOptInfo.cpp
index dc499fa..53f2e02 100644
--- a/src/gpu/GrProcOptInfo.cpp
+++ b/src/gpu/GrProcOptInfo.cpp
@@ -8,8 +8,6 @@
 #include "GrProcOptInfo.h"
 
 #include "GrBatch.h"
-#include "GrFragmentProcessor.h"
-#include "GrFragmentStage.h"
 #include "GrGeometryProcessor.h"
 
 void GrProcOptInfo::calcColorWithBatch(const GrBatch* batch,
diff --git a/src/gpu/GrProcOptInfo.h b/src/gpu/GrProcOptInfo.h
index f518172..0430916 100644
--- a/src/gpu/GrProcOptInfo.h
+++ b/src/gpu/GrProcOptInfo.h
@@ -10,9 +10,9 @@
 
 #include "GrColor.h"
 #include "GrInvariantOutput.h"
+#include "GrStagedProcessor.h"
 
 class GrBatch;
-class GrFragmentStage;
 class GrFragmentProcessor;
 class GrPrimitiveProcessor;
 class GrProcessor;
diff --git a/src/gpu/effects/GrConfigConversionEffect.h b/src/gpu/effects/GrConfigConversionEffect.h
index f00a284..d87d009 100644
--- a/src/gpu/effects/GrConfigConversionEffect.h
+++ b/src/gpu/effects/GrConfigConversionEffect.h
@@ -10,7 +10,6 @@
 
 #include "GrSingleTextureEffect.h"
 
-class GrFragmentStage;
 class GrInvariantOutput;
 
 /**
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.h b/src/gpu/gl/builders/GrGLProgramBuilder.h
index 4b784ac..8143230 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.h
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.h
@@ -16,7 +16,6 @@
 #include "../GrGLUniformHandle.h"
 #include "../GrGLPrimitiveProcessor.h"
 #include "../GrGLXferProcessor.h"
-#include "../../GrPendingFragmentStage.h"
 #include "../../GrPipeline.h"
 
 /*