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

Side by Side Diff: src/gpu/GrClipMaskManager.cpp

Issue 2006643005: Start on replacing path+style with shape in patherenderer (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: rebase after breaking out more Created 4 years, 6 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 | src/gpu/GrDrawContext.cpp » ('j') | 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 2012 Google Inc. 2 * Copyright 2012 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 "GrClipMaskManager.h" 8 #include "GrClipMaskManager.h"
9 #include "GrCaps.h" 9 #include "GrCaps.h"
10 #include "GrDrawingManager.h" 10 #include "GrDrawingManager.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 if (needsStencil) { 84 if (needsStencil) {
85 type = element->isAA() 85 type = element->isAA()
86 ? GrPathRendererChain::kStencilAndColorAntiAlias_Dra wType 86 ? GrPathRendererChain::kStencilAndColorAntiAlias_Dra wType
87 : GrPathRendererChain::kStencilAndColor_DrawType; 87 : GrPathRendererChain::kStencilAndColor_DrawType;
88 } else { 88 } else {
89 type = element->isAA() 89 type = element->isAA()
90 ? GrPathRendererChain::kColorAntiAlias_DrawType 90 ? GrPathRendererChain::kColorAntiAlias_DrawType
91 : GrPathRendererChain::kColor_DrawType; 91 : GrPathRendererChain::kColor_DrawType;
92 } 92 }
93 93
94 GrShape shape(path, GrStyle::SimpleFill());
94 GrPathRenderer::CanDrawPathArgs canDrawArgs; 95 GrPathRenderer::CanDrawPathArgs canDrawArgs;
95 canDrawArgs.fShaderCaps = context->caps()->shaderCaps(); 96 canDrawArgs.fShaderCaps = context->caps()->shaderCaps();
96 canDrawArgs.fViewMatrix = &viewMatrix; 97 canDrawArgs.fViewMatrix = &viewMatrix;
97 canDrawArgs.fPath = &path; 98 canDrawArgs.fShape = &shape;
98 canDrawArgs.fStyle = &GrStyle::SimpleFill();
99 canDrawArgs.fAntiAlias = element->isAA(); 99 canDrawArgs.fAntiAlias = element->isAA();
100 canDrawArgs.fHasUserStencilSettings = hasUserStencilSettings; 100 canDrawArgs.fHasUserStencilSettings = hasUserStencilSettings;
101 canDrawArgs.fIsStencilBufferMSAA = drawContext->isStencilBufferMultisamp led(); 101 canDrawArgs.fIsStencilBufferMSAA = drawContext->isStencilBufferMultisamp led();
102 102
103 // the 'false' parameter disallows use of the SW path renderer 103 // the 'false' parameter disallows use of the SW path renderer
104 GrPathRenderer* pr = context->drawingManager()->getPathRenderer(canDrawA rgs, false, type); 104 GrPathRenderer* pr = context->drawingManager()->getPathRenderer(canDrawA rgs, false, type);
105 if (prOut) { 105 if (prOut) {
106 *prOut = pr; 106 *prOut = pr;
107 } 107 }
108 return SkToBool(!pr); 108 return SkToBool(!pr);
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 if (Element::kRect_Type == element->getType()) { 608 if (Element::kRect_Type == element->getType()) {
609 stencilSupport = GrPathRenderer::kNoRestriction_StencilSupport; 609 stencilSupport = GrPathRenderer::kNoRestriction_StencilSupport;
610 fillInverted = false; 610 fillInverted = false;
611 } else { 611 } else {
612 element->asPath(&clipPath); 612 element->asPath(&clipPath);
613 fillInverted = clipPath.isInverseFillType(); 613 fillInverted = clipPath.isInverseFillType();
614 if (fillInverted) { 614 if (fillInverted) {
615 clipPath.toggleInverseFillType(); 615 clipPath.toggleInverseFillType();
616 } 616 }
617 617
618 GrShape shape(clipPath, GrStyle::SimpleFill());
618 GrPathRenderer::CanDrawPathArgs canDrawArgs; 619 GrPathRenderer::CanDrawPathArgs canDrawArgs;
619 canDrawArgs.fShaderCaps = context->caps()->shaderCaps(); 620 canDrawArgs.fShaderCaps = context->caps()->shaderCaps();
620 canDrawArgs.fViewMatrix = &viewMatrix; 621 canDrawArgs.fViewMatrix = &viewMatrix;
621 canDrawArgs.fPath = &clipPath; 622 canDrawArgs.fShape = &shape;
622 canDrawArgs.fStyle = &GrStyle::SimpleFill();
623 canDrawArgs.fAntiAlias = false; 623 canDrawArgs.fAntiAlias = false;
624 canDrawArgs.fHasUserStencilSettings = false; 624 canDrawArgs.fHasUserStencilSettings = false;
625 canDrawArgs.fIsStencilBufferMSAA = drawContext->isStencilBufferM ultisampled(); 625 canDrawArgs.fIsStencilBufferMSAA = drawContext->isStencilBufferM ultisampled();
626 626
627 pr = context->drawingManager()->getPathRenderer(canDrawArgs, fal se, 627 pr = context->drawingManager()->getPathRenderer(canDrawArgs, fal se,
628 GrPathRendererCh ain::kStencilOnly_DrawType, 628 GrPathRendererCh ain::kStencilOnly_DrawType,
629 &stencilSupport) ; 629 &stencilSupport) ;
630 if (!pr) { 630 if (!pr) {
631 return false; 631 return false;
632 } 632 }
(...skipping 18 matching lines...) Expand all
651 0xffff, 651 0xffff,
652 GrUserStencilOp::kIncMaybeClamp, 652 GrUserStencilOp::kIncMaybeClamp,
653 GrUserStencilOp::kIncMaybeClamp, 653 GrUserStencilOp::kIncMaybeClamp,
654 0xffff>() 654 0xffff>()
655 ); 655 );
656 if (Element::kRect_Type == element->getType()) { 656 if (Element::kRect_Type == element->getType()) {
657 drawContext->drawContextPriv().stencilRect(clip, &kDrawToSte ncil, useHWAA, 657 drawContext->drawContextPriv().stencilRect(clip, &kDrawToSte ncil, useHWAA,
658 viewMatrix, eleme nt->getRect()); 658 viewMatrix, eleme nt->getRect());
659 } else { 659 } else {
660 if (!clipPath.isEmpty()) { 660 if (!clipPath.isEmpty()) {
661 GrShape shape(clipPath, GrStyle::SimpleFill());
661 if (canRenderDirectToStencil) { 662 if (canRenderDirectToStencil) {
662 GrPaint paint; 663 GrPaint paint;
663 paint.setXPFactory(GrDisableColorXPFactory::Make()); 664 paint.setXPFactory(GrDisableColorXPFactory::Make());
664 paint.setAntiAlias(element->isAA()); 665 paint.setAntiAlias(element->isAA());
665 666
666 GrPathRenderer::DrawPathArgs args; 667 GrPathRenderer::DrawPathArgs args;
667 args.fResourceProvider = context->resourceProvider() ; 668 args.fResourceProvider = context->resourceProvider() ;
668 args.fPaint = &paint; 669 args.fPaint = &paint;
669 args.fUserStencilSettings = &kDrawToStencil; 670 args.fUserStencilSettings = &kDrawToStencil;
670 args.fDrawContext = drawContext; 671 args.fDrawContext = drawContext;
671 args.fClip = &clip; 672 args.fClip = &clip;
672 args.fColor = GrColor_WHITE; 673 args.fColor = GrColor_WHITE;
673 args.fViewMatrix = &viewMatrix; 674 args.fViewMatrix = &viewMatrix;
674 args.fPath = &clipPath; 675 args.fShape = &shape;
675 args.fStyle = &GrStyle::SimpleFill();
676 args.fAntiAlias = false; 676 args.fAntiAlias = false;
677 args.fGammaCorrect = false; 677 args.fGammaCorrect = false;
678 pr->drawPath(args); 678 pr->drawPath(args);
679 } else { 679 } else {
680 GrPathRenderer::StencilPathArgs args; 680 GrPathRenderer::StencilPathArgs args;
681 args.fResourceProvider = context->resourceProvider() ; 681 args.fResourceProvider = context->resourceProvider() ;
682 args.fDrawContext = drawContext; 682 args.fDrawContext = drawContext;
683 args.fClip = &clip; 683 args.fClip = &clip;
684 args.fViewMatrix = &viewMatrix; 684 args.fViewMatrix = &viewMatrix;
685 args.fPath = &clipPath;
686 args.fIsAA = element->isAA(); 685 args.fIsAA = element->isAA();
686 args.fShape = &shape;
687 pr->stencilPath(args); 687 pr->stencilPath(args);
688 } 688 }
689 } 689 }
690 } 690 }
691 } 691 }
692 692
693 // now we modify the clip bit by rendering either the clip 693 // now we modify the clip bit by rendering either the clip
694 // element directly or a bounding rect of the entire clip. 694 // element directly or a bounding rect of the entire clip.
695 clip.enableStencilClip(true); 695 clip.enableStencilClip(true);
696 for (GrUserStencilSettings const* const* pass = stencilPasses; *pass ; ++pass) { 696 for (GrUserStencilSettings const* const* pass = stencilPasses; *pass ; ++pass) {
697 697
698 if (drawDirectToClip) { 698 if (drawDirectToClip) {
699 if (Element::kRect_Type == element->getType()) { 699 if (Element::kRect_Type == element->getType()) {
700 drawContext->drawContextPriv().stencilRect(clip, *pass, useHWAA, viewMatrix, 700 drawContext->drawContextPriv().stencilRect(clip, *pass, useHWAA, viewMatrix,
701 element->getR ect()); 701 element->getR ect());
702 } else { 702 } else {
703 GrShape shape(clipPath, GrStyle::SimpleFill());
703 GrPaint paint; 704 GrPaint paint;
704 paint.setXPFactory(GrDisableColorXPFactory::Make()); 705 paint.setXPFactory(GrDisableColorXPFactory::Make());
705 paint.setAntiAlias(element->isAA()); 706 paint.setAntiAlias(element->isAA());
706
707 GrPathRenderer::DrawPathArgs args; 707 GrPathRenderer::DrawPathArgs args;
708 args.fResourceProvider = context->resourceProvider(); 708 args.fResourceProvider = context->resourceProvider();
709 args.fPaint = &paint; 709 args.fPaint = &paint;
710 args.fUserStencilSettings = *pass; 710 args.fUserStencilSettings = *pass;
711 args.fDrawContext = drawContext; 711 args.fDrawContext = drawContext;
712 args.fClip = &clip; 712 args.fClip = &clip;
713 args.fColor = GrColor_WHITE; 713 args.fColor = GrColor_WHITE;
714 args.fViewMatrix = &viewMatrix; 714 args.fViewMatrix = &viewMatrix;
715 args.fPath = &clipPath; 715 args.fShape = &shape;
716 args.fStyle = &GrStyle::SimpleFill();
717 args.fAntiAlias = false; 716 args.fAntiAlias = false;
718 args.fGammaCorrect = false; 717 args.fGammaCorrect = false;
719 pr->drawPath(args); 718 pr->drawPath(args);
720 } 719 }
721 } else { 720 } else {
722 // The view matrix is setup to do clip space -> stencil spac e translation, so 721 // The view matrix is setup to do clip space -> stencil spac e translation, so
723 // draw rect in clip space. 722 // draw rect in clip space.
724 drawContext->drawContextPriv().stencilRect(clip, *pass, fals e, viewMatrix, 723 drawContext->drawContextPriv().stencilRect(clip, *pass, fals e, viewMatrix,
725 SkRect::Make(clip SpaceIBounds)); 724 SkRect::Make(clip SpaceIBounds));
726 } 725 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 // but leave the pixels inside the geometry alone. For reverse diffe rence we invert all 767 // but leave the pixels inside the geometry alone. For reverse diffe rence we invert all
769 // the pixels before clearing the ones outside the geometry. 768 // the pixels before clearing the ones outside the geometry.
770 if (SkRegion::kReverseDifference_Op == op) { 769 if (SkRegion::kReverseDifference_Op == op) {
771 SkRect temp = SkRect::Make(clipSpaceIBounds); 770 SkRect temp = SkRect::Make(clipSpaceIBounds);
772 // invert the entire scene 771 // invert the entire scene
773 helper.drawRect(temp, SkRegion::kXOR_Op, false, 0xFF); 772 helper.drawRect(temp, SkRegion::kXOR_Op, false, 0xFF);
774 } 773 }
775 SkPath clipPath; 774 SkPath clipPath;
776 element->asPath(&clipPath); 775 element->asPath(&clipPath);
777 clipPath.toggleInverseFillType(); 776 clipPath.toggleInverseFillType();
778 helper.drawPath(clipPath, GrStyle::SimpleFill(), SkRegion::kReplace_ Op, 777 GrShape shape(clipPath, GrStyle::SimpleFill());
779 element->isAA(), 0x00); 778 helper.drawShape(shape, SkRegion::kReplace_Op, element->isAA(), 0x00 );
780 continue; 779 continue;
781 } 780 }
782 781
783 // The other ops (union, xor, diff) only affect pixels inside 782 // The other ops (union, xor, diff) only affect pixels inside
784 // the geometry so they can just be drawn normally 783 // the geometry so they can just be drawn normally
785 if (Element::kRect_Type == element->getType()) { 784 if (Element::kRect_Type == element->getType()) {
786 helper.drawRect(element->getRect(), op, element->isAA(), 0xFF); 785 helper.drawRect(element->getRect(), op, element->isAA(), 0xFF);
787 } else { 786 } else {
788 SkPath path; 787 SkPath path;
789 element->asPath(&path); 788 element->asPath(&path);
790 helper.drawPath(path, GrStyle::SimpleFill(), op, element->isAA(), 0x FF); 789 GrShape shape(path, GrStyle::SimpleFill());
790 helper.drawShape(shape, op, element->isAA(), 0xFF);
791 } 791 }
792 } 792 }
793 793
794 // Allocate clip mask texture 794 // Allocate clip mask texture
795 GrSurfaceDesc desc; 795 GrSurfaceDesc desc;
796 desc.fWidth = clipSpaceIBounds.width(); 796 desc.fWidth = clipSpaceIBounds.width();
797 desc.fHeight = clipSpaceIBounds.height(); 797 desc.fHeight = clipSpaceIBounds.height();
798 desc.fConfig = kAlpha_8_GrPixelConfig; 798 desc.fConfig = kAlpha_8_GrPixelConfig;
799 799
800 sk_sp<GrTexture> result(texProvider->createApproxTexture(desc)); 800 sk_sp<GrTexture> result(texProvider->createApproxTexture(desc));
801 if (!result) { 801 if (!result) {
802 return nullptr; 802 return nullptr;
803 } 803 }
804 result->resourcePriv().setUniqueKey(key); 804 result->resourcePriv().setUniqueKey(key);
805 805
806 helper.toTexture(result.get()); 806 helper.toTexture(result.get());
807 807
808 return result; 808 return result;
809 } 809 }
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrDrawContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698