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-03 14:34:46 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-03 14:34:46 +0000
commitd472620458e2383e6dd949f4e1aaf61160717ffe (patch)
tree2822ac4f1c55d6eaa9ed4ac6dc2b7014de5410ff /src/gpu/effects
parentdea8e252e1259f5bdd15e16a21646402058b939d (diff)
Registry-based unit test for custom effects
Review URL: http://codereview.appspot.com/6447085/ git-svn-id: http://skia.googlecode.com/svn/trunk@4946 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/effects')
-rw-r--r--src/gpu/effects/GrColorTableEffect.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/gpu/effects/GrColorTableEffect.cpp b/src/gpu/effects/GrColorTableEffect.cpp
index f1ce664826..94eb8fdd74 100644
--- a/src/gpu/effects/GrColorTableEffect.cpp
+++ b/src/gpu/effects/GrColorTableEffect.cpp
@@ -52,11 +52,20 @@ void GrGLColorTableEffect::emitFS(GrGLShaderBuilder* builder,
static const float kColorScaleFactor = 255.0f / 256.0f;
static const float kColorOffsetFactor = 1.0f / 512.0f;
SkString* code = &builder->fFSCode;
- code->appendf("\t\tvec4 coord = vec4(%s.rgb / %s.a, %s.a);\n",
- inputColor, inputColor, inputColor);
- code->appendf("\t\tcoord = coord * %f + vec4(%f, %f, %f, %f);\n",
- kColorScaleFactor,
- kColorOffsetFactor, kColorOffsetFactor, kColorOffsetFactor, kColorOffsetFactor);
+ if (NULL == inputColor) {
+ // the input color is solid white (all ones).
+ static const float kMaxValue = kColorScaleFactor + kColorOffsetFactor;
+ code->appendf("\t\tvec4 coord = vec4(%f, %f, %f, %f);\n",
+ kMaxValue, kMaxValue, kMaxValue, kMaxValue);
+
+ } else {
+ code->appendf("\t\tvec4 coord = vec4(%s.rgb / %s.a, %s.a);\n",
+ inputColor, inputColor, inputColor);
+ code->appendf("\t\tcoord = coord * %f + vec4(%f, %f, %f, %f);\n",
+ kColorScaleFactor,
+ kColorOffsetFactor, kColorOffsetFactor,
+ kColorOffsetFactor, kColorOffsetFactor);
+ }
const GrTextureAccess& access = *fCustomStage.textureAccess(0);
code->appendf("\t\t%s.a = ", outputColor);