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, this->pipeline()); | |
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 21 matching lines...) Expand all Loading... |
305 } | 303 } |
306 } else { | 304 } else { |
307 if (isIndexed) { | 305 if (isIndexed) { |
308 maxIndices = 3 * maxVertices; | 306 maxIndices = 3 * maxVertices; |
309 primitiveType = kTriangles_GrPrimitiveType; | 307 primitiveType = kTriangles_GrPrimitiveType; |
310 } else { | 308 } else { |
311 primitiveType = kTriangleFan_GrPrimitiveType; | 309 primitiveType = kTriangleFan_GrPrimitiveType; |
312 } | 310 } |
313 } | 311 } |
314 | 312 |
| 313 target->initDraw(gp, primitiveType); |
| 314 |
315 // allocate vertex / index buffers | 315 // allocate vertex / index buffers |
316 const GrVertexBuffer* vertexBuffer; | 316 const GrVertexBuffer* vertexBuffer; |
317 int firstVertex; | 317 int firstVertex; |
318 | 318 |
319 void* verts = target->makeVertexSpace(vertexStride, maxVertices, | 319 void* verts = target->makeVertexSpace(vertexStride, maxVertices, |
320 &vertexBuffer, &firstVertex); | 320 &vertexBuffer, &firstVertex); |
321 | 321 |
322 if (!verts) { | 322 if (!verts) { |
323 SkDebugf("Could not allocate vertices\n"); | 323 SkDebugf("Could not allocate vertices\n"); |
324 return; | 324 return; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 GrVertices vertices; |
366 if (isIndexed) { | 366 if (isIndexed) { |
367 vertices.initIndexed(primitiveType, vertexBuffer, indexBuffer, first
Vertex, firstIndex, | 367 vertices.initIndexed(vertexBuffer, indexBuffer, firstVertex, firstIn
dex, |
368 vertexOffset, indexOffset); | 368 vertexOffset, indexOffset); |
369 } else { | 369 } else { |
370 vertices.init(primitiveType, vertexBuffer, firstVertex, vertexOffset
); | 370 vertices.init(vertexBuffer, firstVertex, vertexOffset); |
371 } | 371 } |
372 target->draw(vertices); | 372 target->draw(vertices); |
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 |
(...skipping 388 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 |