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

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

Issue 1969693003: Revert of Separate user and raw stencil settings (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 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 | « src/gpu/batches/GrPathStencilSettings.h ('k') | src/gpu/batches/GrStencilPathBatch.h » ('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 8
9 #include "GrStencilAndCoverPathRenderer.h" 9 #include "GrStencilAndCoverPathRenderer.h"
10 #include "GrCaps.h" 10 #include "GrCaps.h"
(...skipping 18 matching lines...) Expand all
29 GrStencilAndCoverPathRenderer::GrStencilAndCoverPathRenderer(GrResourceProvider* resourceProvider) 29 GrStencilAndCoverPathRenderer::GrStencilAndCoverPathRenderer(GrResourceProvider* resourceProvider)
30 : fResourceProvider(resourceProvider) { 30 : fResourceProvider(resourceProvider) {
31 } 31 }
32 32
33 bool GrStencilAndCoverPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) c onst { 33 bool GrStencilAndCoverPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) c onst {
34 // GrPath doesn't support hairline paths. Also, an arbitrary path effect cou ld change 34 // GrPath doesn't support hairline paths. Also, an arbitrary path effect cou ld change
35 // the style type to hairline. 35 // the style type to hairline.
36 if (args.fStyle->hasNonDashPathEffect() || args.fStyle->strokeRec().isHairli neStyle()) { 36 if (args.fStyle->hasNonDashPathEffect() || args.fStyle->strokeRec().isHairli neStyle()) {
37 return false; 37 return false;
38 } 38 }
39 if (args.fHasUserStencilSettings) { 39 if (!args.fIsStencilDisabled) {
40 return false; 40 return false;
41 } 41 }
42 if (args.fAntiAlias) { 42 if (args.fAntiAlias) {
43 return args.fIsStencilBufferMSAA; 43 return args.fIsStencilBufferMSAA;
44 } else { 44 } else {
45 return true; // doesn't do per-path AA, relies on the target having MSAA 45 return true; // doesn't do per-path AA, relies on the target having MSAA
46 } 46 }
47 } 47 }
48 48
49 static GrPath* get_gr_path(GrResourceProvider* resourceProvider, const SkPath& s kPath, 49 static GrPath* get_gr_path(GrResourceProvider* resourceProvider, const SkPath& s kPath,
(...skipping 23 matching lines...) Expand all
73 } 73 }
74 74
75 bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) { 75 bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) {
76 GR_AUDIT_TRAIL_AUTO_FRAME(args.fTarget->getAuditTrail(), 76 GR_AUDIT_TRAIL_AUTO_FRAME(args.fTarget->getAuditTrail(),
77 "GrStencilAndCoverPathRenderer::onDrawPath"); 77 "GrStencilAndCoverPathRenderer::onDrawPath");
78 SkASSERT(!args.fStyle->strokeRec().isHairlineStyle()); 78 SkASSERT(!args.fStyle->strokeRec().isHairlineStyle());
79 const SkPath& path = *args.fPath; 79 const SkPath& path = *args.fPath;
80 GrPipelineBuilder* pipelineBuilder = args.fPipelineBuilder; 80 GrPipelineBuilder* pipelineBuilder = args.fPipelineBuilder;
81 const SkMatrix& viewMatrix = *args.fViewMatrix; 81 const SkMatrix& viewMatrix = *args.fViewMatrix;
82 82
83 SkASSERT(!pipelineBuilder->hasUserStencilSettings()); 83 SkASSERT(pipelineBuilder->getStencil().isDisabled());
84 84
85 if (args.fAntiAlias) { 85 if (args.fAntiAlias) {
86 SkASSERT(pipelineBuilder->getRenderTarget()->isStencilBufferMultisampled ()); 86 SkASSERT(pipelineBuilder->getRenderTarget()->isStencilBufferMultisampled ());
87 pipelineBuilder->enableState(GrPipelineBuilder::kHWAntialias_Flag); 87 pipelineBuilder->enableState(GrPipelineBuilder::kHWAntialias_Flag);
88 } 88 }
89 89
90 SkAutoTUnref<GrPath> p(get_gr_path(fResourceProvider, path, *args.fStyle)); 90 SkAutoTUnref<GrPath> p(get_gr_path(fResourceProvider, path, *args.fStyle));
91 91
92 if (path.isInverseFillType()) { 92 if (path.isInverseFillType()) {
93 static constexpr GrUserStencilSettings kInvertedCoverPass( 93 static constexpr GrStencilSettings kInvertedStencilPass(
94 GrUserStencilSettings::StaticInit< 94 kKeep_StencilOp,
95 0x0000, 95 kZero_StencilOp,
96 // We know our rect will hit pixels outside the clip and the use r bits will be 0 96 // We know our rect will hit pixels outside the clip and the user bi ts will be 0
97 // outside the clip. So we can't just fill where the user bits a re 0. We also need 97 // outside the clip. So we can't just fill where the user bits are 0 . We also need to
98 // to check that the clip bit is set. 98 // check that the clip bit is set.
99 GrUserStencilTest::kEqualIfInClip, 99 kEqualIfInClip_StencilFunc,
100 0xffff, 100 0xffff,
101 GrUserStencilOp::kKeep, 101 0x0000,
102 GrUserStencilOp::kZero, 102 0xffff);
103 0xffff>()
104 );
105 103
106 104 pipelineBuilder->setStencil(kInvertedStencilPass);
107 pipelineBuilder->setUserStencil(&kInvertedCoverPass);
108 105
109 // fake inverse with a stencil and cover 106 // fake inverse with a stencil and cover
110 args.fTarget->stencilPath(*pipelineBuilder, viewMatrix, p, p->getFillTyp e()); 107 args.fTarget->stencilPath(*pipelineBuilder, viewMatrix, p, p->getFillTyp e());
111 108
112 SkMatrix invert = SkMatrix::I(); 109 SkMatrix invert = SkMatrix::I();
113 SkRect bounds = 110 SkRect bounds =
114 SkRect::MakeLTRB(0, 0, SkIntToScalar(pipelineBuilder->getRenderTarge t()->width()), 111 SkRect::MakeLTRB(0, 0, SkIntToScalar(pipelineBuilder->getRenderTarge t()->width()),
115 SkIntToScalar(pipelineBuilder->getRenderTarget()->h eight())); 112 SkIntToScalar(pipelineBuilder->getRenderTarget()->h eight()));
116 SkMatrix vmi; 113 SkMatrix vmi;
117 // mapRect through persp matrix may not be correct 114 // mapRect through persp matrix may not be correct
(...skipping 11 matching lines...) Expand all
129 const SkMatrix& viewM = viewMatrix.hasPerspective() ? SkMatrix::I() : vi ewMatrix; 126 const SkMatrix& viewM = viewMatrix.hasPerspective() ? SkMatrix::I() : vi ewMatrix;
130 if (pipelineBuilder->getRenderTarget()->hasMixedSamples()) { 127 if (pipelineBuilder->getRenderTarget()->hasMixedSamples()) {
131 pipelineBuilder->disableState(GrPipelineBuilder::kHWAntialias_Flag); 128 pipelineBuilder->disableState(GrPipelineBuilder::kHWAntialias_Flag);
132 } 129 }
133 130
134 SkAutoTUnref<GrDrawBatch> batch( 131 SkAutoTUnref<GrDrawBatch> batch(
135 GrRectBatchFactory::CreateNonAAFill(args.fColor, viewM, bounds, nullptr, 132 GrRectBatchFactory::CreateNonAAFill(args.fColor, viewM, bounds, nullptr,
136 &invert)); 133 &invert));
137 args.fTarget->drawBatch(*pipelineBuilder, batch); 134 args.fTarget->drawBatch(*pipelineBuilder, batch);
138 } else { 135 } else {
139 static constexpr GrUserStencilSettings kCoverPass( 136 static constexpr GrStencilSettings kStencilPass(
140 GrUserStencilSettings::StaticInit< 137 kZero_StencilOp,
141 0x0000, 138 kKeep_StencilOp,
142 GrUserStencilTest::kNotEqual, 139 kNotEqual_StencilFunc,
143 0xffff, 140 0xffff,
144 GrUserStencilOp::kZero, 141 0x0000,
145 GrUserStencilOp::kKeep, 142 0xffff);
146 0xffff>()
147 );
148 143
149 pipelineBuilder->setUserStencil(&kCoverPass); 144 pipelineBuilder->setStencil(kStencilPass);
150 SkAutoTUnref<GrDrawPathBatchBase> batch( 145 SkAutoTUnref<GrDrawPathBatchBase> batch(
151 GrDrawPathBatch::Create(viewMatrix, args.fColor, p->getFillType( ), p)); 146 GrDrawPathBatch::Create(viewMatrix, args.fColor, p->getFillType( ), p));
152 args.fTarget->drawPathBatch(*pipelineBuilder, batch); 147 args.fTarget->drawPathBatch(*pipelineBuilder, batch);
153 } 148 }
154 149
155 pipelineBuilder->disableUserStencil(); 150 pipelineBuilder->stencil()->setDisabled();
156 return true; 151 return true;
157 } 152 }
OLDNEW
« no previous file with comments | « src/gpu/batches/GrPathStencilSettings.h ('k') | src/gpu/batches/GrStencilPathBatch.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698