OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef GrVertexBatch_DEFINED | 8 #ifndef GrVertexBatch_DEFINED |
9 #define GrVertexBatch_DEFINED | 9 #define GrVertexBatch_DEFINED |
10 | 10 |
11 #include "GrDrawBatch.h" | 11 #include "GrDrawBatch.h" |
12 #include "GrPrimitiveProcessor.h" | 12 #include "GrPrimitiveProcessor.h" |
13 #include "GrPendingProgramElement.h" | 13 #include "GrPendingProgramElement.h" |
14 #include "GrVertices.h" | 14 #include "GrVertices.h" |
15 | 15 |
16 #include "SkTLList.h" | 16 #include "SkTLList.h" |
17 | 17 |
18 class GrBatchFlushState; | 18 class GrBatchFlushState; |
19 | 19 |
20 /** | 20 /** |
21 * Base class for vertex-based GrBatches. | 21 * Base class for vertex-based GrBatches. |
22 */ | 22 */ |
23 class GrVertexBatch : public GrDrawBatch { | 23 class GrVertexBatch : public GrDrawBatch { |
24 public: | 24 public: |
25 class Target; | 25 class Target; |
26 | 26 |
27 GrVertexBatch(); | 27 GrVertexBatch(); |
28 | 28 |
29 void prepareDraws(GrBatchFlushState* state); | |
30 void issueDraws(GrBatchFlushState* state); | |
31 | |
32 protected: | 29 protected: |
33 /** Helper for rendering instances using an instanced index index buffer. Th
is class creates the | 30 /** Helper for rendering instances using an instanced index index buffer. Th
is class creates the |
34 space for the vertices and flushes the draws to the batch target. */ | 31 space for the vertices and flushes the draws to the batch target. */ |
35 class InstancedHelper { | 32 class InstancedHelper { |
36 public: | 33 public: |
37 InstancedHelper() {} | 34 InstancedHelper() {} |
38 /** Returns the allocated storage for the vertices. The caller should po
pulate the before | 35 /** Returns the allocated storage for the vertices. The caller should po
pulate the before |
39 vertices before calling issueDraws(). */ | 36 vertices before calling issueDraws(). */ |
40 void* init(Target*, GrPrimitiveType, size_t vertexStride, | 37 void* init(Target*, GrPrimitiveType, size_t vertexStride, |
41 const GrIndexBuffer*, int verticesPerInstance, int indicesPer
Instance, | 38 const GrIndexBuffer*, int verticesPerInstance, int indicesPer
Instance, |
(...skipping 16 matching lines...) Expand all Loading... |
58 and on sucess a pointer to the vertex data that the caller should po
pulate before | 55 and on sucess a pointer to the vertex data that the caller should po
pulate before |
59 calling issueDraws(). */ | 56 calling issueDraws(). */ |
60 void* init(Target* batchTarget, size_t vertexStride, int quadsToDraw); | 57 void* init(Target* batchTarget, size_t vertexStride, int quadsToDraw); |
61 | 58 |
62 using InstancedHelper::recordDraw; | 59 using InstancedHelper::recordDraw; |
63 private: | 60 private: |
64 typedef InstancedHelper INHERITED; | 61 typedef InstancedHelper INHERITED; |
65 }; | 62 }; |
66 | 63 |
67 private: | 64 private: |
| 65 void onPrepare(GrBatchFlushState* state) final; |
| 66 void onDraw(GrBatchFlushState* state) final; |
| 67 |
68 virtual void onPrepareDraws(Target*) = 0; | 68 virtual void onPrepareDraws(Target*) = 0; |
69 | 69 |
70 // A set of contiguous draws with no inline uploads between them that all us
e the same | 70 // A set of contiguous draws with no inline uploads between them that all us
e the same |
71 // primitive processor. All the draws in a DrawArray share a primitive proce
ssor and use the | 71 // primitive processor. All the draws in a DrawArray share a primitive proce
ssor and use the |
72 // the batch's GrPipeline. | 72 // the batch's GrPipeline. |
73 struct DrawArray { | 73 struct DrawArray { |
74 SkSTArray<1, GrVertices, true> fDraws; | 74 SkSTArray<1, GrVertices, true> fDraws; |
75 GrPendingProgramElement<const GrPrimitiveProcessor> fPrimitiveProcessor; | 75 GrPendingProgramElement<const GrPrimitiveProcessor> fPrimitiveProcessor; |
76 }; | 76 }; |
77 | 77 |
78 // Array of DrawArray. There may be inline uploads between each DrawArray an
d each DrawArray | 78 // Array of DrawArray. There may be inline uploads between each DrawArray an
d each DrawArray |
79 // may use a different primitive processor. | 79 // may use a different primitive processor. |
80 SkTLList<DrawArray> fDrawArrays; | 80 SkTLList<DrawArray> fDrawArrays; |
81 | 81 |
82 // What is this? | 82 // What is this? |
83 GrBatchTracker fBatchTracker; | 83 GrBatchTracker fBatchTracker; |
84 | 84 |
85 typedef GrDrawBatch INHERITED; | 85 typedef GrDrawBatch INHERITED; |
86 }; | 86 }; |
87 | 87 |
88 #endif | 88 #endif |
OLD | NEW |