OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 "GrMSAAPathRenderer.h" | 8 #include "GrMSAAPathRenderer.h" |
9 | 9 |
10 #include "GrAuditTrail.h" | 10 #include "GrAuditTrail.h" |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 | 218 |
219 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 219 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
220 | 220 |
221 typedef GrGeometryProcessor INHERITED; | 221 typedef GrGeometryProcessor INHERITED; |
222 }; | 222 }; |
223 | 223 |
224 class MSAAPathBatch : public GrVertexBatch { | 224 class MSAAPathBatch : public GrVertexBatch { |
225 public: | 225 public: |
226 DEFINE_BATCH_CLASS_ID | 226 DEFINE_BATCH_CLASS_ID |
227 | 227 |
228 MSAAPathBatch(GrColor color, const SkPath& path, const SkMatrix& viewMatrix, | 228 MSAAPathBatch(GrColor color, const SkPath& path, const SkMatrix& viewMatrix) |
229 const SkRect& devBounds) | |
230 : INHERITED(ClassID()) | 229 : INHERITED(ClassID()) |
231 , fViewMatrix(viewMatrix) { | 230 , fViewMatrix(viewMatrix) { |
232 fPaths.emplace_back(PathInfo{color, path}); | 231 fPaths.emplace_back(PathInfo{color, path}); |
233 this->setBounds(devBounds); | 232 this->setTransformedBounds(path.getBounds(), viewMatrix, HasAABloat::kNo
, IsZeroArea::kNo); |
234 int contourCount; | 233 int contourCount; |
235 this->computeWorstCasePointCount(path, &contourCount, &fMaxLineVertices,
&fMaxQuadVertices); | 234 this->computeWorstCasePointCount(path, &contourCount, &fMaxLineVertices,
&fMaxQuadVertices); |
236 fMaxLineIndices = fMaxLineVertices * 3; | 235 fMaxLineIndices = fMaxLineVertices * 3; |
237 fMaxQuadIndices = fMaxQuadVertices * 3; | 236 fMaxQuadIndices = fMaxQuadVertices * 3; |
238 fIsIndexed = contourCount > 1; | 237 fIsIndexed = contourCount > 1; |
239 } | 238 } |
240 | 239 |
241 const char* name() const override { return "MSAAPathBatch"; } | 240 const char* name() const override { return "MSAAPathBatch"; } |
242 | 241 |
243 void computePipelineOptimizations(GrInitInvariantOutput* color, | 242 void computePipelineOptimizations(GrInitInvariantOutput* color, |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 if (!fViewMatrix.cheapEqualTo(that->fViewMatrix)) { | 452 if (!fViewMatrix.cheapEqualTo(that->fViewMatrix)) { |
454 return false; | 453 return false; |
455 } | 454 } |
456 | 455 |
457 if ((fMaxLineIndices + that->fMaxLineIndices > SK_MaxU16) || | 456 if ((fMaxLineIndices + that->fMaxLineIndices > SK_MaxU16) || |
458 (fMaxQuadIndices + that->fMaxQuadIndices > SK_MaxU16)) { | 457 (fMaxQuadIndices + that->fMaxQuadIndices > SK_MaxU16)) { |
459 return false; | 458 return false; |
460 } | 459 } |
461 | 460 |
462 fPaths.push_back_n(that->fPaths.count(), that->fPaths.begin()); | 461 fPaths.push_back_n(that->fPaths.count(), that->fPaths.begin()); |
463 this->joinBounds(that->bounds()); | 462 this->joinBounds(*that); |
464 fIsIndexed = true; | 463 fIsIndexed = true; |
465 fMaxLineVertices += that->fMaxLineVertices; | 464 fMaxLineVertices += that->fMaxLineVertices; |
466 fMaxQuadVertices += that->fMaxQuadVertices; | 465 fMaxQuadVertices += that->fMaxQuadVertices; |
467 fMaxLineIndices += that->fMaxLineIndices; | 466 fMaxLineIndices += that->fMaxLineIndices; |
468 fMaxQuadIndices += that->fMaxQuadIndices; | 467 fMaxQuadIndices += that->fMaxQuadIndices; |
469 return true; | 468 return true; |
470 } | 469 } |
471 | 470 |
472 bool createGeom(MSAALineVertices& lines, | 471 bool createGeom(MSAALineVertices& lines, |
473 MSAAQuadVertices& quads, | 472 MSAAQuadVertices& quads, |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(pa
int)); | 660 GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(pa
int)); |
662 pipelineBuilder.setDrawFace(drawFace[p]); | 661 pipelineBuilder.setDrawFace(drawFace[p]); |
663 if (passes[p]) { | 662 if (passes[p]) { |
664 pipelineBuilder.setUserStencil(passes[p]); | 663 pipelineBuilder.setUserStencil(passes[p]); |
665 } else { | 664 } else { |
666 pipelineBuilder.setUserStencil(userStencilSettings); | 665 pipelineBuilder.setUserStencil(userStencilSettings); |
667 } | 666 } |
668 | 667 |
669 drawContext->drawBatch(pipelineBuilder, clip, batch); | 668 drawContext->drawBatch(pipelineBuilder, clip, batch); |
670 } else { | 669 } else { |
671 SkAutoTUnref<MSAAPathBatch> batch(new MSAAPathBatch(paint.getColor()
, path, viewMatrix, | 670 SkAutoTUnref<MSAAPathBatch> batch(new MSAAPathBatch(paint.getColor()
, path, |
672 devBounds)); | 671 viewMatrix)); |
673 if (!batch->isValid()) { | 672 if (!batch->isValid()) { |
674 return false; | 673 return false; |
675 } | 674 } |
676 | 675 |
677 GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(pa
int)); | 676 GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(pa
int)); |
678 pipelineBuilder.setDrawFace(drawFace[p]); | 677 pipelineBuilder.setDrawFace(drawFace[p]); |
679 if (passes[p]) { | 678 if (passes[p]) { |
680 pipelineBuilder.setUserStencil(passes[p]); | 679 pipelineBuilder.setUserStencil(passes[p]); |
681 } else { | 680 } else { |
682 pipelineBuilder.setUserStencil(userStencilSettings); | 681 pipelineBuilder.setUserStencil(userStencilSettings); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 | 724 |
726 GrPaint paint; | 725 GrPaint paint; |
727 paint.setXPFactory(GrDisableColorXPFactory::Make()); | 726 paint.setXPFactory(GrDisableColorXPFactory::Make()); |
728 paint.setAntiAlias(args.fIsAA); | 727 paint.setAntiAlias(args.fIsAA); |
729 | 728 |
730 this->internalDrawPath(args.fDrawContext, paint, &GrUserStencilSettings::kUn
used, *args.fClip, | 729 this->internalDrawPath(args.fDrawContext, paint, &GrUserStencilSettings::kUn
used, *args.fClip, |
731 *args.fViewMatrix, *args.fShape, true); | 730 *args.fViewMatrix, *args.fShape, true); |
732 } | 731 } |
733 | 732 |
734 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 733 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
OLD | NEW |