OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkColorPriv_DEFINED | 8 #ifndef SkColorPriv_DEFINED |
9 #define SkColorPriv_DEFINED | 9 #define SkColorPriv_DEFINED |
10 | 10 |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
274 to return 32bits, so that the compiler won't generate extra instructions to | 274 to return 32bits, so that the compiler won't generate extra instructions to |
275 "clean" the top 16bits. | 275 "clean" the top 16bits. |
276 */ | 276 */ |
277 static inline U16CPU SkAlphaMulRGB16(U16CPU c, unsigned scale) { | 277 static inline U16CPU SkAlphaMulRGB16(U16CPU c, unsigned scale) { |
278 return SkCompact_rgb_16(SkExpand_rgb_16(c) * (scale >> 3) >> 5); | 278 return SkCompact_rgb_16(SkExpand_rgb_16(c) * (scale >> 3) >> 5); |
279 } | 279 } |
280 | 280 |
281 // this helper explicitly returns a clean 16bit value (but slower) | 281 // this helper explicitly returns a clean 16bit value (but slower) |
282 #define SkAlphaMulRGB16_ToU16(c, s) (uint16_t)SkAlphaMulRGB16(c, s) | 282 #define SkAlphaMulRGB16_ToU16(c, s) (uint16_t)SkAlphaMulRGB16(c, s) |
283 | 283 |
284 /** Blend pre-expanded ARGB32 with 16bit color value by the 0..32 scale paramete r. | |
285 The computation yields only 16bits of valid data, but we claim to return | |
286 32bits, so that the compiler won't generate extra instructions to "clean" | |
287 the top 16bits. | |
288 */ | |
289 static inline U16CPU SkBlend32A_D565(uint16_t dst, unsigned scale, uint32_t src_ expand) { | |
reed1
2015/02/12 14:44:06
Why is there 32A in the name? Can you pick a name
henrik.smiding
2015/02/12 15:45:06
It was hard to come up with a good name. The metho
| |
290 uint32_t dst_expand = SkExpand_rgb_16(dst) * scale; | |
291 return SkCompact_rgb_16((src_expand + dst_expand) >> 5); | |
292 } | |
293 | |
284 /** Blend src and dst 16bit colors by the 0..256 scale parameter. | 294 /** Blend src and dst 16bit colors by the 0..256 scale parameter. |
285 The computation yields only 16bits of valid data, but we claim | 295 The computation yields only 16bits of valid data, but we claim |
286 to return 32bits, so that the compiler won't generate extra instructions to | 296 to return 32bits, so that the compiler won't generate extra instructions to |
287 "clean" the top 16bits. | 297 "clean" the top 16bits. |
288 */ | 298 */ |
289 static inline U16CPU SkBlendRGB16(U16CPU src, U16CPU dst, int srcScale) { | 299 static inline U16CPU SkBlendRGB16(U16CPU src, U16CPU dst, int srcScale) { |
290 SkASSERT((unsigned)srcScale <= 256); | 300 SkASSERT((unsigned)srcScale <= 256); |
291 | 301 |
292 srcScale >>= 3; | 302 srcScale >>= 3; |
293 | 303 |
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1021 int srcG = SkColorGetG(src); | 1031 int srcG = SkColorGetG(src); |
1022 int srcB = SkColorGetB(src); | 1032 int srcB = SkColorGetB(src); |
1023 | 1033 |
1024 for (int i = 0; i < width; i++) { | 1034 for (int i = 0; i < width; i++) { |
1025 dst[i] = SkBlendLCD16Opaque(srcR, srcG, srcB, dst[i], mask[i], | 1035 dst[i] = SkBlendLCD16Opaque(srcR, srcG, srcB, dst[i], mask[i], |
1026 opaqueDst); | 1036 opaqueDst); |
1027 } | 1037 } |
1028 } | 1038 } |
1029 | 1039 |
1030 #endif | 1040 #endif |
OLD | NEW |