| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "GrXferProcessor.h" | 8 #include "GrXferProcessor.h" |
| 9 #include "GrPipelineBuilder.h" | 9 #include "GrPipelineBuilder.h" |
| 10 #include "GrProcOptInfo.h" | 10 #include "GrProcOptInfo.h" |
| 11 #include "gl/GrGLCaps.h" | 11 #include "gl/GrGLCaps.h" |
| 12 | 12 |
| 13 GrXferProcessor::GrXferProcessor() | 13 GrXferProcessor::GrXferProcessor(GrRenderTarget* dst) |
| 14 : fWillReadDstColor(false) | 14 : fWillReadDstColor(false) |
| 15 , fDstReadUsesMixedSamples(false) | 15 , fDstReadUsesMixedSamples(false) |
| 16 , fReadsCoverage(true) | 16 , fReadsCoverage(true) |
| 17 , fDstTextureOffset() { | 17 , fDstTextureOffset() { |
| 18 } | 18 } |
| 19 | 19 |
| 20 GrXferProcessor::GrXferProcessor(const DstTexture* dstTexture, | 20 GrXferProcessor::GrXferProcessor(const DstTexture* dstTexture, |
| 21 bool willReadDstColor, | 21 bool willReadDstColor, |
| 22 bool hasMixedSamples) | 22 bool hasMixedSamples, |
| 23 GrRenderTarget* dst) |
| 23 : fWillReadDstColor(willReadDstColor) | 24 : fWillReadDstColor(willReadDstColor) |
| 24 , fDstReadUsesMixedSamples(willReadDstColor && hasMixedSamples) | 25 , fDstReadUsesMixedSamples(willReadDstColor && hasMixedSamples) |
| 25 , fReadsCoverage(true) | 26 , fReadsCoverage(true) |
| 26 , fDstTextureOffset() { | 27 , fDstTextureOffset() { |
| 27 if (dstTexture && dstTexture->texture()) { | 28 if (dstTexture && dstTexture->texture()) { |
| 28 SkASSERT(willReadDstColor); | 29 SkASSERT(willReadDstColor); |
| 29 fDstTexture.reset(dstTexture->texture()); | 30 fDstTexture.reset(dstTexture->texture(), GrTextureParams::kNone_FilterMo
de,SkShader::kClamp_TileMode, dst); |
| 30 fDstTextureOffset = dstTexture->offset(); | 31 fDstTextureOffset = dstTexture->offset(); |
| 31 this->addTextureAccess(&fDstTexture); | 32 this->addTextureAccess(&fDstTexture); |
| 32 this->setWillReadFragmentPosition(); | 33 this->setWillReadFragmentPosition(); |
| 33 } | 34 } |
| 34 } | 35 } |
| 35 | 36 |
| 36 GrXferProcessor::OptFlags GrXferProcessor::getOptimizations(const GrProcOptInfo&
colorPOI, | 37 GrXferProcessor::OptFlags GrXferProcessor::getOptimizations(const GrProcOptInfo&
colorPOI, |
| 37 const GrProcOptInfo&
coveragePOI, | 38 const GrProcOptInfo&
coveragePOI, |
| 38 bool doesStencilWrit
e, | 39 bool doesStencilWrit
e, |
| 39 GrColor* overrideCol
or, | 40 GrColor* overrideCol
or, |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 return out; | 198 return out; |
| 198 } | 199 } |
| 199 #endif | 200 #endif |
| 200 | 201 |
| 201 /////////////////////////////////////////////////////////////////////////////// | 202 /////////////////////////////////////////////////////////////////////////////// |
| 202 | 203 |
| 203 GrXferProcessor* GrXPFactory::createXferProcessor(const GrProcOptInfo& colorPOI, | 204 GrXferProcessor* GrXPFactory::createXferProcessor(const GrProcOptInfo& colorPOI, |
| 204 const GrProcOptInfo& coverageP
OI, | 205 const GrProcOptInfo& coverageP
OI, |
| 205 bool hasMixedSamples, | 206 bool hasMixedSamples, |
| 206 const DstTexture* dstTexture, | 207 const DstTexture* dstTexture, |
| 207 const GrCaps& caps) const { | 208 const GrCaps& caps, GrRenderTa
rget* dst) const { |
| 208 #ifdef SK_DEBUG | 209 #ifdef SK_DEBUG |
| 209 if (this->willReadDstColor(caps, colorPOI, coveragePOI, hasMixedSamples)) { | 210 bool willReadDstColor = this->willReadDstColor(caps, colorPOI, coveragePOI,
hasMixedSamples); |
| 211 |
| 212 if (willReadDstColor) { |
| 210 if (!caps.shaderCaps()->dstReadInShaderSupport()) { | 213 if (!caps.shaderCaps()->dstReadInShaderSupport()) { |
| 211 SkASSERT(dstTexture && dstTexture->texture()); | 214 SkASSERT(dstTexture && dstTexture->texture()); |
| 212 } else { | 215 } else { |
| 213 SkASSERT(!dstTexture || !dstTexture->texture()); | 216 SkASSERT(!dstTexture || !dstTexture->texture()); |
| 214 } | 217 } |
| 215 } else { | 218 } else { |
| 216 SkASSERT(!dstTexture || !dstTexture->texture()); | 219 SkASSERT(!dstTexture || !dstTexture->texture()); |
| 217 } | 220 } |
| 218 SkASSERT(!hasMixedSamples || caps.shaderCaps()->dualSourceBlendingSupport())
; | 221 SkASSERT(!hasMixedSamples || caps.shaderCaps()->dualSourceBlendingSupport())
; |
| 219 #endif | 222 #endif |
| 220 return this->onCreateXferProcessor(caps, colorPOI, coveragePOI, hasMixedSamp
les, dstTexture); | 223 return this->onCreateXferProcessor(caps, colorPOI, coveragePOI, hasMixedSamp
les, dstTexture, dst); |
| 221 } | 224 } |
| 222 | 225 |
| 223 bool GrXPFactory::willNeedDstTexture(const GrCaps& caps, | 226 bool GrXPFactory::willNeedDstTexture(const GrCaps& caps, |
| 224 const GrProcOptInfo& colorPOI, | 227 const GrProcOptInfo& colorPOI, |
| 225 const GrProcOptInfo& coveragePOI, | 228 const GrProcOptInfo& coveragePOI, |
| 226 bool hasMixedSamples) const { | 229 bool hasMixedSamples) const { |
| 227 return (this->willReadDstColor(caps, colorPOI, coveragePOI, hasMixedSamples)
&& | 230 return (this->willReadDstColor(caps, colorPOI, coveragePOI, hasMixedSamples)
&& |
| 228 !caps.shaderCaps()->dstReadInShaderSupport()); | 231 !caps.shaderCaps()->dstReadInShaderSupport()); |
| 229 } | 232 } |
| OLD | NEW |