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

Unified Diff: src/gpu/batches/GrVertexBatch.h

Issue 1286043004: Make GrVertexBatch objects hold their own draws during GrDrawTarget flush (Closed) Base URL: https://skia.googlesource.com/skia.git@m
Patch Set: forward decl 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/GrTestBatch.h ('k') | src/gpu/batches/GrVertexBatch.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/batches/GrVertexBatch.h
diff --git a/src/gpu/batches/GrVertexBatch.h b/src/gpu/batches/GrVertexBatch.h
index 882cfa0c8ddda977120f02afc8e36fa0bb04e1bf..b868962411a7fd32e73df3fecfa8f0e34f605ef5 100644
--- a/src/gpu/batches/GrVertexBatch.h
+++ b/src/gpu/batches/GrVertexBatch.h
@@ -9,20 +9,25 @@
#define GrVertexBatch_DEFINED
#include "GrDrawBatch.h"
-#include "GrBatchTarget.h"
+#include "GrPrimitiveProcessor.h"
+#include "GrPendingProgramElement.h"
+#include "GrVertices.h"
+
+#include "SkTLList.h"
+
+class GrBatchFlushState;
/**
* Base class for vertex-based GrBatches.
*/
class GrVertexBatch : public GrDrawBatch {
public:
- GrVertexBatch();
+ class Target;
- virtual void generateGeometry(GrBatchTarget*) = 0;
+ GrVertexBatch();
- // TODO this goes away when batches are everywhere
- void setNumberOfDraws(int numberOfDraws) { fNumberOfDraws = numberOfDraws; }
- int numberOfDraws() const { return fNumberOfDraws; }
+ void prepareDraws(GrBatchFlushState* state);
+ void issueDraws(GrBatchFlushState* state);
protected:
/** Helper for rendering instances using an instanced index index buffer. This class creates the
@@ -32,15 +37,12 @@ protected:
InstancedHelper() {}
/** Returns the allocated storage for the vertices. The caller should populate the before
vertices before calling issueDraws(). */
- void* init(GrBatchTarget* batchTarget, GrPrimitiveType, size_t vertexStride,
+ void* init(Target*, GrPrimitiveType, size_t vertexStride,
const GrIndexBuffer*, int verticesPerInstance, int indicesPerInstance,
int instancesToDraw);
/** Call after init() to issue draws to the batch target.*/
- void issueDraw(GrBatchTarget* batchTarget) {
- SkASSERT(fVertices.instanceCount());
- batchTarget->draw(fVertices);
- }
+ void recordDraw(Target* target);
private:
GrVertices fVertices;
};
@@ -55,16 +57,31 @@ protected:
/** Finds the cached quad index buffer and reserves vertex space. Returns NULL on failure
and on sucess a pointer to the vertex data that the caller should populate before
calling issueDraws(). */
- void* init(GrBatchTarget* batchTarget, size_t vertexStride, int quadsToDraw);
-
- using InstancedHelper::issueDraw;
+ void* init(Target* batchTarget, size_t vertexStride, int quadsToDraw);
+ using InstancedHelper::recordDraw;
private:
typedef InstancedHelper INHERITED;
};
private:
- int fNumberOfDraws;
+ virtual void onPrepareDraws(Target*) = 0;
+
+ // A set of contiguous draws with no inline uploads between them that all use the same
+ // primitive processor. All the draws in a DrawArray share a primitive processor and use the
+ // the batch's GrPipeline.
+ struct DrawArray {
+ SkSTArray<1, GrVertices, true> fDraws;
+ GrPendingProgramElement<const GrPrimitiveProcessor> fPrimitiveProcessor;
+ };
+
+ // Array of DrawArray. There may be inline uploads between each DrawArray and each DrawArray
+ // may use a different primitive processor.
+ SkTLList<DrawArray> fDrawArrays;
+
+ // What is this?
+ GrBatchTracker fBatchTracker;
+
typedef GrDrawBatch INHERITED;
};
« no previous file with comments | « src/gpu/batches/GrTestBatch.h ('k') | src/gpu/batches/GrVertexBatch.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698