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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 fFlushState.reset(); | 214 fFlushState.reset(); |
215 } | 215 } |
216 | 216 |
217 void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawBat
ch* batch) { | 217 void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawBat
ch* batch) { |
218 // Setup clip | 218 // Setup clip |
219 GrPipelineBuilder::AutoRestoreStencil ars; | 219 GrPipelineBuilder::AutoRestoreStencil ars; |
220 GrAppliedClip clip; | 220 GrAppliedClip clip; |
221 if (!fClipMaskManager->setupClipping(pipelineBuilder, &ars, &batch->bounds()
, &clip)) { | 221 if (!fClipMaskManager->setupClipping(pipelineBuilder, &ars, &batch->bounds()
, &clip)) { |
222 return; | 222 return; |
223 } | 223 } |
224 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; | |
225 if (clip.clipCoverageFragmentProcessor()) { | |
226 arfps.set(&pipelineBuilder); | |
227 arfps.addCoverageFragmentProcessor(clip.clipCoverageFragmentProcessor())
; | |
228 } | |
229 | 224 |
230 GrPipeline::CreateArgs args; | 225 GrPipeline::CreateArgs args; |
231 if (!this->installPipelineInDrawBatch(&pipelineBuilder, &clip.scissorState()
, batch)) { | 226 if (!this->installPipelineInDrawBatch(&pipelineBuilder, &clip, batch)) { |
232 return; | 227 return; |
233 } | 228 } |
234 | 229 |
235 #ifdef ENABLE_MDB | 230 #ifdef ENABLE_MDB |
236 SkASSERT(fRenderTarget); | 231 SkASSERT(fRenderTarget); |
237 batch->pipeline()->addDependenciesTo(fRenderTarget); | 232 batch->pipeline()->addDependenciesTo(fRenderTarget); |
238 #endif | 233 #endif |
239 | 234 |
240 this->recordBatch(batch); | 235 this->recordBatch(batch); |
241 } | 236 } |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 // after setting up clipping but before onDrawBatch(). TODO: Figure out a be
tter model for | 339 // after setting up clipping but before onDrawBatch(). TODO: Figure out a be
tter model for |
345 // handling stencil settings WRT interactions between pipeline(builder), cli
pmaskmanager, and | 340 // handling stencil settings WRT interactions between pipeline(builder), cli
pmaskmanager, and |
346 // batches. | 341 // batches. |
347 | 342 |
348 GrPipelineBuilder::AutoRestoreStencil ars; | 343 GrPipelineBuilder::AutoRestoreStencil ars; |
349 GrAppliedClip clip; | 344 GrAppliedClip clip; |
350 if (!fClipMaskManager->setupClipping(pipelineBuilder, &ars, &batch->bounds()
, &clip)) { | 345 if (!fClipMaskManager->setupClipping(pipelineBuilder, &ars, &batch->bounds()
, &clip)) { |
351 return; | 346 return; |
352 } | 347 } |
353 | 348 |
354 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; | |
355 if (clip.clipCoverageFragmentProcessor()) { | |
356 arfps.set(&pipelineBuilder); | |
357 arfps.addCoverageFragmentProcessor(clip.clipCoverageFragmentProcessor())
; | |
358 } | |
359 | |
360 // Ensure the render target has a stencil buffer and get the stencil setting
s. | 349 // Ensure the render target has a stencil buffer and get the stencil setting
s. |
361 GrStencilSettings stencilSettings; | 350 GrStencilSettings stencilSettings; |
362 GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); | 351 GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); |
363 GrStencilAttachment* sb = fResourceProvider->attachStencilAttachment(rt); | 352 GrStencilAttachment* sb = fResourceProvider->attachStencilAttachment(rt); |
364 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); | 353 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); |
365 batch->setStencilSettings(stencilSettings); | 354 batch->setStencilSettings(stencilSettings); |
366 | 355 |
367 GrPipeline::CreateArgs args; | 356 GrPipeline::CreateArgs args; |
368 if (!this->installPipelineInDrawBatch(&pipelineBuilder, &clip.scissorState()
, batch)) { | 357 if (!this->installPipelineInDrawBatch(&pipelineBuilder, &clip, batch)) { |
369 return; | 358 return; |
370 } | 359 } |
371 | 360 |
372 this->recordBatch(batch); | 361 this->recordBatch(batch); |
373 } | 362 } |
374 | 363 |
375 void GrDrawTarget::drawNonAARect(const GrPipelineBuilder& pipelineBuilder, | 364 void GrDrawTarget::drawNonAARect(const GrPipelineBuilder& pipelineBuilder, |
376 GrColor color, | 365 GrColor color, |
377 const SkMatrix& viewMatrix, | 366 const SkMatrix& viewMatrix, |
378 const SkRect& rect) { | 367 const SkRect& rect) { |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 fBatches[fFirstUnpreparedBatch++]->prepare(&fFlushState); | 527 fBatches[fFirstUnpreparedBatch++]->prepare(&fFlushState); |
539 } | 528 } |
540 if (fOptions.fImmediateMode) { | 529 if (fOptions.fImmediateMode) { |
541 this->flush(); | 530 this->flush(); |
542 } | 531 } |
543 } | 532 } |
544 | 533 |
545 /////////////////////////////////////////////////////////////////////////////// | 534 /////////////////////////////////////////////////////////////////////////////// |
546 | 535 |
547 bool GrDrawTarget::installPipelineInDrawBatch(const GrPipelineBuilder* pipelineB
uilder, | 536 bool GrDrawTarget::installPipelineInDrawBatch(const GrPipelineBuilder* pipelineB
uilder, |
548 const GrScissorState* scissor, | 537 const GrAppliedClip* clip, GrDrawB
atch* batch) { |
549 GrDrawBatch* batch) { | 538 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; |
| 539 if (clip->clipCoverageFragmentProcessor()) { |
| 540 arfps.set(pipelineBuilder); |
| 541 arfps.addCoverageFragmentProcessor(clip->clipCoverageFragmentProcessor()
); |
| 542 } |
| 543 |
550 GrPipeline::CreateArgs args; | 544 GrPipeline::CreateArgs args; |
551 args.fPipelineBuilder = pipelineBuilder; | 545 args.fPipelineBuilder = pipelineBuilder; |
552 args.fCaps = this->caps(); | 546 args.fCaps = this->caps(); |
553 args.fScissor = scissor; | |
554 args.fColorPOI = pipelineBuilder->colorProcInfo(batch); | 547 args.fColorPOI = pipelineBuilder->colorProcInfo(batch); |
555 args.fCoveragePOI = pipelineBuilder->coverageProcInfo(batch); | 548 args.fCoveragePOI = pipelineBuilder->coverageProcInfo(batch); |
| 549 args.fClip = clip; |
556 if (!this->setupDstReadIfNecessary(*pipelineBuilder, args.fColorPOI, | 550 if (!this->setupDstReadIfNecessary(*pipelineBuilder, args.fColorPOI, |
557 args.fCoveragePOI, &args.fDstTexture, | 551 args.fCoveragePOI, &args.fDstTexture, |
558 batch->bounds())) { | 552 batch->bounds())) { |
559 return false; | 553 return false; |
560 } | 554 } |
561 | 555 |
562 if (!batch->installPipeline(args)) { | 556 if (!batch->installPipeline(args)) { |
563 return false; | 557 return false; |
564 } | 558 } |
565 | 559 |
566 return true; | 560 return true; |
567 } | 561 } |
568 | 562 |
569 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend
erTarget* rt) { | 563 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend
erTarget* rt) { |
570 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); | 564 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); |
571 this->recordBatch(batch); | 565 this->recordBatch(batch); |
572 batch->unref(); | 566 batch->unref(); |
573 } | 567 } |
OLD | NEW |