| 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 GrBatchBuffer_DEFINED | 8 #ifndef GrBatchBuffer_DEFINED |
| 9 #define GrBatchBuffer_DEFINED | 9 #define GrBatchBuffer_DEFINED |
| 10 | 10 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 GrBatchFlushState* fState; | 154 GrBatchFlushState* fState; |
| 155 GrDrawBatch* fBatch; | 155 GrDrawBatch* fBatch; |
| 156 }; | 156 }; |
| 157 | 157 |
| 158 /** Extension of GrDrawBatch::Target for use by GrVertexBatch. Adds the ability
to create vertex | 158 /** Extension of GrDrawBatch::Target for use by GrVertexBatch. Adds the ability
to create vertex |
| 159 draws. */ | 159 draws. */ |
| 160 class GrVertexBatch::Target : public GrDrawBatch::Target { | 160 class GrVertexBatch::Target : public GrDrawBatch::Target { |
| 161 public: | 161 public: |
| 162 Target(GrBatchFlushState* state, GrVertexBatch* batch) : INHERITED(state, ba
tch) {} | 162 Target(GrBatchFlushState* state, GrVertexBatch* batch) : INHERITED(state, ba
tch) {} |
| 163 | 163 |
| 164 void initDraw(const GrPrimitiveProcessor* primProc, const GrPipeline* pipeli
ne) { | 164 void initDraw(const GrPrimitiveProcessor* primProc, GrPrimitiveType primitiv
eType) { |
| 165 GrVertexBatch::DrawArray* draws = this->vertexBatch()->fDrawArrays.addTo
Tail(); | 165 GrVertexBatch::DrawArray* draws = this->vertexBatch()->fDrawArrays.addTo
Tail(); |
| 166 draws->fPrimitiveProcessor.reset(primProc); | 166 draws->fPrimitiveProcessor.reset(primProc); |
| 167 draws->fPrimitiveType = primitiveType; |
| 167 this->state()->advanceToken(); | 168 this->state()->advanceToken(); |
| 168 } | 169 } |
| 169 | 170 |
| 170 void draw(const GrVertices& vertices) { | 171 void draw(const GrVertices& vertices) { |
| 171 this->vertexBatch()->fDrawArrays.tail()->fDraws.push_back(vertices); | 172 this->vertexBatch()->fDrawArrays.tail()->fDraws.push_back(vertices); |
| 172 } | 173 } |
| 173 | 174 |
| 174 void* makeVertexSpace(size_t vertexSize, int vertexCount, | 175 void* makeVertexSpace(size_t vertexSize, int vertexCount, |
| 175 const GrVertexBuffer** buffer, int* startVertex) { | 176 const GrVertexBuffer** buffer, int* startVertex) { |
| 176 return this->state()->makeVertexSpace(vertexSize, vertexCount, buffer, s
tartVertex); | 177 return this->state()->makeVertexSpace(vertexSize, vertexCount, buffer, s
tartVertex); |
| 177 } | 178 } |
| 178 | 179 |
| 179 uint16_t* makeIndexSpace(int indexCount, const GrIndexBuffer** buffer, int*
startIndex) { | 180 uint16_t* makeIndexSpace(int indexCount, const GrIndexBuffer** buffer, int*
startIndex) { |
| 180 return this->state()->makeIndexSpace(indexCount, buffer, startIndex); | 181 return this->state()->makeIndexSpace(indexCount, buffer, startIndex); |
| 181 } | 182 } |
| 182 | 183 |
| 183 /** Helpers for batches which over-allocate and then return data to the pool
. */ | 184 /** Helpers for batches which over-allocate and then return data to the pool
. */ |
| 184 void putBackIndices(int indices) { this->state()->putBackIndices(indices); } | 185 void putBackIndices(int indices) { this->state()->putBackIndices(indices); } |
| 185 void putBackVertices(int vertices, size_t vertexStride) { | 186 void putBackVertices(int vertices, size_t vertexStride) { |
| 186 this->state()->putBackVertexSpace(vertices * vertexStride); | 187 this->state()->putBackVertexSpace(vertices * vertexStride); |
| 187 } | 188 } |
| 188 | 189 |
| 189 private: | 190 private: |
| 190 GrVertexBatch* vertexBatch() { return static_cast<GrVertexBatch*>(this->batc
h()); } | 191 GrVertexBatch* vertexBatch() { return static_cast<GrVertexBatch*>(this->batc
h()); } |
| 191 typedef GrDrawBatch::Target INHERITED; | 192 typedef GrDrawBatch::Target INHERITED; |
| 192 }; | 193 }; |
| 193 | 194 |
| 194 #endif | 195 #endif |
| OLD | NEW |