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 "GrBatch.h" | 10 #include "GrBatch.h" |
11 #include "GrBatchTarget.h" | 11 #include "GrBatchTarget.h" |
12 #include "GrBufferAllocPool.h" | 12 #include "GrBufferAllocPool.h" |
13 #include "GrContext.h" | 13 #include "GrContext.h" |
14 #include "GrDefaultGeoProcFactory.h" | 14 #include "GrDefaultGeoProcFactory.h" |
15 #include "GrPathUtils.h" | 15 #include "GrPathUtils.h" |
16 #include "GrPipelineBuilder.h" | 16 #include "GrPipelineBuilder.h" |
17 #include "GrVertexBuffer.h" | 17 #include "GrVertices.h" |
18 #include "SkGeometry.h" | 18 #include "SkGeometry.h" |
19 #include "SkString.h" | 19 #include "SkString.h" |
20 #include "SkStrokeRec.h" | 20 #include "SkStrokeRec.h" |
21 #include "SkTLazy.h" | 21 #include "SkTLazy.h" |
22 #include "SkTraceEvent.h" | 22 #include "SkTraceEvent.h" |
23 | 23 |
24 GrDefaultPathRenderer::GrDefaultPathRenderer(bool separateStencilSupport, | 24 GrDefaultPathRenderer::GrDefaultPathRenderer(bool separateStencilSupport, |
25 bool stencilWrapOpsSupport) | 25 bool stencilWrapOpsSupport) |
26 : fSeparateStencil(separateStencilSupport) | 26 : fSeparateStencil(separateStencilSupport) |
27 , fStencilWrapOps(stencilWrapOpsSupport) { | 27 , fStencilWrapOps(stencilWrapOpsSupport) { |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 primitiveType = kTriangles_GrPrimitiveType; | 312 primitiveType = kTriangles_GrPrimitiveType; |
313 } else { | 313 } else { |
314 primitiveType = kTriangleFan_GrPrimitiveType; | 314 primitiveType = kTriangleFan_GrPrimitiveType; |
315 } | 315 } |
316 } | 316 } |
317 | 317 |
318 // allocate vertex / index buffers | 318 // allocate vertex / index buffers |
319 const GrVertexBuffer* vertexBuffer; | 319 const GrVertexBuffer* vertexBuffer; |
320 int firstVertex; | 320 int firstVertex; |
321 | 321 |
322 void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride, | 322 void* verts = batchTarget->vertexPool()->makeSpace(vertexStride, |
323 maxVertices, | 323 maxVertices, |
324 &vertexBuffer, | 324 &vertexBuffer, |
325 &firstVertex); | 325 &firstVertex); |
326 | 326 |
327 if (!vertices) { | 327 if (!verts) { |
328 SkDebugf("Could not allocate vertices\n"); | 328 SkDebugf("Could not allocate vertices\n"); |
329 return; | 329 return; |
330 } | 330 } |
331 | 331 |
332 const GrIndexBuffer* indexBuffer = NULL; | 332 const GrIndexBuffer* indexBuffer = NULL; |
333 int firstIndex = 0; | 333 int firstIndex = 0; |
334 | 334 |
335 void* indices = NULL; | 335 void* indices = NULL; |
336 if (isIndexed) { | 336 if (isIndexed) { |
337 indices = batchTarget->indexPool()->makeSpace(maxIndices, | 337 indices = batchTarget->indexPool()->makeSpace(maxIndices, |
338 &indexBuffer, | 338 &indexBuffer, |
339 &firstIndex); | 339 &firstIndex); |
340 | 340 |
341 if (!indices) { | 341 if (!indices) { |
342 SkDebugf("Could not allocate indices\n"); | 342 SkDebugf("Could not allocate indices\n"); |
343 return; | 343 return; |
344 } | 344 } |
345 } | 345 } |
346 | 346 |
347 // fill buffers | 347 // fill buffers |
348 int vertexOffset = 0; | 348 int vertexOffset = 0; |
349 int indexOffset = 0; | 349 int indexOffset = 0; |
350 for (int i = 0; i < instanceCount; i++) { | 350 for (int i = 0; i < instanceCount; i++) { |
351 Geometry& args = fGeoData[i]; | 351 Geometry& args = fGeoData[i]; |
352 | 352 |
353 int vertexCnt = 0; | 353 int vertexCnt = 0; |
354 int indexCnt = 0; | 354 int indexCnt = 0; |
355 if (!this->createGeom(vertices, | 355 if (!this->createGeom(verts, |
356 vertexOffset, | 356 vertexOffset, |
357 indices, | 357 indices, |
358 indexOffset, | 358 indexOffset, |
359 &vertexCnt, | 359 &vertexCnt, |
360 &indexCnt, | 360 &indexCnt, |
361 args.fPath, | 361 args.fPath, |
362 args.fTolerance, | 362 args.fTolerance, |
363 isIndexed)) { | 363 isIndexed)) { |
364 return; | 364 return; |
365 } | 365 } |
366 | 366 |
367 vertexOffset += vertexCnt; | 367 vertexOffset += vertexCnt; |
368 indexOffset += indexCnt; | 368 indexOffset += indexCnt; |
369 SkASSERT(vertexOffset <= maxVertices && indexOffset <= maxIndices); | 369 SkASSERT(vertexOffset <= maxVertices && indexOffset <= maxIndices); |
370 } | 370 } |
371 | 371 |
372 GrDrawTarget::DrawInfo drawInfo; | 372 GrVertices vertices; |
373 if (isIndexed) { | 373 if (isIndexed) { |
374 drawInfo.initIndexed(primitiveType, vertexBuffer, indexBuffer, first
Vertex, firstIndex, | 374 vertices.initIndexed(primitiveType, vertexBuffer, indexBuffer, first
Vertex, firstIndex, |
375 vertexOffset, indexOffset); | 375 vertexOffset, indexOffset); |
376 } else { | 376 } else { |
377 drawInfo.init(primitiveType, vertexBuffer, firstVertex, vertexOffset
); | 377 vertices.init(primitiveType, vertexBuffer, firstVertex, vertexOffset
); |
378 } | 378 } |
379 batchTarget->draw(drawInfo); | 379 batchTarget->draw(vertices); |
380 | 380 |
381 // put back reserves | 381 // put back reserves |
382 batchTarget->putBackIndices((size_t)(maxIndices - indexOffset)); | 382 batchTarget->putBackIndices((size_t)(maxIndices - indexOffset)); |
383 batchTarget->putBackVertices((size_t)(maxVertices - vertexOffset), (size
_t)vertexStride); | 383 batchTarget->putBackVertices((size_t)(maxVertices - vertexOffset), (size
_t)vertexStride); |
384 } | 384 } |
385 | 385 |
386 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 386 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
387 | 387 |
388 private: | 388 private: |
389 DefaultPathBatch(const Geometry& geometry, uint8_t coverage, const SkMatrix&
viewMatrix, | 389 DefaultPathBatch(const Geometry& geometry, uint8_t coverage, const SkMatrix&
viewMatrix, |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 | 741 |
742 void GrDefaultPathRenderer::onStencilPath(GrDrawTarget* target, | 742 void GrDefaultPathRenderer::onStencilPath(GrDrawTarget* target, |
743 GrPipelineBuilder* pipelineBuilder, | 743 GrPipelineBuilder* pipelineBuilder, |
744 const SkMatrix& viewMatrix, | 744 const SkMatrix& viewMatrix, |
745 const SkPath& path, | 745 const SkPath& path, |
746 const GrStrokeInfo& stroke) { | 746 const GrStrokeInfo& stroke) { |
747 SkASSERT(SkPath::kInverseEvenOdd_FillType != path.getFillType()); | 747 SkASSERT(SkPath::kInverseEvenOdd_FillType != path.getFillType()); |
748 SkASSERT(SkPath::kInverseWinding_FillType != path.getFillType()); | 748 SkASSERT(SkPath::kInverseWinding_FillType != path.getFillType()); |
749 this->internalDrawPath(target, pipelineBuilder, GrColor_WHITE, viewMatrix, p
ath, stroke, true); | 749 this->internalDrawPath(target, pipelineBuilder, GrColor_WHITE, viewMatrix, p
ath, stroke, true); |
750 } | 750 } |
OLD | NEW |