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) { |
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 this->state()->advanceToken(); | 167 this->state()->advanceToken(); |
168 } | 168 } |
169 | 169 |
170 void draw(const GrVertices& vertices) { | 170 void draw(const GrMesh& mesh) { |
171 this->vertexBatch()->fDrawArrays.tail()->fDraws.push_back(vertices); | 171 this->vertexBatch()->fDrawArrays.tail()->fDraws.push_back(mesh); |
172 } | 172 } |
173 | 173 |
174 void* makeVertexSpace(size_t vertexSize, int vertexCount, | 174 void* makeVertexSpace(size_t vertexSize, int vertexCount, |
175 const GrVertexBuffer** buffer, int* startVertex) { | 175 const GrVertexBuffer** buffer, int* startVertex) { |
176 return this->state()->makeVertexSpace(vertexSize, vertexCount, buffer, s
tartVertex); | 176 return this->state()->makeVertexSpace(vertexSize, vertexCount, buffer, s
tartVertex); |
177 } | 177 } |
178 | 178 |
179 uint16_t* makeIndexSpace(int indexCount, const GrIndexBuffer** buffer, int*
startIndex) { | 179 uint16_t* makeIndexSpace(int indexCount, const GrIndexBuffer** buffer, int*
startIndex) { |
180 return this->state()->makeIndexSpace(indexCount, buffer, startIndex); | 180 return this->state()->makeIndexSpace(indexCount, buffer, startIndex); |
181 } | 181 } |
182 | 182 |
183 /** Helpers for batches which over-allocate and then return data to the pool
. */ | 183 /** Helpers for batches which over-allocate and then return data to the pool
. */ |
184 void putBackIndices(int indices) { this->state()->putBackIndices(indices); } | 184 void putBackIndices(int indices) { this->state()->putBackIndices(indices); } |
185 void putBackVertices(int vertices, size_t vertexStride) { | 185 void putBackVertices(int vertices, size_t vertexStride) { |
186 this->state()->putBackVertexSpace(vertices * vertexStride); | 186 this->state()->putBackVertexSpace(vertices * vertexStride); |
187 } | 187 } |
188 | 188 |
189 private: | 189 private: |
190 GrVertexBatch* vertexBatch() { return static_cast<GrVertexBatch*>(this->batc
h()); } | 190 GrVertexBatch* vertexBatch() { return static_cast<GrVertexBatch*>(this->batc
h()); } |
191 typedef GrDrawBatch::Target INHERITED; | 191 typedef GrDrawBatch::Target INHERITED; |
192 }; | 192 }; |
193 | 193 |
194 #endif | 194 #endif |
OLD | NEW |