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 "gl/GrGLCaps.h" | 9 #include "gl/GrGLCaps.h" |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 fDstCopyTextureOffset = dstCopy->offset(); | 21 fDstCopyTextureOffset = dstCopy->offset(); |
22 this->addTextureAccess(&fDstCopy); | 22 this->addTextureAccess(&fDstCopy); |
23 this->setWillReadFragmentPosition(); | 23 this->setWillReadFragmentPosition(); |
24 } | 24 } |
25 } | 25 } |
26 | 26 |
27 GrXferProcessor::OptFlags GrXferProcessor::getOptimizations(const GrProcOptInfo&
colorPOI, | 27 GrXferProcessor::OptFlags GrXferProcessor::getOptimizations(const GrProcOptInfo&
colorPOI, |
28 const GrProcOptInfo&
coveragePOI, | 28 const GrProcOptInfo&
coveragePOI, |
29 bool doesStencilWrit
e, | 29 bool doesStencilWrit
e, |
30 GrColor* overrideCol
or, | 30 GrColor* overrideCol
or, |
31 const GrDrawTargetCa
ps& caps) { | 31 const GrCaps& caps)
{ |
32 GrXferProcessor::OptFlags flags = this->onGetOptimizations(colorPOI, | 32 GrXferProcessor::OptFlags flags = this->onGetOptimizations(colorPOI, |
33 coveragePOI, | 33 coveragePOI, |
34 doesStencilWrite, | 34 doesStencilWrite, |
35 overrideColor, | 35 overrideColor, |
36 caps); | 36 caps); |
37 | 37 |
38 if (flags & GrXferProcessor::kIgnoreCoverage_OptFlag) { | 38 if (flags & GrXferProcessor::kIgnoreCoverage_OptFlag) { |
39 fReadsCoverage = false; | 39 fReadsCoverage = false; |
40 } | 40 } |
41 return flags; | 41 return flags; |
42 } | 42 } |
43 | 43 |
44 void GrXferProcessor::getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBu
ilder* b) const { | 44 void GrXferProcessor::getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBu
ilder* b) const { |
45 uint32_t key = this->willReadDstColor() ? 0x1 : 0x0; | 45 uint32_t key = this->willReadDstColor() ? 0x1 : 0x0; |
46 if (this->getDstCopyTexture() && | 46 if (this->getDstCopyTexture() && |
47 kTopLeft_GrSurfaceOrigin == this->getDstCopyTexture()->origin()) { | 47 kTopLeft_GrSurfaceOrigin == this->getDstCopyTexture()->origin()) { |
48 key |= 0x2; | 48 key |= 0x2; |
49 } | 49 } |
50 b->add32(key); | 50 b->add32(key); |
51 this->onGetGLProcessorKey(caps, b); | 51 this->onGetGLProcessorKey(caps, b); |
52 } | 52 } |
53 | 53 |
54 bool GrXferProcessor::willNeedXferBarrier(const GrRenderTarget* rt, | 54 bool GrXferProcessor::willNeedXferBarrier(const GrRenderTarget* rt, |
55 const GrDrawTargetCaps& caps, | 55 const GrCaps& caps, |
56 GrXferBarrierType* outBarrierType) con
st { | 56 GrXferBarrierType* outBarrierType) con
st { |
57 if (static_cast<const GrSurface*>(rt) == this->getDstCopyTexture()) { | 57 if (static_cast<const GrSurface*>(rt) == this->getDstCopyTexture()) { |
58 // Texture barriers are required when a shader reads and renders to the
same texture. | 58 // Texture barriers are required when a shader reads and renders to the
same texture. |
59 SkASSERT(rt); | 59 SkASSERT(rt); |
60 SkASSERT(caps.textureBarrierSupport()); | 60 SkASSERT(caps.textureBarrierSupport()); |
61 *outBarrierType = kTexture_GrXferBarrierType; | 61 *outBarrierType = kTexture_GrXferBarrierType; |
62 return true; | 62 return true; |
63 } | 63 } |
64 return this->onWillNeedXferBarrier(rt, caps, outBarrierType); | 64 return this->onWillNeedXferBarrier(rt, caps, outBarrierType); |
65 } | 65 } |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 coeff_string(fDstBlend), fBlendConstant); | 156 coeff_string(fDstBlend), fBlendConstant); |
157 return out; | 157 return out; |
158 } | 158 } |
159 #endif | 159 #endif |
160 | 160 |
161 /////////////////////////////////////////////////////////////////////////////// | 161 /////////////////////////////////////////////////////////////////////////////// |
162 | 162 |
163 GrXferProcessor* GrXPFactory::createXferProcessor(const GrProcOptInfo& colorPOI, | 163 GrXferProcessor* GrXPFactory::createXferProcessor(const GrProcOptInfo& colorPOI, |
164 const GrProcOptInfo& coverageP
OI, | 164 const GrProcOptInfo& coverageP
OI, |
165 const GrDeviceCoordTexture* ds
tCopy, | 165 const GrDeviceCoordTexture* ds
tCopy, |
166 const GrDrawTargetCaps& caps)
const { | 166 const GrCaps& caps) const { |
167 #ifdef SK_DEBUG | 167 #ifdef SK_DEBUG |
168 if (this->willReadDstColor(caps, colorPOI, coveragePOI)) { | 168 if (this->willReadDstColor(caps, colorPOI, coveragePOI)) { |
169 if (!caps.shaderCaps()->dstReadInShaderSupport()) { | 169 if (!caps.shaderCaps()->dstReadInShaderSupport()) { |
170 SkASSERT(dstCopy && dstCopy->texture()); | 170 SkASSERT(dstCopy && dstCopy->texture()); |
171 } else { | 171 } else { |
172 SkASSERT(!dstCopy || !dstCopy->texture()); | 172 SkASSERT(!dstCopy || !dstCopy->texture()); |
173 } | 173 } |
174 } else { | 174 } else { |
175 SkASSERT(!dstCopy || !dstCopy->texture()); | 175 SkASSERT(!dstCopy || !dstCopy->texture()); |
176 } | 176 } |
177 #endif | 177 #endif |
178 return this->onCreateXferProcessor(caps, colorPOI, coveragePOI, dstCopy); | 178 return this->onCreateXferProcessor(caps, colorPOI, coveragePOI, dstCopy); |
179 } | 179 } |
180 | 180 |
181 bool GrXPFactory::willNeedDstCopy(const GrDrawTargetCaps& caps, const GrProcOptI
nfo& colorPOI, | 181 bool GrXPFactory::willNeedDstCopy(const GrCaps& caps, const GrProcOptInfo& color
POI, |
182 const GrProcOptInfo& coveragePOI) const { | 182 const GrProcOptInfo& coveragePOI) const { |
183 return (this->willReadDstColor(caps, colorPOI, coveragePOI) | 183 return (this->willReadDstColor(caps, colorPOI, coveragePOI) |
184 && !caps.shaderCaps()->dstReadInShaderSupport()); | 184 && !caps.shaderCaps()->dstReadInShaderSupport()); |
185 } | 185 } |
186 | 186 |
OLD | NEW |