From 31bab3934c773c2bd4c1e5e9ba8eb87c1c623b09 Mon Sep 17 00:00:00 2001 From: "tomhudson@google.com" Date: Tue, 3 Jan 2012 20:12:42 +0000 Subject: [PATCH] Fix off-by-one error in assertion; improve coverage_to_exact_alpha() implementation. http://codereview.appspot.com/5504116/ git-svn-id: http://skia.googlecode.com/svn/trunk@2947 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/core/SkBlitter.cpp | 2 +- src/core/SkScan_AntiPath.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/SkBlitter.cpp b/src/core/SkBlitter.cpp index 8bb4b4f20a..ec1606687c 100644 --- a/src/core/SkBlitter.cpp +++ b/src/core/SkBlitter.cpp @@ -487,7 +487,7 @@ void SkRgnClipBlitter::blitAntiRect(int x, int y, int width, int height, const SkIRect& r = iter.rect(); SkASSERT(bounds.contains(r)); SkASSERT(r.fLeft >= x); - SkASSERT(r.fRight < x + width + 2); + SkASSERT(r.fRight <= x + width + 2); SkAlpha effectiveLeftAlpha = (r.fLeft == x) ? leftAlpha : 255; SkAlpha effectiveRightAlpha = (r.fRight == x + width + 2) ? diff --git a/src/core/SkScan_AntiPath.cpp b/src/core/SkScan_AntiPath.cpp index fc7f737e13..97843ef7c3 100644 --- a/src/core/SkScan_AntiPath.cpp +++ b/src/core/SkScan_AntiPath.cpp @@ -157,9 +157,9 @@ static inline int coverage_to_alpha(int aa) { } static inline int coverage_to_exact_alpha(int aa) { - static int map [] = { 0, 64, 128, 192, 255 }; - SkASSERT(SHIFT == 2); - return map[aa]; + int alpha = (256 >> SHIFT) * aa; + // clamp 256->255 + return alpha - (alpha >> 8); } void SuperBlitter::blitH(int x, int y, int width) { -- 2.34.1