From: reed@android.com Date: Thu, 11 Mar 2010 21:56:16 +0000 (+0000) Subject: fix off-by-1 in alpha in colorshader setup X-Git-Tag: submit/tizen/20180928.044319~19231 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8f073382bb6a9b3998a74e6b58654476b77b4c86;p=platform%2Fupstream%2FlibSkiaSharp.git 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 --- 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; }