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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 GrBatchToken currentToken() const { return fCurrentToken; } | 69 GrBatchToken currentToken() const { return fCurrentToken; } |
70 | 70 |
71 /** The last token flushed to all the way to the backend API. */ | 71 /** The last token flushed to all the way to the backend API. */ |
72 GrBatchToken lastFlushedToken() const { return fLastFlushedToken; } | 72 GrBatchToken lastFlushedToken() const { return fLastFlushedToken; } |
73 | 73 |
74 /** This is a magic token that can be used to indicate that an upload should
occur before | 74 /** This is a magic token that can be used to indicate that an upload should
occur before |
75 any draws for any batch in the current flush execute. */ | 75 any draws for any batch in the current flush execute. */ |
76 GrBatchToken asapToken() const { return fLastFlushedToken + 1; } | 76 GrBatchToken asapToken() const { return fLastFlushedToken + 1; } |
77 | 77 |
78 void* makeVertexSpace(size_t vertexSize, int vertexCount, | 78 void* makeVertexSpace(size_t vertexSize, int vertexCount, |
79 const GrVertexBuffer** buffer, int* startVertex); | 79 const GrBuffer** buffer, int* startVertex); |
80 uint16_t* makeIndexSpace(int indexCount, const GrIndexBuffer** buffer, int*
startIndex); | 80 uint16_t* makeIndexSpace(int indexCount, const GrBuffer** buffer, int* start
Index); |
81 | 81 |
82 /** This is called after each batch has a chance to prepare its draws and be
fore the draws | 82 /** This is called after each batch has a chance to prepare its draws and be
fore the draws |
83 are issued. */ | 83 are issued. */ |
84 void preIssueDraws() { | 84 void preIssueDraws() { |
85 fVertexPool.unmap(); | 85 fVertexPool.unmap(); |
86 fIndexPool.unmap(); | 86 fIndexPool.unmap(); |
87 int uploadCount = fAsapUploads.count(); | 87 int uploadCount = fAsapUploads.count(); |
88 for (int i = 0; i < uploadCount; i++) { | 88 for (int i = 0; i < uploadCount; i++) { |
89 fAsapUploads[i]->upload(&fUploader); | 89 fAsapUploads[i]->upload(&fUploader); |
90 } | 90 } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 GrMesh& mesh) { | 170 void draw(const GrMesh& mesh) { |
171 this->vertexBatch()->fDrawArrays.tail()->fDraws.push_back(mesh); | 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 GrBuffer** 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 GrBuffer** buffer, int* start
Index) { |
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 |