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 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 GrColor color, | |
564 const SkMatrix& viewMatrix, | 563 const SkMatrix& viewMatrix, |
565 const GrShape& shape, | 564 const GrShape& shape, |
566 bool stencilOnly) { | 565 bool stencilOnly) { |
567 SkASSERT(shape.style().isSimpleFill()); | 566 SkASSERT(shape.style().isSimpleFill()); |
568 SkPath path; | 567 SkPath path; |
569 shape.asPath(&path); | 568 shape.asPath(&path); |
570 | 569 |
571 int passCount = 0; | 570 int passCount = 0; |
572 const GrUserStencilSettings* passes[3]; | 571 const GrUserStencilSettings* passes[3]; |
573 GrPipelineBuilder::DrawFace drawFace[3]; | 572 GrPipelineBuilder::DrawFace drawFace[3]; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 if (!viewMatrix.invert(&localMatrix)) { | 648 if (!viewMatrix.invert(&localMatrix)) { |
650 return false; | 649 return false; |
651 } | 650 } |
652 } | 651 } |
653 } else { | 652 } else { |
654 bounds = path.getBounds(); | 653 bounds = path.getBounds(); |
655 } | 654 } |
656 const SkMatrix& viewM = (reverse && viewMatrix.hasPerspective()) ? S
kMatrix::I() : | 655 const SkMatrix& viewM = (reverse && viewMatrix.hasPerspective()) ? S
kMatrix::I() : |
657 v
iewMatrix; | 656 v
iewMatrix; |
658 SkAutoTUnref<GrDrawBatch> batch( | 657 SkAutoTUnref<GrDrawBatch> batch( |
659 GrRectBatchFactory::CreateNonAAFill(color, viewM, bounds, nu
llptr, | 658 GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewM,
bounds, nullptr, |
660 &localMatrix)); | 659 &localMatrix)); |
661 | 660 |
662 GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(pa
int)); | 661 GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(pa
int)); |
663 pipelineBuilder.setDrawFace(drawFace[p]); | 662 pipelineBuilder.setDrawFace(drawFace[p]); |
664 if (passes[p]) { | 663 if (passes[p]) { |
665 pipelineBuilder.setUserStencil(passes[p]); | 664 pipelineBuilder.setUserStencil(passes[p]); |
666 } else { | 665 } else { |
667 pipelineBuilder.setUserStencil(userStencilSettings); | 666 pipelineBuilder.setUserStencil(userStencilSettings); |
668 } | 667 } |
669 | 668 |
670 drawContext->drawBatch(pipelineBuilder, clip, batch); | 669 drawContext->drawBatch(pipelineBuilder, clip, batch); |
671 } else { | 670 } else { |
672 SkAutoTUnref<MSAAPathBatch> batch(new MSAAPathBatch(color, path, vie
wMatrix, | 671 SkAutoTUnref<MSAAPathBatch> batch(new MSAAPathBatch(paint.getColor()
, path, viewMatrix, |
673 devBounds)); | 672 devBounds)); |
674 if (!batch->isValid()) { | 673 if (!batch->isValid()) { |
675 return false; | 674 return false; |
676 } | 675 } |
677 | 676 |
678 GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(pa
int)); | 677 GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(pa
int)); |
679 pipelineBuilder.setDrawFace(drawFace[p]); | 678 pipelineBuilder.setDrawFace(drawFace[p]); |
680 if (passes[p]) { | 679 if (passes[p]) { |
681 pipelineBuilder.setUserStencil(passes[p]); | 680 pipelineBuilder.setUserStencil(passes[p]); |
682 } else { | 681 } else { |
(...skipping 23 matching lines...) Expand all Loading... |
706 const GrShape* shape = args.fShape; | 705 const GrShape* shape = args.fShape; |
707 if (shape->style().applies()) { | 706 if (shape->style().applies()) { |
708 SkScalar styleScale = GrStyle::MatrixToScaleFactor(*args.fViewMatrix); | 707 SkScalar styleScale = GrStyle::MatrixToScaleFactor(*args.fViewMatrix); |
709 tmpShape.init(args.fShape->applyStyle(GrStyle::Apply::kPathEffectAndStro
keRec, styleScale)); | 708 tmpShape.init(args.fShape->applyStyle(GrStyle::Apply::kPathEffectAndStro
keRec, styleScale)); |
710 shape = tmpShape.get(); | 709 shape = tmpShape.get(); |
711 } | 710 } |
712 return this->internalDrawPath(args.fDrawContext, | 711 return this->internalDrawPath(args.fDrawContext, |
713 *args.fPaint, | 712 *args.fPaint, |
714 args.fUserStencilSettings, | 713 args.fUserStencilSettings, |
715 *args.fClip, | 714 *args.fClip, |
716 args.fColor, | |
717 *args.fViewMatrix, | 715 *args.fViewMatrix, |
718 *shape, | 716 *shape, |
719 false); | 717 false); |
720 } | 718 } |
721 | 719 |
722 void GrMSAAPathRenderer::onStencilPath(const StencilPathArgs& args) { | 720 void GrMSAAPathRenderer::onStencilPath(const StencilPathArgs& args) { |
723 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), | 721 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), |
724 "GrMSAAPathRenderer::onStencilPath"); | 722 "GrMSAAPathRenderer::onStencilPath"); |
725 SkASSERT(args.fShape->style().isSimpleFill()); | 723 SkASSERT(args.fShape->style().isSimpleFill()); |
726 SkASSERT(!args.fShape->mayBeInverseFilledAfterStyling()); | 724 SkASSERT(!args.fShape->mayBeInverseFilledAfterStyling()); |
727 | 725 |
728 GrPaint paint; | 726 GrPaint paint; |
729 paint.setXPFactory(GrDisableColorXPFactory::Make()); | 727 paint.setXPFactory(GrDisableColorXPFactory::Make()); |
730 paint.setAntiAlias(args.fIsAA); | 728 paint.setAntiAlias(args.fIsAA); |
731 | 729 |
732 this->internalDrawPath(args.fDrawContext, paint, &GrUserStencilSettings::kUn
used, *args.fClip, | 730 this->internalDrawPath(args.fDrawContext, paint, &GrUserStencilSettings::kUn
used, *args.fClip, |
733 GrColor_WHITE, *args.fViewMatrix, *args.fShape, true)
; | 731 *args.fViewMatrix, *args.fShape, true); |
734 } | 732 } |
735 | 733 |
736 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 734 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
OLD | NEW |