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

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

Issue 2057613003: Fix GrDrawContextPriv::stencilRect (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: useHWAA 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 SkIRect domainTexels = SkIRect::MakeWH(devBound.width(), devBound.height()); 44 SkIRect domainTexels = SkIRect::MakeWH(devBound.width(), devBound.height());
45 return sk_sp<GrFragmentProcessor>(GrTextureDomainEffect::Make( 45 return sk_sp<GrFragmentProcessor>(GrTextureDomainEffect::Make(
46 result, 46 result,
47 mat, 47 mat,
48 GrTextureDomain::MakeTexelDomain(result , domainTexels), 48 GrTextureDomain::MakeTexelDomain(result , domainTexels),
49 GrTextureDomain::kDecal_Mode, 49 GrTextureDomain::kDecal_Mode,
50 GrTextureParams::kNone_FilterMode, 50 GrTextureParams::kNone_FilterMode,
51 kDevice_GrCoordSet)); 51 kDevice_GrCoordSet));
52 } 52 }
53 53
54 void GrClipMaskManager::DrawNonAARect(GrDrawContext* drawContext,
55 const GrFixedClip& clip,
56 const SkMatrix& viewMatrix,
57 const SkRect& rect,
58 bool doAA,
59 const GrUserStencilSettings* stencilSettin gs) {
60 drawContext->drawContextPriv().stencilRect(clip, stencilSettings, doAA, view Matrix, rect);
61 }
62
63 // Does the path in 'element' require SW rendering? If so, return true (and, 54 // Does the path in 'element' require SW rendering? If so, return true (and,
64 // optionally, set 'prOut' to NULL. If not, return false (and, optionally, set 55 // optionally, set 'prOut' to NULL. If not, return false (and, optionally, set
65 // 'prOut' to the non-SW path renderer that will do the job). 56 // 'prOut' to the non-SW path renderer that will do the job).
66 bool GrClipMaskManager::PathNeedsSWRenderer(GrContext* context, 57 bool GrClipMaskManager::PathNeedsSWRenderer(GrContext* context,
67 bool hasUserStencilSettings, 58 bool hasUserStencilSettings,
68 const GrDrawContext* drawContext, 59 const GrDrawContext* drawContext,
69 const SkMatrix& viewMatrix, 60 const SkMatrix& viewMatrix,
70 const Element* element, 61 const Element* element,
71 GrPathRenderer** prOut, 62 GrPathRenderer** prOut,
72 bool needsStencil) { 63 bool needsStencil) {
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 GrFixedClip clip(stencilSpaceIBounds); 584 GrFixedClip clip(stencilSpaceIBounds);
594 585
595 drawContext->drawContextPriv().clearStencilClip( 586 drawContext->drawContextPriv().clearStencilClip(
596 stencilSpaceIBounds, 587 stencilSpaceIBounds,
597 GrReducedClip::kAllIn_InitialState = = initialState); 588 GrReducedClip::kAllIn_InitialState = = initialState);
598 589
599 // walk through each clip element and perform its set op 590 // walk through each clip element and perform its set op
600 // with the existing clip. 591 // with the existing clip.
601 for (GrReducedClip::ElementList::Iter iter(elements.headIter()); iter.ge t(); iter.next()) { 592 for (GrReducedClip::ElementList::Iter iter(elements.headIter()); iter.ge t(); iter.next()) {
602 const Element* element = iter.get(); 593 const Element* element = iter.get();
594 bool useHWAA = element->isAA() && drawContext->isStencilBufferMultis ampled();
603 595
604 bool fillInverted = false; 596 bool fillInverted = false;
605 // enabled at bottom of loop 597 // enabled at bottom of loop
606 clip.enableStencilClip(false); 598 clip.enableStencilClip(false);
607 599
608 // This will be used to determine whether the clip shape can be rend ered into the 600 // This will be used to determine whether the clip shape can be rend ered into the
609 // stencil with arbitrary stencil settings. 601 // stencil with arbitrary stencil settings.
610 GrPathRenderer::StencilSupport stencilSupport; 602 GrPathRenderer::StencilSupport stencilSupport;
611 603
612 SkRegion::Op op = element->getOp(); 604 SkRegion::Op op = element->getOp();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 static constexpr GrUserStencilSettings kDrawToStencil( 647 static constexpr GrUserStencilSettings kDrawToStencil(
656 GrUserStencilSettings::StaticInit< 648 GrUserStencilSettings::StaticInit<
657 0x0000, 649 0x0000,
658 GrUserStencilTest::kAlways, 650 GrUserStencilTest::kAlways,
659 0xffff, 651 0xffff,
660 GrUserStencilOp::kIncMaybeClamp, 652 GrUserStencilOp::kIncMaybeClamp,
661 GrUserStencilOp::kIncMaybeClamp, 653 GrUserStencilOp::kIncMaybeClamp,
662 0xffff>() 654 0xffff>()
663 ); 655 );
664 if (Element::kRect_Type == element->getType()) { 656 if (Element::kRect_Type == element->getType()) {
665 DrawNonAARect(drawContext, clip, viewMatrix, 657 drawContext->drawContextPriv().stencilRect(clip, &kDrawToSte ncil, useHWAA,
666 element->getRect(), element->isAA(), &kDrawToS tencil); 658 viewMatrix, eleme nt->getRect());
667 } else { 659 } else {
668 if (!clipPath.isEmpty()) { 660 if (!clipPath.isEmpty()) {
669 if (canRenderDirectToStencil) { 661 if (canRenderDirectToStencil) {
670 GrPaint paint; 662 GrPaint paint;
671 paint.setXPFactory(GrDisableColorXPFactory::Make()); 663 paint.setXPFactory(GrDisableColorXPFactory::Make());
672 paint.setAntiAlias(element->isAA()); 664 paint.setAntiAlias(element->isAA());
673 665
674 GrPathRenderer::DrawPathArgs args; 666 GrPathRenderer::DrawPathArgs args;
675 args.fResourceProvider = context->resourceProvider() ; 667 args.fResourceProvider = context->resourceProvider() ;
676 args.fPaint = &paint; 668 args.fPaint = &paint;
(...skipping 21 matching lines...) Expand all
698 } 690 }
699 } 691 }
700 692
701 // now we modify the clip bit by rendering either the clip 693 // now we modify the clip bit by rendering either the clip
702 // element directly or a bounding rect of the entire clip. 694 // element directly or a bounding rect of the entire clip.
703 clip.enableStencilClip(true); 695 clip.enableStencilClip(true);
704 for (GrUserStencilSettings const* const* pass = stencilPasses; *pass ; ++pass) { 696 for (GrUserStencilSettings const* const* pass = stencilPasses; *pass ; ++pass) {
705 697
706 if (drawDirectToClip) { 698 if (drawDirectToClip) {
707 if (Element::kRect_Type == element->getType()) { 699 if (Element::kRect_Type == element->getType()) {
708 DrawNonAARect(drawContext, clip, 700 drawContext->drawContextPriv().stencilRect(clip, *pass, useHWAA, viewMatrix,
709 viewMatrix, element->getRect(), element->i sAA(), *pass); 701 element->getR ect());
710 } else { 702 } else {
711 GrPaint paint; 703 GrPaint paint;
712 paint.setXPFactory(GrDisableColorXPFactory::Make()); 704 paint.setXPFactory(GrDisableColorXPFactory::Make());
713 paint.setAntiAlias(element->isAA()); 705 paint.setAntiAlias(element->isAA());
714 706
715 GrPathRenderer::DrawPathArgs args; 707 GrPathRenderer::DrawPathArgs args;
716 args.fResourceProvider = context->resourceProvider(); 708 args.fResourceProvider = context->resourceProvider();
717 args.fPaint = &paint; 709 args.fPaint = &paint;
718 args.fUserStencilSettings = *pass; 710 args.fUserStencilSettings = *pass;
719 args.fDrawContext = drawContext; 711 args.fDrawContext = drawContext;
720 args.fClip = &clip; 712 args.fClip = &clip;
721 args.fColor = GrColor_WHITE; 713 args.fColor = GrColor_WHITE;
722 args.fViewMatrix = &viewMatrix; 714 args.fViewMatrix = &viewMatrix;
723 args.fPath = &clipPath; 715 args.fPath = &clipPath;
724 args.fStyle = &GrStyle::SimpleFill(); 716 args.fStyle = &GrStyle::SimpleFill();
725 args.fAntiAlias = false; 717 args.fAntiAlias = false;
726 args.fGammaCorrect = false; 718 args.fGammaCorrect = false;
727 pr->drawPath(args); 719 pr->drawPath(args);
728 } 720 }
729 } else { 721 } else {
730 // The view matrix is setup to do clip space -> stencil spac e translation, so 722 // The view matrix is setup to do clip space -> stencil spac e translation, so
731 // draw rect in clip space. 723 // draw rect in clip space.
732 DrawNonAARect(drawContext, clip, viewMatrix, 724 drawContext->drawContextPriv().stencilRect(clip, *pass, fals e, viewMatrix,
733 SkRect::Make(clipSpaceIBounds), false, *pass); 725 SkRect::Make(clip SpaceIBounds));
734 } 726 }
735 } 727 }
736 } 728 }
737 } 729 }
738 return true; 730 return true;
739 } 731 }
740 732
741 //////////////////////////////////////////////////////////////////////////////// 733 ////////////////////////////////////////////////////////////////////////////////
742 sk_sp<GrTexture> GrClipMaskManager::CreateSoftwareClipMask( 734 sk_sp<GrTexture> GrClipMaskManager::CreateSoftwareClipMask(
743 GrTextureProvider* texProvid er, 735 GrTextureProvider* texProvid er,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 sk_sp<GrTexture> result(texProvider->createApproxTexture(desc)); 800 sk_sp<GrTexture> result(texProvider->createApproxTexture(desc));
809 if (!result) { 801 if (!result) {
810 return nullptr; 802 return nullptr;
811 } 803 }
812 result->resourcePriv().setUniqueKey(key); 804 result->resourcePriv().setUniqueKey(key);
813 805
814 helper.toTexture(result.get()); 806 helper.toTexture(result.get());
815 807
816 return result; 808 return result;
817 } 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