Remove uniform view matrix from GrGLPrimitiveProcessor base class

BUG=skia:

Review URL: https://codereview.chromium.org/1151693005
diff --git a/src/gpu/gl/GrGLGeometryProcessor.cpp b/src/gpu/gl/GrGLGeometryProcessor.cpp
index 60c0043..dc4518f 100644
--- a/src/gpu/gl/GrGLGeometryProcessor.cpp
+++ b/src/gpu/gl/GrGLGeometryProcessor.cpp
@@ -91,24 +91,35 @@
 
 void GrGLGeometryProcessor::setupPosition(GrGLGPBuilder* pb,
                                           GrGPArgs* gpArgs,
+                                          const char* posName) {
+    GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
+    gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2");
+    vsBuilder->codeAppendf("vec2 %s = %s;", gpArgs->fPositionVar.c_str(), posName);
+}
+
+void GrGLGeometryProcessor::setupPosition(GrGLGPBuilder* pb,
+                                          GrGPArgs* gpArgs,
                                           const char* posName,
-                                          const SkMatrix& mat) {
+                                          const SkMatrix& mat,
+                                          UniformHandle* viewMatrixUniform) {
     GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
     if (mat.isIdentity()) {
         gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2");
-
         vsBuilder->codeAppendf("vec2 %s = %s;", gpArgs->fPositionVar.c_str(), posName);
-    } else if (!mat.hasPerspective()) {
-        this->addUniformViewMatrix(pb);
-        gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2");
-
-        vsBuilder->codeAppendf("vec2 %s = vec2(%s * vec3(%s, 1));",
-                               gpArgs->fPositionVar.c_str(), this->uViewM(), posName);
     } else {
-        this->addUniformViewMatrix(pb);
-        gpArgs->fPositionVar.set(kVec3f_GrSLType, "pos3");
-
-        vsBuilder->codeAppendf("vec3 %s = %s * vec3(%s, 1);",
-                               gpArgs->fPositionVar.c_str(), this->uViewM(), posName);
+        const char* viewMatrixName;
+        *viewMatrixUniform = pb->addUniform(GrGLProgramBuilder::kVertex_Visibility,
+                                            kMat33f_GrSLType, kHigh_GrSLPrecision,
+                                            "uViewM",
+                                            &viewMatrixName);
+        if (!mat.hasPerspective()) {
+            gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2");
+            vsBuilder->codeAppendf("vec2 %s = vec2(%s * vec3(%s, 1));",
+                                   gpArgs->fPositionVar.c_str(), viewMatrixName, posName);
+        } else {
+            gpArgs->fPositionVar.set(kVec3f_GrSLType, "pos3");
+            vsBuilder->codeAppendf("vec3 %s = %s * vec3(%s, 1);",
+                                   gpArgs->fPositionVar.c_str(), viewMatrixName, posName);
+        }
     }
 }
diff --git a/src/gpu/gl/GrGLGeometryProcessor.h b/src/gpu/gl/GrGLGeometryProcessor.h
index dfb2b90..747d82a 100644
--- a/src/gpu/gl/GrGLGeometryProcessor.h
+++ b/src/gpu/gl/GrGLGeometryProcessor.h
@@ -64,10 +64,9 @@
     };
 
     // Create the correct type of position variable given the CTM
-    void setupPosition(GrGLGPBuilder* pb,
-                       GrGPArgs* gpArgs,
-                       const char* posName,
-                       const SkMatrix& mat = SkMatrix::I());
+    void setupPosition(GrGLGPBuilder*, GrGPArgs*, const char* posName);
+    void setupPosition(GrGLGPBuilder*, GrGPArgs*, const char* posName, const SkMatrix& mat,
+                       UniformHandle* viewMatrixUniform);
 
     static uint32_t ComputePosKey(const SkMatrix& mat) {
         if (mat.isIdentity()) {
diff --git a/src/gpu/gl/GrGLPrimitiveProcessor.cpp b/src/gpu/gl/GrGLPrimitiveProcessor.cpp
index 893e556..6dd112c 100644
--- a/src/gpu/gl/GrGLPrimitiveProcessor.cpp
+++ b/src/gpu/gl/GrGLPrimitiveProcessor.cpp
@@ -44,22 +44,3 @@
                                    &stagedLocalVarName);
     fs->codeAppendf("%s = %s;", outputName, stagedLocalVarName);
 }
-
-void GrGLPrimitiveProcessor::addUniformViewMatrix(GrGLGPBuilder* pb) {
-    fViewMatrixUniform = pb->addUniform(GrGLProgramBuilder::kVertex_Visibility,
-                                        kMat33f_GrSLType, kHigh_GrSLPrecision,
-                                        "uViewM",
-                                        &fViewMatrixName);
-}
-
-void GrGLPrimitiveProcessor::setUniformViewMatrix(const GrGLProgramDataManager& pdman,
-                                                  const SkMatrix& viewMatrix) {
-    if (!viewMatrix.isIdentity() && !fViewMatrix.cheapEqualTo(viewMatrix)) {
-        SkASSERT(fViewMatrixUniform.isValid());
-        fViewMatrix = viewMatrix;
-
-        GrGLfloat viewMatrix[3 * 3];
-        GrGLGetMatrix<3>(viewMatrix, fViewMatrix);
-        pdman.setMatrix3f(fViewMatrixUniform, viewMatrix);
-    }
-}
diff --git a/src/gpu/gl/GrGLPrimitiveProcessor.h b/src/gpu/gl/GrGLPrimitiveProcessor.h
index 90ee203..7345eae 100644
--- a/src/gpu/gl/GrGLPrimitiveProcessor.h
+++ b/src/gpu/gl/GrGLPrimitiveProcessor.h
@@ -17,7 +17,6 @@
 
 class GrGLPrimitiveProcessor {
 public:
-    GrGLPrimitiveProcessor() : fViewMatrixName(NULL) { fViewMatrix = SkMatrix::InvalidMatrix(); }
     virtual ~GrGLPrimitiveProcessor() {}
 
     typedef GrGLProgramDataManager::UniformHandle UniformHandle;
@@ -76,18 +75,6 @@
 protected:
     void setupUniformColor(GrGLGPBuilder* pb, const char* outputName, UniformHandle* colorUniform);
 
-    const char* uViewM() const { return fViewMatrixName; }
-
-    /** a helper function to setup the uniform handle for the uniform view matrix */
-    void addUniformViewMatrix(GrGLGPBuilder*);
-
-
-    /** a helper function to upload a uniform viewmatrix.
-     * TODO we can remove this function when we have deferred geometry in place
-     */
-    void setUniformViewMatrix(const GrGLProgramDataManager&,
-                              const SkMatrix& viewMatrix);
-
     class ShaderVarHandle {
     public:
         bool isValid() const { return fHandle > -1; }
@@ -111,11 +98,6 @@
     };
 
     SkSTArray<8, SkSTArray<2, Transform, true> > fInstalledTransforms;
-
-private:
-    UniformHandle fViewMatrixUniform;
-    SkMatrix fViewMatrix;
-    const char* fViewMatrixName;
 };
 
 #endif