From 8f073382bb6a9b3998a74e6b58654476b77b4c86 Mon Sep 17 00:00:00 2001 From: "reed@android.com" Date: Thu, 11 Mar 2010 21:56:16 +0000 Subject: [PATCH] fix off-by-1 in alpha in colorshader setup don't promise HasSpan16 if we're supposed to dither git-svn-id: http://skia.googlecode.com/svn/trunk@526 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/core/SkShader.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp index 5290f2ff0a..f33036debc 100644 --- a/src/core/SkShader.cpp +++ b/src/core/SkShader.cpp @@ -256,14 +256,16 @@ bool SkColorShader::setContext(const SkBitmap& device, const SkPaint& paint, fColor16 = SkPack888ToRGB16(r, g, b); if (a != 255) { - a = SkAlpha255To256(a); - r = SkAlphaMul(r, a); - g = SkAlphaMul(g, a); - b = SkAlphaMul(b, a); + r = SkMulDiv255Round(r, a); + g = SkMulDiv255Round(g, a); + b = SkMulDiv255Round(b, a); } fPMColor = SkPackARGB32(a, r, g, b); - fFlags = kHasSpan16_Flag | kConstInY32_Flag; + fFlags = kConstInY32_Flag; + if (paint.isDither() == false) { + fFlags |= kHasSpan16_Flag; + } if (SkGetPackedA32(fPMColor) == 255) { fFlags |= kOpaqueAlpha_Flag; } -- 2.34.1