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 25 matching lines...) Expand all Loading... |
36 uint32_t getChecksum() const { return *this->atOffset<uint32_t, kChecksumOff
set>(); } | 36 uint32_t getChecksum() const { return *this->atOffset<uint32_t, kChecksumOff
set>(); } |
37 | 37 |
38 /** | 38 /** |
39 * Builds a program descriptor from a GrOptDrawState. Whether the primitive
type is points, and | 39 * Builds a program descriptor from a GrOptDrawState. Whether the primitive
type is points, and |
40 * the caps of the GrGpuGL are also inputs. It also outputs the color and co
verage stages | 40 * the caps of the GrGpuGL are also inputs. It also outputs the color and co
verage stages |
41 * referenced by the generated descriptor. Coverage stages from the drawStat
e may be treated as | 41 * referenced by the generated descriptor. Coverage stages from the drawStat
e may be treated as |
42 * color stages in the output. | 42 * color stages in the output. |
43 */ | 43 */ |
44 static bool Build(const GrOptDrawState&, | 44 static bool Build(const GrOptDrawState&, |
45 GrGpu::DrawType, | 45 GrGpu::DrawType, |
46 GrBlendCoeff srcCoeff, | |
47 GrBlendCoeff dstCoeff, | |
48 GrGpuGL*, | 46 GrGpuGL*, |
49 const GrDeviceCoordTexture* dstCopy, | 47 const GrDeviceCoordTexture*, |
50 const GrGeometryStage** geometryProcessor, | |
51 SkTArray<const GrFragmentStage*, true>* colorStages, | |
52 SkTArray<const GrFragmentStage*, true>* coverageStages, | |
53 GrGLProgramDesc*); | 48 GrGLProgramDesc*); |
54 | 49 |
55 bool hasGeometryProcessor() const { | 50 bool hasGeometryProcessor() const { |
56 return SkToBool(this->getHeader().fHasGeometryProcessor); | 51 return SkToBool(this->getHeader().fHasGeometryProcessor); |
57 } | 52 } |
58 | 53 |
59 int numColorEffects() const { | 54 int numColorEffects() const { |
60 return this->getHeader().fColorEffectCnt; | 55 return this->getHeader().fColorEffectCnt; |
61 } | 56 } |
62 | 57 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 static bool BuildStagedProcessorKey(const typename ProcessorKeyBuilder::Stag
edProcessor& stage, | 148 static bool BuildStagedProcessorKey(const typename ProcessorKeyBuilder::Stag
edProcessor& stage, |
154 const GrGLCaps& caps, | 149 const GrGLCaps& caps, |
155 bool requiresLocalCoordAttrib, | 150 bool requiresLocalCoordAttrib, |
156 GrGLProgramDesc* desc, | 151 GrGLProgramDesc* desc, |
157 int* offsetAndSizeIndex); | 152 int* offsetAndSizeIndex); |
158 void finalize(); | 153 void finalize(); |
159 | 154 |
160 const KeyHeader& getHeader() const { return *this->atOffset<KeyHeader, kHead
erOffset>(); } | 155 const KeyHeader& getHeader() const { return *this->atOffset<KeyHeader, kHead
erOffset>(); } |
161 | 156 |
162 /** Used to provide effects' keys to their emitCode() function. */ | 157 /** Used to provide effects' keys to their emitCode() function. */ |
163 class EffectKeyProvider { | 158 class ProcKeyProvider { |
164 public: | 159 public: |
165 enum EffectType { | 160 enum ProcessorType { |
166 kGeometryProcessor_EffectType, | 161 kGeometry_ProcessorType, |
167 kColor_EffectType, | 162 kFragment_ProcessorType, |
168 kCoverage_EffectType, | |
169 }; | 163 }; |
170 | 164 |
171 EffectKeyProvider(const GrGLProgramDesc* desc, EffectType type) : fDesc(
desc) { | 165 ProcKeyProvider(const GrGLProgramDesc* desc, ProcessorType type) |
| 166 : fDesc(desc), fBaseIndex(0) { |
172 switch (type) { | 167 switch (type) { |
173 case kGeometryProcessor_EffectType: | 168 case kGeometry_ProcessorType: |
174 // there can be only one | 169 // there can be only one |
175 fBaseIndex = 0; | 170 fBaseIndex = 0; |
176 break; | 171 break; |
177 case kColor_EffectType: | 172 case kFragment_ProcessorType: |
178 fBaseIndex = desc->hasGeometryProcessor() ? 1 : 0; | 173 fBaseIndex = desc->hasGeometryProcessor() ? 1 : 0; |
179 break; | 174 break; |
180 case kCoverage_EffectType: | |
181 fBaseIndex = desc->numColorEffects() + (desc->hasGeometryPro
cessor() ? 1 : 0); | |
182 break; | |
183 } | 175 } |
184 } | 176 } |
185 | 177 |
186 GrProcessorKey get(int index) const { | 178 GrProcessorKey get(int index) const { |
187 const uint16_t* offsetsAndLengths = reinterpret_cast<const uint16_t*
>( | 179 const uint16_t* offsetsAndLengths = reinterpret_cast<const uint16_t*
>( |
188 fDesc->fKey.begin() + kEffectKeyOffsetsAndLengthOffset); | 180 fDesc->fKey.begin() + kEffectKeyOffsetsAndLengthOffset); |
189 // We store two uint16_ts per effect, one for the offset to the effe
ct's key and one for | 181 // We store two uint16_ts per effect, one for the offset to the effe
ct's key and one for |
190 // its length. Here we just need the offset. | 182 // its length. Here we just need the offset. |
191 uint16_t offset = offsetsAndLengths[2 * (fBaseIndex + index) + 0]; | 183 uint16_t offset = offsetsAndLengths[2 * (fBaseIndex + index) + 0]; |
192 uint16_t length = offsetsAndLengths[2 * (fBaseIndex + index) + 1]; | 184 uint16_t length = offsetsAndLengths[2 * (fBaseIndex + index) + 1]; |
(...skipping 21 matching lines...) Expand all Loading... |
214 // visible to GrGLProcessors. Then make public accessors as necessary and re
move friends. | 206 // visible to GrGLProcessors. Then make public accessors as necessary and re
move friends. |
215 friend class GrGLProgram; | 207 friend class GrGLProgram; |
216 friend class GrGLProgramBuilder; | 208 friend class GrGLProgramBuilder; |
217 friend class GrGLLegacyNvprProgramBuilder; | 209 friend class GrGLLegacyNvprProgramBuilder; |
218 friend class GrGLVertexBuilder; | 210 friend class GrGLVertexBuilder; |
219 friend class GrGLFragmentShaderBuilder; | 211 friend class GrGLFragmentShaderBuilder; |
220 friend class GrGLGeometryBuilder; | 212 friend class GrGLGeometryBuilder; |
221 }; | 213 }; |
222 | 214 |
223 #endif | 215 #endif |
OLD | NEW |