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

Side by Side Diff: src/gpu/GrPathRenderer.h

Issue 1962243002: 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/GrGpu.h ('k') | src/gpu/GrPipeline.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 2011 Google Inc. 2 * Copyright 2011 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 #ifndef GrPathRenderer_DEFINED 8 #ifndef GrPathRenderer_DEFINED
9 #define GrPathRenderer_DEFINED 9 #define GrPathRenderer_DEFINED
10 10
11 #include "GrDrawTarget.h" 11 #include "GrDrawTarget.h"
12 #include "GrStencil.h"
13 #include "GrStyle.h" 12 #include "GrStyle.h"
14 13
15 #include "SkDrawProcs.h" 14 #include "SkDrawProcs.h"
16 #include "SkTArray.h" 15 #include "SkTArray.h"
17 16
18 class SkPath; 17 class SkPath;
19 struct GrPoint; 18 struct GrPoint;
20 19
21 /** 20 /**
22 * Base class for drawing paths into a GrDrawTarget. 21 * Base class for drawing paths into a GrDrawTarget.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 * fAntiAlias True if anti-aliasing is required. 74 * fAntiAlias True if anti-aliasing is required.
76 */ 75 */
77 struct CanDrawPathArgs { 76 struct CanDrawPathArgs {
78 const GrShaderCaps* fShaderCaps; 77 const GrShaderCaps* fShaderCaps;
79 const SkMatrix* fViewMatrix; 78 const SkMatrix* fViewMatrix;
80 const SkPath* fPath; 79 const SkPath* fPath;
81 const GrStyle* fStyle; 80 const GrStyle* fStyle;
82 bool fAntiAlias; 81 bool fAntiAlias;
83 82
84 // These next two are only used by GrStencilAndCoverPathRenderer 83 // These next two are only used by GrStencilAndCoverPathRenderer
85 bool fIsStencilDisabled; 84 bool fHasUserStencilSettings;
86 bool fIsStencilBufferMSAA; 85 bool fIsStencilBufferMSAA;
87 86
88 void validate() const { 87 void validate() const {
89 SkASSERT(fShaderCaps); 88 SkASSERT(fShaderCaps);
90 SkASSERT(fViewMatrix); 89 SkASSERT(fViewMatrix);
91 SkASSERT(fPath); 90 SkASSERT(fPath);
92 SkASSERT(fStyle); 91 SkASSERT(fStyle);
93 SkASSERT(!fPath->isEmpty()); 92 SkASSERT(!fPath->isEmpty());
94 } 93 }
95 }; 94 };
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 bool drawPath(const DrawPathArgs& args) { 147 bool drawPath(const DrawPathArgs& args) {
149 SkDEBUGCODE(args.validate();) 148 SkDEBUGCODE(args.validate();)
150 #ifdef SK_DEBUG 149 #ifdef SK_DEBUG
151 CanDrawPathArgs canArgs; 150 CanDrawPathArgs canArgs;
152 canArgs.fShaderCaps = args.fTarget->caps()->shaderCaps(); 151 canArgs.fShaderCaps = args.fTarget->caps()->shaderCaps();
153 canArgs.fViewMatrix = args.fViewMatrix; 152 canArgs.fViewMatrix = args.fViewMatrix;
154 canArgs.fPath = args.fPath; 153 canArgs.fPath = args.fPath;
155 canArgs.fStyle = args.fStyle; 154 canArgs.fStyle = args.fStyle;
156 canArgs.fAntiAlias = args.fAntiAlias; 155 canArgs.fAntiAlias = args.fAntiAlias;
157 156
158 canArgs.fIsStencilDisabled = args.fPipelineBuilder->getStencil().isDisab led(); 157 canArgs.fHasUserStencilSettings = args.fPipelineBuilder->hasUserStencilS ettings();
159 canArgs.fIsStencilBufferMSAA = 158 canArgs.fIsStencilBufferMSAA =
160 args.fPipelineBuilder->getRenderTarget()->isStencilBuf ferMultisampled(); 159 args.fPipelineBuilder->getRenderTarget()->isStencilBuf ferMultisampled();
161 SkASSERT(this->canDrawPath(canArgs)); 160 SkASSERT(this->canDrawPath(canArgs));
162 if (!args.fPipelineBuilder->getStencil().isDisabled()) { 161 if (args.fPipelineBuilder->hasUserStencilSettings()) {
163 SkASSERT(kNoRestriction_StencilSupport == this->getStencilSupport(*a rgs.fPath)); 162 SkASSERT(kNoRestriction_StencilSupport == this->getStencilSupport(*a rgs.fPath));
164 SkASSERT(args.fStyle->isSimpleFill()); 163 SkASSERT(args.fStyle->isSimpleFill());
165 } 164 }
166 #endif 165 #endif
167 return this->onDrawPath(args); 166 return this->onDrawPath(args);
168 } 167 }
169 168
170 /* Args to stencilPath(). 169 /* Args to stencilPath().
171 * 170 *
172 * fTarget The target that the path will be rendered to. 171 * fTarget The target that the path will be rendered to.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 /** 252 /**
254 * Subclass implementation of canDrawPath() 253 * Subclass implementation of canDrawPath()
255 */ 254 */
256 virtual bool onCanDrawPath(const CanDrawPathArgs& args) const = 0; 255 virtual bool onCanDrawPath(const CanDrawPathArgs& args) const = 0;
257 256
258 /** 257 /**
259 * Subclass implementation of stencilPath(). Subclass must override iff it e ver returns 258 * Subclass implementation of stencilPath(). Subclass must override iff it e ver returns
260 * kStencilOnly in onGetStencilSupport(). 259 * kStencilOnly in onGetStencilSupport().
261 */ 260 */
262 virtual void onStencilPath(const StencilPathArgs& args) { 261 virtual void onStencilPath(const StencilPathArgs& args) {
263 static constexpr GrStencilSettings kIncrementStencil( 262 static constexpr GrUserStencilSettings kIncrementStencil(
264 kReplace_StencilOp, 263 GrUserStencilSettings::StaticInit<
265 kReplace_StencilOp, 264 0xffff,
266 kAlways_StencilFunc, 265 GrUserStencilTest::kAlways,
267 0xffff, 266 0xffff,
268 0xffff, 267 GrUserStencilOp::kReplace,
269 0xffff); 268 GrUserStencilOp::kReplace,
270 args.fPipelineBuilder->setStencil(kIncrementStencil); 269 0xffff>()
270 );
271 args.fPipelineBuilder->setUserStencil(&kIncrementStencil);
271 args.fPipelineBuilder->setDisableColorXPFactory(); 272 args.fPipelineBuilder->setDisableColorXPFactory();
272 DrawPathArgs drawArgs; 273 DrawPathArgs drawArgs;
273 drawArgs.fTarget = args.fTarget; 274 drawArgs.fTarget = args.fTarget;
274 drawArgs.fResourceProvider = args.fResourceProvider; 275 drawArgs.fResourceProvider = args.fResourceProvider;
275 drawArgs.fPipelineBuilder = args.fPipelineBuilder; 276 drawArgs.fPipelineBuilder = args.fPipelineBuilder;
276 drawArgs.fColor = 0xFFFFFFFF; 277 drawArgs.fColor = 0xFFFFFFFF;
277 drawArgs.fViewMatrix = args.fViewMatrix; 278 drawArgs.fViewMatrix = args.fViewMatrix;
278 drawArgs.fPath = args.fPath; 279 drawArgs.fPath = args.fPath;
279 drawArgs.fStyle = &GrStyle::SimpleFill(); 280 drawArgs.fStyle = &GrStyle::SimpleFill();
280 drawArgs.fAntiAlias = false; 281 drawArgs.fAntiAlias = false;
281 drawArgs.fGammaCorrect = false; 282 drawArgs.fGammaCorrect = false;
282 this->drawPath(drawArgs); 283 this->drawPath(drawArgs);
283 } 284 }
284 285
285 typedef SkRefCnt INHERITED; 286 typedef SkRefCnt INHERITED;
286 }; 287 };
287 288
288 #endif 289 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrGpu.h ('k') | src/gpu/GrPipeline.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698