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 #include "GrDrawVerticesBatch.h" | 8 #include "GrDrawVerticesBatch.h" |
9 | 9 |
10 #include "GrBatchTarget.h" | 10 #include "GrBatchTarget.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 vertices.initIndexed(this->primitiveType(), vertexBuffer, indexBuffer, f
irstVertex, | 177 vertices.initIndexed(this->primitiveType(), vertexBuffer, indexBuffer, f
irstVertex, |
178 firstIndex, this->vertexCount(), this->indexCount()
); | 178 firstIndex, this->vertexCount(), this->indexCount()
); |
179 | 179 |
180 } else { | 180 } else { |
181 vertices.init(this->primitiveType(), vertexBuffer, firstVertex, this->ve
rtexCount()); | 181 vertices.init(this->primitiveType(), vertexBuffer, firstVertex, this->ve
rtexCount()); |
182 } | 182 } |
183 batchTarget->draw(vertices); | 183 batchTarget->draw(vertices); |
184 } | 184 } |
185 | 185 |
186 bool GrDrawVerticesBatch::onCombineIfPossible(GrBatch* t, const GrCaps& caps) { | 186 bool GrDrawVerticesBatch::onCombineIfPossible(GrBatch* t, const GrCaps& caps) { |
187 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *t->pipeline(
), t->bounds(), | 187 GrDrawVerticesBatch* that = t->cast<GrDrawVerticesBatch>(); |
188 caps)) { | 188 |
| 189 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pipeli
ne(), |
| 190 that->bounds(), caps)) { |
189 return false; | 191 return false; |
190 } | 192 } |
191 | 193 |
192 GrDrawVerticesBatch* that = t->cast<GrDrawVerticesBatch>(); | |
193 | |
194 if (!this->batchablePrimitiveType() || this->primitiveType() != that->primit
iveType()) { | 194 if (!this->batchablePrimitiveType() || this->primitiveType() != that->primit
iveType()) { |
195 return false; | 195 return false; |
196 } | 196 } |
197 | 197 |
198 SkASSERT(this->usesLocalCoords() == that->usesLocalCoords()); | 198 SkASSERT(this->usesLocalCoords() == that->usesLocalCoords()); |
199 | 199 |
200 // We currently use a uniform viewmatrix for this batch | 200 // We currently use a uniform viewmatrix for this batch |
201 if (!this->viewMatrix().cheapEqualTo(that->viewMatrix())) { | 201 if (!this->viewMatrix().cheapEqualTo(that->viewMatrix())) { |
202 return false; | 202 return false; |
203 } | 203 } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 if (hasColors) { | 288 if (hasColors) { |
289 colors->push_back(GrRandomColor(random)); | 289 colors->push_back(GrRandomColor(random)); |
290 } | 290 } |
291 if (hasIndices) { | 291 if (hasIndices) { |
292 SkASSERT(maxVertex <= SK_MaxU16); | 292 SkASSERT(maxVertex <= SK_MaxU16); |
293 indices->push_back(random->nextULessThan((uint16_t)maxVertex)); | 293 indices->push_back(random->nextULessThan((uint16_t)maxVertex)); |
294 } | 294 } |
295 } | 295 } |
296 } | 296 } |
297 | 297 |
298 BATCH_TEST_DEFINE(VerticesBatch) { | 298 DRAW_BATCH_TEST_DEFINE(VerticesBatch) { |
299 GrPrimitiveType type = GrPrimitiveType(random->nextULessThan(kLast_GrPrimiti
veType + 1)); | 299 GrPrimitiveType type = GrPrimitiveType(random->nextULessThan(kLast_GrPrimiti
veType + 1)); |
300 uint32_t primitiveCount = random->nextRangeU(1, 100); | 300 uint32_t primitiveCount = random->nextRangeU(1, 100); |
301 | 301 |
302 // TODO make 'sensible' indexbuffers | 302 // TODO make 'sensible' indexbuffers |
303 SkTArray<SkPoint> positions; | 303 SkTArray<SkPoint> positions; |
304 SkTArray<SkPoint> texCoords; | 304 SkTArray<SkPoint> texCoords; |
305 SkTArray<GrColor> colors; | 305 SkTArray<GrColor> colors; |
306 SkTArray<uint16_t> indices; | 306 SkTArray<uint16_t> indices; |
307 | 307 |
308 bool hasTexCoords = random->nextBool(); | 308 bool hasTexCoords = random->nextBool(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 geometry.fColor = GrRandomColor(random); | 340 geometry.fColor = GrRandomColor(random); |
341 return GrDrawVerticesBatch::Create(geometry, type, viewMatrix, | 341 return GrDrawVerticesBatch::Create(geometry, type, viewMatrix, |
342 positions.begin(), vertexCount, | 342 positions.begin(), vertexCount, |
343 indices.begin(), hasIndices ? vertexCount
: 0, | 343 indices.begin(), hasIndices ? vertexCount
: 0, |
344 colors.begin(), | 344 colors.begin(), |
345 texCoords.begin(), | 345 texCoords.begin(), |
346 bounds); | 346 bounds); |
347 } | 347 } |
348 | 348 |
349 #endif | 349 #endif |
OLD | NEW |