| 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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 | 309 |
| 310 GrBatch* batch = GrStencilPathBatch::Create(viewMatrix, | 310 GrBatch* batch = GrStencilPathBatch::Create(viewMatrix, |
| 311 pipelineBuilder.isHWAntialias(), | 311 pipelineBuilder.isHWAntialias(), |
| 312 stencilSettings, clip.scissorSta
te(), | 312 stencilSettings, clip.scissorSta
te(), |
| 313 pipelineBuilder.getRenderTarget(
), | 313 pipelineBuilder.getRenderTarget(
), |
| 314 path); | 314 path); |
| 315 this->recordBatch(batch); | 315 this->recordBatch(batch); |
| 316 batch->unref(); | 316 batch->unref(); |
| 317 } | 317 } |
| 318 | 318 |
| 319 void GrDrawTarget::drawPath(const GrPipelineBuilder& pipelineBuilder, | |
| 320 const SkMatrix& viewMatrix, | |
| 321 GrColor color, | |
| 322 const GrPath* path, | |
| 323 GrPathRendering::FillType fill) { | |
| 324 SkASSERT(path); | |
| 325 SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport()); | |
| 326 | |
| 327 GrDrawPathBatchBase* batch = GrDrawPathBatch::Create(viewMatrix, color, path
); | |
| 328 this->drawPathBatch(pipelineBuilder, batch, fill); | |
| 329 batch->unref(); | |
| 330 } | |
| 331 | |
| 332 void GrDrawTarget::drawPathsFromRange(const GrPipelineBuilder& pipelineBuilder, | |
| 333 const SkMatrix& viewMatrix, | |
| 334 const SkMatrix& localMatrix, | |
| 335 GrColor color, | |
| 336 GrPathRange* range, | |
| 337 GrPathRangeDraw* draw, | |
| 338 GrPathRendering::FillType fill, | |
| 339 const SkRect& bounds) { | |
| 340 GrDrawPathBatchBase* batch = GrDrawPathRangeBatch::Create(viewMatrix, localM
atrix, color, | |
| 341 range, draw, bound
s); | |
| 342 this->drawPathBatch(pipelineBuilder, batch, fill); | |
| 343 batch->unref(); | |
| 344 } | |
| 345 | |
| 346 void GrDrawTarget::drawPathBatch(const GrPipelineBuilder& pipelineBuilder, | 319 void GrDrawTarget::drawPathBatch(const GrPipelineBuilder& pipelineBuilder, |
| 347 GrDrawPathBatchBase* batch, | 320 GrDrawPathBatchBase* batch) { |
| 348 GrPathRendering::FillType fill) { | |
| 349 // This looks like drawBatch() but there is an added wrinkle that stencil se
ttings get inserted | 321 // This looks like drawBatch() but there is an added wrinkle that stencil se
ttings get inserted |
| 350 // after setting up clipping but before onDrawBatch(). TODO: Figure out a be
tter model for | 322 // after setting up clipping but before onDrawBatch(). TODO: Figure out a be
tter model for |
| 351 // handling stencil settings WRT interactions between pipeline(builder), cli
pmaskmanager, and | 323 // handling stencil settings WRT interactions between pipeline(builder), cli
pmaskmanager, and |
| 352 // batches. | 324 // batches. |
| 325 SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport()); |
| 353 | 326 |
| 354 GrPipelineBuilder::AutoRestoreStencil ars; | 327 GrPipelineBuilder::AutoRestoreStencil ars; |
| 355 GrAppliedClip clip; | 328 GrAppliedClip clip; |
| 356 if (!fClipMaskManager->setupClipping(pipelineBuilder, &ars, &batch->bounds()
, &clip)) { | 329 if (!fClipMaskManager->setupClipping(pipelineBuilder, &ars, &batch->bounds()
, &clip)) { |
| 357 return; | 330 return; |
| 358 } | 331 } |
| 359 | 332 |
| 360 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; | 333 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; |
| 361 if (clip.clipCoverageFragmentProcessor()) { | 334 if (clip.clipCoverageFragmentProcessor()) { |
| 362 arfps.set(&pipelineBuilder); | 335 arfps.set(&pipelineBuilder); |
| 363 arfps.addCoverageFragmentProcessor(clip.clipCoverageFragmentProcessor())
; | 336 arfps.addCoverageFragmentProcessor(clip.clipCoverageFragmentProcessor())
; |
| 364 } | 337 } |
| 365 | 338 |
| 366 // Ensure the render target has a stencil buffer and get the stencil setting
s. | 339 // Ensure the render target has a stencil buffer and get the stencil setting
s. |
| 367 GrStencilSettings stencilSettings; | 340 GrStencilSettings stencilSettings; |
| 368 GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); | 341 GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); |
| 369 GrStencilAttachment* sb = fResourceProvider->attachStencilAttachment(rt); | 342 GrStencilAttachment* sb = fResourceProvider->attachStencilAttachment(rt); |
| 370 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); | 343 this->getPathStencilSettingsForFilltype(batch->fillType(), sb, &stencilSetti
ngs); |
| 371 batch->setStencilSettings(stencilSettings); | 344 batch->setStencilSettings(stencilSettings); |
| 372 | 345 |
| 373 GrPipeline::CreateArgs args; | 346 GrPipeline::CreateArgs args; |
| 374 if (!this->installPipelineInDrawBatch(&pipelineBuilder, &clip.scissorState()
, batch)) { | 347 if (!this->installPipelineInDrawBatch(&pipelineBuilder, &clip.scissorState()
, batch)) { |
| 375 return; | 348 return; |
| 376 } | 349 } |
| 377 | 350 |
| 378 this->recordBatch(batch); | 351 this->recordBatch(batch); |
| 379 } | 352 } |
| 380 | 353 |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 } | 541 } |
| 569 | 542 |
| 570 return true; | 543 return true; |
| 571 } | 544 } |
| 572 | 545 |
| 573 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend
erTarget* rt) { | 546 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend
erTarget* rt) { |
| 574 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); | 547 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); |
| 575 this->recordBatch(batch); | 548 this->recordBatch(batch); |
| 576 batch->unref(); | 549 batch->unref(); |
| 577 } | 550 } |
| OLD | NEW |