| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 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 #include "GrDrawTarget.h" | 9 #include "GrDrawTarget.h" |
| 10 | 10 |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 *outStencilSettings = winding_path_stencil_settings(); | 180 *outStencilSettings = winding_path_stencil_settings(); |
| 181 break; | 181 break; |
| 182 case GrPathRendering::kEvenOdd_FillType: | 182 case GrPathRendering::kEvenOdd_FillType: |
| 183 *outStencilSettings = even_odd_path_stencil_settings(); | 183 *outStencilSettings = even_odd_path_stencil_settings(); |
| 184 break; | 184 break; |
| 185 } | 185 } |
| 186 this->clipMaskManager()->adjustPathStencilParams(sb, outStencilSettings); | 186 this->clipMaskManager()->adjustPathStencilParams(sb, outStencilSettings); |
| 187 } | 187 } |
| 188 | 188 |
| 189 void GrDrawTarget::stencilPath(const GrPipelineBuilder& pipelineBuilder, | 189 void GrDrawTarget::stencilPath(const GrPipelineBuilder& pipelineBuilder, |
| 190 const GrPathProcessor* pathProc, | 190 const SkMatrix& viewMatrix, |
| 191 const GrPath* path, | 191 const GrPath* path, |
| 192 GrPathRendering::FillType fill) { | 192 GrPathRendering::FillType fill) { |
| 193 // TODO: extract portions of checkDraw that are relevant to path stenciling. | 193 // TODO: extract portions of checkDraw that are relevant to path stenciling. |
| 194 SkASSERT(path); | 194 SkASSERT(path); |
| 195 SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport()); | 195 SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport()); |
| 196 | 196 |
| 197 // Setup clip | 197 // Setup clip |
| 198 GrScissorState scissorState; | 198 GrScissorState scissorState; |
| 199 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; | 199 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; |
| 200 GrPipelineBuilder::AutoRestoreStencil ars; | 200 GrPipelineBuilder::AutoRestoreStencil ars; |
| 201 if (!this->setupClip(pipelineBuilder, &arfps, &ars, &scissorState, nullptr))
{ | 201 if (!this->setupClip(pipelineBuilder, &arfps, &ars, &scissorState, nullptr))
{ |
| 202 return; | 202 return; |
| 203 } | 203 } |
| 204 | 204 |
| 205 // set stencil settings for path | 205 // set stencil settings for path |
| 206 GrStencilSettings stencilSettings; | 206 GrStencilSettings stencilSettings; |
| 207 GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); | 207 GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); |
| 208 GrStencilAttachment* sb = rt->renderTargetPriv().attachStencilAttachment(); | 208 GrStencilAttachment* sb = rt->renderTargetPriv().attachStencilAttachment(); |
| 209 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); | 209 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); |
| 210 | 210 |
| 211 GrBatch* batch = GrStencilPathBatch::Create(pathProc->viewMatrix(), | 211 GrBatch* batch = GrStencilPathBatch::Create(viewMatrix, |
| 212 pipelineBuilder.isHWAntialias(), | 212 pipelineBuilder.isHWAntialias(), |
| 213 stencilSettings, scissorState, | 213 stencilSettings, scissorState, |
| 214 pipelineBuilder.getRenderTarget(
), | 214 pipelineBuilder.getRenderTarget(
), |
| 215 path); | 215 path); |
| 216 this->onDrawBatch(batch); | 216 this->onDrawBatch(batch); |
| 217 batch->unref(); | 217 batch->unref(); |
| 218 } | 218 } |
| 219 | 219 |
| 220 void GrDrawTarget::drawPath(const GrPipelineBuilder& pipelineBuilder, | 220 void GrDrawTarget::drawPath(const GrPipelineBuilder& pipelineBuilder, |
| 221 const GrPathProcessor* pathProc, | 221 const SkMatrix& viewMatrix, |
| 222 GrColor color, |
| 222 const GrPath* path, | 223 const GrPath* path, |
| 223 GrPathRendering::FillType fill) { | 224 GrPathRendering::FillType fill) { |
| 224 SkASSERT(path); | 225 SkASSERT(path); |
| 225 SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport()); | 226 SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport()); |
| 226 | 227 |
| 227 GrDrawPathBatchBase* batch = GrDrawPathBatch::Create(pathProc, path); | 228 GrDrawPathBatchBase* batch = GrDrawPathBatch::Create(viewMatrix, color, path
); |
| 228 this->drawPathBatch(pipelineBuilder, batch, fill); | 229 this->drawPathBatch(pipelineBuilder, batch, fill); |
| 229 batch->unref(); | 230 batch->unref(); |
| 230 } | 231 } |
| 231 | 232 |
| 232 void GrDrawTarget::drawPathsFromRange(const GrPipelineBuilder& pipelineBuilder, | 233 void GrDrawTarget::drawPathsFromRange(const GrPipelineBuilder& pipelineBuilder, |
| 233 const GrPathProcessor* pathProc, | 234 const SkMatrix& viewMatrix, |
| 235 const SkMatrix& localMatrix, |
| 236 GrColor color, |
| 234 GrPathRangeDraw* draw, | 237 GrPathRangeDraw* draw, |
| 235 GrPathRendering::FillType fill) { | 238 GrPathRendering::FillType fill) { |
| 236 GrDrawPathBatchBase* batch = GrDrawPathRangeBatch::Create(pathProc, draw); | 239 GrDrawPathBatchBase* batch = GrDrawPathRangeBatch::Create(viewMatrix, localM
atrix, color, draw); |
| 237 this->drawPathBatch(pipelineBuilder, batch, fill); | 240 this->drawPathBatch(pipelineBuilder, batch, fill); |
| 238 batch->unref(); | 241 batch->unref(); |
| 239 } | 242 } |
| 240 | 243 |
| 241 void GrDrawTarget::drawPathBatch(const GrPipelineBuilder& pipelineBuilder, | 244 void GrDrawTarget::drawPathBatch(const GrPipelineBuilder& pipelineBuilder, |
| 242 GrDrawPathBatchBase* batch, | 245 GrDrawPathBatchBase* batch, |
| 243 GrPathRendering::FillType fill) { | 246 GrPathRendering::FillType fill) { |
| 244 // This looks like drawBatch() but there is an added wrinkle that stencil se
ttings get inserted | 247 // This looks like drawBatch() but there is an added wrinkle that stencil se
ttings get inserted |
| 245 // after setupClip() but before onDrawBatch(). TODO: Figure out a better mod
el for handling | 248 // after setupClip() but before onDrawBatch(). TODO: Figure out a better mod
el for handling |
| 246 // stencil settings WRT interactions between pipeline(builder), clipmaskmana
ger, and batches. | 249 // stencil settings WRT interactions between pipeline(builder), clipmaskmana
ger, and batches. |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 // The clip mask manager can rebuild all its clip masks so just | 415 // The clip mask manager can rebuild all its clip masks so just |
| 413 // get rid of them all. | 416 // get rid of them all. |
| 414 fClipMaskManager->purgeResources(); | 417 fClipMaskManager->purgeResources(); |
| 415 }; | 418 }; |
| 416 | 419 |
| 417 void GrClipTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend
erTarget* rt) { | 420 void GrClipTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend
erTarget* rt) { |
| 418 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); | 421 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); |
| 419 this->onDrawBatch(batch); | 422 this->onDrawBatch(batch); |
| 420 batch->unref(); | 423 batch->unref(); |
| 421 } | 424 } |
| OLD | NEW |