diff options
author | 2012-08-28 16:02:42 +0000 | |
---|---|---|
committer | 2012-08-28 16:02:42 +0000 | |
commit | 1bfe01d06b896eca94c80d9af9a6bb30216b5e42 (patch) | |
tree | 0e256137f26992e498744aa58a10f6d7a99a3198 /include/core/SkColorPriv.h | |
parent | 9c72827f90759b37e11da6df6126bc484b5b5d91 (diff) |
When creating gray from lcd, use luminance instead of coverage.
https://codereview.appspot.com/6496048/
git-svn-id: http://skia.googlecode.com/svn/trunk@5318 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core/SkColorPriv.h')
-rw-r--r-- | include/core/SkColorPriv.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/core/SkColorPriv.h b/include/core/SkColorPriv.h index a2e1bc5df6..21743bdb68 100644 --- a/include/core/SkColorPriv.h +++ b/include/core/SkColorPriv.h @@ -32,6 +32,16 @@ #define SK_LUM_COEFF_B SK_ITU_BT709_LUM_COEFF_B ///@} +/** Computes the luminance from the given r, g, and b in accordance with + SK_LUM_COEFF_X. For correct results, r, g, and b should be in linear space. +*/ +static inline U8CPU SkComputeLuminance(U8CPU r, U8CPU g, U8CPU b) { + //The following is + //r * SK_LUM_COEFF_R + g * SK_LUM_COEFF_G + b * SK_LUM_COEFF_B + //with SK_LUM_COEFF_X in 1.8 fixed point (rounding adjusted to sum to 256). + return (r * 54 + g * 183 + b * 19) >> 8; +} + /** Turn 0..255 into 0..256 by adding 1 at the half-way point. Used to turn a byte into a scale value, so that we can say scale * value >> 8 instead of alpha * value / 255. |