OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 #include "gl/GrGLShaderBuilder.h" | 8 #include "gl/GrGLShaderBuilder.h" |
9 #include "gl/GrGLProgram.h" | 9 #include "gl/GrGLProgram.h" |
10 #include "gl/GrGLUniformHandle.h" | 10 #include "gl/GrGLUniformHandle.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 *output = builder->getOutput(); | 105 *output = builder->getOutput(); |
106 return true; | 106 return true; |
107 } | 107 } |
108 return false; | 108 return false; |
109 } | 109 } |
110 | 110 |
111 bool GrGLShaderBuilder::genProgram(const GrEffectStage* colorStages[], | 111 bool GrGLShaderBuilder::genProgram(const GrEffectStage* colorStages[], |
112 const GrEffectStage* coverageStages[]) { | 112 const GrEffectStage* coverageStages[]) { |
113 const GrGLProgramDesc::KeyHeader& header = this->desc().getHeader(); | 113 const GrGLProgramDesc::KeyHeader& header = this->desc().getHeader(); |
114 | 114 |
115 // incoming color to current stage being processed. | |
116 GrGLSLExpr4 inColor = this->getInputColor(); | |
117 | |
118 fOutput.fColorEffects = | |
119 this->createAndEmitEffects(colorStages, | |
120 this->desc().getEffectKeys(), | |
121 this->desc().numColorEffects(), | |
122 &inColor); | |
123 | |
124 /////////////////////////////////////////////////////////////////////////// | 115 /////////////////////////////////////////////////////////////////////////// |
125 // compute the partial coverage | 116 // emit code to read the dst copy texture, if necessary |
126 GrGLSLExpr4 inCoverage = this->getInputCoverage(); | |
127 | |
128 fOutput.fCoverageEffects = | |
129 this->createAndEmitEffects(coverageStages, | |
130 this->desc().getEffectKeys() + this->desc().
numColorEffects(), | |
131 this->desc().numCoverageEffects(), | |
132 &inCoverage); | |
133 | |
134 if (GrGLProgramDesc::CoverageOutputUsesSecondaryOutput(header.fCoverageOutpu
t)) { | |
135 const char* secondaryOutputName = this->enableSecondaryOutput(); | |
136 | |
137 // default coeff to ones for kCoverage_DualSrcOutput | |
138 GrGLSLExpr4 coeff(1); | |
139 if (GrGLProgramDesc::kSecondaryCoverageISA_CoverageOutput == header.fCov
erageOutput) { | |
140 // Get (1-A) into coeff | |
141 coeff = GrGLSLExpr4::VectorCast(GrGLSLExpr1(1) - inColor.a()); | |
142 } else if (GrGLProgramDesc::kSecondaryCoverageISC_CoverageOutput == | |
143 header.fCoverageOutput){ | |
144 // Get (1-RGBA) into coeff | |
145 coeff = GrGLSLExpr4(1) - inColor; | |
146 } | |
147 // Get coeff * coverage into modulate and then write that to the dual so
urce output. | |
148 this->fsCodeAppendf("\t%s = %s;\n", secondaryOutputName, (coeff * inCove
rage).c_str()); | |
149 } | |
150 | |
151 /////////////////////////////////////////////////////////////////////////// | |
152 // combine color and coverage as frag color | |
153 | |
154 // Get "color * coverage" into fragColor | |
155 GrGLSLExpr4 fragColor = inColor * inCoverage; | |
156 // Now tack on "+(1-coverage)dst onto the frag color if we were asked to do
so. | |
157 if (GrGLProgramDesc::kCombineWithDst_CoverageOutput == header.fCoverageOutpu
t) { | |
158 GrGLSLExpr4 dstCoeff = GrGLSLExpr4(1) - inCoverage; | |
159 | |
160 GrGLSLExpr4 dstContribution = dstCoeff * GrGLSLExpr4(this->dstColor()); | |
161 | |
162 fragColor = fragColor + dstContribution; | |
163 } | |
164 this->fsCodeAppendf("\t%s = %s;\n", this->getColorOutputName(), fragColor.c_
str()); | |
165 | |
166 if (!this->finish()) { | |
167 return false; | |
168 } | |
169 | |
170 return true; | |
171 } | |
172 | |
173 ////////////////////////////////////////////////////////////////////////////// | |
174 | |
175 GrGLShaderBuilder::GrGLShaderBuilder(GrGpuGL* gpu, | |
176 GrGLUniformManager* uniformManager, | |
177 const GrGLProgramDesc& desc) | |
178 : fDesc(desc) | |
179 , fGpu(gpu) | |
180 , fUniformManager(SkRef(uniformManager)) | |
181 , fFSFeaturesAddedMask(0) | |
182 , fFSInputs(kVarsPerBlock) | |
183 , fFSOutputs(kMaxFSOutputs) | |
184 , fUniforms(kVarsPerBlock) | |
185 , fSetupFragPosition(false) | |
186 , fTopLeftFragPosRead(kTopLeftFragPosRead_FragPosKey == desc.getHeader().fFr
agPosKey) | |
187 , fHasCustomColorOutput(false) | |
188 , fHasSecondaryOutput(false) { | |
189 | |
190 const GrGLProgramDesc::KeyHeader& header = desc.getHeader(); | |
191 | |
192 // Emit code to read the dst copy textue if necessary. | |
193 if (kNoDstRead_DstReadKey != header.fDstReadKey && | 117 if (kNoDstRead_DstReadKey != header.fDstReadKey && |
194 GrGLCaps::kNone_FBFetchType == fGpu->glCaps().fbFetchType()) { | 118 GrGLCaps::kNone_FBFetchType == fGpu->glCaps().fbFetchType()) { |
195 bool topDown = SkToBool(kTopLeftOrigin_DstReadKeyBit & header.fDstReadKe
y); | 119 bool topDown = SkToBool(kTopLeftOrigin_DstReadKeyBit & header.fDstReadKe
y); |
196 const char* dstCopyTopLeftName; | 120 const char* dstCopyTopLeftName; |
197 const char* dstCopyCoordScaleName; | 121 const char* dstCopyCoordScaleName; |
198 const char* dstCopySamplerName; | 122 const char* dstCopySamplerName; |
199 uint32_t configMask; | 123 uint32_t configMask; |
200 if (SkToBool(kUseAlphaConfig_DstReadKeyBit & header.fDstReadKey)) { | 124 if (SkToBool(kUseAlphaConfig_DstReadKeyBit & header.fDstReadKey)) { |
201 configMask = kA_GrColorComponentFlag; | 125 configMask = kA_GrColorComponentFlag; |
202 } else { | 126 } else { |
(...skipping 18 matching lines...) Expand all Loading... |
221 this->fsCodeAppendf("\tvec4 %s = ", kDstCopyColorName); | 145 this->fsCodeAppendf("\tvec4 %s = ", kDstCopyColorName); |
222 append_texture_lookup(&fFSCode, | 146 append_texture_lookup(&fFSCode, |
223 fGpu, | 147 fGpu, |
224 dstCopySamplerName, | 148 dstCopySamplerName, |
225 "_dstTexCoord", | 149 "_dstTexCoord", |
226 configMask, | 150 configMask, |
227 "rgba"); | 151 "rgba"); |
228 this->fsCodeAppend(";\n\n"); | 152 this->fsCodeAppend(";\n\n"); |
229 } | 153 } |
230 | 154 |
| 155 /////////////////////////////////////////////////////////////////////////// |
| 156 // get the initial color and coverage to feed into the first effect in each
effect chain |
| 157 |
| 158 GrGLSLExpr4 inputColor; |
| 159 GrGLSLExpr4 inputCoverage; |
| 160 |
231 if (GrGLProgramDesc::kUniform_ColorInput == header.fColorInput) { | 161 if (GrGLProgramDesc::kUniform_ColorInput == header.fColorInput) { |
232 const char* name; | 162 const char* name; |
233 fOutput.fUniformHandles.fColorUni = | 163 fOutput.fUniformHandles.fColorUni = |
234 this->addUniform(GrGLShaderBuilder::kFragment_Visibility, kVec4f_GrS
LType, "Color", | 164 this->addUniform(GrGLShaderBuilder::kFragment_Visibility, kVec4f_GrS
LType, "Color", |
235 &name); | 165 &name); |
236 fInputColor = GrGLSLExpr4(name); | 166 inputColor = GrGLSLExpr4(name); |
237 } else if (GrGLProgramDesc::kSolidWhite_ColorInput == header.fColorInput) { | 167 } else if (GrGLProgramDesc::kSolidWhite_ColorInput == header.fColorInput) { |
238 fInputColor = GrGLSLExpr4(1); | 168 inputColor = GrGLSLExpr4(1); |
239 } else if (GrGLProgramDesc::kTransBlack_ColorInput == header.fColorInput) { | 169 } else if (GrGLProgramDesc::kTransBlack_ColorInput == header.fColorInput) { |
240 fInputColor = GrGLSLExpr4(0); | 170 inputColor = GrGLSLExpr4(0); |
241 } | 171 } |
242 | 172 |
243 if (GrGLProgramDesc::kUniform_ColorInput == header.fCoverageInput) { | 173 if (GrGLProgramDesc::kUniform_ColorInput == header.fCoverageInput) { |
244 const char* name; | 174 const char* name; |
245 fOutput.fUniformHandles.fCoverageUni = | 175 fOutput.fUniformHandles.fCoverageUni = |
246 this->addUniform(GrGLShaderBuilder::kFragment_Visibility, kVec4f_GrS
LType, "Coverage", | 176 this->addUniform(GrGLShaderBuilder::kFragment_Visibility, kVec4f_GrS
LType, "Coverage", |
247 &name); | 177 &name); |
248 fInputCoverage = GrGLSLExpr4(name); | 178 inputCoverage = GrGLSLExpr4(name); |
249 } else if (GrGLProgramDesc::kSolidWhite_ColorInput == header.fCoverageInput)
{ | 179 } else if (GrGLProgramDesc::kSolidWhite_ColorInput == header.fCoverageInput)
{ |
250 fInputCoverage = GrGLSLExpr4(1); | 180 inputCoverage = GrGLSLExpr4(1); |
251 } else if (GrGLProgramDesc::kTransBlack_ColorInput == header.fCoverageInput)
{ | 181 } else if (GrGLProgramDesc::kTransBlack_ColorInput == header.fCoverageInput)
{ |
252 fInputCoverage = GrGLSLExpr4(0); | 182 inputCoverage = GrGLSLExpr4(0); |
253 } | 183 } |
254 | 184 |
255 if (k110_GrGLSLGeneration != fGpu->glslGeneration()) { | 185 if (k110_GrGLSLGeneration != fGpu->glslGeneration()) { |
256 fFSOutputs.push_back().set(kVec4f_GrSLType, | 186 fFSOutputs.push_back().set(kVec4f_GrSLType, |
257 GrGLShaderVar::kOut_TypeModifier, | 187 GrGLShaderVar::kOut_TypeModifier, |
258 declared_color_output_name()); | 188 declared_color_output_name()); |
259 fHasCustomColorOutput = true; | 189 fHasCustomColorOutput = true; |
260 } | 190 } |
| 191 |
| 192 this->emitCodeBeforeEffects(&inputColor, &inputCoverage); |
| 193 |
| 194 /////////////////////////////////////////////////////////////////////////// |
| 195 // emit the per-effect code for both color and coverage effects |
| 196 |
| 197 fOutput.fColorEffects = |
| 198 this->createAndEmitEffects(colorStages, |
| 199 this->desc().getEffectKeys(), |
| 200 this->desc().numColorEffects(), |
| 201 &inputColor); |
| 202 |
| 203 fOutput.fCoverageEffects = |
| 204 this->createAndEmitEffects(coverageStages, |
| 205 this->desc().getEffectKeys() + this->desc().
numColorEffects(), |
| 206 this->desc().numCoverageEffects(), |
| 207 &inputCoverage); |
| 208 |
| 209 this->emitCodeAfterEffects(); |
| 210 |
| 211 /////////////////////////////////////////////////////////////////////////// |
| 212 // write the secondary color output if necessary |
| 213 if (GrGLProgramDesc::CoverageOutputUsesSecondaryOutput(header.fCoverageOutpu
t)) { |
| 214 const char* secondaryOutputName = this->enableSecondaryOutput(); |
| 215 |
| 216 // default coeff to ones for kCoverage_DualSrcOutput |
| 217 GrGLSLExpr4 coeff(1); |
| 218 if (GrGLProgramDesc::kSecondaryCoverageISA_CoverageOutput == header.fCov
erageOutput) { |
| 219 // Get (1-A) into coeff |
| 220 coeff = GrGLSLExpr4::VectorCast(GrGLSLExpr1(1) - inputColor.a()); |
| 221 } else if (GrGLProgramDesc::kSecondaryCoverageISC_CoverageOutput == |
| 222 header.fCoverageOutput){ |
| 223 // Get (1-RGBA) into coeff |
| 224 coeff = GrGLSLExpr4(1) - inputColor; |
| 225 } |
| 226 // Get coeff * coverage into modulate and then write that to the dual so
urce output. |
| 227 this->fsCodeAppendf("\t%s = %s;\n", secondaryOutputName, (coeff * inputC
overage).c_str()); |
| 228 } |
| 229 |
| 230 /////////////////////////////////////////////////////////////////////////// |
| 231 // combine color and coverage as frag color |
| 232 |
| 233 // Get "color * coverage" into fragColor |
| 234 GrGLSLExpr4 fragColor = inputColor * inputCoverage; |
| 235 // Now tack on "+(1-coverage)dst onto the frag color if we were asked to do
so. |
| 236 if (GrGLProgramDesc::kCombineWithDst_CoverageOutput == header.fCoverageOutpu
t) { |
| 237 GrGLSLExpr4 dstCoeff = GrGLSLExpr4(1) - inputCoverage; |
| 238 |
| 239 GrGLSLExpr4 dstContribution = dstCoeff * GrGLSLExpr4(this->dstColor()); |
| 240 |
| 241 fragColor = fragColor + dstContribution; |
| 242 } |
| 243 this->fsCodeAppendf("\t%s = %s;\n", this->getColorOutputName(), fragColor.c_
str()); |
| 244 |
| 245 if (!this->finish()) { |
| 246 return false; |
| 247 } |
| 248 |
| 249 return true; |
| 250 } |
| 251 |
| 252 ////////////////////////////////////////////////////////////////////////////// |
| 253 |
| 254 GrGLShaderBuilder::GrGLShaderBuilder(GrGpuGL* gpu, |
| 255 GrGLUniformManager* uniformManager, |
| 256 const GrGLProgramDesc& desc) |
| 257 : fDesc(desc) |
| 258 , fGpu(gpu) |
| 259 , fUniformManager(SkRef(uniformManager)) |
| 260 , fFSFeaturesAddedMask(0) |
| 261 , fFSInputs(kVarsPerBlock) |
| 262 , fFSOutputs(kMaxFSOutputs) |
| 263 , fUniforms(kVarsPerBlock) |
| 264 , fSetupFragPosition(false) |
| 265 , fTopLeftFragPosRead(kTopLeftFragPosRead_FragPosKey == desc.getHeader().fFr
agPosKey) |
| 266 , fHasCustomColorOutput(false) |
| 267 , fHasSecondaryOutput(false) { |
261 } | 268 } |
262 | 269 |
263 bool GrGLShaderBuilder::enableFeature(GLSLFeature feature) { | 270 bool GrGLShaderBuilder::enableFeature(GLSLFeature feature) { |
264 switch (feature) { | 271 switch (feature) { |
265 case kStandardDerivatives_GLSLFeature: | 272 case kStandardDerivatives_GLSLFeature: |
266 if (!fGpu->glCaps().shaderDerivativeSupport()) { | 273 if (!fGpu->glCaps().shaderDerivativeSupport()) { |
267 return false; | 274 return false; |
268 } | 275 } |
269 if (kGLES_GrGLStandard == fGpu->glStandard()) { | 276 if (kGLES_GrGLStandard == fGpu->glStandard()) { |
270 this->addFSFeature(1 << kStandardDerivatives_GLSLFeature, | 277 this->addFSFeature(1 << kStandardDerivatives_GLSLFeature, |
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 //////////////////////////////////////////////////////////////////////////////// | 822 //////////////////////////////////////////////////////////////////////////////// |
816 | 823 |
817 GrGLFullShaderBuilder::GrGLFullShaderBuilder(GrGpuGL* gpu, | 824 GrGLFullShaderBuilder::GrGLFullShaderBuilder(GrGpuGL* gpu, |
818 GrGLUniformManager* uniformManager, | 825 GrGLUniformManager* uniformManager, |
819 const GrGLProgramDesc& desc) | 826 const GrGLProgramDesc& desc) |
820 : INHERITED(gpu, uniformManager, desc) | 827 : INHERITED(gpu, uniformManager, desc) |
821 , fVSAttrs(kVarsPerBlock) | 828 , fVSAttrs(kVarsPerBlock) |
822 , fVSOutputs(kVarsPerBlock) | 829 , fVSOutputs(kVarsPerBlock) |
823 , fGSInputs(kVarsPerBlock) | 830 , fGSInputs(kVarsPerBlock) |
824 , fGSOutputs(kVarsPerBlock) { | 831 , fGSOutputs(kVarsPerBlock) { |
| 832 } |
825 | 833 |
| 834 void GrGLFullShaderBuilder::emitCodeBeforeEffects(GrGLSLExpr4* color, GrGLSLExpr
4* coverage) { |
826 const GrGLProgramDesc::KeyHeader& header = this->desc().getHeader(); | 835 const GrGLProgramDesc::KeyHeader& header = this->desc().getHeader(); |
827 | 836 |
828 fOutput.fHasVertexShader = true; | 837 fOutput.fHasVertexShader = true; |
829 | 838 |
830 fPositionVar = &fVSAttrs.push_back(); | 839 fPositionVar = &fVSAttrs.push_back(); |
831 fPositionVar->set(kVec2f_GrSLType, GrGLShaderVar::kAttribute_TypeModifier, "
aPosition"); | 840 fPositionVar->set(kVec2f_GrSLType, GrGLShaderVar::kAttribute_TypeModifier, "
aPosition"); |
832 if (-1 != header.fLocalCoordAttributeIndex) { | 841 if (-1 != header.fLocalCoordAttributeIndex) { |
833 fLocalCoordsVar = &fVSAttrs.push_back(); | 842 fLocalCoordsVar = &fVSAttrs.push_back(); |
834 fLocalCoordsVar->set(kVec2f_GrSLType, | 843 fLocalCoordsVar->set(kVec2f_GrSLType, |
835 GrGLShaderVar::kAttribute_TypeModifier, | 844 GrGLShaderVar::kAttribute_TypeModifier, |
836 "aLocalCoords"); | 845 "aLocalCoords"); |
837 } else { | 846 } else { |
838 fLocalCoordsVar = fPositionVar; | 847 fLocalCoordsVar = fPositionVar; |
839 } | 848 } |
840 | 849 |
841 const char* viewMName; | 850 const char* viewMName; |
842 fOutput.fUniformHandles.fViewMatrixUni = | 851 fOutput.fUniformHandles.fViewMatrixUni = |
843 this->addUniform(GrGLShaderBuilder::kVertex_Visibility, kMat33f_GrSLType
, "ViewM", | 852 this->addUniform(GrGLShaderBuilder::kVertex_Visibility, kMat33f_GrSLType
, "ViewM", |
844 &viewMName); | 853 &viewMName); |
845 const char* rtAdjustName; | |
846 fOutput.fUniformHandles.fRTAdjustmentUni = | |
847 this->addUniform(GrGLShaderBuilder::kVertex_Visibility, kVec4f_GrSLType,
"rtAdjustment", | |
848 &rtAdjustName); | |
849 | 854 |
850 // Transform the position into Skia's device coords. | 855 // Transform the position into Skia's device coords. |
851 this->vsCodeAppendf("\tvec3 pos3 = %s * vec3(%s, 1);\n", | 856 this->vsCodeAppendf("\tvec3 pos3 = %s * vec3(%s, 1);\n", |
852 viewMName, fPositionVar->c_str()); | 857 viewMName, fPositionVar->c_str()); |
853 | 858 |
854 // Transform from Skia's device coords to GL's normalized device coords. | |
855 this->vsCodeAppendf( | |
856 "\tgl_Position = vec4(dot(pos3.xz, %s.xy), dot(pos3.yz, %s.zw), 0, pos3.
z);\n", | |
857 rtAdjustName, rtAdjustName); | |
858 | |
859 // we output point size in the GS if present | 859 // we output point size in the GS if present |
860 if (header.fEmitsPointSize | 860 if (header.fEmitsPointSize |
861 #if GR_GL_EXPERIMENTAL_GS | 861 #if GR_GL_EXPERIMENTAL_GS |
862 && !header.fExperimentalGS | 862 && !header.fExperimentalGS |
863 #endif | 863 #endif |
864 ) { | 864 ) { |
865 this->vsCodeAppend("\tgl_PointSize = 1.0;\n"); | 865 this->vsCodeAppend("\tgl_PointSize = 1.0;\n"); |
866 } | 866 } |
867 | 867 |
868 if (GrGLProgramDesc::kAttribute_ColorInput == header.fColorInput) { | 868 if (GrGLProgramDesc::kAttribute_ColorInput == header.fColorInput) { |
869 this->addAttribute(kVec4f_GrSLType, color_attribute_name()); | 869 this->addAttribute(kVec4f_GrSLType, color_attribute_name()); |
870 const char *vsName, *fsName; | 870 const char *vsName, *fsName; |
871 this->addVarying(kVec4f_GrSLType, "Color", &vsName, &fsName); | 871 this->addVarying(kVec4f_GrSLType, "Color", &vsName, &fsName); |
872 this->vsCodeAppendf("\t%s = %s;\n", vsName, color_attribute_name()); | 872 this->vsCodeAppendf("\t%s = %s;\n", vsName, color_attribute_name()); |
873 this->setInputColor(fsName); | 873 *color = fsName; |
874 } | 874 } |
875 | 875 |
876 if (GrGLProgramDesc::kAttribute_ColorInput == header.fCoverageInput) { | 876 if (GrGLProgramDesc::kAttribute_ColorInput == header.fCoverageInput) { |
877 this->addAttribute(kVec4f_GrSLType, coverage_attribute_name()); | 877 this->addAttribute(kVec4f_GrSLType, coverage_attribute_name()); |
878 const char *vsName, *fsName; | 878 const char *vsName, *fsName; |
879 this->addVarying(kVec4f_GrSLType, "Coverage", &vsName, &fsName); | 879 this->addVarying(kVec4f_GrSLType, "Coverage", &vsName, &fsName); |
880 this->vsCodeAppendf("\t%s = %s;\n", vsName, coverage_attribute_name()); | 880 this->vsCodeAppendf("\t%s = %s;\n", vsName, coverage_attribute_name()); |
881 this->setInputCoverage(fsName); | 881 *coverage = fsName; |
882 } | 882 } |
883 } | 883 } |
884 | 884 |
| 885 void GrGLFullShaderBuilder::emitCodeAfterEffects() { |
| 886 const char* rtAdjustName; |
| 887 fOutput.fUniformHandles.fRTAdjustmentUni = |
| 888 this->addUniform(GrGLShaderBuilder::kVertex_Visibility, kVec4f_GrSLType,
"rtAdjustment", |
| 889 &rtAdjustName); |
| 890 |
| 891 // Transform from Skia's device coords to GL's normalized device coords. |
| 892 this->vsCodeAppendf( |
| 893 "\tgl_Position = vec4(dot(pos3.xz, %s.xy), dot(pos3.yz, %s.zw), 0, pos3.
z);\n", |
| 894 rtAdjustName, rtAdjustName); |
| 895 } |
| 896 |
885 bool GrGLFullShaderBuilder::addAttribute(GrSLType type, const char* name) { | 897 bool GrGLFullShaderBuilder::addAttribute(GrSLType type, const char* name) { |
886 for (int i = 0; i < fVSAttrs.count(); ++i) { | 898 for (int i = 0; i < fVSAttrs.count(); ++i) { |
887 const GrGLShaderVar& attr = fVSAttrs[i]; | 899 const GrGLShaderVar& attr = fVSAttrs[i]; |
888 // if attribute already added, don't add it again | 900 // if attribute already added, don't add it again |
889 if (attr.getName().equals(name)) { | 901 if (attr.getName().equals(name)) { |
890 SkASSERT(attr.getType() == type); | 902 SkASSERT(attr.getType() == type); |
891 return false; | 903 return false; |
892 } | 904 } |
893 } | 905 } |
894 fVSAttrs.push_back().set(type, | 906 fVSAttrs.push_back().set(type, |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 GL_CALL(BindAttribLocation(programId, attrib->fIndex, attrib->fName.c_s
tr())); | 1067 GL_CALL(BindAttribLocation(programId, attrib->fIndex, attrib->fName.c_s
tr())); |
1056 } | 1068 } |
1057 } | 1069 } |
1058 | 1070 |
1059 //////////////////////////////////////////////////////////////////////////////// | 1071 //////////////////////////////////////////////////////////////////////////////// |
1060 | 1072 |
1061 GrGLFragmentOnlyShaderBuilder::GrGLFragmentOnlyShaderBuilder(GrGpuGL* gpu, | 1073 GrGLFragmentOnlyShaderBuilder::GrGLFragmentOnlyShaderBuilder(GrGpuGL* gpu, |
1062 GrGLUniformManager*
uniformManager, | 1074 GrGLUniformManager*
uniformManager, |
1063 const GrGLProgramDe
sc& desc) | 1075 const GrGLProgramDe
sc& desc) |
1064 : INHERITED(gpu, uniformManager, desc) { | 1076 : INHERITED(gpu, uniformManager, desc) { |
1065 | |
1066 SkASSERT(!desc.getHeader().fHasVertexCode); | 1077 SkASSERT(!desc.getHeader().fHasVertexCode); |
1067 SkASSERT(gpu->glCaps().pathRenderingSupport()); | 1078 SkASSERT(gpu->glCaps().pathRenderingSupport()); |
1068 SkASSERT(GrGLProgramDesc::kAttribute_ColorInput != desc.getHeader().fColorIn
put); | 1079 SkASSERT(GrGLProgramDesc::kAttribute_ColorInput != desc.getHeader().fColorIn
put); |
1069 SkASSERT(GrGLProgramDesc::kAttribute_ColorInput != desc.getHeader().fCoverag
eInput); | 1080 SkASSERT(GrGLProgramDesc::kAttribute_ColorInput != desc.getHeader().fCoverag
eInput); |
1070 } | 1081 } |
1071 | 1082 |
1072 int GrGLFragmentOnlyShaderBuilder::addTexCoordSets(int count) { | 1083 int GrGLFragmentOnlyShaderBuilder::addTexCoordSets(int count) { |
1073 int firstFreeCoordSet = fOutput.fTexCoordSetCnt; | 1084 int firstFreeCoordSet = fOutput.fTexCoordSetCnt; |
1074 fOutput.fTexCoordSetCnt += count; | 1085 fOutput.fTexCoordSetCnt += count; |
1075 SkASSERT(gpu()->glCaps().maxFixedFunctionTextureCoords() >= fOutput.fTexCoor
dSetCnt); | 1086 SkASSERT(gpu()->glCaps().maxFixedFunctionTextureCoords() >= fOutput.fTexCoor
dSetCnt); |
1076 return firstFreeCoordSet; | 1087 return firstFreeCoordSet; |
1077 } | 1088 } |
1078 | 1089 |
1079 GrGLProgramEffects* GrGLFragmentOnlyShaderBuilder::createAndEmitEffects( | 1090 GrGLProgramEffects* GrGLFragmentOnlyShaderBuilder::createAndEmitEffects( |
1080 const GrEffectStage* effectStages[], | 1091 const GrEffectStage* effectStages[], |
1081 const EffectKey effectKeys[], | 1092 const EffectKey effectKeys[], |
1082 int effectCnt, | 1093 int effectCnt, |
1083 GrGLSLExpr4* inOutFSColor) { | 1094 GrGLSLExpr4* inOutFSColor) { |
1084 | 1095 |
1085 GrGLPathTexGenProgramEffectsBuilder pathTexGenEffectsBuilder(this, | 1096 GrGLPathTexGenProgramEffectsBuilder pathTexGenEffectsBuilder(this, |
1086 effectCnt); | 1097 effectCnt); |
1087 this->INHERITED::createAndEmitEffects(&pathTexGenEffectsBuilder, | 1098 this->INHERITED::createAndEmitEffects(&pathTexGenEffectsBuilder, |
1088 effectStages, | 1099 effectStages, |
1089 effectKeys, | 1100 effectKeys, |
1090 effectCnt, | 1101 effectCnt, |
1091 inOutFSColor); | 1102 inOutFSColor); |
1092 return pathTexGenEffectsBuilder.finish(); | 1103 return pathTexGenEffectsBuilder.finish(); |
1093 } | 1104 } |
OLD | NEW |