LEFT | RIGHT |
(no file at all) | |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef SkColorPriv_DEFINED | 10 #ifndef SkColorPriv_DEFINED |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 */ | 348 */ |
349 static inline U16CPU SkSrcOver32To16(SkPMColor src, uint16_t dst) { | 349 static inline U16CPU SkSrcOver32To16(SkPMColor src, uint16_t dst) { |
350 unsigned sr = SkGetPackedR32(src); | 350 unsigned sr = SkGetPackedR32(src); |
351 unsigned sg = SkGetPackedG32(src); | 351 unsigned sg = SkGetPackedG32(src); |
352 unsigned sb = SkGetPackedB32(src); | 352 unsigned sb = SkGetPackedB32(src); |
353 | 353 |
354 unsigned dr = SkGetPackedR16(dst); | 354 unsigned dr = SkGetPackedR16(dst); |
355 unsigned dg = SkGetPackedG16(dst); | 355 unsigned dg = SkGetPackedG16(dst); |
356 unsigned db = SkGetPackedB16(dst); | 356 unsigned db = SkGetPackedB16(dst); |
357 | 357 |
358 unsigned isa = 255 - SkGetPackedA32(src); | 358 unsigned scale = SkAlpha255To256(255 - SkGetPackedA32(src)); |
359 | 359 |
360 dr = (sr + SkMul16ShiftRound(dr, isa, SK_R16_BITS)) >> (8 - SK_R16_BITS); | 360 dr = (sr + ((dr * scale) >> SK_R16_BITS)) >> (8 - SK_R16_BITS); |
361 dg = (sg + SkMul16ShiftRound(dg, isa, SK_G16_BITS)) >> (8 - SK_G16_BITS); | 361 dg = (sg + ((dg * scale) >> SK_G16_BITS)) >> (8 - SK_G16_BITS); |
362 db = (sb + SkMul16ShiftRound(db, isa, SK_B16_BITS)) >> (8 - SK_B16_BITS); | 362 db = (sb + ((db * scale) >> SK_B16_BITS)) >> (8 - SK_B16_BITS); |
363 | 363 |
364 return SkPackRGB16(dr, dg, db); | 364 return SkPackRGB16(dr, dg, db); |
365 } | 365 } |
366 | 366 |
367 ////////////////////////////////////////////////////////////////////////////////
//////////// | 367 ////////////////////////////////////////////////////////////////////////////////
//////////// |
368 // Convert a 16bit pixel to a 32bit pixel | 368 // Convert a 16bit pixel to a 32bit pixel |
369 | 369 |
370 static inline unsigned SkR16ToR32(unsigned r) { | 370 static inline unsigned SkR16ToR32(unsigned r) { |
371 return (r << (8 - SK_R16_BITS)) | (r >> (2 * SK_R16_BITS - 8)); | 371 return (r << (8 - SK_R16_BITS)) | (r >> (2 * SK_R16_BITS - 8)); |
372 } | 372 } |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 (((c >> (SK_B32_SHIFT + 4)) & 0xF) << 16) | | 658 (((c >> (SK_B32_SHIFT + 4)) & 0xF) << 16) | |
659 (((c >> (SK_A32_SHIFT + 4)) & 0xF) << 0); | 659 (((c >> (SK_A32_SHIFT + 4)) & 0xF) << 0); |
660 } | 660 } |
661 | 661 |
662 // takes two values and alternamtes them as part of a memset16 | 662 // takes two values and alternamtes them as part of a memset16 |
663 // used for cheap 2x2 dithering when the colors are opaque | 663 // used for cheap 2x2 dithering when the colors are opaque |
664 void sk_dither_memset16(uint16_t dst[], uint16_t value, uint16_t other, int n); | 664 void sk_dither_memset16(uint16_t dst[], uint16_t value, uint16_t other, int n); |
665 | 665 |
666 #endif | 666 #endif |
667 | 667 |
LEFT | RIGHT |