round the alphamul so we don't overflow a byte
git-svn-id: http://skia.googlecode.com/svn/trunk@1071 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkScan_Antihair.cpp b/src/core/SkScan_Antihair.cpp
index ebd860b..157c748 100644
--- a/src/core/SkScan_Antihair.cpp
+++ b/src/core/SkScan_Antihair.cpp
@@ -670,6 +670,8 @@
///////////////////////////////////////////////////////////////////////////////
+#define SkAlphaMulRound(a, b) SkMulDiv255Round(a, b)
+
// calls blitRect() if the rectangle is non-empty
static void fillcheckrect(int L, int T, int R, int B, SkBlitter* blitter) {
if (L < R && T < B) {
@@ -695,7 +697,9 @@
// 1 - (1 - a)*(1 - b)
static inline U8CPU InvAlphaMul(U8CPU a, U8CPU b) {
- return SkToU8(a + b - SkAlphaMul(a, b));
+ // need precise rounding (not just SkAlphaMul) so that values like
+ // a=228, b=252 don't overflow the result
+ return SkToU8(a + b - SkAlphaMulRound(a, b));
}
static void inner_scanline(FDot8 L, int top, FDot8 R, U8CPU alpha,