OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2015 Google Inc. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license that can be | |
5 * found in the LICENSE file. | |
6 */ | |
7 | |
8 #include "GrXferProcessor.h" | |
9 #include "gl/GrGLCaps.h" | |
10 | |
11 // Interpretation of DstReadKey when generating code | |
12 enum { | |
13 kNoDstRead_DstReadKey = 0, | |
14 kYesDstRead_DstReadKeyBit = 0x1, // Set if we read the dst. | |
15 kDstCopyRead_DstReadKeyBit = 0x2, // Set if we use a dst-copy-read. | |
16 kTopLeftOrigin_DstReadKeyBit = 0x4, // Set if dst-copy origin is top-left . | |
bsalomon
2015/01/30 14:59:15
canonicalize on always tl or bl?
egdaniel
2015/02/03 16:47:44
Done.
| |
17 }; | |
18 | |
19 /////////////////////////////////////////////////////////////////////////////// | |
20 | |
21 GrXferProcessor::GrXferProcessor() : fWillReadDstColor(false), fDstReadKey(kNoDs tRead_DstReadKey) { | |
22 } | |
23 | |
24 GrXferProcessor::GrXferProcessor(const GrDeviceCoordTexture* dstCopy, int32_t ds tReadKey) | |
25 : fWillReadDstColor(false) | |
26 , fDstReadKey(dstReadKey) { | |
27 if (dstCopy && dstCopy->texture()) { | |
28 SkASSERT(kDstCopyRead_DstReadKeyBit & fDstReadKey); | |
29 fDstCopy.reset(dstCopy->texture()); | |
30 fOffset = dstCopy->offset(); | |
31 this->addTextureAccess(&fDstCopy); | |
32 } | |
33 } | |
34 | |
35 void GrXferProcessor::getGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuil der* b) const { | |
36 b->add32(fDstReadKey); | |
37 this->onGetGLProcessorKey(caps, b); | |
38 } | |
39 | |
40 bool GrXferProcessor::hasDstCopy() const { | |
41 return (kDstCopyRead_DstReadKeyBit & fDstReadKey); | |
42 } | |
43 | |
44 bool GrXferProcessor::dstCopyIsTopDown() const { | |
45 return (kTopLeftOrigin_DstReadKeyBit & fDstReadKey); | |
46 } | |
47 | |
48 /////////////////////////////////////////////////////////////////////////////// | |
49 | |
50 GrXferProcessor* GrXPFactory::createXferProcessor(const GrProcOptInfo& colorPOI, | |
51 const GrProcOptInfo& coverageP OI, | |
52 const GrDeviceCoordTexture* ds tCopy, | |
53 const GrDrawTargetCaps& caps) const { | |
54 int32_t dstReadKey; | |
55 if (this->willReadDst()) { | |
56 dstReadKey = kYesDstRead_DstReadKeyBit; | |
57 if (!caps.dstReadInShaderSupport()) { | |
58 SkASSERT(dstCopy->texture()); | |
59 dstReadKey |= kDstCopyRead_DstReadKeyBit; | |
60 if (kTopLeft_GrSurfaceOrigin == dstCopy->texture()->origin()) { | |
61 dstReadKey |= kTopLeftOrigin_DstReadKeyBit; | |
62 } | |
63 } | |
64 } else { | |
65 dstReadKey = kNoDstRead_DstReadKey; | |
66 | |
67 } | |
68 return this->onCreateXferProcessor(colorPOI, coveragePOI, dstCopy, dstReadKe y); | |
69 } | |
70 | |
71 bool GrXPFactory::willNeedDstCopy(const GrDrawTargetCaps& caps) const { | |
72 return (this->willReadDst() && !caps.dstReadInShaderSupport()); | |
73 } | |
74 | |
OLD | NEW |