OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 GrGLProgramDesc_DEFINED | 8 #ifndef GrGLProgramDesc_DEFINED |
9 #define GrGLProgramDesc_DEFINED | 9 #define GrGLProgramDesc_DEFINED |
10 | 10 |
(...skipping 30 matching lines...) Expand all Loading... | |
41 uint32_t keyLength() const { return *this->atOffset<uint32_t, kLengthOffset> (); } | 41 uint32_t keyLength() const { return *this->atOffset<uint32_t, kLengthOffset> (); } |
42 | 42 |
43 // Gets the a checksum of the key. Can be used as a hash value for a fast lo okup in a cache. | 43 // Gets the a checksum of the key. Can be used as a hash value for a fast lo okup in a cache. |
44 uint32_t getChecksum() const { return *this->atOffset<uint32_t, kChecksumOff set>(); } | 44 uint32_t getChecksum() const { return *this->atOffset<uint32_t, kChecksumOff set>(); } |
45 | 45 |
46 // For unit testing. | 46 // For unit testing. |
47 bool setRandom(SkRandom*, | 47 bool setRandom(SkRandom*, |
48 const GrGpuGL* gpu, | 48 const GrGpuGL* gpu, |
49 const GrRenderTarget* dummyDstRenderTarget, | 49 const GrRenderTarget* dummyDstRenderTarget, |
50 const GrTexture* dummyDstCopyTexture, | 50 const GrTexture* dummyDstCopyTexture, |
51 const GrEffectStage* geometryProcessor, | |
51 const GrEffectStage* stages[], | 52 const GrEffectStage* stages[], |
52 int numColorStages, | 53 int numColorStages, |
53 int numCoverageStages, | 54 int numCoverageStages, |
54 int currAttribIndex); | 55 int currAttribIndex); |
55 | 56 |
56 /** | 57 /** |
57 * Builds a program descriptor from a GrDrawState. Whether the primitive typ e is points, the | 58 * Builds a program descriptor from a GrDrawState. Whether the primitive typ e is points, the |
58 * output of GrDrawState::getBlendOpts, and the caps of the GrGpuGL are also inputs. It also | 59 * output of GrDrawState::getBlendOpts, and the caps of the GrGpuGL are also inputs. It also |
59 * outputs the color and coverage stages referenced by the generated descrip tor. This may | 60 * outputs the color and coverage stages referenced by the generated descrip tor. This may |
60 * not contain all stages from the draw state and coverage stages from the d rawState may | 61 * not contain all stages from the draw state and coverage stages from the d rawState may |
61 * be treated as color stages in the output. | 62 * be treated as color stages in the output. |
62 */ | 63 */ |
63 static bool Build(const GrDrawState&, | 64 static bool Build(const GrDrawState&, |
64 GrGpu::DrawType drawType, | 65 GrGpu::DrawType drawType, |
65 GrDrawState::BlendOptFlags, | 66 GrDrawState::BlendOptFlags, |
66 GrBlendCoeff srcCoeff, | 67 GrBlendCoeff srcCoeff, |
67 GrBlendCoeff dstCoeff, | 68 GrBlendCoeff dstCoeff, |
68 const GrGpuGL* gpu, | 69 const GrGpuGL* gpu, |
69 const GrDeviceCoordTexture* dstCopy, | 70 const GrDeviceCoordTexture* dstCopy, |
71 const GrEffectStage** outGeometryProcessor, | |
70 SkTArray<const GrEffectStage*, true>* outColorStages, | 72 SkTArray<const GrEffectStage*, true>* outColorStages, |
71 SkTArray<const GrEffectStage*, true>* outCoverageStages, | 73 SkTArray<const GrEffectStage*, true>* outCoverageStages, |
72 GrGLProgramDesc* outDesc); | 74 GrGLProgramDesc* outDesc); |
73 | 75 |
76 bool hasGeometryProcessor() const { | |
77 return this->getHeader().fHasGeometryProcessor; | |
78 } | |
79 | |
74 int numColorEffects() const { | 80 int numColorEffects() const { |
75 return this->getHeader().fColorEffectCnt; | 81 return this->getHeader().fColorEffectCnt; |
76 } | 82 } |
77 | 83 |
78 int numCoverageEffects() const { | 84 int numCoverageEffects() const { |
79 return this->getHeader().fCoverageEffectCnt; | 85 return this->getHeader().fCoverageEffectCnt; |
80 } | 86 } |
81 | 87 |
82 int numTotalEffects() const { return this->numColorEffects() + this->numCove rageEffects(); } | 88 int numTotalEffects() const { return this->numColorEffects() + this->numCove rageEffects(); } |
83 | 89 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 // production) | 160 // production) |
155 #if GR_GL_EXPERIMENTAL_GS | 161 #if GR_GL_EXPERIMENTAL_GS |
156 SkBool8 fExperimentalGS; | 162 SkBool8 fExperimentalGS; |
157 #endif | 163 #endif |
158 | 164 |
159 int8_t fPositionAttributeIndex; | 165 int8_t fPositionAttributeIndex; |
160 int8_t fLocalCoordAttributeIndex; | 166 int8_t fLocalCoordAttributeIndex; |
161 int8_t fColorAttributeIndex; | 167 int8_t fColorAttributeIndex; |
162 int8_t fCoverageAttributeIndex; | 168 int8_t fCoverageAttributeIndex; |
163 | 169 |
170 SkBool8 fSeparateCoverageFromColor; | |
bsalomon
2014/08/29 15:07:25
eek! What's this for?
joshua.litt
2014/09/02 16:06:21
I might have done something dumb. Basically, I us
| |
171 | |
172 SkBool8 fHasGeometryProcessor; | |
164 int8_t fColorEffectCnt; | 173 int8_t fColorEffectCnt; |
165 int8_t fCoverageEffectCnt; | 174 int8_t fCoverageEffectCnt; |
166 }; | 175 }; |
167 | 176 |
168 // The key, stored in fKey, is composed of five parts: | 177 // The key, stored in fKey, is composed of five parts: |
169 // 1. uint32_t for total key length. | 178 // 1. uint32_t for total key length. |
170 // 2. uint32_t for a checksum. | 179 // 2. uint32_t for a checksum. |
171 // 3. Header struct defined above. | 180 // 3. Header struct defined above. |
172 // 4. An array of offsets to effect keys and their sizes (see 5). uint16_t f or each | 181 // 4. An array of offsets to effect keys and their sizes (see 5). uint16_t f or each |
173 // offset and size. | 182 // offset and size. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
206 bool* setTrueIfRequiresVertexShader); | 215 bool* setTrueIfRequiresVertexShader); |
207 | 216 |
208 void finalize(); | 217 void finalize(); |
209 | 218 |
210 const KeyHeader& getHeader() const { return *this->atOffset<KeyHeader, kHead erOffset>(); } | 219 const KeyHeader& getHeader() const { return *this->atOffset<KeyHeader, kHead erOffset>(); } |
211 | 220 |
212 /** Used to provide effects' keys to their emitCode() function. */ | 221 /** Used to provide effects' keys to their emitCode() function. */ |
213 class EffectKeyProvider { | 222 class EffectKeyProvider { |
214 public: | 223 public: |
215 enum EffectType { | 224 enum EffectType { |
225 kGeometryProcessor_EffectType, | |
216 kColor_EffectType, | 226 kColor_EffectType, |
217 kCoverage_EffectType, | 227 kCoverage_EffectType, |
218 }; | 228 }; |
219 | 229 |
220 EffectKeyProvider(const GrGLProgramDesc* desc, EffectType type) : fDesc( desc) { | 230 EffectKeyProvider(const GrGLProgramDesc* desc, EffectType type) : fDesc( desc) { |
221 // Coverage effect key offsets begin immediately after those of the color effects. | 231 switch (type) { |
222 fBaseIndex = kColor_EffectType == type ? 0 : desc->numColorEffects() ; | 232 case kGeometryProcessor_EffectType: |
233 // there can be only one | |
234 fBaseIndex = 0; | |
235 break; | |
236 case kColor_EffectType: | |
237 fBaseIndex = desc->hasGeometryProcessor() ? 1 : 0; | |
238 break; | |
239 case kCoverage_EffectType: | |
240 fBaseIndex = desc->numColorEffects() + (desc->hasGeometryPro cessor() ? 1 : 0); | |
241 break; | |
242 } | |
223 } | 243 } |
224 | 244 |
225 GrEffectKey get(int index) const { | 245 GrEffectKey get(int index) const { |
226 const uint16_t* offsetsAndLengths = reinterpret_cast<const uint16_t* >( | 246 const uint16_t* offsetsAndLengths = reinterpret_cast<const uint16_t* >( |
227 fDesc->fKey.begin() + kEffectKeyOffsetsAndLengthOffset); | 247 fDesc->fKey.begin() + kEffectKeyOffsetsAndLengthOffset); |
228 // We store two uint16_ts per effect, one for the offset to the effe ct's key and one for | 248 // We store two uint16_ts per effect, one for the offset to the effe ct's key and one for |
229 // its length. Here we just need the offset. | 249 // its length. Here we just need the offset. |
230 uint16_t offset = offsetsAndLengths[2 * (fBaseIndex + index) + 0]; | 250 uint16_t offset = offsetsAndLengths[2 * (fBaseIndex + index) + 0]; |
231 uint16_t length = offsetsAndLengths[2 * (fBaseIndex + index) + 1]; | 251 uint16_t length = offsetsAndLengths[2 * (fBaseIndex + index) + 1]; |
232 // Currently effects must add to the key in units of uint32_t. | 252 // Currently effects must add to the key in units of uint32_t. |
(...skipping 21 matching lines...) Expand all Loading... | |
254 friend class GrGLProgram; | 274 friend class GrGLProgram; |
255 friend class GrGLProgramBuilder; | 275 friend class GrGLProgramBuilder; |
256 friend class GrGLFullProgramBuilder; | 276 friend class GrGLFullProgramBuilder; |
257 friend class GrGLFragmentOnlyProgramBuilder; | 277 friend class GrGLFragmentOnlyProgramBuilder; |
258 friend class GrGLVertexShaderBuilder; | 278 friend class GrGLVertexShaderBuilder; |
259 friend class GrGLFragmentShaderBuilder; | 279 friend class GrGLFragmentShaderBuilder; |
260 friend class GrGLGeometryShaderBuilder; | 280 friend class GrGLGeometryShaderBuilder; |
261 }; | 281 }; |
262 | 282 |
263 #endif | 283 #endif |
OLD | NEW |