| 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 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 SkB32Assert(b); | 517 SkB32Assert(b); |
| 518 | 518 |
| 519 if (a != 255) { | 519 if (a != 255) { |
| 520 r = SkMulDiv255Round(r, a); | 520 r = SkMulDiv255Round(r, a); |
| 521 g = SkMulDiv255Round(g, a); | 521 g = SkMulDiv255Round(g, a); |
| 522 b = SkMulDiv255Round(b, a); | 522 b = SkMulDiv255Round(b, a); |
| 523 } | 523 } |
| 524 return SkPackARGB32(a, r, g, b); | 524 return SkPackARGB32(a, r, g, b); |
| 525 } | 525 } |
| 526 | 526 |
| 527 static inline uint32_t SkAlphaMulQ(uint32_t c, unsigned scale) { | 527 // When Android is compiled optimizing for size, SkAlphaMulQ doesn't get |
| 528 // inlined; forcing inlining significantly improves performance. |
| 529 static SK_ALWAYS_INLINE uint32_t SkAlphaMulQ(uint32_t c, unsigned scale) { |
| 528 uint32_t mask = 0xFF00FF; | 530 uint32_t mask = 0xFF00FF; |
| 529 | 531 |
| 530 uint32_t rb = ((c & mask) * scale) >> 8; | 532 uint32_t rb = ((c & mask) * scale) >> 8; |
| 531 uint32_t ag = ((c >> 8) & mask) * scale; | 533 uint32_t ag = ((c >> 8) & mask) * scale; |
| 532 return (rb & mask) | (ag & ~mask); | 534 return (rb & mask) | (ag & ~mask); |
| 533 } | 535 } |
| 534 | 536 |
| 535 static inline SkPMColor SkPMSrcOver(SkPMColor src, SkPMColor dst) { | 537 static inline SkPMColor SkPMSrcOver(SkPMColor src, SkPMColor dst) { |
| 536 return src + SkAlphaMulQ(dst, SkAlpha255To256(255 - SkGetPackedA32(src))); | 538 return src + SkAlphaMulQ(dst, SkAlpha255To256(255 - SkGetPackedA32(src))); |
| 537 } | 539 } |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1048 int srcG = SkColorGetG(src); | 1050 int srcG = SkColorGetG(src); |
| 1049 int srcB = SkColorGetB(src); | 1051 int srcB = SkColorGetB(src); |
| 1050 | 1052 |
| 1051 for (int i = 0; i < width; i++) { | 1053 for (int i = 0; i < width; i++) { |
| 1052 dst[i] = SkBlendLCD16Opaque(srcR, srcG, srcB, dst[i], mask[i], | 1054 dst[i] = SkBlendLCD16Opaque(srcR, srcG, srcB, dst[i], mask[i], |
| 1053 opaqueDst); | 1055 opaqueDst); |
| 1054 } | 1056 } |
| 1055 } | 1057 } |
| 1056 | 1058 |
| 1057 #endif | 1059 #endif |
| OLD | NEW |