Chromium Code Reviews| 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 "GrCaps.h" | 11 #include "GrCaps.h" |
| 12 #include "GrGpu.h" | 12 #include "GrGpu.h" |
| 13 #include "GrPath.h" | 13 #include "GrPath.h" |
| 14 #include "GrPipeline.h" | 14 #include "GrPipeline.h" |
| 15 #include "GrMemoryPool.h" | 15 #include "GrMemoryPool.h" |
| 16 #include "GrRenderTarget.h" | 16 #include "GrRenderTarget.h" |
| 17 #include "GrResourceProvider.h" | 17 #include "GrResourceProvider.h" |
| 18 #include "GrRenderTargetPriv.h" | 18 #include "GrRenderTargetPriv.h" |
| 19 #include "GrSurfacePriv.h" | 19 #include "GrSurfacePriv.h" |
| 20 #include "GrTexture.h" | 20 #include "GrTexture.h" |
| 21 #include "GrVertexBuffer.h" | 21 #include "GrVertexBuffer.h" |
| 22 | 22 #include "gl/GrGLRenderTarget.h" |
| 23 #include "batches/GrClearBatch.h" | 23 #include "batches/GrClearBatch.h" |
| 24 #include "batches/GrCopySurfaceBatch.h" | 24 #include "batches/GrCopySurfaceBatch.h" |
| 25 #include "batches/GrDiscardBatch.h" | 25 #include "batches/GrDiscardBatch.h" |
| 26 #include "batches/GrDrawBatch.h" | 26 #include "batches/GrDrawBatch.h" |
| 27 #include "batches/GrDrawPathBatch.h" | 27 #include "batches/GrDrawPathBatch.h" |
| 28 #include "batches/GrRectBatchFactory.h" | 28 #include "batches/GrRectBatchFactory.h" |
| 29 #include "batches/GrStencilPathBatch.h" | 29 #include "batches/GrStencilPathBatch.h" |
| 30 | 30 |
| 31 #include "SkStrokeRec.h" | 31 #include "SkStrokeRec.h" |
| 32 | 32 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 203 SkIRect ibounds; | 203 SkIRect ibounds; |
| 204 bounds.roundOut(&ibounds); | 204 bounds.roundOut(&ibounds); |
| 205 // In multi-draw buffer all the batches use the same render target a nd we won't need to | 205 // In multi-draw buffer all the batches use the same render target a nd we won't need to |
| 206 // get the batchs bounds. | 206 // get the batchs bounds. |
| 207 if (GrRenderTarget* rt = fBatches[i]->renderTarget()) { | 207 if (GrRenderTarget* rt = fBatches[i]->renderTarget()) { |
| 208 fGpu->drawDebugWireRect(rt, ibounds, 0xFF000000 | random.nextU() ); | 208 fGpu->drawDebugWireRect(rt, ibounds, 0xFF000000 | random.nextU() ); |
| 209 } | 209 } |
| 210 } | 210 } |
| 211 fBatches[i]->draw(flushState); | 211 fBatches[i]->draw(flushState); |
| 212 } | 212 } |
| 213 | |
| 214 fGpu->performFlushWorkaround(); | |
| 213 } | 215 } |
| 214 | 216 |
| 215 void GrDrawTarget::reset() { | 217 void GrDrawTarget::reset() { |
| 216 fBatches.reset(); | 218 fBatches.reset(); |
| 217 } | 219 } |
| 218 | 220 |
| 219 void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawBat ch* batch) { | 221 void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawBat ch* batch) { |
| 220 // Setup clip | 222 // Setup clip |
| 221 GrPipelineBuilder::AutoRestoreStencil ars; | 223 GrPipelineBuilder::AutoRestoreStencil ars; |
| 222 GrAppliedClip clip; | 224 GrAppliedClip clip; |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 506 } | 508 } |
| 507 } | 509 } |
| 508 } else { | 510 } else { |
| 509 GrBATCH_INFO("\t\tFirstBatch\n"); | 511 GrBATCH_INFO("\t\tFirstBatch\n"); |
| 510 } | 512 } |
| 511 fBatches.push_back().reset(SkRef(batch)); | 513 fBatches.push_back().reset(SkRef(batch)); |
| 512 } | 514 } |
| 513 | 515 |
| 514 /////////////////////////////////////////////////////////////////////////////// | 516 /////////////////////////////////////////////////////////////////////////////// |
| 515 | 517 |
| 518 #ifdef ENABLE_PLS | |
|
bsalomon
2016/01/04 15:33:46
There is an SkTPin that does the same thing.
| |
| 519 static int clamp(int min, int v, int max) { | |
| 520 return SkTMin(SkTMax(v, min), max); | |
| 521 } | |
| 522 #endif | |
| 523 | |
| 516 bool GrDrawTarget::installPipelineInDrawBatch(const GrPipelineBuilder* pipelineB uilder, | 524 bool GrDrawTarget::installPipelineInDrawBatch(const GrPipelineBuilder* pipelineB uilder, |
| 517 const GrScissorState* scissor, | 525 const GrScissorState* scissor, |
| 518 GrDrawBatch* batch) { | 526 GrDrawBatch* batch) { |
| 519 GrPipeline::CreateArgs args; | 527 GrPipeline::CreateArgs args; |
| 520 args.fPipelineBuilder = pipelineBuilder; | 528 args.fPipelineBuilder = pipelineBuilder; |
| 521 args.fCaps = this->caps(); | 529 args.fCaps = this->caps(); |
| 522 args.fScissor = scissor; | 530 args.fScissor = scissor; |
| 523 batch->getPipelineOptimizations(&args.fOpts); | 531 batch->getPipelineOptimizations(&args.fOpts); |
| 532 #ifdef ENABLE_PLS | |
| 533 GrScissorState finalScissor; | |
| 534 if (args.fOpts.fOverrides.fUsePLSDstRead) { | |
| 535 // FIXME shouldn't have to cast to GL implementation here | |
|
bsalomon
2016/01/04 15:33:46
The viewport rect isn't really right because it re
| |
| 536 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(pipelineBuilde r->getRenderTarget()); | |
| 537 GrGLIRect viewport = rt->getViewport(); | |
| 538 SkIRect ibounds; | |
| 539 ibounds.fLeft = clamp(viewport.fLeft, SkScalarFloorToInt(batch->boun ds().fLeft), | |
| 540 viewport.fWidth); | |
| 541 ibounds.fTop = clamp(viewport.fBottom, SkScalarFloorToInt(batch->bou nds().fTop), | |
| 542 viewport.fHeight); | |
| 543 ibounds.fRight = clamp(viewport.fLeft, SkScalarCeilToInt(batch->boun ds().fRight), | |
| 544 viewport.fWidth); | |
| 545 ibounds.fBottom = clamp(viewport.fBottom, SkScalarCeilToInt(batch->b ounds().fBottom), | |
| 546 viewport.fHeight); | |
| 547 if (scissor != nullptr && scissor->enabled()) { | |
| 548 if (!ibounds.intersect(scissor->rect())) { | |
| 549 ibounds = scissor->rect(); | |
| 550 } | |
| 551 } | |
| 552 finalScissor.set(ibounds); | |
| 553 args.fScissor = &finalScissor; | |
| 554 } | |
| 555 #endif | |
| 524 args.fOpts.fColorPOI.completeCalculations(pipelineBuilder->fColorFragmentPro cessors.begin(), | 556 args.fOpts.fColorPOI.completeCalculations(pipelineBuilder->fColorFragmentPro cessors.begin(), |
| 525 pipelineBuilder->numColorFragmentP rocessors()); | 557 pipelineBuilder->numColorFragmentP rocessors()); |
| 526 args.fOpts.fCoveragePOI.completeCalculations( | 558 args.fOpts.fCoveragePOI.completeCalculations( |
| 527 pipelineBuilder->fCoverageFragmen tProcessors.begin(), | 559 pipelineBuilder->fCoverageFragmen tProcessors.begin(), |
| 528 pipelineBuilder->numCoverageFragm entProcessors()); | 560 pipelineBuilder->numCoverageFragm entProcessors()); |
| 529 if (!this->setupDstReadIfNecessary(*pipelineBuilder, args.fOpts, &args.fDstT exture, | 561 if (!this->setupDstReadIfNecessary(*pipelineBuilder, args.fOpts, &args.fDstT exture, |
| 530 batch->bounds())) { | 562 batch->bounds())) { |
| 531 return false; | 563 return false; |
| 532 } | 564 } |
| 533 | 565 |
| 534 if (!batch->installPipeline(args)) { | 566 if (!batch->installPipeline(args)) { |
| 535 return false; | 567 return false; |
| 536 } | 568 } |
| 537 | 569 |
| 538 return true; | 570 return true; |
| 539 } | 571 } |
| 540 | 572 |
| 541 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend erTarget* rt) { | 573 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend erTarget* rt) { |
| 542 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); | 574 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); |
| 543 this->recordBatch(batch); | 575 this->recordBatch(batch); |
| 544 batch->unref(); | 576 batch->unref(); |
| 545 } | 577 } |
| OLD | NEW |