| 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 GrBatch_DEFINED | 8 #ifndef GrBatch_DEFINED |
| 9 #define GrBatch_DEFINED | 9 #define GrBatch_DEFINED |
| 10 | 10 |
| 11 #include <new> | 11 #include <new> |
| 12 // TODO remove this header when we move entirely to batch | |
| 13 #include "GrDrawTarget.h" | |
| 14 #include "GrBatchTarget.h" | 12 #include "GrBatchTarget.h" |
| 15 #include "GrGeometryProcessor.h" | 13 #include "GrGeometryProcessor.h" |
| 14 #include "GrVertices.h" |
| 16 #include "SkRefCnt.h" | 15 #include "SkRefCnt.h" |
| 17 #include "SkThread.h" | 16 #include "SkThread.h" |
| 18 #include "SkTypes.h" | 17 #include "SkTypes.h" |
| 19 | 18 |
| 20 class GrGpu; | 19 class GrGpu; |
| 21 class GrIndexBufferAllocPool; | 20 class GrIndexBufferAllocPool; |
| 22 class GrPipeline; | 21 class GrPipeline; |
| 23 class GrVertexBufferAllocPool; | 22 class GrVertexBufferAllocPool; |
| 24 | 23 |
| 25 struct GrInitInvariantOutput; | 24 struct GrInitInvariantOutput; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 public: | 118 public: |
| 120 InstancedHelper() : fInstancesRemaining(0) {} | 119 InstancedHelper() : fInstancesRemaining(0) {} |
| 121 /** Returns the allocated storage for the vertices. The caller should po
pulate the before | 120 /** Returns the allocated storage for the vertices. The caller should po
pulate the before |
| 122 vertices before calling issueDraws(). */ | 121 vertices before calling issueDraws(). */ |
| 123 void* init(GrBatchTarget* batchTarget, GrPrimitiveType, size_t vertexStr
ide, | 122 void* init(GrBatchTarget* batchTarget, GrPrimitiveType, size_t vertexStr
ide, |
| 124 const GrIndexBuffer*, int verticesPerInstance, int indicesPer
Instance, | 123 const GrIndexBuffer*, int verticesPerInstance, int indicesPer
Instance, |
| 125 int instancesToDraw); | 124 int instancesToDraw); |
| 126 | 125 |
| 127 /** Call after init() to issue draws to the batch target.*/ | 126 /** Call after init() to issue draws to the batch target.*/ |
| 128 void issueDraws(GrBatchTarget* batchTarget) { | 127 void issueDraws(GrBatchTarget* batchTarget) { |
| 129 SkASSERT(fDrawInfo.instanceCount()); | 128 SkASSERT(fVertices.instanceCount()); |
| 130 do { | 129 do { |
| 131 batchTarget->draw(fDrawInfo); | 130 batchTarget->draw(fVertices); |
| 132 } while (fDrawInfo.nextInstances(&fInstancesRemaining, fMaxInstances
PerDraw)); | 131 } while (fVertices.nextInstances(&fInstancesRemaining, fMaxInstances
PerDraw)); |
| 133 } | 132 } |
| 134 private: | 133 private: |
| 135 int fInstancesRemaining; | 134 int fInstancesRemaining; |
| 136 int fMaxInstancesPerDraw; | 135 int fMaxInstancesPerDraw; |
| 137 GrDrawTarget::DrawInfo fDrawInfo; | 136 GrVertices fVertices; |
| 138 }; | 137 }; |
| 139 | 138 |
| 140 static const int kVerticesPerQuad = 4; | 139 static const int kVerticesPerQuad = 4; |
| 141 static const int kIndicesPerQuad = 6; | 140 static const int kIndicesPerQuad = 6; |
| 142 | 141 |
| 143 /** A specialization of InstanceHelper for quad rendering. */ | 142 /** A specialization of InstanceHelper for quad rendering. */ |
| 144 class QuadHelper : private InstancedHelper { | 143 class QuadHelper : private InstancedHelper { |
| 145 public: | 144 public: |
| 146 QuadHelper() : INHERITED() {} | 145 QuadHelper() : INHERITED() {} |
| 147 /** Finds the cached quad index buffer and reserves vertex space. Return
s NULL on failure | 146 /** Finds the cached quad index buffer and reserves vertex space. Return
s NULL on failure |
| (...skipping 28 matching lines...) Expand all Loading... |
| 176 static int32_t gCurrBatchClassID; | 175 static int32_t gCurrBatchClassID; |
| 177 | 176 |
| 178 SkDEBUGCODE(bool fUsed;) | 177 SkDEBUGCODE(bool fUsed;) |
| 179 | 178 |
| 180 int fNumberOfDraws; | 179 int fNumberOfDraws; |
| 181 | 180 |
| 182 typedef SkRefCnt INHERITED; | 181 typedef SkRefCnt INHERITED; |
| 183 }; | 182 }; |
| 184 | 183 |
| 185 #endif | 184 #endif |
| OLD | NEW |