Switch GrMeshDrawOp::Target to be the stand alone GrMeshDrawTarget class
The Tessellator classes will survive in the NGA and they use
GrMeshDrawOp::Target - but GrMeshDrawOp will not survive.
This is a prelude to making all the remaining GrOp-derived classes OGA-only.
Bug: skia:11837
Change-Id: I62dc92e5f42d672342113f12dcedf3435fab993f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419198
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
diff --git a/src/gpu/GrVertexChunkArray.h b/src/gpu/GrVertexChunkArray.h
index b559bfc..3d570d8 100644
--- a/src/gpu/GrVertexChunkArray.h
+++ b/src/gpu/GrVertexChunkArray.h
@@ -12,7 +12,8 @@
#include "include/private/SkTArray.h"
#include "src/gpu/GrBuffer.h"
#include "src/gpu/GrVertexWriter.h"
-#include "src/gpu/ops/GrMeshDrawOp.h"
+
+class GrMeshDrawTarget;
// Represents a chunk of vertex data. Use with GrVertexChunkArray and GrVertexChunkBuilder. We write
// the data out in chunks when we don't start out knowing exactly how many vertices (or instances)
@@ -33,7 +34,7 @@
// entire lifetime of this object.
class GrVertexChunkBuilder : SkNoncopyable {
public:
- GrVertexChunkBuilder(GrMeshDrawOp::Target* target, GrVertexChunkArray* chunks, size_t stride,
+ GrVertexChunkBuilder(GrMeshDrawTarget* target, GrVertexChunkArray* chunks, size_t stride,
int minVerticesPerChunk)
: fTarget(target)
, fChunks(chunks)
@@ -42,12 +43,7 @@
SkASSERT(fMinVerticesPerChunk > 0);
}
- ~GrVertexChunkBuilder() {
- if (!fChunks->empty()) {
- fTarget->putBackVertices(fCurrChunkVertexCapacity - fCurrChunkVertexCount, fStride);
- fChunks->back().fCount = fCurrChunkVertexCount;
- }
- }
+ ~GrVertexChunkBuilder();
// Appends 'count' contiguous vertices. These vertices are not guaranteed to be contiguous with
// previous or future calls to appendVertices.
@@ -78,30 +74,9 @@
}
private:
- bool allocChunk(int minCount) {
- if (!fChunks->empty()) {
- // No need to put back vertices; the buffer is full.
- fChunks->back().fCount = fCurrChunkVertexCount;
- }
- fCurrChunkVertexCount = 0;
- GrVertexChunk* chunk = &fChunks->push_back();
- int minAllocCount = std::max(minCount, fMinVerticesPerChunk);
- fCurrChunkVertexWriter = {fTarget->makeVertexSpaceAtLeast(fStride, minAllocCount,
- minAllocCount, &chunk->fBuffer,
- &chunk->fBase,
- &fCurrChunkVertexCapacity)};
- if (!fCurrChunkVertexWriter || !chunk->fBuffer || fCurrChunkVertexCapacity < minCount) {
- SkDebugf("WARNING: Failed to allocate vertex buffer for GrVertexChunk.\n");
- fChunks->pop_back();
- SkASSERT(fCurrChunkVertexCount == 0);
- fCurrChunkVertexCapacity = 0;
- return false;
- }
- fMinVerticesPerChunk *= 2;
- return true;
- }
+ bool allocChunk(int minCount);
- GrMeshDrawOp::Target* const fTarget;
+ GrMeshDrawTarget* const fTarget;
GrVertexChunkArray* const fChunks;
const size_t fStride;
int fMinVerticesPerChunk;