aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/effects
diff options
context:
space:
mode:
Diffstat (limited to 'src/effects')
-rw-r--r--src/effects/SkBlendImageFilter.cpp4
-rw-r--r--src/effects/SkLightingImageFilter.cpp7
-rw-r--r--src/effects/SkMagnifierImageFilter.cpp5
-rw-r--r--src/effects/SkMorphologyImageFilter.cpp10
-rw-r--r--src/effects/gradients/SkGradientShader.cpp15
-rw-r--r--src/effects/gradients/SkGradientShaderPriv.h7
-rw-r--r--src/effects/gradients/SkLinearGradient.cpp2
-rw-r--r--src/effects/gradients/SkRadialGradient.cpp2
-rw-r--r--src/effects/gradients/SkSweepGradient.cpp2
-rw-r--r--src/effects/gradients/SkTwoPointConicalGradient.cpp6
-rw-r--r--src/effects/gradients/SkTwoPointRadialGradient.cpp2
11 files changed, 26 insertions, 36 deletions
diff --git a/src/effects/SkBlendImageFilter.cpp b/src/effects/SkBlendImageFilter.cpp
index 825767783d..f4ef9def7f 100644
--- a/src/effects/SkBlendImageFilter.cpp
+++ b/src/effects/SkBlendImageFilter.cpp
@@ -263,8 +263,8 @@ void GrGLBlendEffect::emitFS(GrGLShaderBuilder* builder,
const char* bgColor = inputColor;
const char* fgColor = "fgColor";
code->appendf("\t\tvec4 %s = ", fgColor);
- builder->appendTextureLookup(code, samplerName);
- code->append(";\n");
+ builder->emitTextureLookup(samplerName);
+ code->appendf(";\n");
code->appendf("\t\t%s.a = 1.0 - (1.0 - %s.a) * (1.0 - %s.b);\n", outputColor, bgColor, fgColor);
switch (fMode) {
case SkBlendImageFilter::kNormal_Mode:
diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp
index 8eb28bb3c5..408e7021ff 100644
--- a/src/effects/SkLightingImageFilter.cpp
+++ b/src/effects/SkLightingImageFilter.cpp
@@ -1160,7 +1160,7 @@ void GrGLLightingEffect::emitFS(GrGLShaderBuilder* builder,
SkString texCoords;
texCoords.appendf("coord + vec2(%d, %d) * %s", dx, dy, imgInc);
code->appendf("\t\tm[%d] = ", index++);
- builder->appendTextureLookup(code, samplerName, texCoords.c_str());
+ builder->emitTextureLookup(samplerName, texCoords.c_str());
code->appendf(".a;\n");
}
}
@@ -1168,12 +1168,11 @@ void GrGLLightingEffect::emitFS(GrGLShaderBuilder* builder,
SkString arg;
arg.appendf("%s * m[4]", surfScale);
fLight->emitSurfaceToLight(builder, code, arg.c_str());
- code->append(";\n");
+ code->appendf(";\n");
code->appendf("\t\t%s = %s(%s(m, %s), surfaceToLight, ",
outputColor, lightFunc.c_str(), interiorNormalName.c_str(), surfScale);
fLight->emitLightColor(builder, "surfaceToLight");
- code->append(");\n");
- GrGLSLMulVarBy4f(code, 2, outputColor, inputColor);
+ code->appendf(")%s;\n", builder->fModulate.c_str());
}
GrGLProgramStage::StageKey GrGLLightingEffect::GenKey(const GrCustomStage& s,
diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp
index 6b8324a7ab..3145321816 100644
--- a/src/effects/SkMagnifierImageFilter.cpp
+++ b/src/effects/SkMagnifierImageFilter.cpp
@@ -159,11 +159,10 @@ void GrGLMagnifierEffect::emitFS(GrGLShaderBuilder* state,
code->appendf("\t\tvec2 mix_coord = mix(coord, zoom_coord, weight);\n");
code->appendf("\t\tvec4 output_color = ");
- state->appendTextureLookup(code, samplerName, "mix_coord");
- code->append(";\n");
+ state->emitTextureLookup(samplerName, "mix_coord");
+ code->appendf(";\n");
code->appendf("\t\t%s = output_color;", outputColor);
- GrGLSLMulVarBy4f(code, 2, outputColor, inputColor);
}
void GrGLMagnifierEffect::setData(const GrGLUniformManager& uman,
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index 04dc2270c6..eb121a72da 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -319,11 +319,11 @@ void GrGLMorphologyEffect::emitFS(GrGLShaderBuilder* builder,
const char* func;
switch (fType) {
case GrMorphologyEffect::kErode_MorphologyType:
- code->appendf("\t\t%s = vec4(1, 1, 1, 1);\n", outputColor);
+ code->appendf("\t\tvec4 value = vec4(1, 1, 1, 1);\n");
func = "min";
break;
case GrMorphologyEffect::kDilate_MorphologyType:
- code->appendf("\t\t%s = vec4(0, 0, 0, 0);\n", outputColor);
+ code->appendf("\t\tvec4 value = vec4(0, 0, 0, 0);\n");
func = "max";
break;
default:
@@ -336,12 +336,12 @@ void GrGLMorphologyEffect::emitFS(GrGLShaderBuilder* builder,
code->appendf("\t\tvec2 coord = %s - %d.0 * %s;\n",
builder->defaultTexCoordsName(), fRadius, imgInc);
code->appendf("\t\tfor (int i = 0; i < %d; i++) {\n", this->width());
- code->appendf("\t\t\t%s = %s(%s, ", outputColor, func, outputColor);
- builder->appendTextureLookup(&builder->fFSCode, samplerName, "coord");
+ code->appendf("\t\t\tvalue = %s(value, ", func);
+ builder->emitTextureLookup(samplerName, "coord");
code->appendf(");\n");
code->appendf("\t\t\tcoord += %s;\n", imgInc);
code->appendf("\t\t}\n");
- GrGLSLMulVarBy4f(code, 2, outputColor, inputColor);
+ code->appendf("\t\t%s = value%s;\n", outputColor, builder->fModulate.c_str());
}
GrGLProgramStage::StageKey GrGLMorphologyEffect::GenKey(const GrCustomStage& s,
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp
index 3d989b7611..891b1cdf9b 100644
--- a/src/effects/gradients/SkGradientShader.cpp
+++ b/src/effects/gradients/SkGradientShader.cpp
@@ -699,19 +699,14 @@ void GrGLGradientStage::setData(const GrGLUniformManager& uman,
}
void GrGLGradientStage::emitColorLookup(GrGLShaderBuilder* builder,
- const char* gradientTValue,
+ const char* tName,
const char* outputColor,
- const char* inputColor,
const char* samplerName) {
- SkString* code = &builder->fFSCode;
- code->appendf("\tvec2 coord = vec2(%s, %s);\n",
- gradientTValue,
- builder->getUniformVariable(fFSYUni).c_str());
- GrGLSLMulVarBy4f(code, 1, outputColor, inputColor);
- code->appendf("\t%s = ", outputColor);
- builder->appendTextureLookupAndModulate(code, inputColor, samplerName, "coord");
- code->append(";\n");
+ builder->fFSCode.appendf("\tvec2 coord = vec2(%s, %s);\n",
+ tName,
+ builder->getUniformVariable(fFSYUni).c_str());
+ builder->emitTextureLookupAndModulate(outputColor, samplerName, "coord");
}
/////////////////////////////////////////////////////////////////////
diff --git a/src/effects/gradients/SkGradientShaderPriv.h b/src/effects/gradients/SkGradientShaderPriv.h
index 2b584f30b6..37959678a2 100644
--- a/src/effects/gradients/SkGradientShaderPriv.h
+++ b/src/effects/gradients/SkGradientShaderPriv.h
@@ -287,11 +287,8 @@ public:
// emit code that gets a fragment's color from an expression for t; for now
// this always uses the texture, but for simpler cases we'll be able to lerp
- void emitColorLookup(GrGLShaderBuilder* builder,
- const char* gradientTValue,
- const char* outputColor,
- const char* inputColor,
- const char* samplerName);
+ void emitColorLookup(GrGLShaderBuilder* builder, const char* t,
+ const char* outputColor, const char* samplerName);
private:
diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp
index 6415927c72..78d2f24a04 100644
--- a/src/effects/gradients/SkLinearGradient.cpp
+++ b/src/effects/gradients/SkLinearGradient.cpp
@@ -553,7 +553,7 @@ void GrGLLinearGradient::emitFS(GrGLShaderBuilder* builder,
const char* samplerName) {
SkString t;
t.printf("%s.x", builder->defaultTexCoordsName());
- this->emitColorLookup(builder, t.c_str(), outputColor, inputColor, samplerName);
+ this->emitColorLookup(builder, t.c_str(), outputColor, samplerName);
}
/////////////////////////////////////////////////////////////////////
diff --git a/src/effects/gradients/SkRadialGradient.cpp b/src/effects/gradients/SkRadialGradient.cpp
index 98433e28ef..317ab68b47 100644
--- a/src/effects/gradients/SkRadialGradient.cpp
+++ b/src/effects/gradients/SkRadialGradient.cpp
@@ -553,7 +553,7 @@ void GrGLRadialGradient::emitFS(GrGLShaderBuilder* builder,
const char* samplerName) {
SkString t;
t.printf("length(%s.xy)", builder->defaultTexCoordsName());
- this->emitColorLookup(builder, t.c_str(), outputColor, inputColor, samplerName);
+ this->emitColorLookup(builder, t.c_str(), outputColor, samplerName);
}
/////////////////////////////////////////////////////////////////////
diff --git a/src/effects/gradients/SkSweepGradient.cpp b/src/effects/gradients/SkSweepGradient.cpp
index 22b211871c..15547de6d4 100644
--- a/src/effects/gradients/SkSweepGradient.cpp
+++ b/src/effects/gradients/SkSweepGradient.cpp
@@ -459,7 +459,7 @@ void GrGLSweepGradient::emitFS(GrGLShaderBuilder* builder,
SkString t;
t.printf("atan(- %s.y, - %s.x) * 0.1591549430918 + 0.5",
builder->defaultTexCoordsName(), builder->defaultTexCoordsName());
- this->emitColorLookup(builder, t.c_str(), outputColor, inputColor, samplerName);
+ this->emitColorLookup(builder, t.c_str(), outputColor, samplerName);
}
/////////////////////////////////////////////////////////////////////
diff --git a/src/effects/gradients/SkTwoPointConicalGradient.cpp b/src/effects/gradients/SkTwoPointConicalGradient.cpp
index c84989b67f..8b32ab6bb7 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient.cpp
+++ b/src/effects/gradients/SkTwoPointConicalGradient.cpp
@@ -593,7 +593,7 @@ void GrGLConical2Gradient::emitFS(GrGLShaderBuilder* builder,
p5.c_str(), p3.c_str());
code->appendf("\t\t");
- this->emitColorLookup(builder, tName.c_str(), outputColor, inputColor, samplerName);
+ this->emitColorLookup(builder, tName.c_str(), outputColor, samplerName);
// otherwise, if r(t) for the larger root was <= 0, try the other root
code->appendf("\t\t} else {\n");
@@ -605,7 +605,7 @@ void GrGLConical2Gradient::emitFS(GrGLShaderBuilder* builder,
tName.c_str(), p5.c_str(), p3.c_str());
code->appendf("\t\t\t");
- this->emitColorLookup(builder, tName.c_str(), outputColor, inputColor, samplerName);
+ this->emitColorLookup(builder, tName.c_str(), outputColor, samplerName);
// end if (r(t) > 0) for smaller root
code->appendf("\t\t\t}\n");
@@ -623,7 +623,7 @@ void GrGLConical2Gradient::emitFS(GrGLShaderBuilder* builder,
code->appendf("\tif (%s * %s + %s > 0.0) {\n", tName.c_str(),
p5.c_str(), p3.c_str());
code->appendf("\t");
- this->emitColorLookup(builder, tName.c_str(), outputColor, inputColor, samplerName);
+ this->emitColorLookup(builder, tName.c_str(), outputColor, samplerName);
code->appendf("\t}\n");
}
}
diff --git a/src/effects/gradients/SkTwoPointRadialGradient.cpp b/src/effects/gradients/SkTwoPointRadialGradient.cpp
index 2192707cc4..693dc32b0a 100644
--- a/src/effects/gradients/SkTwoPointRadialGradient.cpp
+++ b/src/effects/gradients/SkTwoPointRadialGradient.cpp
@@ -601,7 +601,7 @@ void GrGLRadial2Gradient::emitFS(GrGLShaderBuilder* builder,
t.printf("-%s / %s", cName.c_str(), bVar.c_str());
}
- this->emitColorLookup(builder, t.c_str(), outputColor, inputColor, samplerName);
+ this->emitColorLookup(builder, t.c_str(), outputColor, samplerName);
}
void GrGLRadial2Gradient::setData(const GrGLUniformManager& uman,