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