Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(249)

Unified Diff: src/gpu/batches/GrBatch.cpp

Issue 1293583002: Introduce GrBatch subclasses GrDrawBatch and GrVertexBatch to prepare for non-drawing batches (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove duplicated fields in GrVertexBatch Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/batches/GrBatch.h ('k') | src/gpu/batches/GrDrawAtlasBatch.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/batches/GrBatch.cpp
diff --git a/src/gpu/batches/GrBatch.cpp b/src/gpu/batches/GrBatch.cpp
index 3840b4c83bb90e51f0cac66e32538c599ef2ebd5..b696d6b95b1585e9745d533801e9f8dfe04f6216 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;
-}
« no previous file with comments | « src/gpu/batches/GrBatch.h ('k') | src/gpu/batches/GrDrawAtlasBatch.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698