OLD | NEW |
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 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 * fAntiAlias True if anti-aliasing is required. | 76 * fAntiAlias True if anti-aliasing is required. |
77 */ | 77 */ |
78 struct CanDrawPathArgs { | 78 struct CanDrawPathArgs { |
79 const GrShaderCaps* fShaderCaps; | 79 const GrShaderCaps* fShaderCaps; |
80 const SkMatrix* fViewMatrix; | 80 const SkMatrix* fViewMatrix; |
81 const SkPath* fPath; | 81 const SkPath* fPath; |
82 const GrStrokeInfo* fStroke; | 82 const GrStrokeInfo* fStroke; |
83 bool fAntiAlias; | 83 bool fAntiAlias; |
84 | 84 |
85 // These next two are only used by GrStencilAndCoverPathRenderer | 85 // These next two are only used by GrStencilAndCoverPathRenderer |
86 bool fIsStencilDisabled; | 86 bool fHasUserStencilSettings; |
87 bool fIsStencilBufferMSAA; | 87 bool fIsStencilBufferMSAA; |
88 | 88 |
89 void validate() const { | 89 void validate() const { |
90 SkASSERT(fShaderCaps); | 90 SkASSERT(fShaderCaps); |
91 SkASSERT(fViewMatrix); | 91 SkASSERT(fViewMatrix); |
92 SkASSERT(fPath); | 92 SkASSERT(fPath); |
93 SkASSERT(fStroke); | 93 SkASSERT(fStroke); |
94 SkASSERT(!fPath->isEmpty()); | 94 SkASSERT(!fPath->isEmpty()); |
95 } | 95 } |
96 }; | 96 }; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 bool drawPath(const DrawPathArgs& args) { | 149 bool drawPath(const DrawPathArgs& args) { |
150 SkDEBUGCODE(args.validate();) | 150 SkDEBUGCODE(args.validate();) |
151 #ifdef SK_DEBUG | 151 #ifdef SK_DEBUG |
152 CanDrawPathArgs canArgs; | 152 CanDrawPathArgs canArgs; |
153 canArgs.fShaderCaps = args.fTarget->caps()->shaderCaps(); | 153 canArgs.fShaderCaps = args.fTarget->caps()->shaderCaps(); |
154 canArgs.fViewMatrix = args.fViewMatrix; | 154 canArgs.fViewMatrix = args.fViewMatrix; |
155 canArgs.fPath = args.fPath; | 155 canArgs.fPath = args.fPath; |
156 canArgs.fStroke = args.fStroke; | 156 canArgs.fStroke = args.fStroke; |
157 canArgs.fAntiAlias = args.fAntiAlias; | 157 canArgs.fAntiAlias = args.fAntiAlias; |
158 | 158 |
159 canArgs.fIsStencilDisabled = args.fPipelineBuilder->getStencil().isDisab
led(); | 159 canArgs.fHasUserStencilSettings = args.fPipelineBuilder->hasUserStencilS
ettings(); |
160 canArgs.fIsStencilBufferMSAA = | 160 canArgs.fIsStencilBufferMSAA = |
161 args.fPipelineBuilder->getRenderTarget()->isStencilBuf
ferMultisampled(); | 161 args.fPipelineBuilder->getRenderTarget()->isStencilBuf
ferMultisampled(); |
162 SkASSERT(this->canDrawPath(canArgs)); | 162 SkASSERT(this->canDrawPath(canArgs)); |
163 if (!args.fPipelineBuilder->getStencil().isDisabled()) { | 163 if (args.fPipelineBuilder->hasUserStencilSettings()) { |
164 SkASSERT(kNoRestriction_StencilSupport == this->getStencilSupport(*a
rgs.fPath)); | 164 SkASSERT(kNoRestriction_StencilSupport == this->getStencilSupport(*a
rgs.fPath)); |
165 SkASSERT(!args.fStroke->isDashed()); | 165 SkASSERT(!args.fStroke->isDashed()); |
166 SkASSERT(args.fStroke->isFillStyle()); | 166 SkASSERT(args.fStroke->isFillStyle()); |
167 } | 167 } |
168 #endif | 168 #endif |
169 return this->onDrawPath(args); | 169 return this->onDrawPath(args); |
170 } | 170 } |
171 | 171 |
172 /* Args to stencilPath(). | 172 /* Args to stencilPath(). |
173 * | 173 * |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 /** | 256 /** |
257 * Subclass implementation of canDrawPath() | 257 * Subclass implementation of canDrawPath() |
258 */ | 258 */ |
259 virtual bool onCanDrawPath(const CanDrawPathArgs& args) const = 0; | 259 virtual bool onCanDrawPath(const CanDrawPathArgs& args) const = 0; |
260 | 260 |
261 /** | 261 /** |
262 * Subclass implementation of stencilPath(). Subclass must override iff it e
ver returns | 262 * Subclass implementation of stencilPath(). Subclass must override iff it e
ver returns |
263 * kStencilOnly in onGetStencilSupport(). | 263 * kStencilOnly in onGetStencilSupport(). |
264 */ | 264 */ |
265 virtual void onStencilPath(const StencilPathArgs& args) { | 265 virtual void onStencilPath(const StencilPathArgs& args) { |
266 static constexpr GrStencilSettings kIncrementStencil( | 266 static constexpr GrUserStencilSettings kIncrementStencil( |
267 kReplace_StencilOp, | 267 GrUserStencilSettings::StaticInit< |
268 kReplace_StencilOp, | 268 0xffff, |
269 kAlways_StencilFunc, | 269 GrUserStencilTest::kAlways, |
270 0xffff, | 270 0xffff, |
271 0xffff, | 271 GrUserStencilOp::kReplace, |
272 0xffff); | 272 GrUserStencilOp::kReplace, |
273 args.fPipelineBuilder->setStencil(kIncrementStencil); | 273 0xffff>() |
| 274 ); |
| 275 args.fPipelineBuilder->setUserStencil(&kIncrementStencil); |
274 args.fPipelineBuilder->setDisableColorXPFactory(); | 276 args.fPipelineBuilder->setDisableColorXPFactory(); |
275 DrawPathArgs drawArgs; | 277 DrawPathArgs drawArgs; |
276 drawArgs.fTarget = args.fTarget; | 278 drawArgs.fTarget = args.fTarget; |
277 drawArgs.fResourceProvider = args.fResourceProvider; | 279 drawArgs.fResourceProvider = args.fResourceProvider; |
278 drawArgs.fPipelineBuilder = args.fPipelineBuilder; | 280 drawArgs.fPipelineBuilder = args.fPipelineBuilder; |
279 drawArgs.fColor = 0xFFFFFFFF; | 281 drawArgs.fColor = 0xFFFFFFFF; |
280 drawArgs.fViewMatrix = args.fViewMatrix; | 282 drawArgs.fViewMatrix = args.fViewMatrix; |
281 drawArgs.fPath = args.fPath; | 283 drawArgs.fPath = args.fPath; |
282 drawArgs.fStroke = &GrStrokeInfo::FillInfo(); | 284 drawArgs.fStroke = &GrStrokeInfo::FillInfo(); |
283 drawArgs.fAntiAlias = false; | 285 drawArgs.fAntiAlias = false; |
284 drawArgs.fGammaCorrect = false; | 286 drawArgs.fGammaCorrect = false; |
285 this->drawPath(drawArgs); | 287 this->drawPath(drawArgs); |
286 } | 288 } |
287 | 289 |
288 | 290 |
289 typedef SkRefCnt INHERITED; | 291 typedef SkRefCnt INHERITED; |
290 }; | 292 }; |
291 | 293 |
292 #endif | 294 #endif |
OLD | NEW |