diff options
author | 2012-03-12 14:25:18 +0000 | |
---|---|---|
committer | 2012-03-12 14:25:18 +0000 | |
commit | 6adf79746f435df1463ce944598f189db7759cdf (patch) | |
tree | d43855312e9763d357995416f70dc3b46d14bab6 /include/core/SkColorPriv.h | |
parent | 208236d2b6163b977cc9bc299f8df60158ba8226 (diff) |
add SkFourByteInterp256 variant, when the caller has already scaled the last
parameter to 0..256
git-svn-id: http://skia.googlecode.com/svn/trunk@3362 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core/SkColorPriv.h')
-rw-r--r-- | include/core/SkColorPriv.h | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/include/core/SkColorPriv.h b/include/core/SkColorPriv.h index e51b0b9035..a2a9c58b25 100644 --- a/include/core/SkColorPriv.h +++ b/include/core/SkColorPriv.h @@ -220,20 +220,31 @@ static inline SkPMColor SkPackARGB32(U8CPU a, U8CPU r, U8CPU g, U8CPU b) { * utility functions. Third parameter controls blending of the first two: * (src, dst, 0) returns dst * (src, dst, 0xFF) returns src + * srcWeight is [0..256], unlike SkFourByteInterp which takes [0..255] */ -static inline SkPMColor SkFourByteInterp(SkPMColor src, SkPMColor dst, - U8CPU srcWeight) { - unsigned scale = SkAlpha255To256(srcWeight); - +static inline SkPMColor SkFourByteInterp256(SkPMColor src, SkPMColor dst, + unsigned scale) { unsigned a = SkAlphaBlend(SkGetPackedA32(src), SkGetPackedA32(dst), scale); unsigned r = SkAlphaBlend(SkGetPackedR32(src), SkGetPackedR32(dst), scale); unsigned g = SkAlphaBlend(SkGetPackedG32(src), SkGetPackedG32(dst), scale); unsigned b = SkAlphaBlend(SkGetPackedB32(src), SkGetPackedB32(dst), scale); - + return SkPackARGB32(a, r, g, b); } /** + * Abstract 4-byte interpolation, implemented on top of SkPMColor + * utility functions. Third parameter controls blending of the first two: + * (src, dst, 0) returns dst + * (src, dst, 0xFF) returns src + */ +static inline SkPMColor SkFourByteInterp(SkPMColor src, SkPMColor dst, + U8CPU srcWeight) { + unsigned scale = SkAlpha255To256(srcWeight); + return SkFourByteInterp256(src, dst, scale); +} + +/** * 32b optimized version; currently appears to be 10% faster even on 64b * architectures than an equivalent 64b version and 30% faster than * SkFourByteInterp(). Third parameter controls blending of the first two: |