Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(328)

Unified Diff: src/gpu/gl/GrGLShaderBuilder.cpp

Issue 26190003: Potentially optimize some GrGLEffects for known input color values (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/gl/GrGLShaderBuilder.h ('k') | src/gpu/gl/GrGLVertexEffect.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGLShaderBuilder.cpp
diff --git a/src/gpu/gl/GrGLShaderBuilder.cpp b/src/gpu/gl/GrGLShaderBuilder.cpp
index 40ca0f2567fadddc842ec34376005104e83c66bc..40a0888362cc900c42ef15840e6447755a8ca749 100644
--- a/src/gpu/gl/GrGLShaderBuilder.cpp
+++ b/src/gpu/gl/GrGLShaderBuilder.cpp
@@ -289,13 +289,13 @@ void GrGLShaderBuilder::fsAppendTextureLookup(const GrGLShaderBuilder::TextureSa
}
void GrGLShaderBuilder::fsAppendTextureLookupAndModulate(
- const char* modulation,
+ const GrGLSLExpr4& modulation,
const GrGLShaderBuilder::TextureSampler& sampler,
const char* coordName,
GrSLType varyingType) {
SkString lookup;
this->appendTextureLookup(&lookup, sampler, coordName, varyingType);
- fFSCode.append((GrGLSLExpr4(modulation) * GrGLSLExpr4(lookup)).c_str());
+ fFSCode.append((modulation * GrGLSLExpr4(lookup)).c_str());
}
GrGLShaderBuilder::DstReadKey GrGLShaderBuilder::KeyForDstRead(const GrTexture* dstCopy,
@@ -516,45 +516,24 @@ void GrGLShaderBuilder::createAndEmitEffects(GrGLProgramEffectsBuilder* programE
const EffectKey effectKeys[],
int effectCnt,
GrGLSLExpr4* fsInOutColor) {
- bool effectEmitted = false;
-
- GrGLSLExpr4 inColor = *fsInOutColor;
- GrGLSLExpr4 outColor;
-
for (int e = 0; e < effectCnt; ++e) {
SkASSERT(NULL != effectStages[e] && NULL != effectStages[e]->getEffect());
const GrEffectStage& stage = *effectStages[e];
CodeStage::AutoStageRestore csar(&fCodeStage, &stage);
- if (inColor.isZeros()) {
- SkString inColorName;
-
- // Effects have no way to communicate zeros, they treat an empty string as ones.
- this->nameVariable(&inColorName, '\0', "input");
- this->fsCodeAppendf("\tvec4 %s = %s;\n", inColorName.c_str(), inColor.c_str());
- inColor = inColorName;
- }
-
// create var to hold stage result
SkString outColorName;
this->nameVariable(&outColorName, '\0', "output");
this->fsCodeAppendf("\tvec4 %s;\n", outColorName.c_str());
- outColor = outColorName;
-
programEffectsBuilder->emitEffect(stage,
effectKeys[e],
- outColor.c_str(),
- inColor.isOnes() ? NULL : inColor.c_str(),
+ outColorName.c_str(),
+ *fsInOutColor,
fCodeStage.stageIndex());
- inColor = outColor;
- effectEmitted = true;
- }
-
- if (effectEmitted) {
- *fsInOutColor = outColor;
+ *fsInOutColor = GrGLSLExpr4(outColorName);
}
}
@@ -747,7 +726,7 @@ GrGLFullShaderBuilder::GrGLFullShaderBuilder(GrGpuGL* gpu,
const char *vsName, *fsName;
this->addVarying(kVec4f_GrSLType, "Color", &vsName, &fsName);
this->vsCodeAppendf("\t%s = %s;\n", vsName, color_attribute_name());
- this->setInputColor(fsName);
+ this->setInputColor(GrGLSLExpr4(fsName));
}
if (GrGLProgramDesc::kAttribute_ColorInput == header.fCoverageInput) {
@@ -755,7 +734,7 @@ GrGLFullShaderBuilder::GrGLFullShaderBuilder(GrGpuGL* gpu,
const char *vsName, *fsName;
this->addVarying(kVec4f_GrSLType, "Coverage", &vsName, &fsName);
this->vsCodeAppendf("\t%s = %s;\n", vsName, coverage_attribute_name());
- this->setInputCoverage(fsName);
+ this->setInputCoverage(GrGLSLExpr4(fsName));
}
}
« no previous file with comments | « src/gpu/gl/GrGLShaderBuilder.h ('k') | src/gpu/gl/GrGLVertexEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698