summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-05 21:35:09 +0000
committercommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-05 21:35:09 +0000
commitabc68a8eeb478a8123d4d283bab5088d0bb949f9 (patch)
tree6cf24983bbc94a08b0db9ff2f7353be254e36b1d
parenta8d28efa76c581b6c6a94f889f38e050a8d21679 (diff)
downloadinclude-abc68a8eeb478a8123d4d283bab5088d0bb949f9.tar.gz
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/include@14581 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--core/SkColorPriv.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/core/SkColorPriv.h b/core/SkColorPriv.h
index 9591f22..d5571df 100644
--- a/core/SkColorPriv.h
+++ b/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)
*/