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 |
11 #include "GrAuditTrail.h" | 11 #include "GrAuditTrail.h" |
12 #include "GrCaps.h" | 12 #include "GrCaps.h" |
13 #include "GrGpu.h" | 13 #include "GrGpu.h" |
14 #include "GrPath.h" | 14 #include "GrPath.h" |
15 #include "GrPipeline.h" | 15 #include "GrPipeline.h" |
16 #include "GrMemoryPool.h" | 16 #include "GrMemoryPool.h" |
17 #include "GrRenderTarget.h" | 17 #include "GrRenderTarget.h" |
18 #include "GrResourceProvider.h" | 18 #include "GrResourceProvider.h" |
19 #include "GrRenderTargetPriv.h" | 19 #include "GrRenderTargetPriv.h" |
20 #include "GrSurfacePriv.h" | 20 #include "GrSurfacePriv.h" |
21 #include "GrTexture.h" | 21 #include "GrTexture.h" |
22 #include "GrVertexBuffer.h" | 22 #include "GrVertexBuffer.h" |
23 #include "gl/GrGLRenderTarget.h" | |
24 | 23 |
25 #include "SkStrokeRec.h" | 24 #include "SkStrokeRec.h" |
26 | 25 |
27 #include "batches/GrClearBatch.h" | 26 #include "batches/GrClearBatch.h" |
28 #include "batches/GrCopySurfaceBatch.h" | 27 #include "batches/GrCopySurfaceBatch.h" |
29 #include "batches/GrDiscardBatch.h" | 28 #include "batches/GrDiscardBatch.h" |
30 #include "batches/GrDrawBatch.h" | 29 #include "batches/GrDrawBatch.h" |
31 #include "batches/GrDrawPathBatch.h" | 30 #include "batches/GrDrawPathBatch.h" |
32 #include "batches/GrRectBatchFactory.h" | 31 #include "batches/GrRectBatchFactory.h" |
33 #include "batches/GrStencilPathBatch.h" | 32 #include "batches/GrStencilPathBatch.h" |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 SkIRect ibounds; | 205 SkIRect ibounds; |
207 bounds.roundOut(&ibounds); | 206 bounds.roundOut(&ibounds); |
208 // In multi-draw buffer all the batches use the same render target a
nd we won't need to | 207 // In multi-draw buffer all the batches use the same render target a
nd we won't need to |
209 // get the batchs bounds. | 208 // get the batchs bounds. |
210 if (GrRenderTarget* rt = fBatches[i]->renderTarget()) { | 209 if (GrRenderTarget* rt = fBatches[i]->renderTarget()) { |
211 fGpu->drawDebugWireRect(rt, ibounds, 0xFF000000 | random.nextU()
); | 210 fGpu->drawDebugWireRect(rt, ibounds, 0xFF000000 | random.nextU()
); |
212 } | 211 } |
213 } | 212 } |
214 fBatches[i]->draw(flushState); | 213 fBatches[i]->draw(flushState); |
215 } | 214 } |
216 | |
217 fGpu->performFlushWorkaround(); | |
218 } | 215 } |
219 | 216 |
220 void GrDrawTarget::reset() { | 217 void GrDrawTarget::reset() { |
221 fBatches.reset(); | 218 fBatches.reset(); |
222 } | 219 } |
223 | 220 |
224 void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawBat
ch* batch) { | 221 void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawBat
ch* batch) { |
225 // Setup clip | 222 // Setup clip |
226 GrPipelineBuilder::AutoRestoreStencil ars; | 223 GrPipelineBuilder::AutoRestoreStencil ars; |
227 GrAppliedClip clip; | 224 GrAppliedClip clip; |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 /////////////////////////////////////////////////////////////////////////////// | 480 /////////////////////////////////////////////////////////////////////////////// |
484 | 481 |
485 bool GrDrawTarget::installPipelineInDrawBatch(const GrPipelineBuilder* pipelineB
uilder, | 482 bool GrDrawTarget::installPipelineInDrawBatch(const GrPipelineBuilder* pipelineB
uilder, |
486 const GrScissorState* scissor, | 483 const GrScissorState* scissor, |
487 GrDrawBatch* batch) { | 484 GrDrawBatch* batch) { |
488 GrPipeline::CreateArgs args; | 485 GrPipeline::CreateArgs args; |
489 args.fPipelineBuilder = pipelineBuilder; | 486 args.fPipelineBuilder = pipelineBuilder; |
490 args.fCaps = this->caps(); | 487 args.fCaps = this->caps(); |
491 args.fScissor = scissor; | 488 args.fScissor = scissor; |
492 batch->getPipelineOptimizations(&args.fOpts); | 489 batch->getPipelineOptimizations(&args.fOpts); |
493 GrScissorState finalScissor; | |
494 if (args.fOpts.fOverrides.fUsePLSDstRead) { | |
495 GrRenderTarget* rt = pipelineBuilder->getRenderTarget(); | |
496 GrGLIRect viewport; | |
497 viewport.fLeft = 0; | |
498 viewport.fBottom = 0; | |
499 viewport.fWidth = rt->width(); | |
500 viewport.fHeight = rt->height(); | |
501 SkIRect ibounds; | |
502 ibounds.fLeft = SkTPin(SkScalarFloorToInt(batch->bounds().fLeft), viewpo
rt.fLeft, | |
503 viewport.fWidth); | |
504 ibounds.fTop = SkTPin(SkScalarFloorToInt(batch->bounds().fTop), viewport
.fBottom, | |
505 viewport.fHeight); | |
506 ibounds.fRight = SkTPin(SkScalarCeilToInt(batch->bounds().fRight), viewp
ort.fLeft, | |
507 viewport.fWidth); | |
508 ibounds.fBottom = SkTPin(SkScalarCeilToInt(batch->bounds().fBottom), vie
wport.fBottom, | |
509 viewport.fHeight); | |
510 if (scissor != nullptr && scissor->enabled()) { | |
511 if (!ibounds.intersect(scissor->rect())) { | |
512 ibounds = scissor->rect(); | |
513 } | |
514 } | |
515 finalScissor.set(ibounds); | |
516 args.fScissor = &finalScissor; | |
517 } | |
518 args.fOpts.fColorPOI.completeCalculations(pipelineBuilder->fColorFragmentPro
cessors.begin(), | 490 args.fOpts.fColorPOI.completeCalculations(pipelineBuilder->fColorFragmentPro
cessors.begin(), |
519 pipelineBuilder->numColorFragmentP
rocessors()); | 491 pipelineBuilder->numColorFragmentP
rocessors()); |
520 args.fOpts.fCoveragePOI.completeCalculations( | 492 args.fOpts.fCoveragePOI.completeCalculations( |
521 pipelineBuilder->fCoverageFragmen
tProcessors.begin(), | 493 pipelineBuilder->fCoverageFragmen
tProcessors.begin(), |
522 pipelineBuilder->numCoverageFragm
entProcessors()); | 494 pipelineBuilder->numCoverageFragm
entProcessors()); |
523 if (!this->setupDstReadIfNecessary(*pipelineBuilder, args.fOpts, &args.fDstT
exture, | 495 if (!this->setupDstReadIfNecessary(*pipelineBuilder, args.fOpts, &args.fDstT
exture, |
524 batch->bounds())) { | 496 batch->bounds())) { |
525 return false; | 497 return false; |
526 } | 498 } |
527 | 499 |
528 if (!batch->installPipeline(args)) { | 500 if (!batch->installPipeline(args)) { |
529 return false; | 501 return false; |
530 } | 502 } |
531 | 503 |
532 return true; | 504 return true; |
533 } | 505 } |
534 | 506 |
535 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend
erTarget* rt) { | 507 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend
erTarget* rt) { |
536 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); | 508 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); |
537 this->recordBatch(batch); | 509 this->recordBatch(batch); |
538 batch->unref(); | 510 batch->unref(); |
539 } | 511 } |
OLD | NEW |