| 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" |
| 11 #include "GrBatchTest.h" | 11 #include "GrBatchTest.h" |
| 12 #include "GrContext.h" | 12 #include "GrContext.h" |
| 13 #include "GrDefaultGeoProcFactory.h" | 13 #include "GrDefaultGeoProcFactory.h" |
| 14 #include "GrMesh.h" |
| 14 #include "GrPathUtils.h" | 15 #include "GrPathUtils.h" |
| 15 #include "GrPipelineBuilder.h" | 16 #include "GrPipelineBuilder.h" |
| 16 #include "GrVertices.h" | |
| 17 #include "SkGeometry.h" | 17 #include "SkGeometry.h" |
| 18 #include "SkString.h" | 18 #include "SkString.h" |
| 19 #include "SkStrokeRec.h" | 19 #include "SkStrokeRec.h" |
| 20 #include "SkTLazy.h" | 20 #include "SkTLazy.h" |
| 21 #include "SkTraceEvent.h" | 21 #include "SkTraceEvent.h" |
| 22 | 22 |
| 23 #include "batches/GrRectBatchFactory.h" | 23 #include "batches/GrRectBatchFactory.h" |
| 24 #include "batches/GrVertexBatch.h" | 24 #include "batches/GrVertexBatch.h" |
| 25 | 25 |
| 26 GrDefaultPathRenderer::GrDefaultPathRenderer(bool separateStencilSupport, | 26 GrDefaultPathRenderer::GrDefaultPathRenderer(bool separateStencilSupport, |
| (...skipping 235 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, this->pipeline()); | 272 target->initDraw(gp); |
| 273 | 273 |
| 274 int instanceCount = fGeoData.count(); | 274 int instanceCount = fGeoData.count(); |
| 275 | 275 |
| 276 // compute number of vertices | 276 // compute number of vertices |
| 277 int maxVertices = 0; | 277 int maxVertices = 0; |
| 278 | 278 |
| 279 // We will use index buffers if we have multiple paths or one path with
multiple contours | 279 // We will use index buffers if we have multiple paths or one path with
multiple contours |
| 280 bool isIndexed = instanceCount > 1; | 280 bool isIndexed = instanceCount > 1; |
| 281 for (int i = 0; i < instanceCount; i++) { | 281 for (int i = 0; i < instanceCount; i++) { |
| 282 const Geometry& args = fGeoData[i]; | 282 const Geometry& args = fGeoData[i]; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 args.fTolerance, | 355 args.fTolerance, |
| 356 isIndexed)) { | 356 isIndexed)) { |
| 357 return; | 357 return; |
| 358 } | 358 } |
| 359 | 359 |
| 360 vertexOffset += vertexCnt; | 360 vertexOffset += vertexCnt; |
| 361 indexOffset += indexCnt; | 361 indexOffset += indexCnt; |
| 362 SkASSERT(vertexOffset <= maxVertices && indexOffset <= maxIndices); | 362 SkASSERT(vertexOffset <= maxVertices && indexOffset <= maxIndices); |
| 363 } | 363 } |
| 364 | 364 |
| 365 GrVertices vertices; | 365 GrMesh mesh; |
| 366 if (isIndexed) { | 366 if (isIndexed) { |
| 367 vertices.initIndexed(primitiveType, vertexBuffer, indexBuffer, first
Vertex, firstIndex, | 367 mesh.initIndexed(primitiveType, vertexBuffer, indexBuffer, firstVert
ex, firstIndex, |
| 368 vertexOffset, indexOffset); | 368 vertexOffset, indexOffset); |
| 369 } else { | 369 } else { |
| 370 vertices.init(primitiveType, vertexBuffer, firstVertex, vertexOffset
); | 370 mesh.init(primitiveType, vertexBuffer, firstVertex, vertexOffset); |
| 371 } | 371 } |
| 372 target->draw(vertices); | 372 target->draw(mesh); |
| 373 | 373 |
| 374 // put back reserves | 374 // put back reserves |
| 375 target->putBackIndices((size_t)(maxIndices - indexOffset)); | 375 target->putBackIndices((size_t)(maxIndices - indexOffset)); |
| 376 target->putBackVertices((size_t)(maxVertices - vertexOffset), (size_t)ve
rtexStride); | 376 target->putBackVertices((size_t)(maxVertices - vertexOffset), (size_t)ve
rtexStride); |
| 377 } | 377 } |
| 378 | 378 |
| 379 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 379 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
| 380 | 380 |
| 381 DefaultPathBatch(const Geometry& geometry, uint8_t coverage, const SkMatrix&
viewMatrix, | 381 DefaultPathBatch(const Geometry& geometry, uint8_t coverage, const SkMatrix&
viewMatrix, |
| 382 bool isHairline, const SkRect& devBounds) | 382 bool isHairline, const SkRect& devBounds) |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 geometry.fColor = color; | 769 geometry.fColor = color; |
| 770 geometry.fPath = path; | 770 geometry.fPath = path; |
| 771 geometry.fTolerance = srcSpaceTol; | 771 geometry.fTolerance = srcSpaceTol; |
| 772 | 772 |
| 773 viewMatrix.mapRect(&bounds); | 773 viewMatrix.mapRect(&bounds); |
| 774 uint8_t coverage = GrRandomCoverage(random); | 774 uint8_t coverage = GrRandomCoverage(random); |
| 775 return DefaultPathBatch::Create(geometry, coverage, viewMatrix, true, bounds
); | 775 return DefaultPathBatch::Create(geometry, coverage, viewMatrix, true, bounds
); |
| 776 } | 776 } |
| 777 | 777 |
| 778 #endif | 778 #endif |
| OLD | NEW |