diff options
author | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-08-30 19:11:34 +0000 |
---|---|---|
committer | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-08-30 19:11:34 +0000 |
commit | 868a8e7fc83e9ac6ee1418e75b84a0595605626c (patch) | |
tree | 6099dee09e40beed726e2f6d300485935b73cbb2 /src/effects/gradients | |
parent | 7426743837051f43dbc1209775b391b917c69c54 (diff) |
Recommit r5350 with fix for image failures (which affected GLs that don't support ARB_texture_swizzle).
git-svn-id: http://skia.googlecode.com/svn/trunk@5353 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/effects/gradients')
-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 |
7 files changed, 22 insertions, 14 deletions
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, |