diff options
author | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-08-30 17:54:14 +0000 |
---|---|---|
committer | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-08-30 17:54:14 +0000 |
commit | b41b2bc29c0411052f9f45855a98be370d586438 (patch) | |
tree | eaa731fed5fb2f3ae8e7bb703d23eb51f6e7449f /src/effects | |
parent | 1ea01bf4cedc3067e980367e3f189a6d8642d6ce (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/effects')
-rw-r--r-- | src/effects/SkBlendImageFilter.cpp | 4 | ||||
-rw-r--r-- | src/effects/SkLightingImageFilter.cpp | 7 | ||||
-rw-r--r-- | src/effects/SkMagnifierImageFilter.cpp | 5 | ||||
-rw-r--r-- | src/effects/SkMorphologyImageFilter.cpp | 10 | ||||
-rw-r--r-- | src/effects/gradients/SkGradientShader.cpp | 15 | ||||
-rw-r--r-- | src/effects/gradients/SkGradientShaderPriv.h | 7 | ||||
-rw-r--r-- | src/effects/gradients/SkLinearGradient.cpp | 2 | ||||
-rw-r--r-- | src/effects/gradients/SkRadialGradient.cpp | 2 | ||||
-rw-r--r-- | src/effects/gradients/SkSweepGradient.cpp | 2 | ||||
-rw-r--r-- | src/effects/gradients/SkTwoPointConicalGradient.cpp | 6 | ||||
-rw-r--r-- | src/effects/gradients/SkTwoPointRadialGradient.cpp | 2 |
11 files changed, 36 insertions, 26 deletions
diff --git a/src/effects/SkBlendImageFilter.cpp b/src/effects/SkBlendImageFilter.cpp index f4ef9def7f..825767783d 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->emitTextureLookup(samplerName); - code->appendf(";\n"); + builder->appendTextureLookup(code, samplerName); + code->append(";\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 408e7021ff..8eb28bb3c5 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->emitTextureLookup(samplerName, texCoords.c_str()); + builder->appendTextureLookup(code, samplerName, texCoords.c_str()); code->appendf(".a;\n"); } } @@ -1168,11 +1168,12 @@ void GrGLLightingEffect::emitFS(GrGLShaderBuilder* builder, SkString arg; arg.appendf("%s * m[4]", surfScale); fLight->emitSurfaceToLight(builder, code, arg.c_str()); - code->appendf(";\n"); + code->append(";\n"); code->appendf("\t\t%s = %s(%s(m, %s), surfaceToLight, ", outputColor, lightFunc.c_str(), interiorNormalName.c_str(), surfScale); fLight->emitLightColor(builder, "surfaceToLight"); - code->appendf(")%s;\n", builder->fModulate.c_str()); + code->append(");\n"); + GrGLSLMulVarBy4f(code, 2, outputColor, inputColor); } GrGLProgramStage::StageKey GrGLLightingEffect::GenKey(const GrCustomStage& s, diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp index 3145321816..6b8324a7ab 100644 --- a/src/effects/SkMagnifierImageFilter.cpp +++ b/src/effects/SkMagnifierImageFilter.cpp @@ -159,10 +159,11 @@ void GrGLMagnifierEffect::emitFS(GrGLShaderBuilder* state, code->appendf("\t\tvec2 mix_coord = mix(coord, zoom_coord, weight);\n"); code->appendf("\t\tvec4 output_color = "); - state->emitTextureLookup(samplerName, "mix_coord"); - code->appendf(";\n"); + state->appendTextureLookup(code, samplerName, "mix_coord"); + code->append(";\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 eb121a72da..04dc2270c6 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\tvec4 value = vec4(1, 1, 1, 1);\n"); + code->appendf("\t\t%s = vec4(1, 1, 1, 1);\n", outputColor); func = "min"; break; case GrMorphologyEffect::kDilate_MorphologyType: - code->appendf("\t\tvec4 value = vec4(0, 0, 0, 0);\n"); + code->appendf("\t\t%s = vec4(0, 0, 0, 0);\n", outputColor); 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\tvalue = %s(value, ", func); - builder->emitTextureLookup(samplerName, "coord"); + code->appendf("\t\t\t%s = %s(%s, ", outputColor, func, outputColor); + builder->appendTextureLookup(&builder->fFSCode, samplerName, "coord"); code->appendf(");\n"); code->appendf("\t\t\tcoord += %s;\n", imgInc); code->appendf("\t\t}\n"); - code->appendf("\t\t%s = value%s;\n", outputColor, builder->fModulate.c_str()); + GrGLSLMulVarBy4f(code, 2, outputColor, inputColor); } GrGLProgramStage::StageKey GrGLMorphologyEffect::GenKey(const GrCustomStage& s, diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp index 891b1cdf9b..3d989b7611 100644 --- a/src/effects/gradients/SkGradientShader.cpp +++ b/src/effects/gradients/SkGradientShader.cpp @@ -699,14 +699,19 @@ void GrGLGradientStage::setData(const GrGLUniformManager& uman, } void GrGLGradientStage::emitColorLookup(GrGLShaderBuilder* builder, - const char* tName, + const char* gradientTValue, const char* outputColor, + const char* inputColor, const char* samplerName) { - builder->fFSCode.appendf("\tvec2 coord = vec2(%s, %s);\n", - tName, - builder->getUniformVariable(fFSYUni).c_str()); - builder->emitTextureLookupAndModulate(outputColor, samplerName, "coord"); + 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"); } ///////////////////////////////////////////////////////////////////// diff --git a/src/effects/gradients/SkGradientShaderPriv.h b/src/effects/gradients/SkGradientShaderPriv.h index 37959678a2..2b584f30b6 100644 --- a/src/effects/gradients/SkGradientShaderPriv.h +++ b/src/effects/gradients/SkGradientShaderPriv.h @@ -287,8 +287,11 @@ 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* t, - const char* outputColor, const char* samplerName); + void emitColorLookup(GrGLShaderBuilder* builder, + const char* gradientTValue, + const char* outputColor, + const char* inputColor, + const char* samplerName); private: diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp index 78d2f24a04..6415927c72 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, samplerName); + this->emitColorLookup(builder, t.c_str(), outputColor, inputColor, samplerName); } ///////////////////////////////////////////////////////////////////// diff --git a/src/effects/gradients/SkRadialGradient.cpp b/src/effects/gradients/SkRadialGradient.cpp index 317ab68b47..98433e28ef 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, samplerName); + this->emitColorLookup(builder, t.c_str(), outputColor, inputColor, samplerName); } ///////////////////////////////////////////////////////////////////// diff --git a/src/effects/gradients/SkSweepGradient.cpp b/src/effects/gradients/SkSweepGradient.cpp index 15547de6d4..22b211871c 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, samplerName); + this->emitColorLookup(builder, t.c_str(), outputColor, inputColor, samplerName); } ///////////////////////////////////////////////////////////////////// diff --git a/src/effects/gradients/SkTwoPointConicalGradient.cpp b/src/effects/gradients/SkTwoPointConicalGradient.cpp index 8b32ab6bb7..c84989b67f 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, samplerName); + this->emitColorLookup(builder, tName.c_str(), outputColor, inputColor, 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, samplerName); + this->emitColorLookup(builder, tName.c_str(), outputColor, inputColor, 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, samplerName); + this->emitColorLookup(builder, tName.c_str(), outputColor, inputColor, samplerName); code->appendf("\t}\n"); } } diff --git a/src/effects/gradients/SkTwoPointRadialGradient.cpp b/src/effects/gradients/SkTwoPointRadialGradient.cpp index 693dc32b0a..2192707cc4 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, samplerName); + this->emitColorLookup(builder, t.c_str(), outputColor, inputColor, samplerName); } void GrGLRadial2Gradient::setData(const GrGLUniformManager& uman, |