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