Implement a fixed count stroke tessellator
This new tessellator renders strokes as fixed-count triangle strip
instances. Any extra triangles not needed by the instance are emitted
as degenerate triangles. Since it draws in order, this tessellator
allows us to batch dynamic colors even when hw tessellation is not
supported.
Bug: skia:10419
Change-Id: If03a8b76319471ae4d4580dda019b69204d9197b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/398416
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
diff --git a/src/gpu/GrVertexChunkArray.h b/src/gpu/GrVertexChunkArray.h
index febde51..1a1d7a1 100644
--- a/src/gpu/GrVertexChunkArray.h
+++ b/src/gpu/GrVertexChunkArray.h
@@ -19,8 +19,8 @@
// we will end up writing.
struct GrVertexChunk {
sk_sp<const GrBuffer> fBuffer;
- int fVertexCount = 0;
- int fBaseVertex;
+ int fCount = 0;
+ int fBase; // baseVertex or baseInstance, depending on the use case.
};
// Represents an array of GrVertexChunks.
@@ -45,7 +45,7 @@
~GrVertexChunkBuilder() {
if (!fChunks->empty()) {
fTarget->putBackVertices(fCurrChunkVertexCapacity - fCurrChunkVertexCount, fStride);
- fChunks->back().fVertexCount = fCurrChunkVertexCount;
+ fChunks->back().fCount = fCurrChunkVertexCount;
}
}
@@ -68,7 +68,7 @@
bool allocChunk(int minCount) {
if (!fChunks->empty()) {
// No need to put back vertices; the buffer is full.
- fChunks->back().fVertexCount = fCurrChunkVertexCount;
+ fChunks->back().fCount = fCurrChunkVertexCount;
}
fCurrChunkVertexCount = 0;
GrVertexChunk* chunk = &fChunks->push_back();
@@ -76,7 +76,7 @@
fMinVerticesPerChunk * minCount,
fMinVerticesPerChunk * minCount,
&chunk->fBuffer,
- &chunk->fBaseVertex,
+ &chunk->fBase,
&fCurrChunkVertexCapacity)};
if (!fCurrChunkVertexWriter || !chunk->fBuffer || fCurrChunkVertexCapacity < minCount) {
SkDebugf("WARNING: Failed to allocate vertex buffer for GrVertexChunk.\n");