Move new WriteVertexData utility to a GrVertexWriter helper struct
Encapsulates the pointer storage and advancement, shortens usage.
Bug: skia:
Change-Id: Id06cd273ed638395d1fd53b3b66f87d4d33a4f3b
Reviewed-on: https://skia-review.googlesource.com/c/170727
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
diff --git a/src/gpu/ops/GrAAConvexPathRenderer.cpp b/src/gpu/ops/GrAAConvexPathRenderer.cpp
index 1f2b703..624c261 100644
--- a/src/gpu/ops/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/ops/GrAAConvexPathRenderer.cpp
@@ -18,6 +18,7 @@
#include "GrRenderTargetContext.h"
#include "GrShape.h"
#include "GrSimpleMeshDrawOpHelper.h"
+#include "GrVertexWriter.h"
#include "SkGeometry.h"
#include "SkPathPriv.h"
#include "SkPointPriv.h"
@@ -690,19 +691,20 @@
// extract the result vertices and indices from the GrAAConvexTessellator
static void extract_lines_only_verts(const GrAAConvexTessellator& tess,
- void* vertices,
+ void* vertData,
GrColor color,
uint16_t* idxs,
bool tweakAlphaForCoverage) {
+ GrVertexWriter verts{vertData};
for (int i = 0; i < tess.numPts(); ++i) {
- vertices = GrMeshDrawOp::WriteVertexData(vertices, tess.point(i));
+ verts.write(tess.point(i));
if (tweakAlphaForCoverage) {
SkASSERT(SkScalarRoundToInt(255.0f * tess.coverage(i)) <= 255);
unsigned scale = SkScalarRoundToInt(255.0f * tess.coverage(i));
GrColor scaledColor = (0xff == scale) ? color : SkAlphaMulQ(color, scale);
- vertices = GrMeshDrawOp::WriteVertexData(vertices, scaledColor);
+ verts.write(scaledColor);
} else {
- vertices = GrMeshDrawOp::WriteVertexData(vertices, color, tess.coverage(i));
+ verts.write(color, tess.coverage(i));
}
}