From d472620458e2383e6dd949f4e1aaf61160717ffe Mon Sep 17 00:00:00 2001 From: "bsalomon@google.com" Date: Fri, 3 Aug 2012 14:34:46 +0000 Subject: 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 --- src/gpu/effects/GrColorTableEffect.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/gpu/effects') 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); -- cgit v1.2.3