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 #include "GrGLFragmentShaderBuilder.h" | 8 #include "GrGLFragmentShaderBuilder.h" |
9 #include "GrGLShaderStringBuilder.h" | 9 #include "GrGLShaderStringBuilder.h" |
10 #include "GrGLProgramBuilder.h" | 10 #include "GrGLProgramBuilder.h" |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
172 gpu->glCaps().fbFetchExtensionString()); | 172 gpu->glCaps().fbFetchExtensionString()); |
173 | 173 |
174 // Some versions of this extension string require declaring custom color output on ES 3.0+ | 174 // Some versions of this extension string require declaring custom color output on ES 3.0+ |
175 const char* fbFetchColorName = gpu->glCaps().fbFetchColorName(); | 175 const char* fbFetchColorName = gpu->glCaps().fbFetchColorName(); |
176 if (gpu->glCaps().fbFetchNeedsCustomOutput()) { | 176 if (gpu->glCaps().fbFetchNeedsCustomOutput()) { |
177 this->enableCustomOutput(); | 177 this->enableCustomOutput(); |
178 fOutputs[fCustomColorOutputIndex].setTypeModifier(GrShaderVar::kInOu t_TypeModifier); | 178 fOutputs[fCustomColorOutputIndex].setTypeModifier(GrShaderVar::kInOu t_TypeModifier); |
179 fbFetchColorName = declared_color_output_name(); | 179 fbFetchColorName = declared_color_output_name(); |
180 } | 180 } |
181 return fbFetchColorName; | 181 return fbFetchColorName; |
182 } else if (fProgramBuilder->fUniformHandles.fDstCopySamplerUni.isValid()) { | 182 } else { |
183 return kDstCopyColorName; | 183 return kDstCopyColorName; |
184 } else { | 184 } |
185 return ""; | |
186 } | |
187 } | |
188 | |
189 void GrGLFragmentShaderBuilder::emitCodeToReadDstTexture() { | |
190 bool topDown = SkToBool(kTopLeftOrigin_DstReadKeyBit & fProgramBuilder->head er().fDstReadKey); | |
191 const char* dstCopyTopLeftName; | |
192 const char* dstCopyCoordScaleName; | |
193 const char* dstCopySamplerName; | |
194 uint32_t configMask; | |
195 if (SkToBool(kUseAlphaConfig_DstReadKeyBit & fProgramBuilder->header().fDstR eadKey)) { | |
196 configMask = kA_GrColorComponentFlag; | |
197 } else { | |
198 configMask = kRGBA_GrColorComponentFlags; | |
199 } | |
200 fProgramBuilder->fUniformHandles.fDstCopySamplerUni = | |
joshualitt
2015/02/02 15:42:25
Delete the dstcopy stuff from BuiltInUniformHandle
| |
201 fProgramBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility , | |
202 kSampler2D_GrSLType, | |
203 kDefault_GrSLPrecision, | |
204 "DstCopySampler", | |
205 &dstCopySamplerName); | |
206 fProgramBuilder->fUniformHandles.fDstCopyTopLeftUni = | |
207 fProgramBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility , | |
208 kVec2f_GrSLType, | |
209 kDefault_GrSLPrecision, | |
210 "DstCopyUpperLeft", | |
211 &dstCopyTopLeftName); | |
212 fProgramBuilder->fUniformHandles.fDstCopyScaleUni = | |
213 fProgramBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility , | |
214 kVec2f_GrSLType, | |
215 kDefault_GrSLPrecision, | |
216 "DstCopyCoordScale", | |
217 &dstCopyCoordScaleName); | |
218 const char* fragPos = this->fragmentPosition(); | |
219 | |
220 this->codeAppend("// Read color from copy of the destination.\n"); | |
221 this->codeAppendf("vec2 _dstTexCoord = (%s.xy - %s) * %s;", | |
222 fragPos, dstCopyTopLeftName, dstCopyCoordScaleName); | |
223 if (!topDown) { | |
224 this->codeAppend("_dstTexCoord.y = 1.0 - _dstTexCoord.y;"); | |
225 } | |
226 this->codeAppendf("vec4 %s = ", GrGLFragmentShaderBuilder::kDstCopyColorName ); | |
227 this->appendTextureLookup(dstCopySamplerName, | |
228 "_dstTexCoord", | |
229 configMask, | |
230 "rgba"); | |
231 this->codeAppend(";"); | |
232 } | 185 } |
233 | 186 |
234 void GrGLFragmentShaderBuilder::enableCustomOutput() { | 187 void GrGLFragmentShaderBuilder::enableCustomOutput() { |
235 if (!fHasCustomColorOutput) { | 188 if (!fHasCustomColorOutput) { |
236 fHasCustomColorOutput = true; | 189 fHasCustomColorOutput = true; |
237 fCustomColorOutputIndex = fOutputs.count(); | 190 fCustomColorOutputIndex = fOutputs.count(); |
238 fOutputs.push_back().set(kVec4f_GrSLType, | 191 fOutputs.push_back().set(kVec4f_GrSLType, |
239 GrGLShaderVar::kOut_TypeModifier, | 192 GrGLShaderVar::kOut_TypeModifier, |
240 declared_color_output_name()); | 193 declared_color_output_name()); |
241 } | 194 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
297 } | 250 } |
298 } | 251 } |
299 | 252 |
300 void GrGLFragmentShaderBuilder::addVarying(GrGLVarying* v, GrSLPrecision fsPrec) { | 253 void GrGLFragmentShaderBuilder::addVarying(GrGLVarying* v, GrSLPrecision fsPrec) { |
301 v->fFsIn = v->fVsOut; | 254 v->fFsIn = v->fVsOut; |
302 if (v->fGsOut) { | 255 if (v->fGsOut) { |
303 v->fFsIn = v->fGsOut; | 256 v->fFsIn = v->fGsOut; |
304 } | 257 } |
305 fInputs.push_back().set(v->fType, GrGLShaderVar::kVaryingIn_TypeModifier, v- >fFsIn, fsPrec); | 258 fInputs.push_back().set(v->fType, GrGLShaderVar::kVaryingIn_TypeModifier, v- >fFsIn, fsPrec); |
306 } | 259 } |
OLD | NEW |