diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-04-07 13:31:48 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-04-07 13:31:48 +0000 |
commit | 3a968750b29b3bb15452a4d4ed040c382727a297 (patch) | |
tree | 43cccfc33b5951fbb84eb142ca4268c1b9d28812 /src/core/SkScan_Antihair.cpp | |
parent | a076e9be17654a60310e72c4f70fcd5337f56dbf (diff) |
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
Diffstat (limited to 'src/core/SkScan_Antihair.cpp')
-rw-r--r-- | src/core/SkScan_Antihair.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/core/SkScan_Antihair.cpp b/src/core/SkScan_Antihair.cpp index ebd860be7c..157c748a46 100644 --- a/src/core/SkScan_Antihair.cpp +++ b/src/core/SkScan_Antihair.cpp @@ -670,6 +670,8 @@ void SkScan::AntiFillRect(const SkRect& origR, const SkRegion* clip, /////////////////////////////////////////////////////////////////////////////// +#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 @@ static inline int FDot8Ceil(FDot8 x) { // 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, |