diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-05-05 21:35:09 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-05-05 21:35:09 +0000 |
commit | 06a32062620daee7a93742f553829a8d4f93f720 (patch) | |
tree | 8da77dd974876640da2ecb442f9080a7889bb86a /include/core/SkColorPriv.h | |
parent | 60da8f39522a7523063f4a0f58d05285c695b562 (diff) |
fix TriColorShader to respect the paint's alpha
results can be seen in new gm: vertices_80
BUG=skia:
R=scroggo@google.com
Author: reed@google.com
Review URL: https://codereview.chromium.org/270023002
git-svn-id: http://skia.googlecode.com/svn/trunk@14581 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core/SkColorPriv.h')
-rw-r--r-- | include/core/SkColorPriv.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/core/SkColorPriv.h b/include/core/SkColorPriv.h index 9591f22725..d5571dfea9 100644 --- a/include/core/SkColorPriv.h +++ b/include/core/SkColorPriv.h @@ -181,6 +181,15 @@ static inline unsigned SkAlpha255To256(U8CPU alpha) { return alpha + 1; } +/** + * Turn a 0..255 value into a 0..256 value, rounding up if the value is >= 0x80. + * This is slightly more accurate than SkAlpha255To256. + */ +static inline unsigned Sk255To256(U8CPU value) { + SkASSERT(SkToU8(value) == value); + return value + (value >> 7); +} + /** Multiplify value by 0..256, and shift the result down 8 (i.e. return (value * alpha256) >> 8) */ |