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