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 "GrPipeline.h" |
9 #include "GrPipelineBuilder.h" | 10 #include "GrPipelineBuilder.h" |
10 #include "GrProcOptInfo.h" | 11 #include "GrProcOptInfo.h" |
11 #include "gl/GrGLCaps.h" | 12 #include "gl/GrGLCaps.h" |
12 | 13 |
13 GrXferProcessor::GrXferProcessor() | 14 GrXferProcessor::GrXferProcessor() |
14 : fWillReadDstColor(false) | 15 : fWillReadDstColor(false) |
15 , fDstReadUsesMixedSamples(false) | 16 , fDstReadUsesMixedSamples(false) |
16 , fReadsCoverage(true) | 17 , fReadsCoverage(true) |
17 , fDstTextureOffset() { | 18 , fDstTextureOffset() { |
18 } | 19 } |
19 | 20 |
20 GrXferProcessor::GrXferProcessor(const DstTexture* dstTexture, | 21 GrXferProcessor::GrXferProcessor(const DstTexture* dstTexture, |
21 bool willReadDstColor, | 22 bool willReadDstColor, |
22 bool hasMixedSamples) | 23 bool hasMixedSamples) |
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()); |
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( |
37 const GrProcOptInfo&
coveragePOI, | 38 const GrPipelineOptimizat
ions& optimizations, |
38 bool doesStencilWrit
e, | 39 bool doesStencilWrite, |
39 GrColor* overrideCol
or, | 40 GrColor* overrideColor, |
40 const GrCaps& caps)
{ | 41 const GrCaps& caps) { |
41 GrXferProcessor::OptFlags flags = this->onGetOptimizations(colorPOI, | 42 GrXferProcessor::OptFlags flags = this->onGetOptimizations(optimizations, |
42 coveragePOI, | |
43 doesStencilWrite, | 43 doesStencilWrite, |
44 overrideColor, | 44 overrideColor, |
45 caps); | 45 caps); |
46 | 46 |
47 if (this->willReadDstColor()) { | 47 if (this->willReadDstColor()) { |
48 // When performing a dst read we handle coverage in the base class. | 48 // When performing a dst read we handle coverage in the base class. |
49 SkASSERT(!(flags & GrXferProcessor::kIgnoreCoverage_OptFlag)); | 49 SkASSERT(!(flags & GrXferProcessor::kIgnoreCoverage_OptFlag)); |
50 if (coveragePOI.isSolidWhite()) { | 50 if (optimizations.fCoveragePOI.isSolidWhite()) { |
51 flags |= GrXferProcessor::kIgnoreCoverage_OptFlag; | 51 flags |= GrXferProcessor::kIgnoreCoverage_OptFlag; |
52 } | 52 } |
53 } | 53 } |
54 if (flags & GrXferProcessor::kIgnoreCoverage_OptFlag) { | 54 if (flags & GrXferProcessor::kIgnoreCoverage_OptFlag) { |
55 fReadsCoverage = false; | 55 fReadsCoverage = false; |
56 } | 56 } |
57 return flags; | 57 return flags; |
58 } | 58 } |
59 | 59 |
60 bool GrXferProcessor::hasSecondaryOutput() const { | 60 bool GrXferProcessor::hasSecondaryOutput() const { |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 SkString out; | 193 SkString out; |
194 out.printf("write_color(%d) equation(%s) src_coeff(%s) dst_coeff:(%s) const(
0x%08x)", | 194 out.printf("write_color(%d) equation(%s) src_coeff(%s) dst_coeff:(%s) const(
0x%08x)", |
195 fWriteColor, equation_string(fEquation), coeff_string(fSrcBlend), | 195 fWriteColor, equation_string(fEquation), coeff_string(fSrcBlend), |
196 coeff_string(fDstBlend), fBlendConstant); | 196 coeff_string(fDstBlend), fBlendConstant); |
197 return out; | 197 return out; |
198 } | 198 } |
199 #endif | 199 #endif |
200 | 200 |
201 /////////////////////////////////////////////////////////////////////////////// | 201 /////////////////////////////////////////////////////////////////////////////// |
202 | 202 |
203 GrXferProcessor* GrXPFactory::createXferProcessor(const GrProcOptInfo& colorPOI, | 203 GrXferProcessor* GrXPFactory::createXferProcessor(const GrPipelineOptimizations&
optimizations, |
204 const GrProcOptInfo& coverageP
OI, | |
205 bool hasMixedSamples, | 204 bool hasMixedSamples, |
206 const DstTexture* dstTexture, | 205 const DstTexture* dstTexture, |
207 const GrCaps& caps) const { | 206 const GrCaps& caps) const { |
208 #ifdef SK_DEBUG | 207 #ifdef SK_DEBUG |
209 if (this->willReadDstColor(caps, colorPOI, coveragePOI, hasMixedSamples)) { | 208 if (this->willReadDstColor(caps, optimizations, hasMixedSamples)) { |
210 if (!caps.shaderCaps()->dstReadInShaderSupport()) { | 209 if (!caps.shaderCaps()->dstReadInShaderSupport()) { |
211 SkASSERT(dstTexture && dstTexture->texture()); | 210 SkASSERT(dstTexture && dstTexture->texture()); |
212 } else { | 211 } else { |
213 SkASSERT(!dstTexture || !dstTexture->texture()); | 212 SkASSERT(!dstTexture || !dstTexture->texture()); |
214 } | 213 } |
215 } else { | 214 } else { |
216 SkASSERT(!dstTexture || !dstTexture->texture()); | 215 SkASSERT(!dstTexture || !dstTexture->texture()); |
217 } | 216 } |
218 SkASSERT(!hasMixedSamples || caps.shaderCaps()->dualSourceBlendingSupport())
; | 217 SkASSERT(!hasMixedSamples || caps.shaderCaps()->dualSourceBlendingSupport())
; |
219 #endif | 218 #endif |
220 return this->onCreateXferProcessor(caps, colorPOI, coveragePOI, hasMixedSamp
les, dstTexture); | 219 return this->onCreateXferProcessor(caps, optimizations, hasMixedSamples, dst
Texture); |
221 } | 220 } |
222 | 221 |
223 bool GrXPFactory::willNeedDstTexture(const GrCaps& caps, | 222 bool GrXPFactory::willNeedDstTexture(const GrCaps& caps, |
224 const GrProcOptInfo& colorPOI, | 223 const GrPipelineOptimizations& optimization
s, |
225 const GrProcOptInfo& coveragePOI, | |
226 bool hasMixedSamples) const { | 224 bool hasMixedSamples) const { |
227 return (this->willReadDstColor(caps, colorPOI, coveragePOI, hasMixedSamples)
&& | 225 return (this->willReadDstColor(caps, optimizations, hasMixedSamples) && |
228 !caps.shaderCaps()->dstReadInShaderSupport()); | 226 !caps.shaderCaps()->dstReadInShaderSupport()); |
229 } | 227 } |
OLD | NEW |