Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/gpu/batches/GrMSAAPathRenderer.cpp

Issue 2135053002: Simplify MSAA path renderer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
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;
571
570 int passCount = 0; 572 int passCount = 0;
571 const GrUserStencilSettings* passes[3]; 573 const GrUserStencilSettings* passes[kMaxNumPasses];
572 GrPipelineBuilder::DrawFace drawFace[3];
573 bool reverse = false; 574 bool reverse = false;
574 bool lastPassIsBounds; 575 bool lastPassIsBounds;
575 576
576 if (single_pass_shape(shape)) { 577 if (single_pass_shape(shape)) {
577 passCount = 1; 578 passCount = 1;
578 if (stencilOnly) { 579 if (stencilOnly) {
579 passes[0] = &gDirectToStencil; 580 passes[0] = &gDirectToStencil;
580 } else { 581 } else {
581 passes[0] = nullptr; 582 passes[0] = userStencilSettings;
582 } 583 }
583 drawFace[0] = GrPipelineBuilder::kBoth_DrawFace;
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) {
593 passCount = 1; 593 passCount = 1;
594 lastPassIsBounds = false; 594 lastPassIsBounds = false;
595 } else { 595 } else {
596 passCount = 2; 596 passCount = 2;
597 lastPassIsBounds = true; 597 lastPassIsBounds = true;
598 if (reverse) { 598 if (reverse) {
599 passes[1] = &gInvEOColorPass; 599 passes[1] = &gInvEOColorPass;
600 } else { 600 } else {
601 passes[1] = &gEOColorPass; 601 passes[1] = &gEOColorPass;
602 } 602 }
603 } 603 }
604 drawFace[0] = drawFace[1] = GrPipelineBuilder::kBoth_DrawFace;
605 break; 604 break;
606 605
607 case SkPath::kInverseWinding_FillType: 606 case SkPath::kInverseWinding_FillType:
608 reverse = true; 607 reverse = true;
609 // fallthrough 608 // fallthrough
610 case SkPath::kWinding_FillType: 609 case SkPath::kWinding_FillType:
611 passes[0] = &gWindStencilSeparateWithWrap; 610 passes[0] = &gWindStencilSeparateWithWrap;
612 passCount = 2; 611 passCount = 2;
613 drawFace[0] = GrPipelineBuilder::kBoth_DrawFace;
614 if (stencilOnly) { 612 if (stencilOnly) {
615 lastPassIsBounds = false; 613 lastPassIsBounds = false;
616 --passCount; 614 passCount = 1;
617 } else { 615 } else {
618 lastPassIsBounds = true; 616 lastPassIsBounds = true;
619 drawFace[passCount-1] = GrPipelineBuilder::kBoth_DrawFace;
620 if (reverse) { 617 if (reverse) {
621 passes[passCount-1] = &gInvWindColorPass; 618 passes[1] = &gInvWindColorPass;
622 } else { 619 } else {
623 passes[passCount-1] = &gWindColorPass; 620 passes[1] = &gWindColorPass;
624 } 621 }
625 } 622 }
626 break; 623 break;
627 default: 624 default:
628 SkDEBUGFAIL("Unknown path fFill!"); 625 SkDEBUGFAIL("Unknown path fFill!");
629 return false; 626 return false;
630 } 627 }
631 } 628 }
632 629
633 SkRect devBounds; 630 SkRect devBounds;
634 GetPathDevBounds(path, drawContext->width(), drawContext->height(), viewMatr ix, &devBounds); 631 GetPathDevBounds(path, drawContext->width(), drawContext->height(), viewMatr ix, &devBounds);
635 632
633 SkASSERT(passCount <= kMaxNumPasses);
634
636 for (int p = 0; p < passCount; ++p) { 635 for (int p = 0; p < passCount; ++p) {
637 if (lastPassIsBounds && (p == passCount-1)) { 636 if (lastPassIsBounds && (p == passCount-1)) {
638 SkRect bounds; 637 SkRect bounds;
639 SkMatrix localMatrix = SkMatrix::I(); 638 SkMatrix localMatrix = SkMatrix::I();
640 if (reverse) { 639 if (reverse) {
641 // draw over the dev bounds (which will be the whole dst surface for inv fill). 640 // draw over the dev bounds (which will be the whole dst surface for inv fill).
642 bounds = devBounds; 641 bounds = devBounds;
643 SkMatrix vmi; 642 SkMatrix vmi;
644 // mapRect through persp matrix may not be correct 643 // mapRect through persp matrix may not be correct
645 if (!viewMatrix.hasPerspective() && viewMatrix.invert(&vmi)) { 644 if (!viewMatrix.hasPerspective() && viewMatrix.invert(&vmi)) {
646 vmi.mapRect(&bounds); 645 vmi.mapRect(&bounds);
647 } else { 646 } else {
648 if (!viewMatrix.invert(&localMatrix)) { 647 if (!viewMatrix.invert(&localMatrix)) {
649 return false; 648 return false;
650 } 649 }
651 } 650 }
652 } else { 651 } else {
653 bounds = path.getBounds(); 652 bounds = path.getBounds();
654 } 653 }
655 const SkMatrix& viewM = (reverse && viewMatrix.hasPerspective()) ? S kMatrix::I() : 654 const SkMatrix& viewM = (reverse && viewMatrix.hasPerspective()) ? S kMatrix::I() :
656 v iewMatrix; 655 v iewMatrix;
657 SkAutoTUnref<GrDrawBatch> batch( 656 SkAutoTUnref<GrDrawBatch> batch(
658 GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewM, bounds, nullptr, 657 GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewM, bounds, nullptr,
659 &localMatrix)); 658 &localMatrix));
660 659
661 SkASSERT(GrPipelineBuilder::kBoth_DrawFace == drawFace[p]);
662 GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(pa int)); 660 GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(pa int));
663 pipelineBuilder.setDrawFace(drawFace[p]); 661 pipelineBuilder.setUserStencil(passes[p]);
664 if (passes[p]) {
665 pipelineBuilder.setUserStencil(passes[p]);
666 } else {
667 pipelineBuilder.setUserStencil(userStencilSettings);
668 }
669 662
670 drawContext->drawBatch(pipelineBuilder, clip, batch); 663 drawContext->drawBatch(pipelineBuilder, clip, batch);
671 } else { 664 } else {
672 SkAutoTUnref<MSAAPathBatch> batch(new MSAAPathBatch(paint.getColor() , path, 665 SkAutoTUnref<MSAAPathBatch> batch(new MSAAPathBatch(paint.getColor() , path,
673 viewMatrix, devB ounds)); 666 viewMatrix, devB ounds));
674 if (!batch->isValid()) { 667 if (!batch->isValid()) {
675 return false; 668 return false;
676 } 669 }
677 670
678 GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(pa int)); 671 GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(pa int));
679 pipelineBuilder.setDrawFace(drawFace[p]); 672 pipelineBuilder.setUserStencil(passes[p]);
680 if (passes[p]) {
681 pipelineBuilder.setUserStencil(passes[p]);
682 } else {
683 pipelineBuilder.setUserStencil(userStencilSettings);
684 }
685 if (passCount > 1) { 673 if (passCount > 1) {
686 pipelineBuilder.setDisableColorXPFactory(); 674 pipelineBuilder.setDisableColorXPFactory();
687 } 675 }
688 676
689 drawContext->drawBatch(pipelineBuilder, clip, batch); 677 drawContext->drawBatch(pipelineBuilder, clip, batch);
690 } 678 }
691 } 679 }
692 return true; 680 return true;
693 } 681 }
694 682
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 714
727 GrPaint paint; 715 GrPaint paint;
728 paint.setXPFactory(GrDisableColorXPFactory::Make()); 716 paint.setXPFactory(GrDisableColorXPFactory::Make());
729 paint.setAntiAlias(args.fIsAA); 717 paint.setAntiAlias(args.fIsAA);
730 718
731 this->internalDrawPath(args.fDrawContext, paint, &GrUserStencilSettings::kUn used, *args.fClip, 719 this->internalDrawPath(args.fDrawContext, paint, &GrUserStencilSettings::kUn used, *args.fClip,
732 *args.fViewMatrix, *args.fShape, true); 720 *args.fViewMatrix, *args.fShape, true);
733 } 721 }
734 722
735 //////////////////////////////////////////////////////////////////////////////// /////////////////// 723 //////////////////////////////////////////////////////////////////////////////// ///////////////////
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698