Remove templating from QuadUVMatrix::apply, and fix const-ness

The function is inlined - the compiler can do whatever optimizations it
wants at each call-site. In the future, stride and uvOffset won't be
static (with optional wide colors), so this is required anyway.

Also, the pointer being passed in is never const, so stop cleverly
casting away the const-ness via reinterpret into and out of intptr_t.

Bug: skia:
Change-Id: I404c418a01d70ac77667ba89338940b086922dc6
Reviewed-on: https://skia-review.googlesource.com/c/179988
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/gm/beziereffects.cpp b/gm/beziereffects.cpp
index 41c24c3..ff4ea00 100644
--- a/gm/beziereffects.cpp
+++ b/gm/beziereffects.cpp
@@ -330,7 +330,7 @@
         }
         SkRect rect = this->rect();
         SkPointPriv::SetRectTriStrip(&verts[0].fPosition, rect, sizeof(Vertex));
-        fDevToUV.apply<4, sizeof(Vertex), sizeof(SkPoint)>(verts);
+        fDevToUV.apply(verts, 4, sizeof(Vertex), sizeof(SkPoint));
         auto pipe = this->makePipeline(target);
         helper.recordDraw(target, this->gp(), pipe.fPipeline, pipe.fFixedDynamicState);
     }
diff --git a/src/gpu/GrPathUtils.h b/src/gpu/GrPathUtils.h
index a1a1fe7..f358dfc 100644
--- a/src/gpu/GrPathUtils.h
+++ b/src/gpu/GrPathUtils.h
@@ -59,34 +59,29 @@
         void set(const SkPoint controlPts[3]);
 
         /**
-         * Applies the matrix to vertex positions to compute UV coords. This
-         * has been templated so that the compiler can easliy unroll the loop
-         * and reorder to avoid stalling for loads. The assumption is that a
-         * path renderer will have a small fixed number of vertices that it
-         * uploads for each quad.
+         * Applies the matrix to vertex positions to compute UV coords.
          *
-         * N is the number of vertices.
-         * STRIDE is the size of each vertex.
-         * UV_OFFSET is the offset of the UV values within each vertex.
          * vertices is a pointer to the first vertex.
+         * vertexCount is the number of vertices.
+         * stride is the size of each vertex.
+         * uvOffset is the offset of the UV values within each vertex.
          */
-        template <int N, size_t STRIDE, size_t UV_OFFSET>
-        void apply(const void* vertices) const {
+        void apply(void* vertices, int vertexCount, size_t stride, size_t uvOffset) const {
             intptr_t xyPtr = reinterpret_cast<intptr_t>(vertices);
-            intptr_t uvPtr = reinterpret_cast<intptr_t>(vertices) + UV_OFFSET;
+            intptr_t uvPtr = reinterpret_cast<intptr_t>(vertices) + uvOffset;
             float sx = fM[0];
             float kx = fM[1];
             float tx = fM[2];
             float ky = fM[3];
             float sy = fM[4];
             float ty = fM[5];
-            for (int i = 0; i < N; ++i) {
+            for (int i = 0; i < vertexCount; ++i) {
                 const SkPoint* xy = reinterpret_cast<const SkPoint*>(xyPtr);
                 SkPoint* uv = reinterpret_cast<SkPoint*>(uvPtr);
                 uv->fX = sx * xy->fX + kx * xy->fY + tx;
                 uv->fY = ky * xy->fX + sy * xy->fY + ty;
-                xyPtr += STRIDE;
-                uvPtr += STRIDE;
+                xyPtr += stride;
+                uvPtr += stride;
             }
         }
     private:
diff --git a/src/gpu/ops/GrAAConvexPathRenderer.cpp b/src/gpu/ops/GrAAConvexPathRenderer.cpp
index 1deb8be..269004a 100644
--- a/src/gpu/ops/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/ops/GrAAConvexPathRenderer.cpp
@@ -506,7 +506,7 @@
             verts[*v + 5].fD1 = -SK_ScalarMax/100;
 
             GrPathUtils::QuadUVMatrix toUV(qpts);
-            toUV.apply<6, sizeof(QuadVertex), offsetof(QuadVertex, fUV)>(verts + *v);
+            toUV.apply(verts + *v, 6, sizeof(QuadVertex), offsetof(QuadVertex, fUV));
 
             idxs[*i + 0] = *v + 3;
             idxs[*i + 1] = *v + 1;
diff --git a/src/gpu/ops/GrAAHairLinePathRenderer.cpp b/src/gpu/ops/GrAAHairLinePathRenderer.cpp
index 8f4c2f9..e03ce3f 100644
--- a/src/gpu/ops/GrAAHairLinePathRenderer.cpp
+++ b/src/gpu/ops/GrAAHairLinePathRenderer.cpp
@@ -514,7 +514,7 @@
 static void set_uv_quad(const SkPoint qpts[3], BezierVertex verts[kQuadNumVertices]) {
     // this should be in the src space, not dev coords, when we have perspective
     GrPathUtils::QuadUVMatrix DevToUV(qpts);
-    DevToUV.apply<kQuadNumVertices, sizeof(BezierVertex), sizeof(SkPoint)>(verts);
+    DevToUV.apply(verts, kQuadNumVertices, sizeof(BezierVertex), sizeof(SkPoint));
 }
 
 static void bloat_quad(const SkPoint qpts[3], const SkMatrix* toDevice,