diff options
author | 2015-08-13 13:34:48 -0700 | |
---|---|---|
committer | 2015-08-13 13:34:48 -0700 | |
commit | abd30f54b7ff1704a8930c4307ea242d09425d02 (patch) | |
tree | 08eb5fdaa2fbe55f2e763a1d3c05054896919b68 /src/gpu/batches/GrBatch.cpp | |
parent | 8f34372f7e97482e5e61ab298b7edaa008ba2f4c (diff) |
Introduce GrBatch subclasses GrDrawBatch and GrVertexBatch to prepare for non-drawing batches
Review URL: https://codereview.chromium.org/1293583002
Diffstat (limited to 'src/gpu/batches/GrBatch.cpp')
-rw-r--r-- | src/gpu/batches/GrBatch.cpp | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/src/gpu/batches/GrBatch.cpp b/src/gpu/batches/GrBatch.cpp index 3840b4c83b..b696d6b95b 100644 --- a/src/gpu/batches/GrBatch.cpp +++ b/src/gpu/batches/GrBatch.cpp @@ -50,8 +50,6 @@ void GrBatch::operator delete(void* target) { GrBatch::GrBatch() : fClassID(kIllegalBatchID) - , fNumberOfDraws(0) - , fPipelineInstalled(false) #if GR_BATCH_SPEW , fUniqueID(GenID(&gCurrBatchUniqueID)) #endif @@ -59,13 +57,34 @@ GrBatch::GrBatch() SkDEBUGCODE(fUsed = false;) } -GrBatch::~GrBatch() { +GrBatch::~GrBatch() {} + +////////////////////////////////////////////////////////////////////////////// + +GrDrawBatch::GrDrawBatch() : fPipelineInstalled(false) { } + +GrDrawBatch::~GrDrawBatch() { if (fPipelineInstalled) { this->pipeline()->~GrPipeline(); } } -void* GrBatch::InstancedHelper::init(GrBatchTarget* batchTarget, GrPrimitiveType primType, +bool GrDrawBatch::installPipeline(const GrPipeline::CreateArgs& args) { + GrPipelineOptimizations opts; + void* location = fPipelineStorage.get(); + if (!GrPipeline::CreateAt(location, args, &opts)) { + return false; + } + this->initBatchTracker(opts); + fPipelineInstalled = true; + return true; +} + +////////////////////////////////////////////////////////////////////////////// + +GrVertexBatch::GrVertexBatch() : fNumberOfDraws(0) {} + +void* GrVertexBatch::InstancedHelper::init(GrBatchTarget* batchTarget, GrPrimitiveType primType, size_t vertexStride, const GrIndexBuffer* indexBuffer, int verticesPerInstance, int indicesPerInstance, int instancesToDraw) { @@ -92,7 +111,8 @@ void* GrBatch::InstancedHelper::init(GrBatchTarget* batchTarget, GrPrimitiveType return vertices; } -void* GrBatch::QuadHelper::init(GrBatchTarget* batchTarget, size_t vertexStride, int quadsToDraw) { +void* GrVertexBatch::QuadHelper::init(GrBatchTarget* batchTarget, size_t vertexStride, + int quadsToDraw) { SkAutoTUnref<const GrIndexBuffer> quadIndexBuffer( batchTarget->resourceProvider()->refQuadIndexBuffer()); if (!quadIndexBuffer) { @@ -102,14 +122,3 @@ void* GrBatch::QuadHelper::init(GrBatchTarget* batchTarget, size_t vertexStride, return this->INHERITED::init(batchTarget, kTriangles_GrPrimitiveType, vertexStride, quadIndexBuffer, kVerticesPerQuad, kIndicesPerQuad, quadsToDraw); } - -bool GrBatch::installPipeline(const GrPipeline::CreateArgs& args) { - GrPipelineOptimizations opts; - void* location = fPipelineStorage.get(); - if (!GrPipeline::CreateAt(location, args, &opts)) { - return false; - } - this->initBatchTracker(opts); - fPipelineInstalled = true; - return true; -} |