aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/effects
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-30 17:54:14 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-30 17:54:14 +0000
commitb41b2bc29c0411052f9f45855a98be370d586438 (patch)
treeeaa731fed5fb2f3ae8e7bb703d23eb51f6e7449f /src/gpu/effects
parent1ea01bf4cedc3067e980367e3f189a6d8642d6ce (diff)
Remove fModulate from GrGLShaderBuilder
Review URL: https://codereview.appspot.com/6495051/ git-svn-id: http://skia.googlecode.com/svn/trunk@5350 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/effects')
-rw-r--r--src/gpu/effects/GrConfigConversionEffect.cpp24
-rw-r--r--src/gpu/effects/GrConvolutionEffect.cpp8
-rw-r--r--src/gpu/effects/GrSingleTextureEffect.cpp4
-rw-r--r--src/gpu/effects/GrTextureDomainEffect.cpp4
4 files changed, 21 insertions, 19 deletions
diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp
index fbf5a4090a..318c03e653 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -23,37 +23,39 @@ public:
const char* outputColor,
const char* inputColor,
const char* samplerName) SK_OVERRIDE {
- builder->fFSCode.append("\tvec4 tempColor;\n");
- builder->emitTextureLookupAndModulate("tempColor", samplerName);
+ builder->fFSCode.appendf("\t\t%s = ", outputColor);
+ builder->appendTextureLookup(&builder->fFSCode, samplerName);
+ builder->fFSCode.appendf("%s;\n", builder->fSwizzle.c_str());
if (GrConfigConversionEffect::kNone_PMConversion == fPMConversion) {
GrAssert(fSwapRedAndBlue);
- builder->fFSCode.appendf("\t%s = tempColor.bgra;\n", outputColor);
+ builder->fFSCode.appendf("\t%s = %s.bgra;\n", outputColor, outputColor);
} else {
const char* swiz = fSwapRedAndBlue ? "bgr" : "rgb";
switch (fPMConversion) {
case GrConfigConversionEffect::kMulByAlpha_RoundUp_PMConversion:
builder->fFSCode.appendf(
- "\t%s = vec4(ceil(tempColor.%s*tempColor.a*255.0)/255.0, tempColor.a);\n",
- outputColor, swiz);
+ "\t\t%s = vec4(ceil(%s.%s * %s.a * 255.0) / 255.0, %s.a);\n",
+ outputColor, outputColor, swiz, outputColor, outputColor);
break;
case GrConfigConversionEffect::kMulByAlpha_RoundDown_PMConversion:
builder->fFSCode.appendf(
- "\t%s = vec4(floor(tempColor.%s*tempColor.a*255.0)/255.0, tempColor.a);\n",
- outputColor, swiz);
+ "\t\t%s = vec4(floor(%s.%s * %s.a * 255.0) / 255.0, %s.a);\n",
+ outputColor, outputColor, swiz, outputColor, outputColor);
break;
case GrConfigConversionEffect::kDivByAlpha_RoundUp_PMConversion:
- builder->fFSCode.appendf("\t%s = tempColor.a <= 0.0 ? vec4(0,0,0,0) : vec4(ceil(tempColor.%s / tempColor.a * 255.0)/255.0, tempColor.a);\n",
- outputColor, swiz);
+ builder->fFSCode.appendf("\t\t%s = %s.a <= 0.0 ? vec4(0,0,0,0) : vec4(ceil(%s.%s / %s.a * 255.0) / 255.0, %s.a);\n",
+ outputColor, outputColor, outputColor, swiz, outputColor, outputColor);
break;
case GrConfigConversionEffect::kDivByAlpha_RoundDown_PMConversion:
- builder->fFSCode.appendf("\t%s = tempColor.a <= 0.0 ? vec4(0,0,0,0) : vec4(floor(tempColor.%s / tempColor.a * 255.0)/255.0, tempColor.a);\n",
- outputColor, swiz);
+ builder->fFSCode.appendf("\t\t%s = %s.a <= 0.0 ? vec4(0,0,0,0) : vec4(floor(%s.%s / %s.a * 255.0) / 255.0, %s.a);\n",
+ outputColor, outputColor, outputColor, swiz, outputColor, outputColor);
break;
default:
GrCrash("Unknown conversion op.");
break;
}
}
+ GrGLSLMulVarBy4f(&builder->fFSCode, 2, outputColor, inputColor);
}
static inline StageKey GenKey(const GrCustomStage& s, const GrGLCaps&) {
diff --git a/src/gpu/effects/GrConvolutionEffect.cpp b/src/gpu/effects/GrConvolutionEffect.cpp
index 162a0cc4c8..635064fef7 100644
--- a/src/gpu/effects/GrConvolutionEffect.cpp
+++ b/src/gpu/effects/GrConvolutionEffect.cpp
@@ -84,15 +84,11 @@ void GrGLConvolutionEffect::emitFS(GrGLShaderBuilder* builder,
index.appendS32(i);
kernel.appendArrayAccess(index.c_str(), &kernelIndex);
code->appendf("\t\t%s += ", outputColor);
- builder->emitTextureLookup(samplerName, "coord");
+ builder->appendTextureLookup(&builder->fFSCode, samplerName, "coord");
code->appendf(" * %s;\n", kernelIndex.c_str());
code->appendf("\t\tcoord += %s;\n", imgInc);
}
-
- if (builder->fModulate.size()) {
- code->appendf("\t\t%s = %s%s;\n", outputColor, outputColor,
- builder->fModulate.c_str());
- }
+ GrGLSLMulVarBy4f(&builder->fFSCode, 2, outputColor, inputColor);
}
void GrGLConvolutionEffect::setData(const GrGLUniformManager& uman,
diff --git a/src/gpu/effects/GrSingleTextureEffect.cpp b/src/gpu/effects/GrSingleTextureEffect.cpp
index 42a8bf9501..dc91a68c20 100644
--- a/src/gpu/effects/GrSingleTextureEffect.cpp
+++ b/src/gpu/effects/GrSingleTextureEffect.cpp
@@ -23,7 +23,9 @@ public:
const char* outputColor,
const char* inputColor,
const char* samplerName) SK_OVERRIDE {
- builder->emitTextureLookupAndModulate(outputColor, samplerName);
+ builder->fFSCode.appendf("\t%s = ", outputColor);
+ builder->appendTextureLookupAndModulate(&builder->fFSCode, inputColor, samplerName);
+ builder->fFSCode.append(";\n");
}
static inline StageKey GenKey(const GrCustomStage&, const GrGLCaps&) { return 0; }
diff --git a/src/gpu/effects/GrTextureDomainEffect.cpp b/src/gpu/effects/GrTextureDomainEffect.cpp
index a67dd49afd..f5306c7b01 100644
--- a/src/gpu/effects/GrTextureDomainEffect.cpp
+++ b/src/gpu/effects/GrTextureDomainEffect.cpp
@@ -55,7 +55,9 @@ void GrGLTextureDomainEffect::emitFS(GrGLShaderBuilder* builder,
builder->getUniformCStr(fNameUni),
builder->getUniformCStr(fNameUni));
- builder->emitTextureLookupAndModulate(outputColor, samplerName, "clampCoord");
+ builder->fFSCode.appendf("\t%s = ", outputColor);
+ builder->appendTextureLookupAndModulate(&builder->fFSCode, inputColor, samplerName, "clampCoord");
+ builder->fFSCode.append(";\n");
}
void GrGLTextureDomainEffect::setData(const GrGLUniformManager& uman,