Index: include/core/SkColorPriv.h |
diff --git a/include/core/SkColorPriv.h b/include/core/SkColorPriv.h |
index 9591f22725a81289059a04bb82bddc79c849cc25..d5571dfea970bdc627595e532f780c1d96d31008 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) |
*/ |