Centralize geometry processor vertex shader transform code

GrGLSLGeometryProcessors no longer have to call emitTransforms() in
their onEmitCode() function. Instead, the GpArgs struct allows them to
set a GrShaderVar that holds the computed or explicitly provided local
coordinates in the vertex shader.

The base GrGLSLGeometryProcessor now automatically uses that to collect
all of the transforms that can then be lifted out of FPs to the vertex
shader, and base their computation on the GP provided local coordinate.

As part of this, there is no more built-in magic concatenation of a
local matrix / inverse view matrix to these coordinate transforms. GP
implementations that relied on this now manage their own uniform for this
matrix and compute the local coordinate before assigning to GpArgs.

The base GrGLSLGeometryProcessor is updated to provide helpers for this
pattern.

Bug: skia:10396
Change-Id: I56afb3fff4b806f6015ab13626ac1afde9ef5c2b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/297027
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/tools/gpu/TestOps.cpp b/tools/gpu/TestOps.cpp
index ff5201a..1ef7420 100644
--- a/tools/gpu/TestOps.cpp
+++ b/tools/gpu/TestOps.cpp
@@ -32,26 +32,29 @@
 
     const char* name() const override { return "TestRectOp::GP"; }
 
-    GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps& caps) const override;
+    GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps& caps) const override {
+        return new GLSLGP();
+    }
 
-    void getGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override {}
+    void getGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder* b) const override {
+        GLSLGP::GenKey(*this, b);
+    }
 
     bool wideColor() const { return fInColor.cpuType() != kUByte4_norm_GrVertexAttribType; }
 
 private:
-    Attribute fInPosition = {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
-    Attribute fInLocalCoords = {"inLocalCoords", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
-    Attribute fInColor;
-    SkMatrix fLocalMatrix;
-};
-
-GrGLSLPrimitiveProcessor* GP::createGLSLInstance(const GrShaderCaps& caps) const {
     class GLSLGP : public GrGLSLGeometryProcessor {
+    public:
         void setData(const GrGLSLProgramDataManager& pdman,
                      const GrPrimitiveProcessor& pp,
                      const CoordTransformRange& transformRange) override {
             const auto& gp = pp.cast<GP>();
-            this->setTransformDataHelper(gp.fLocalMatrix, pdman, transformRange);
+            this->setTransformDataHelper(pdman, transformRange);
+            this->setTransform(pdman, fLocalMatrixUni, gp.fLocalMatrix);
+        }
+
+        static void GenKey(const GP& gp, GrProcessorKeyBuilder* b) {
+            b->add32(ComputeMatrixKey(gp.fLocalMatrix));
         }
 
     private:
@@ -65,13 +68,19 @@
             args.fFragBuilder->codeAppendf("%s = %s;", args.fOutputColor, colorVarying.fsIn());
             args.fFragBuilder->codeAppendf("%s = half4(1);", args.fOutputCoverage);
             this->writeOutputPosition(args.fVertBuilder, gpArgs, gp.fInPosition.name());
-            this->emitTransforms(args.fVertBuilder, args.fVaryingHandler, args.fUniformHandler,
-                                 gp.fInLocalCoords.asShaderVar(), gp.fLocalMatrix,
-                                 args.fFPCoordTransformHandler);
+            this->writeLocalCoord(args.fVertBuilder, args.fUniformHandler, gpArgs,
+                                  gp.fInLocalCoords.asShaderVar(), gp.fLocalMatrix,
+                                  &fLocalMatrixUni);
         }
+
+        UniformHandle fLocalMatrixUni;
     };
-    return new GLSLGP();
-}
+
+    Attribute fInPosition = {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
+    Attribute fInLocalCoords = {"inLocalCoords", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
+    Attribute fInColor;
+    SkMatrix fLocalMatrix;
+};
 
 class TestRectOp final : public GrMeshDrawOp {
 public: