OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 #ifndef GrProgramDesc_DEFINED | 8 #ifndef GrProgramDesc_DEFINED |
9 #define GrProgramDesc_DEFINED | 9 #define GrProgramDesc_DEFINED |
10 | 10 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 bool operator!= (const GrProgramDesc& other) const { | 49 bool operator!= (const GrProgramDesc& other) const { |
50 return !(*this == other); | 50 return !(*this == other); |
51 } | 51 } |
52 | 52 |
53 static bool Less(const GrProgramDesc& a, const GrProgramDesc& b) { | 53 static bool Less(const GrProgramDesc& a, const GrProgramDesc& b) { |
54 return memcmp(a.asKey(), b.asKey(), a.keyLength() & ~0x3) < 0; | 54 return memcmp(a.asKey(), b.asKey(), a.keyLength() & ~0x3) < 0; |
55 } | 55 } |
56 | 56 |
57 struct KeyHeader { | 57 struct KeyHeader { |
58 uint8_t fDstReadKey; // set by GrGLShaderBuilder i
f there | |
59 // are effects that must read
the dst. | |
60 // Otherwise, 0. | |
61 uint8_t fFragPosKey; // set by GrGLShaderBuilder i
f there are | 58 uint8_t fFragPosKey; // set by GrGLShaderBuilder i
f there are |
62 // effects that read the frag
ment position. | 59 // effects that read the frag
ment position. |
63 // Otherwise, 0. | 60 // Otherwise, 0. |
64 | 61 |
65 int8_t fColorEffectCnt; | 62 int8_t fColorEffectCnt; |
66 int8_t fCoverageEffectCnt; | 63 int8_t fCoverageEffectCnt; |
67 }; | 64 }; |
68 | 65 |
69 int numColorEffects() const { | 66 int numColorEffects() const { |
70 return this->header().fColorEffectCnt; | 67 return this->header().fColorEffectCnt; |
71 } | 68 } |
72 | 69 |
73 int numCoverageEffects() const { | 70 int numCoverageEffects() const { |
74 return this->header().fCoverageEffectCnt; | 71 return this->header().fCoverageEffectCnt; |
75 } | 72 } |
76 | 73 |
77 int numTotalEffects() const { return this->numColorEffects() + this->numCove
rageEffects(); } | 74 int numTotalEffects() const { return this->numColorEffects() + this->numCove
rageEffects(); } |
78 | 75 |
79 // This should really only be used internally, base classes should return th
eir own headers | 76 // This should really only be used internally, base classes should return th
eir own headers |
80 const KeyHeader& header() const { return *this->atOffset<KeyHeader, kHeaderO
ffset>(); } | 77 const KeyHeader& header() const { return *this->atOffset<KeyHeader, kHeaderO
ffset>(); } |
81 | 78 |
82 // A struct to communicate descriptor information to the program descriptor
builder | |
83 struct DescInfo { | |
84 bool operator==(const DescInfo& that) const { | |
85 return fReadsDst == that.fReadsDst && | |
86 fReadsFragPosition == that.fReadsFragPosition; | |
87 } | |
88 bool operator!=(const DescInfo& that) const { return !(*this == that); }
; | |
89 | |
90 // These flags give aggregated info on the processor stages that are use
d when building | |
91 // programs. | |
92 bool fReadsDst; | |
93 bool fReadsFragPosition; | |
94 }; | |
95 | |
96 private: | 79 private: |
97 template<typename T, size_t OFFSET> T* atOffset() { | 80 template<typename T, size_t OFFSET> T* atOffset() { |
98 return reinterpret_cast<T*>(reinterpret_cast<intptr_t>(fKey.begin()) + O
FFSET); | 81 return reinterpret_cast<T*>(reinterpret_cast<intptr_t>(fKey.begin()) + O
FFSET); |
99 } | 82 } |
100 | 83 |
101 template<typename T, size_t OFFSET> const T* atOffset() const { | 84 template<typename T, size_t OFFSET> const T* atOffset() const { |
102 return reinterpret_cast<const T*>(reinterpret_cast<intptr_t>(fKey.begin(
)) + OFFSET); | 85 return reinterpret_cast<const T*>(reinterpret_cast<intptr_t>(fKey.begin(
)) + OFFSET); |
103 } | 86 } |
104 | 87 |
105 void finalize() { | 88 void finalize() { |
(...skipping 27 matching lines...) Expand all Loading... |
133 kPreAllocSize = kHeaderOffset + kHeaderSize + | 116 kPreAllocSize = kHeaderOffset + kHeaderSize + |
134 kMaxPreallocProcessors * sizeof(uint32_t) * kIntsPerProc
essor, | 117 kMaxPreallocProcessors * sizeof(uint32_t) * kIntsPerProc
essor, |
135 }; | 118 }; |
136 | 119 |
137 SkSTArray<kPreAllocSize, uint8_t, true> fKey; | 120 SkSTArray<kPreAllocSize, uint8_t, true> fKey; |
138 | 121 |
139 friend class GrGLProgramDescBuilder; | 122 friend class GrGLProgramDescBuilder; |
140 }; | 123 }; |
141 | 124 |
142 #endif | 125 #endif |
OLD | NEW |