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

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

Issue 1420043002: Narrow the distribution of GrDrawTarget a bit (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 2 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 | « include/gpu/GrPathRendererChain.h ('k') | src/gpu/GrContext.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 "GrDrawContext.h" 10 #include "GrDrawContext.h"
(...skipping 29 matching lines...) Expand all
40 SkIRect domainTexels = SkIRect::MakeWH(devBound.width(), devBound.height()); 40 SkIRect domainTexels = SkIRect::MakeWH(devBound.width(), devBound.height());
41 return GrTextureDomainEffect::Create(result, 41 return GrTextureDomainEffect::Create(result,
42 mat, 42 mat,
43 GrTextureDomain::MakeTexelDomain(result , domainTexels), 43 GrTextureDomain::MakeTexelDomain(result , domainTexels),
44 GrTextureDomain::kDecal_Mode, 44 GrTextureDomain::kDecal_Mode,
45 GrTextureParams::kNone_FilterMode, 45 GrTextureParams::kNone_FilterMode,
46 kDevice_GrCoordSet); 46 kDevice_GrCoordSet);
47 } 47 }
48 48
49 static bool path_needs_SW_renderer(GrContext* context, 49 static bool path_needs_SW_renderer(GrContext* context,
50 const GrDrawTarget* gpu,
51 const GrPipelineBuilder& pipelineBuilder, 50 const GrPipelineBuilder& pipelineBuilder,
52 const SkMatrix& viewMatrix, 51 const SkMatrix& viewMatrix,
53 const SkPath& origPath, 52 const SkPath& origPath,
54 const GrStrokeInfo& stroke, 53 const GrStrokeInfo& stroke,
55 bool doAA) { 54 bool doAA) {
56 // the gpu alpha mask will draw the inverse paths as non-inverse to a temp b uffer 55 // the gpu alpha mask will draw the inverse paths as non-inverse to a temp b uffer
57 SkTCopyOnFirstWrite<SkPath> path(origPath); 56 SkTCopyOnFirstWrite<SkPath> path(origPath);
58 if (path->isInverseFillType()) { 57 if (path->isInverseFillType()) {
59 path.writable()->toggleInverseFillType(); 58 path.writable()->toggleInverseFillType();
60 } 59 }
61 // last (false) parameter disallows use of the SW path renderer 60 // last (false) parameter disallows use of the SW path renderer
62 GrPathRendererChain::DrawType type = doAA ? 61 GrPathRendererChain::DrawType type = doAA ?
63 GrPathRendererChain::kColorAntiAlias_Dr awType : 62 GrPathRendererChain::kColorAntiAlias_Dr awType :
64 GrPathRendererChain::kColor_DrawType; 63 GrPathRendererChain::kColor_DrawType;
65 64
66 return nullptr == context->getPathRenderer(gpu, &pipelineBuilder, viewMatrix , *path, stroke, 65 return nullptr == context->getPathRenderer(&pipelineBuilder, viewMatrix, *pa th, stroke,
67 false, type); 66 false, type);
68 } 67 }
69 68
70 GrClipMaskManager::GrClipMaskManager(GrDrawTarget* drawTarget) 69 GrClipMaskManager::GrClipMaskManager(GrDrawTarget* drawTarget)
71 : fDrawTarget(drawTarget) 70 : fDrawTarget(drawTarget)
72 , fClipMode(kIgnoreClip_StencilClipMode) { 71 , fClipMode(kIgnoreClip_StencilClipMode) {
73 } 72 }
74 73
75 GrContext* GrClipMaskManager::getContext() { return fDrawTarget->cmmAccess().con text(); } 74 GrContext* GrClipMaskManager::getContext() { return fDrawTarget->cmmAccess().con text(); }
76 75
77 /* 76 /*
(...skipping 14 matching lines...) Expand all
92 SkMatrix translate; 91 SkMatrix translate;
93 translate.setTranslate(clipToMaskOffset); 92 translate.setTranslate(clipToMaskOffset);
94 93
95 for (GrReducedClip::ElementList::Iter iter(elements.headIter()); iter.get(); iter.next()) { 94 for (GrReducedClip::ElementList::Iter iter(elements.headIter()); iter.get(); iter.next()) {
96 const Element* element = iter.get(); 95 const Element* element = iter.get();
97 // rects can always be drawn directly w/o using the software path 96 // rects can always be drawn directly w/o using the software path
98 // Skip rrects once we're drawing them directly. 97 // Skip rrects once we're drawing them directly.
99 if (Element::kRect_Type != element->getType()) { 98 if (Element::kRect_Type != element->getType()) {
100 SkPath path; 99 SkPath path;
101 element->asPath(&path); 100 element->asPath(&path);
102 if (path_needs_SW_renderer(this->getContext(), fDrawTarget, pipeline Builder, translate, 101 if (path_needs_SW_renderer(this->getContext(), pipelineBuilder, tran slate,
103 path, stroke, element->isAA())) { 102 path, stroke, element->isAA())) {
104 return true; 103 return true;
105 } 104 }
106 } 105 }
107 } 106 }
108 return false; 107 return false;
109 } 108 }
110 109
111 bool GrClipMaskManager::getAnalyticClipProcessor(const GrReducedClip::ElementLis t& elements, 110 bool GrClipMaskManager::getAnalyticClipProcessor(const GrReducedClip::ElementLis t& elements,
112 bool abortIfAA, 111 bool abortIfAA,
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 element->asPath(&path); 405 element->asPath(&path);
407 path.setIsVolatile(true); 406 path.setIsVolatile(true);
408 if (path.isInverseFillType()) { 407 if (path.isInverseFillType()) {
409 path.toggleInverseFillType(); 408 path.toggleInverseFillType();
410 } 409 }
411 GrStrokeInfo stroke(SkStrokeRec::kFill_InitStyle); 410 GrStrokeInfo stroke(SkStrokeRec::kFill_InitStyle);
412 if (nullptr == pr) { 411 if (nullptr == pr) {
413 GrPathRendererChain::DrawType type; 412 GrPathRendererChain::DrawType type;
414 type = element->isAA() ? GrPathRendererChain::kColorAntiAlias_Dr awType : 413 type = element->isAA() ? GrPathRendererChain::kColorAntiAlias_Dr awType :
415 GrPathRendererChain::kColor_DrawType; 414 GrPathRendererChain::kColor_DrawType;
416 pr = this->getContext()->getPathRenderer(fDrawTarget, pipelineBu ilder, viewMatrix, 415 pr = this->getContext()->getPathRenderer(pipelineBuilder, viewMa trix,
417 path, stroke, false, ty pe); 416 path, stroke, false, ty pe);
418 } 417 }
419 if (nullptr == pr) { 418 if (nullptr == pr) {
420 return false; 419 return false;
421 } 420 }
422 GrPathRenderer::DrawPathArgs args; 421 GrPathRenderer::DrawPathArgs args;
423 args.fTarget = fDrawTarget; 422 args.fTarget = fDrawTarget;
424 args.fResourceProvider = this->getContext()->resourceProvider(); 423 args.fResourceProvider = this->getContext()->resourceProvider();
425 args.fPipelineBuilder = pipelineBuilder; 424 args.fPipelineBuilder = pipelineBuilder;
426 args.fColor = color; 425 args.fColor = color;
(...skipping 21 matching lines...) Expand all
448 SkASSERT(Element::kEmpty_Type != element->getType()); 447 SkASSERT(Element::kEmpty_Type != element->getType());
449 SkPath path; 448 SkPath path;
450 element->asPath(&path); 449 element->asPath(&path);
451 if (path.isInverseFillType()) { 450 if (path.isInverseFillType()) {
452 path.toggleInverseFillType(); 451 path.toggleInverseFillType();
453 } 452 }
454 GrStrokeInfo stroke(SkStrokeRec::kFill_InitStyle); 453 GrStrokeInfo stroke(SkStrokeRec::kFill_InitStyle);
455 GrPathRendererChain::DrawType type = element->isAA() ? 454 GrPathRendererChain::DrawType type = element->isAA() ?
456 GrPathRendererChain::kStencilAndColorAntiAlias_DrawType : 455 GrPathRendererChain::kStencilAndColorAntiAlias_DrawType :
457 GrPathRendererChain::kStencilAndColor_DrawType; 456 GrPathRendererChain::kStencilAndColor_DrawType;
458 *pr = this->getContext()->getPathRenderer(fDrawTarget, pipelineBuilder, SkMatrix::I(), path, 457 *pr = this->getContext()->getPathRenderer(pipelineBuilder, SkMatrix::I() , path,
459 stroke, false, type); 458 stroke, false, type);
460 return SkToBool(*pr); 459 return SkToBool(*pr);
461 } 460 }
462 } 461 }
463 462
464 void GrClipMaskManager::mergeMask(GrPipelineBuilder* pipelineBuilder, 463 void GrClipMaskManager::mergeMask(GrPipelineBuilder* pipelineBuilder,
465 GrTexture* dstMask, 464 GrTexture* dstMask,
466 GrTexture* srcMask, 465 GrTexture* srcMask,
467 SkRegion::Op op, 466 SkRegion::Op op,
468 const SkIRect& dstBound, 467 const SkIRect& dstBound,
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 SkPath clipPath; 752 SkPath clipPath;
754 if (Element::kRect_Type == element->getType()) { 753 if (Element::kRect_Type == element->getType()) {
755 stencilSupport = GrPathRenderer::kNoRestriction_StencilSupport; 754 stencilSupport = GrPathRenderer::kNoRestriction_StencilSupport;
756 fillInverted = false; 755 fillInverted = false;
757 } else { 756 } else {
758 element->asPath(&clipPath); 757 element->asPath(&clipPath);
759 fillInverted = clipPath.isInverseFillType(); 758 fillInverted = clipPath.isInverseFillType();
760 if (fillInverted) { 759 if (fillInverted) {
761 clipPath.toggleInverseFillType(); 760 clipPath.toggleInverseFillType();
762 } 761 }
763 pr = this->getContext()->getPathRenderer(fDrawTarget, 762 pr = this->getContext()->getPathRenderer(&pipelineBuilder,
764 &pipelineBuilder,
765 viewMatrix, 763 viewMatrix,
766 clipPath, 764 clipPath,
767 stroke, 765 stroke,
768 false, 766 false,
769 GrPathRendererChain::kS tencilOnly_DrawType, 767 GrPathRendererChain::kS tencilOnly_DrawType,
770 &stencilSupport); 768 &stencilSupport);
771 if (nullptr == pr) { 769 if (nullptr == pr) {
772 return false; 770 return false;
773 } 771 }
774 } 772 }
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 1115
1118 //////////////////////////////////////////////////////////////////////////////// 1116 ////////////////////////////////////////////////////////////////////////////////
1119 1117
1120 void GrClipMaskManager::adjustPathStencilParams(const GrStencilAttachment* stenc ilAttachment, 1118 void GrClipMaskManager::adjustPathStencilParams(const GrStencilAttachment* stenc ilAttachment,
1121 GrStencilSettings* settings) { 1119 GrStencilSettings* settings) {
1122 if (stencilAttachment) { 1120 if (stencilAttachment) {
1123 int stencilBits = stencilAttachment->bits(); 1121 int stencilBits = stencilAttachment->bits();
1124 this->adjustStencilParams(settings, fClipMode, stencilBits); 1122 this->adjustStencilParams(settings, fClipMode, stencilBits);
1125 } 1123 }
1126 } 1124 }
OLDNEW
« no previous file with comments | « include/gpu/GrPathRendererChain.h ('k') | src/gpu/GrContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698