| 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 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 int fMaxQuadVertices; | 551 int fMaxQuadVertices; |
| 552 int fMaxLineIndices; | 552 int fMaxLineIndices; |
| 553 int fMaxQuadIndices; | 553 int fMaxQuadIndices; |
| 554 bool fIsIndexed; | 554 bool fIsIndexed; |
| 555 | 555 |
| 556 typedef GrVertexBatch INHERITED; | 556 typedef GrVertexBatch INHERITED; |
| 557 }; | 557 }; |
| 558 | 558 |
| 559 bool GrMSAAPathRenderer::internalDrawPath(GrDrawContext* drawContext, | 559 bool GrMSAAPathRenderer::internalDrawPath(GrDrawContext* drawContext, |
| 560 const GrPaint& paint, | 560 const GrPaint& paint, |
| 561 const GrUserStencilSettings* userStenc
ilSettings, | 561 const GrUserStencilSettings& userStenc
ilSettings, |
| 562 const GrClip& clip, | 562 const GrClip& clip, |
| 563 const SkMatrix& viewMatrix, | 563 const SkMatrix& viewMatrix, |
| 564 const GrShape& shape, | 564 const GrShape& shape, |
| 565 bool stencilOnly) { | 565 bool stencilOnly) { |
| 566 SkASSERT(shape.style().isSimpleFill()); | 566 SkASSERT(shape.style().isSimpleFill()); |
| 567 SkPath path; | 567 SkPath path; |
| 568 shape.asPath(&path); | 568 shape.asPath(&path); |
| 569 | 569 |
| 570 static const int kMaxNumPasses = 2; | 570 static const int kMaxNumPasses = 2; |
| 571 | 571 |
| 572 int passCount = 0; | 572 int passCount = 0; |
| 573 const GrUserStencilSettings* passes[kMaxNumPasses]; | 573 const GrUserStencilSettings* passes[kMaxNumPasses]; |
| 574 bool reverse = false; | 574 bool reverse = false; |
| 575 bool lastPassIsBounds; | 575 bool lastPassIsBounds; |
| 576 | 576 |
| 577 if (single_pass_shape(shape)) { | 577 if (single_pass_shape(shape)) { |
| 578 passCount = 1; | 578 passCount = 1; |
| 579 if (stencilOnly) { | 579 if (stencilOnly) { |
| 580 passes[0] = &gDirectToStencil; | 580 passes[0] = &gDirectToStencil; |
| 581 } else { | 581 } else { |
| 582 passes[0] = userStencilSettings; | 582 passes[0] = &userStencilSettings; |
| 583 } | 583 } |
| 584 lastPassIsBounds = false; | 584 lastPassIsBounds = false; |
| 585 } else { | 585 } else { |
| 586 switch (path.getFillType()) { | 586 switch (path.getFillType()) { |
| 587 case SkPath::kInverseEvenOdd_FillType: | 587 case SkPath::kInverseEvenOdd_FillType: |
| 588 reverse = true; | 588 reverse = true; |
| 589 // fallthrough | 589 // fallthrough |
| 590 case SkPath::kEvenOdd_FillType: | 590 case SkPath::kEvenOdd_FillType: |
| 591 passes[0] = &gEOStencilPass; | 591 passes[0] = &gEOStencilPass; |
| 592 if (stencilOnly) { | 592 if (stencilOnly) { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 "GrMSAAPathRenderer::onDrawPath"); | 692 "GrMSAAPathRenderer::onDrawPath"); |
| 693 SkTLazy<GrShape> tmpShape; | 693 SkTLazy<GrShape> tmpShape; |
| 694 const GrShape* shape = args.fShape; | 694 const GrShape* shape = args.fShape; |
| 695 if (shape->style().applies()) { | 695 if (shape->style().applies()) { |
| 696 SkScalar styleScale = GrStyle::MatrixToScaleFactor(*args.fViewMatrix); | 696 SkScalar styleScale = GrStyle::MatrixToScaleFactor(*args.fViewMatrix); |
| 697 tmpShape.init(args.fShape->applyStyle(GrStyle::Apply::kPathEffectAndStro
keRec, styleScale)); | 697 tmpShape.init(args.fShape->applyStyle(GrStyle::Apply::kPathEffectAndStro
keRec, styleScale)); |
| 698 shape = tmpShape.get(); | 698 shape = tmpShape.get(); |
| 699 } | 699 } |
| 700 return this->internalDrawPath(args.fDrawContext, | 700 return this->internalDrawPath(args.fDrawContext, |
| 701 *args.fPaint, | 701 *args.fPaint, |
| 702 args.fUserStencilSettings, | 702 *args.fUserStencilSettings, |
| 703 *args.fClip, | 703 *args.fClip, |
| 704 *args.fViewMatrix, | 704 *args.fViewMatrix, |
| 705 *shape, | 705 *shape, |
| 706 false); | 706 false); |
| 707 } | 707 } |
| 708 | 708 |
| 709 void GrMSAAPathRenderer::onStencilPath(const StencilPathArgs& args) { | 709 void GrMSAAPathRenderer::onStencilPath(const StencilPathArgs& args) { |
| 710 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), | 710 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), |
| 711 "GrMSAAPathRenderer::onStencilPath"); | 711 "GrMSAAPathRenderer::onStencilPath"); |
| 712 SkASSERT(args.fShape->style().isSimpleFill()); | 712 SkASSERT(args.fShape->style().isSimpleFill()); |
| 713 SkASSERT(!args.fShape->mayBeInverseFilledAfterStyling()); | 713 SkASSERT(!args.fShape->mayBeInverseFilledAfterStyling()); |
| 714 | 714 |
| 715 GrPaint paint; | 715 GrPaint paint; |
| 716 paint.setXPFactory(GrDisableColorXPFactory::Make()); | 716 paint.setXPFactory(GrDisableColorXPFactory::Make()); |
| 717 paint.setAntiAlias(args.fIsAA); | 717 paint.setAntiAlias(args.fIsAA); |
| 718 | 718 |
| 719 this->internalDrawPath(args.fDrawContext, paint, &GrUserStencilSettings::kUn
used, *args.fClip, | 719 this->internalDrawPath(args.fDrawContext, paint, GrUserStencilSettings::kUnu
sed, *args.fClip, |
| 720 *args.fViewMatrix, *args.fShape, true); | 720 *args.fViewMatrix, *args.fShape, true); |
| 721 } | 721 } |
| 722 | 722 |
| 723 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 723 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| OLD | NEW |