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 24 matching lines...) Expand all Loading... |
35 , fGpuTraceMarkerCount(0) | 35 , fGpuTraceMarkerCount(0) |
36 , fFlushing(false) { | 36 , fFlushing(false) { |
37 SkASSERT(context); | 37 SkASSERT(context); |
38 } | 38 } |
39 | 39 |
40 //////////////////////////////////////////////////////////////////////////////// | 40 //////////////////////////////////////////////////////////////////////////////// |
41 | 41 |
42 bool GrDrawTarget::setupDstReadIfNecessary(const GrPipelineBuilder& pipelineBuil
der, | 42 bool GrDrawTarget::setupDstReadIfNecessary(const GrPipelineBuilder& pipelineBuil
der, |
43 const GrProcOptInfo& colorPOI, | 43 const GrProcOptInfo& colorPOI, |
44 const GrProcOptInfo& coveragePOI, | 44 const GrProcOptInfo& coveragePOI, |
45 GrDeviceCoordTexture* dstCopy, | 45 GrXferProcessor::DstTexture* dstTextu
re, |
46 const SkRect* drawBounds) { | 46 const SkRect* drawBounds) { |
47 if (!pipelineBuilder.willXPNeedDstCopy(*this->caps(), colorPOI, coveragePOI)
) { | 47 if (!pipelineBuilder.willXPNeedDstTexture(*this->caps(), colorPOI, coverageP
OI)) { |
48 return true; | 48 return true; |
49 } | 49 } |
50 | 50 |
51 GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); | 51 GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); |
52 | 52 |
53 if (this->caps()->textureBarrierSupport()) { | 53 if (this->caps()->textureBarrierSupport()) { |
54 if (GrTexture* rtTex = rt->asTexture()) { | 54 if (GrTexture* rtTex = rt->asTexture()) { |
55 // The render target is a texture, se we can read from it directly i
n the shader. The XP | 55 // The render target is a texture, se we can read from it directly i
n the shader. The XP |
56 // will be responsible to detect this situation and request a textur
e barrier. | 56 // will be responsible to detect this situation and request a textur
e barrier. |
57 dstCopy->setTexture(rtTex); | 57 dstTexture->setTexture(rtTex); |
58 dstCopy->setOffset(0, 0); | 58 dstTexture->setOffset(0, 0); |
59 return true; | 59 return true; |
60 } | 60 } |
61 } | 61 } |
62 | 62 |
63 SkIRect copyRect; | 63 SkIRect copyRect; |
64 pipelineBuilder.clip().getConservativeBounds(rt, ©Rect); | 64 pipelineBuilder.clip().getConservativeBounds(rt, ©Rect); |
65 | 65 |
66 if (drawBounds) { | 66 if (drawBounds) { |
67 SkIRect drawIBounds; | 67 SkIRect drawIBounds; |
68 drawBounds->roundOut(&drawIBounds); | 68 drawBounds->roundOut(&drawIBounds); |
(...skipping 25 matching lines...) Expand all Loading... |
94 | 94 |
95 SkAutoTUnref<GrTexture> copy(fContext->textureProvider()->refScratchTexture(
desc, | 95 SkAutoTUnref<GrTexture> copy(fContext->textureProvider()->refScratchTexture(
desc, |
96 GrTextureProvider::kApprox_ScratchTexMatch)); | 96 GrTextureProvider::kApprox_ScratchTexMatch)); |
97 | 97 |
98 if (!copy) { | 98 if (!copy) { |
99 SkDebugf("Failed to create temporary copy of destination texture.\n"); | 99 SkDebugf("Failed to create temporary copy of destination texture.\n"); |
100 return false; | 100 return false; |
101 } | 101 } |
102 SkIPoint dstPoint = {0, 0}; | 102 SkIPoint dstPoint = {0, 0}; |
103 this->copySurface(copy, rt, copyRect, dstPoint); | 103 this->copySurface(copy, rt, copyRect, dstPoint); |
104 dstCopy->setTexture(copy); | 104 dstTexture->setTexture(copy); |
105 dstCopy->setOffset(copyRect.fLeft, copyRect.fTop); | 105 dstTexture->setOffset(copyRect.fLeft, copyRect.fTop); |
106 return true; | 106 return true; |
107 } | 107 } |
108 | 108 |
109 void GrDrawTarget::flush() { | 109 void GrDrawTarget::flush() { |
110 if (fFlushing) { | 110 if (fFlushing) { |
111 return; | 111 return; |
112 } | 112 } |
113 fFlushing = true; | 113 fFlushing = true; |
114 | 114 |
115 this->getGpu()->saveActiveTraceMarkers(); | 115 this->getGpu()->saveActiveTraceMarkers(); |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 this->onCopySurface(dst, src, clippedSrcRect, clippedDstPoint); | 440 this->onCopySurface(dst, src, clippedSrcRect, clippedDstPoint); |
441 } | 441 } |
442 | 442 |
443 void GrDrawTarget::setupPipeline(const PipelineInfo& pipelineInfo, | 443 void GrDrawTarget::setupPipeline(const PipelineInfo& pipelineInfo, |
444 GrPipeline* pipeline) { | 444 GrPipeline* pipeline) { |
445 SkNEW_PLACEMENT_ARGS(pipeline, GrPipeline, (*pipelineInfo.fPipelineBuilder, | 445 SkNEW_PLACEMENT_ARGS(pipeline, GrPipeline, (*pipelineInfo.fPipelineBuilder, |
446 pipelineInfo.fColorPOI, | 446 pipelineInfo.fColorPOI, |
447 pipelineInfo.fCoveragePOI, | 447 pipelineInfo.fCoveragePOI, |
448 *this->caps(), | 448 *this->caps(), |
449 *pipelineInfo.fScissor, | 449 *pipelineInfo.fScissor, |
450 &pipelineInfo.fDstCopy)); | 450 &pipelineInfo.fDstTexture)); |
451 } | 451 } |
452 /////////////////////////////////////////////////////////////////////////////// | 452 /////////////////////////////////////////////////////////////////////////////// |
453 | 453 |
454 GrDrawTarget::PipelineInfo::PipelineInfo(GrPipelineBuilder* pipelineBuilder, | 454 GrDrawTarget::PipelineInfo::PipelineInfo(GrPipelineBuilder* pipelineBuilder, |
455 GrScissorState* scissor, | 455 GrScissorState* scissor, |
456 const GrPrimitiveProcessor* primProc, | 456 const GrPrimitiveProcessor* primProc, |
457 const SkRect* devBounds, | 457 const SkRect* devBounds, |
458 GrDrawTarget* target) | 458 GrDrawTarget* target) |
459 : fPipelineBuilder(pipelineBuilder) | 459 : fPipelineBuilder(pipelineBuilder) |
460 , fScissor(scissor) { | 460 , fScissor(scissor) { |
461 fColorPOI = fPipelineBuilder->colorProcInfo(primProc); | 461 fColorPOI = fPipelineBuilder->colorProcInfo(primProc); |
462 fCoveragePOI = fPipelineBuilder->coverageProcInfo(primProc); | 462 fCoveragePOI = fPipelineBuilder->coverageProcInfo(primProc); |
463 if (!target->setupDstReadIfNecessary(*fPipelineBuilder, fColorPOI, fCoverage
POI, | 463 if (!target->setupDstReadIfNecessary(*fPipelineBuilder, fColorPOI, fCoverage
POI, |
464 &fDstCopy, devBounds)) { | 464 &fDstTexture, devBounds)) { |
465 fPipelineBuilder = NULL; | 465 fPipelineBuilder = NULL; |
466 } | 466 } |
467 } | 467 } |
468 | 468 |
469 GrDrawTarget::PipelineInfo::PipelineInfo(GrPipelineBuilder* pipelineBuilder, | 469 GrDrawTarget::PipelineInfo::PipelineInfo(GrPipelineBuilder* pipelineBuilder, |
470 GrScissorState* scissor, | 470 GrScissorState* scissor, |
471 const GrBatch* batch, | 471 const GrBatch* batch, |
472 const SkRect* devBounds, | 472 const SkRect* devBounds, |
473 GrDrawTarget* target) | 473 GrDrawTarget* target) |
474 : fPipelineBuilder(pipelineBuilder) | 474 : fPipelineBuilder(pipelineBuilder) |
475 , fScissor(scissor) { | 475 , fScissor(scissor) { |
476 fColorPOI = fPipelineBuilder->colorProcInfo(batch); | 476 fColorPOI = fPipelineBuilder->colorProcInfo(batch); |
477 fCoveragePOI = fPipelineBuilder->coverageProcInfo(batch); | 477 fCoveragePOI = fPipelineBuilder->coverageProcInfo(batch); |
478 if (!target->setupDstReadIfNecessary(*fPipelineBuilder, fColorPOI, fCoverage
POI, | 478 if (!target->setupDstReadIfNecessary(*fPipelineBuilder, fColorPOI, fCoverage
POI, |
479 &fDstCopy, devBounds)) { | 479 &fDstTexture, devBounds)) { |
480 fPipelineBuilder = NULL; | 480 fPipelineBuilder = NULL; |
481 } | 481 } |
482 } | 482 } |
483 | 483 |
484 /////////////////////////////////////////////////////////////////////////////// | 484 /////////////////////////////////////////////////////////////////////////////// |
485 | 485 |
486 void GrShaderCaps::reset() { | 486 void GrShaderCaps::reset() { |
487 fShaderDerivativeSupport = false; | 487 fShaderDerivativeSupport = false; |
488 fGeometryShaderSupport = false; | 488 fGeometryShaderSupport = false; |
489 fPathRenderingSupport = false; | 489 fPathRenderingSupport = false; |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 GrPipelineBuilder::AutoRestoreFragmentProcessors* a
rfp, | 729 GrPipelineBuilder::AutoRestoreFragmentProcessors* a
rfp, |
730 GrPipelineBuilder::AutoRestoreStencil* ars, | 730 GrPipelineBuilder::AutoRestoreStencil* ars, |
731 GrScissorState* scissorState, | 731 GrScissorState* scissorState, |
732 const SkRect* devBounds) { | 732 const SkRect* devBounds) { |
733 return fClipMaskManager.setupClipping(pipelineBuilder, | 733 return fClipMaskManager.setupClipping(pipelineBuilder, |
734 arfp, | 734 arfp, |
735 ars, | 735 ars, |
736 scissorState, | 736 scissorState, |
737 devBounds); | 737 devBounds); |
738 } | 738 } |
OLD | NEW |