diff options
author | liyuqian <liyuqian@google.com> | 2016-11-05 06:34:22 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-11-05 06:34:22 -0700 |
commit | 525e13c1d318b067e679d7ca540fc1436c38385b (patch) | |
tree | ad2bdeea5835ea8fb6c272bcf93f19779a3f07b5 /src/core/SkScan_AAAPath.cpp | |
parent | 2478c73bb88cc45ff9aff983db8371904b39bba9 (diff) |
Fix the sum of alpha = 254 instead of 255 by rounding
This patch is a subpatch from https://codereview.chromium.org/2471133002/
I created this CL mainly for Florin to land before he rebaseline the Chrome
layout tests. (Landing the whole patch of 2471133002 would be nice but most
people already left for the weekend so I'd rather not take the risk to break
the Skia during the weekend.)
BUG=skia:
TBR=reed@google.com, mtklein@google.com, fmalita@chromium.org
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2483523002
Review-Url: https://codereview.chromium.org/2483523002
Diffstat (limited to 'src/core/SkScan_AAAPath.cpp')
-rw-r--r-- | src/core/SkScan_AAAPath.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/core/SkScan_AAAPath.cpp b/src/core/SkScan_AAAPath.cpp index 3325249833..91b6e397ae 100644 --- a/src/core/SkScan_AAAPath.cpp +++ b/src/core/SkScan_AAAPath.cpp @@ -83,9 +83,9 @@ number of scan lines in our algorithm is only about 3 + H while the /////////////////////////////////////////////////////////////////////////////// -inline void addAlpha(SkAlpha& alpha, SkAlpha delta) { - SkASSERT(alpha + (int)delta <= 0xFF); - alpha += delta; +static inline void addAlpha(SkAlpha& alpha, SkAlpha delta) { + SkASSERT(alpha + (int)delta <= 256); + alpha = SkAlphaRuns::CatchOverflow(alpha + (int)delta); } class AdditiveBlitter : public SkBlitter { @@ -481,7 +481,7 @@ static inline SkAlpha partialTriangleToAlpha(SkFixed a, SkFixed b) { } static inline SkAlpha getPartialAlpha(SkAlpha alpha, SkFixed partialHeight) { - return (alpha * partialHeight) >> 16; + return (alpha * partialHeight + SK_FixedHalf) >> 16; } static inline SkAlpha getPartialAlpha(SkAlpha alpha, SkAlpha fullAlpha) { |