OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "GrDefaultPathRenderer.h" | 8 #include "GrDefaultPathRenderer.h" |
9 | 9 |
10 #include "GrBatchFlushState.h" | 10 #include "GrBatchFlushState.h" |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 } | 262 } |
263 LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUseP
osition_Type : | 263 LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUseP
osition_Type : |
264 LocalCoords::kUnus
ed_Type); | 264 LocalCoords::kUnus
ed_Type); |
265 gp.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoord
s, | 265 gp.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoord
s, |
266 this->viewMatrix())); | 266 this->viewMatrix())); |
267 } | 267 } |
268 | 268 |
269 size_t vertexStride = gp->getVertexStride(); | 269 size_t vertexStride = gp->getVertexStride(); |
270 SkASSERT(vertexStride == sizeof(SkPoint)); | 270 SkASSERT(vertexStride == sizeof(SkPoint)); |
271 | 271 |
272 target->initDraw(gp); | |
273 | |
274 int instanceCount = fGeoData.count(); | 272 int instanceCount = fGeoData.count(); |
275 | 273 |
276 // compute number of vertices | 274 // compute number of vertices |
277 int maxVertices = 0; | 275 int maxVertices = 0; |
278 | 276 |
279 // We will use index buffers if we have multiple paths or one path with
multiple contours | 277 // We will use index buffers if we have multiple paths or one path with
multiple contours |
280 bool isIndexed = instanceCount > 1; | 278 bool isIndexed = instanceCount > 1; |
281 for (int i = 0; i < instanceCount; i++) { | 279 for (int i = 0; i < instanceCount; i++) { |
282 const Geometry& args = fGeoData[i]; | 280 const Geometry& args = fGeoData[i]; |
283 | 281 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 SkASSERT(vertexOffset <= maxVertices && indexOffset <= maxIndices); | 360 SkASSERT(vertexOffset <= maxVertices && indexOffset <= maxIndices); |
363 } | 361 } |
364 | 362 |
365 GrMesh mesh; | 363 GrMesh mesh; |
366 if (isIndexed) { | 364 if (isIndexed) { |
367 mesh.initIndexed(primitiveType, vertexBuffer, indexBuffer, firstVert
ex, firstIndex, | 365 mesh.initIndexed(primitiveType, vertexBuffer, indexBuffer, firstVert
ex, firstIndex, |
368 vertexOffset, indexOffset); | 366 vertexOffset, indexOffset); |
369 } else { | 367 } else { |
370 mesh.init(primitiveType, vertexBuffer, firstVertex, vertexOffset); | 368 mesh.init(primitiveType, vertexBuffer, firstVertex, vertexOffset); |
371 } | 369 } |
372 target->draw(mesh); | 370 target->draw(gp, mesh); |
373 | 371 |
374 // put back reserves | 372 // put back reserves |
375 target->putBackIndices((size_t)(maxIndices - indexOffset)); | 373 target->putBackIndices((size_t)(maxIndices - indexOffset)); |
376 target->putBackVertices((size_t)(maxVertices - vertexOffset), (size_t)ve
rtexStride); | 374 target->putBackVertices((size_t)(maxVertices - vertexOffset), (size_t)ve
rtexStride); |
377 } | 375 } |
378 | 376 |
379 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 377 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
380 | 378 |
381 DefaultPathBatch(const Geometry& geometry, uint8_t coverage, const SkMatrix&
viewMatrix, | 379 DefaultPathBatch(const Geometry& geometry, uint8_t coverage, const SkMatrix&
viewMatrix, |
382 bool isHairline, const SkRect& devBounds) | 380 bool isHairline, const SkRect& devBounds) |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 geometry.fColor = color; | 767 geometry.fColor = color; |
770 geometry.fPath = path; | 768 geometry.fPath = path; |
771 geometry.fTolerance = srcSpaceTol; | 769 geometry.fTolerance = srcSpaceTol; |
772 | 770 |
773 viewMatrix.mapRect(&bounds); | 771 viewMatrix.mapRect(&bounds); |
774 uint8_t coverage = GrRandomCoverage(random); | 772 uint8_t coverage = GrRandomCoverage(random); |
775 return DefaultPathBatch::Create(geometry, coverage, viewMatrix, true, bounds
); | 773 return DefaultPathBatch::Create(geometry, coverage, viewMatrix, true, bounds
); |
776 } | 774 } |
777 | 775 |
778 #endif | 776 #endif |
OLD | NEW |