| 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 "gl/GrGLProgram.h" | 8 #include "gl/GrGLProgram.h" |
| 9 #include "gl/GrGLSLPrettyPrint.h" | 9 #include "gl/GrGLSLPrettyPrint.h" |
| 10 #include "gl/GrGLUniformHandle.h" | 10 #include "gl/GrGLUniformHandle.h" |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 uni.fVisibility = visibility; | 149 uni.fVisibility = visibility; |
| 150 | 150 |
| 151 // If it is visible in both the VS and FS, the precision must match. | 151 // If it is visible in both the VS and FS, the precision must match. |
| 152 // We declare a default FS precision, but not a default VS. So set the var | 152 // We declare a default FS precision, but not a default VS. So set the var |
| 153 // to use the default FS precision. | 153 // to use the default FS precision. |
| 154 if ((kVertex_Visibility | kFragment_Visibility) == visibility) { | 154 if ((kVertex_Visibility | kFragment_Visibility) == visibility) { |
| 155 // the fragment and vertex precisions must match | 155 // the fragment and vertex precisions must match |
| 156 uni.fVariable.setPrecision(kDefaultFragmentPrecision); | 156 uni.fVariable.setPrecision(kDefaultFragmentPrecision); |
| 157 } | 157 } |
| 158 | 158 |
| 159 if (NULL != outName) { | 159 if (outName) { |
| 160 *outName = uni.fVariable.c_str(); | 160 *outName = uni.fVariable.c_str(); |
| 161 } | 161 } |
| 162 return GrGLProgramDataManager::UniformHandle::CreateFromUniformIndex(fUnifor
ms.count() - 1); | 162 return GrGLProgramDataManager::UniformHandle::CreateFromUniformIndex(fUnifor
ms.count() - 1); |
| 163 } | 163 } |
| 164 | 164 |
| 165 void GrGLProgramBuilder::appendDecls(const VarArray& vars, SkString* out) const
{ | 165 void GrGLProgramBuilder::appendDecls(const VarArray& vars, SkString* out) const
{ |
| 166 for (int i = 0; i < vars.count(); ++i) { | 166 for (int i = 0; i < vars.count(); ++i) { |
| 167 vars[i].appendDecl(this->ctxInfo(), out); | 167 vars[i].appendDecl(this->ctxInfo(), out); |
| 168 out->append(";\n"); | 168 out->append(";\n"); |
| 169 } | 169 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 183 const GrEffectStage* effectStages[
], | 183 const GrEffectStage* effectStages[
], |
| 184 int effectCnt, | 184 int effectCnt, |
| 185 const GrGLProgramDesc::EffectKeyPr
ovider& keyProvider, | 185 const GrGLProgramDesc::EffectKeyPr
ovider& keyProvider, |
| 186 GrGLSLExpr4* fsInOutColor) { | 186 GrGLSLExpr4* fsInOutColor) { |
| 187 bool effectEmitted = false; | 187 bool effectEmitted = false; |
| 188 | 188 |
| 189 GrGLSLExpr4 inColor = *fsInOutColor; | 189 GrGLSLExpr4 inColor = *fsInOutColor; |
| 190 GrGLSLExpr4 outColor; | 190 GrGLSLExpr4 outColor; |
| 191 | 191 |
| 192 for (int e = 0; e < effectCnt; ++e) { | 192 for (int e = 0; e < effectCnt; ++e) { |
| 193 SkASSERT(NULL != effectStages[e] && NULL != effectStages[e]->getEffect()
); | 193 SkASSERT(effectStages[e] && effectStages[e]->getEffect()); |
| 194 const GrEffectStage& stage = *effectStages[e]; | 194 const GrEffectStage& stage = *effectStages[e]; |
| 195 | 195 |
| 196 CodeStage::AutoStageRestore csar(&fCodeStage, &stage); | 196 CodeStage::AutoStageRestore csar(&fCodeStage, &stage); |
| 197 | 197 |
| 198 if (inColor.isZeros()) { | 198 if (inColor.isZeros()) { |
| 199 SkString inColorName; | 199 SkString inColorName; |
| 200 | 200 |
| 201 // Effects have no way to communicate zeros, they treat an empty str
ing as ones. | 201 // Effects have no way to communicate zeros, they treat an empty str
ing as ones. |
| 202 this->nameVariable(&inColorName, '\0', "input"); | 202 this->nameVariable(&inColorName, '\0', "input"); |
| 203 fFS.codeAppendf("\tvec4 %s = %s;\n", inColorName.c_str(), inColor.c_
str()); | 203 fFS.codeAppendf("\tvec4 %s = %s;\n", inColorName.c_str(), inColor.c_
str()); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 , fVS(this) { | 337 , fVS(this) { |
| 338 } | 338 } |
| 339 | 339 |
| 340 void GrGLFullProgramBuilder::emitCodeBeforeEffects(GrGLSLExpr4* color, | 340 void GrGLFullProgramBuilder::emitCodeBeforeEffects(GrGLSLExpr4* color, |
| 341 GrGLSLExpr4* coverage) { | 341 GrGLSLExpr4* coverage) { |
| 342 fVS.emitCodeBeforeEffects(color, coverage); | 342 fVS.emitCodeBeforeEffects(color, coverage); |
| 343 } | 343 } |
| 344 | 344 |
| 345 void GrGLFullProgramBuilder::emitGeometryProcessor(const GrEffectStage* geometry
Processor, | 345 void GrGLFullProgramBuilder::emitGeometryProcessor(const GrEffectStage* geometry
Processor, |
| 346 GrGLSLExpr4* coverage) { | 346 GrGLSLExpr4* coverage) { |
| 347 if (NULL != geometryProcessor) { | 347 if (geometryProcessor) { |
| 348 GrGLProgramDesc::EffectKeyProvider geometryProcessorKeyProvider( | 348 GrGLProgramDesc::EffectKeyProvider geometryProcessorKeyProvider( |
| 349 &this->desc(), GrGLProgramDesc::EffectKeyProvider::kGeometryProc
essor_EffectType); | 349 &this->desc(), GrGLProgramDesc::EffectKeyProvider::kGeometryProc
essor_EffectType); |
| 350 fGeometryProcessor.reset(this->createAndEmitEffect( | 350 fGeometryProcessor.reset(this->createAndEmitEffect( |
| 351 geometryProcessor, | 351 geometryProcessor, |
| 352 geometryProcessorKeyProvider, | 352 geometryProcessorKeyProvider, |
| 353 coverage)); | 353 coverage)); |
| 354 } | 354 } |
| 355 } | 355 } |
| 356 | 356 |
| 357 void GrGLFullProgramBuilder::emitCodeAfterEffects() { | 357 void GrGLFullProgramBuilder::emitCodeAfterEffects() { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 return programEffectsBuilder.finish(); | 404 return programEffectsBuilder.finish(); |
| 405 } | 405 } |
| 406 | 406 |
| 407 void GrGLFullProgramBuilder::createAndEmitEffect(GrGLProgramEffectsBuilder* prog
ramEffectsBuilder, | 407 void GrGLFullProgramBuilder::createAndEmitEffect(GrGLProgramEffectsBuilder* prog
ramEffectsBuilder, |
| 408 const GrEffectStage* effectStages, | 408 const GrEffectStage* effectStages, |
| 409 const GrGLProgramDesc::EffectKeyPr
ovider& keyProvider, | 409 const GrGLProgramDesc::EffectKeyPr
ovider& keyProvider, |
| 410 GrGLSLExpr4* fsInOutColor) { | 410 GrGLSLExpr4* fsInOutColor) { |
| 411 GrGLSLExpr4 inColor = *fsInOutColor; | 411 GrGLSLExpr4 inColor = *fsInOutColor; |
| 412 GrGLSLExpr4 outColor; | 412 GrGLSLExpr4 outColor; |
| 413 | 413 |
| 414 SkASSERT(NULL != effectStages && NULL != effectStages->getEffect()); | 414 SkASSERT(effectStages && effectStages->getEffect()); |
| 415 const GrEffectStage& stage = *effectStages; | 415 const GrEffectStage& stage = *effectStages; |
| 416 | 416 |
| 417 // Using scope to force ASR destructor to be triggered | 417 // Using scope to force ASR destructor to be triggered |
| 418 { | 418 { |
| 419 CodeStage::AutoStageRestore csar(&fCodeStage, &stage); | 419 CodeStage::AutoStageRestore csar(&fCodeStage, &stage); |
| 420 | 420 |
| 421 if (inColor.isZeros()) { | 421 if (inColor.isZeros()) { |
| 422 SkString inColorName; | 422 SkString inColorName; |
| 423 | 423 |
| 424 // Effects have no way to communicate zeros, they treat an empty str
ing as ones. | 424 // Effects have no way to communicate zeros, they treat an empty str
ing as ones. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 | 494 |
| 495 GrGLPathTexGenProgramEffectsBuilder pathTexGenEffectsBuilder(this, | 495 GrGLPathTexGenProgramEffectsBuilder pathTexGenEffectsBuilder(this, |
| 496 effectCnt); | 496 effectCnt); |
| 497 this->INHERITED::createAndEmitEffects(&pathTexGenEffectsBuilder, | 497 this->INHERITED::createAndEmitEffects(&pathTexGenEffectsBuilder, |
| 498 effectStages, | 498 effectStages, |
| 499 effectCnt, | 499 effectCnt, |
| 500 keyProvider, | 500 keyProvider, |
| 501 inOutFSColor); | 501 inOutFSColor); |
| 502 return pathTexGenEffectsBuilder.finish(); | 502 return pathTexGenEffectsBuilder.finish(); |
| 503 } | 503 } |
| OLD | NEW |