Update GrTextureOp to use index buffer offsets for draws

This should, hopefully, be faster on GL as we will only need to update the index-range for a draw rather than the offset into an vertex buffer.

Change-Id: I09e54c37262168661443fa8bf8d3b43cd8faa9db
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/251757
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
diff --git a/src/gpu/ops/GrQuadPerEdgeAA.h b/src/gpu/ops/GrQuadPerEdgeAA.h
index 1a37de4..427e19c 100644
--- a/src/gpu/ops/GrQuadPerEdgeAA.h
+++ b/src/gpu/ops/GrQuadPerEdgeAA.h
@@ -96,6 +96,9 @@
         CoverageMode coverageMode() const;
         size_t vertexSize() const;
 
+        bool needsIndexBuffer() const { return this->indexBufferOption() !=
+                                               IndexBufferOption::kTriStrips; }
+
     private:
         static_assert(GrQuad::kTypeCount <= 4, "GrQuad::Type doesn't fit in 2 bits");
         static_assert(kColorTypeCount <= 4, "Color doesn't fit in 2 bits");
@@ -134,13 +137,23 @@
                      const SkPMColor4f& color, const GrQuad& localQuad, const SkRect& domain,
                      GrQuadAAFlags aa);
 
-    // The mesh will have its index data configured to meet the expectations of the Tessellate()
-    // function, but it the calling code must handle filling a vertex buffer via Tessellate() and
-    // then assigning it to the returned mesh.
+    // This method will return the correct index buffer for the specified indexBufferOption.
+    // It will, correctly, return nullptr if the indexBufferOption is kTriStrips.
+    sk_sp<const GrBuffer> GetIndexBuffer(GrMeshDrawOp::Target*, IndexBufferOption);
+
+    // This method will configure the vertex and index data of the provided 'mesh' to comply
+    // with the indexing method specified in the vertexSpec. It is up to the calling code
+    // to allocate and fill in the vertex data and acquire the correct indexBuffer if it is needed.
     //
-    // Returns false if the index data could not be allocated.
-    bool ConfigureMeshIndices(GrMeshDrawOp::Target* target, GrMesh* mesh, const VertexSpec& spec,
-                              int quadCount);
+    // @param runningQuadCount  the number of quads already stored in 'vertexBuffer' and
+    //                          'indexBuffer' e.g., different GrMeshes have already been placed in
+    //                          the buffers to allow dynamic state changes.
+    // @param quadCount         the number of quads that will be drawn by the provided 'mesh'.
+    //                          A subsequent ConfigureMesh call would the use
+    //                          'runningQuadCount' + 'quadCount' for its new 'runningQuadCount'.
+    void ConfigureMesh(GrMesh* mesh, const VertexSpec&, int runningQuadCount, int quadCount,
+                       int maxVerts, sk_sp<const GrBuffer> vertexBuffer,
+                       sk_sp<const GrBuffer> indexBuffer, int absVertBufferOffset);
 
 } // namespace GrQuadPerEdgeAA