| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #ifndef GrPathRenderer_DEFINED | 9 #ifndef GrPathRenderer_DEFINED |
| 10 #define GrPathRenderer_DEFINED | 10 #define GrPathRenderer_DEFINED |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 * | 75 * |
| 76 * fShaderCaps The shader caps | 76 * fShaderCaps The shader caps |
| 77 * fPipelineBuilder The pipelineBuilder | 77 * fPipelineBuilder The pipelineBuilder |
| 78 * fViewMatrix The viewMatrix | 78 * fViewMatrix The viewMatrix |
| 79 * fPath The path to draw | 79 * fPath The path to draw |
| 80 * fStroke The stroke information (width, join, cap) | 80 * fStroke The stroke information (width, join, cap) |
| 81 * fAntiAlias True if anti-aliasing is required. | 81 * fAntiAlias True if anti-aliasing is required. |
| 82 */ | 82 */ |
| 83 struct CanDrawPathArgs { | 83 struct CanDrawPathArgs { |
| 84 const GrShaderCaps* fShaderCaps; | 84 const GrShaderCaps* fShaderCaps; |
| 85 const GrPipelineBuilder* fPipelineBuilder;// only used by GrStencilAn
dCoverPathRenderer | |
| 86 const SkMatrix* fViewMatrix; | 85 const SkMatrix* fViewMatrix; |
| 87 const SkPath* fPath; | 86 const SkPath* fPath; |
| 88 const GrStrokeInfo* fStroke; | 87 const GrStrokeInfo* fStroke; |
| 89 bool fAntiAlias; | 88 bool fAntiAlias; |
| 90 | 89 |
| 90 // These next two are only used by GrStencilAndCoverPathRenderer |
| 91 bool fIsStencilDisabled; |
| 92 bool fIsStencilBufferMSAA; |
| 93 |
| 91 void validate() const { | 94 void validate() const { |
| 92 SkASSERT(fShaderCaps); | 95 SkASSERT(fShaderCaps); |
| 93 SkASSERT(fPipelineBuilder); | |
| 94 SkASSERT(fViewMatrix); | 96 SkASSERT(fViewMatrix); |
| 95 SkASSERT(fPath); | 97 SkASSERT(fPath); |
| 96 SkASSERT(fStroke); | 98 SkASSERT(fStroke); |
| 97 SkASSERT(!fPath->isEmpty()); | 99 SkASSERT(!fPath->isEmpty()); |
| 98 } | 100 } |
| 99 }; | 101 }; |
| 100 | 102 |
| 101 /** | 103 /** |
| 102 * Returns true if this path renderer is able to render the path. Returning
false allows the | 104 * Returns true if this path renderer is able to render the path. Returning
false allows the |
| 103 * caller to fallback to another path renderer This function is called when
searching for a path | 105 * caller to fallback to another path renderer This function is called when
searching for a path |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 146 |
| 145 /** | 147 /** |
| 146 * Draws the path into the draw target. If getStencilSupport() would return
kNoRestriction then | 148 * Draws the path into the draw target. If getStencilSupport() would return
kNoRestriction then |
| 147 * the subclass must respect the stencil settings of the GrPipelineBuilder. | 149 * the subclass must respect the stencil settings of the GrPipelineBuilder. |
| 148 */ | 150 */ |
| 149 bool drawPath(const DrawPathArgs& args) { | 151 bool drawPath(const DrawPathArgs& args) { |
| 150 SkDEBUGCODE(args.validate();) | 152 SkDEBUGCODE(args.validate();) |
| 151 #ifdef SK_DEBUG | 153 #ifdef SK_DEBUG |
| 152 CanDrawPathArgs canArgs; | 154 CanDrawPathArgs canArgs; |
| 153 canArgs.fShaderCaps = args.fTarget->caps()->shaderCaps(); | 155 canArgs.fShaderCaps = args.fTarget->caps()->shaderCaps(); |
| 154 canArgs.fPipelineBuilder = args.fPipelineBuilder; | |
| 155 canArgs.fViewMatrix = args.fViewMatrix; | 156 canArgs.fViewMatrix = args.fViewMatrix; |
| 156 canArgs.fPath = args.fPath; | 157 canArgs.fPath = args.fPath; |
| 157 canArgs.fStroke = args.fStroke; | 158 canArgs.fStroke = args.fStroke; |
| 158 canArgs.fAntiAlias = args.fAntiAlias; | 159 canArgs.fAntiAlias = args.fAntiAlias; |
| 160 |
| 161 canArgs.fIsStencilDisabled = args.fPipelineBuilder->getStencil().isDisab
led(); |
| 162 canArgs.fIsStencilBufferMSAA = |
| 163 args.fPipelineBuilder->getRenderTarget()->isStencilBuf
ferMultisampled(); |
| 159 SkASSERT(this->canDrawPath(canArgs)); | 164 SkASSERT(this->canDrawPath(canArgs)); |
| 160 SkASSERT(args.fPipelineBuilder->getStencil().isDisabled() || | 165 SkASSERT(args.fPipelineBuilder->getStencil().isDisabled() || |
| 161 kNoRestriction_StencilSupport == this->getStencilSupport(*args.
fPath, | 166 kNoRestriction_StencilSupport == this->getStencilSupport(*args.
fPath, |
| 162 *args.
fStroke)); | 167 *args.
fStroke)); |
| 163 #endif | 168 #endif |
| 164 return this->onDrawPath(args); | 169 return this->onDrawPath(args); |
| 165 } | 170 } |
| 166 | 171 |
| 167 /* Args to stencilPath(). | 172 /* Args to stencilPath(). |
| 168 * | 173 * |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 drawArgs.fStroke = args.fStroke; | 285 drawArgs.fStroke = args.fStroke; |
| 281 drawArgs.fAntiAlias = false; | 286 drawArgs.fAntiAlias = false; |
| 282 this->drawPath(drawArgs); | 287 this->drawPath(drawArgs); |
| 283 } | 288 } |
| 284 | 289 |
| 285 | 290 |
| 286 typedef SkRefCnt INHERITED; | 291 typedef SkRefCnt INHERITED; |
| 287 }; | 292 }; |
| 288 | 293 |
| 289 #endif | 294 #endif |
| OLD | NEW |