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 14 matching lines...) Expand all Loading... |
25 void GrXferProcessor::getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBu
ilder* b) const { | 25 void GrXferProcessor::getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBu
ilder* b) const { |
26 uint32_t key = this->willReadDstColor() ? 0x1 : 0x0; | 26 uint32_t key = this->willReadDstColor() ? 0x1 : 0x0; |
27 if (this->getDstCopyTexture() && | 27 if (this->getDstCopyTexture() && |
28 kTopLeft_GrSurfaceOrigin == this->getDstCopyTexture()->origin()) { | 28 kTopLeft_GrSurfaceOrigin == this->getDstCopyTexture()->origin()) { |
29 key |= 0x2; | 29 key |= 0x2; |
30 } | 30 } |
31 b->add32(key); | 31 b->add32(key); |
32 this->onGetGLProcessorKey(caps, b); | 32 this->onGetGLProcessorKey(caps, b); |
33 } | 33 } |
34 | 34 |
| 35 bool GrXferProcessor::willNeedXferBarrier(const GrRenderTarget* rt, |
| 36 const GrDrawTargetCaps& caps, |
| 37 GrXferBarrierType* outBarrierType) con
st { |
| 38 if (static_cast<const GrSurface*>(rt) == this->getDstCopyTexture()) { |
| 39 // Texture barriers are required when a shader reads and renders to the
same texture. |
| 40 SkASSERT(rt); |
| 41 SkASSERT(caps.textureBarrierSupport()); |
| 42 *outBarrierType = kTexture_GrXferBarrierType; |
| 43 return true; |
| 44 } |
| 45 return false; |
| 46 } |
| 47 |
35 /////////////////////////////////////////////////////////////////////////////// | 48 /////////////////////////////////////////////////////////////////////////////// |
36 | 49 |
37 GrXferProcessor* GrXPFactory::createXferProcessor(const GrProcOptInfo& colorPOI, | 50 GrXferProcessor* GrXPFactory::createXferProcessor(const GrProcOptInfo& colorPOI, |
38 const GrProcOptInfo& coverageP
OI, | 51 const GrProcOptInfo& coverageP
OI, |
39 const GrDeviceCoordTexture* ds
tCopy, | 52 const GrDeviceCoordTexture* ds
tCopy, |
40 const GrDrawTargetCaps& caps)
const { | 53 const GrDrawTargetCaps& caps)
const { |
41 #ifdef SK_DEBUG | 54 #ifdef SK_DEBUG |
42 if (this->willReadDstColor(caps, colorPOI, coveragePOI)) { | 55 if (this->willReadDstColor(caps, colorPOI, coveragePOI)) { |
43 if (!caps.dstReadInShaderSupport()) { | 56 if (!caps.dstReadInShaderSupport()) { |
44 SkASSERT(dstCopy && dstCopy->texture()); | 57 SkASSERT(dstCopy && dstCopy->texture()); |
45 } else { | 58 } else { |
46 SkASSERT(!dstCopy || !dstCopy->texture()); | 59 SkASSERT(!dstCopy || !dstCopy->texture()); |
47 } | 60 } |
48 } else { | 61 } else { |
49 SkASSERT(!dstCopy || !dstCopy->texture()); | 62 SkASSERT(!dstCopy || !dstCopy->texture()); |
50 } | 63 } |
51 #endif | 64 #endif |
52 return this->onCreateXferProcessor(caps, colorPOI, coveragePOI, dstCopy); | 65 return this->onCreateXferProcessor(caps, colorPOI, coveragePOI, dstCopy); |
53 } | 66 } |
54 | 67 |
55 bool GrXPFactory::willNeedDstCopy(const GrDrawTargetCaps& caps, const GrProcOptI
nfo& colorPOI, | 68 bool GrXPFactory::willNeedDstCopy(const GrDrawTargetCaps& caps, const GrProcOptI
nfo& colorPOI, |
56 const GrProcOptInfo& coveragePOI) const { | 69 const GrProcOptInfo& coveragePOI) const { |
57 return (this->willReadDstColor(caps, colorPOI, coveragePOI) && !caps.dstRead
InShaderSupport()); | 70 return (this->willReadDstColor(caps, colorPOI, coveragePOI) && !caps.dstRead
InShaderSupport()); |
58 } | 71 } |
59 | 72 |
OLD | NEW |