| 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 #include "SkBlitRow.h" | 8 #include "SkBlitRow.h" |
| 9 #include "SkCoreBlitters.h" | 9 #include "SkCoreBlitters.h" |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| 11 #include "SkDither.h" | 11 #include "SkDither.h" |
| 12 #include "SkShader.h" | 12 #include "SkShader.h" |
| 13 #include "SkUtils.h" | 13 #include "SkUtils.h" |
| 14 #include "SkUtilsArm.h" | 14 #include "SkUtilsArm.h" |
| 15 #include "SkXfermode.h" | 15 #include "SkXfermode.h" |
| 16 | 16 |
| 17 #if defined(__mips_dsp) | 17 #if defined(__mips_dsp) |
| 18 extern void blitmask_d565_opaque_mips(int width, int height, uint16_t* device, | 18 extern void blitmask_d565_opaque_mips(int width, int height, uint16_t* device, |
| 19 unsigned deviceRB, const uint8_t* alpha, | 19 unsigned deviceRB, const uint8_t* alpha, |
| 20 uint32_t expanded32, unsigned maskRB); | 20 uint32_t expanded32, unsigned maskRB); |
| 21 #endif | 21 #endif |
| 22 | 22 |
| 23 #if SK_ARM_NEON_IS_ALWAYS && defined(SK_CPU_LENDIAN) | 23 #if defined(SK_ARM_HAS_NEON) && defined(SK_CPU_LENDIAN) |
| 24 #include <arm_neon.h> | 24 #include <arm_neon.h> |
| 25 extern void SkRGB16BlitterBlitV_neon(uint16_t* device, | 25 extern void SkRGB16BlitterBlitV_neon(uint16_t* device, |
| 26 int height, | 26 int height, |
| 27 size_t deviceRB, | 27 size_t deviceRB, |
| 28 unsigned scale, | 28 unsigned scale, |
| 29 uint32_t src32); | 29 uint32_t src32); |
| 30 #else | 30 #else |
| 31 // if we don't have neon, then our black blitter is worth the extra code | 31 // if we don't have neon, then our black blitter is worth the extra code |
| 32 #define USE_BLACK_BLITTER | 32 #define USE_BLACK_BLITTER |
| 33 #endif | 33 #endif |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 } | 374 } |
| 375 | 375 |
| 376 uint16_t* SK_RESTRICT device = fDevice.writable_addr16(clip.fLeft, clip.fTop
); | 376 uint16_t* SK_RESTRICT device = fDevice.writable_addr16(clip.fLeft, clip.fTop
); |
| 377 const uint8_t* SK_RESTRICT alpha = mask.getAddr8(clip.fLeft, clip.fTop); | 377 const uint8_t* SK_RESTRICT alpha = mask.getAddr8(clip.fLeft, clip.fTop); |
| 378 int width = clip.width(); | 378 int width = clip.width(); |
| 379 int height = clip.height(); | 379 int height = clip.height(); |
| 380 size_t deviceRB = fDevice.rowBytes() - (width << 1); | 380 size_t deviceRB = fDevice.rowBytes() - (width << 1); |
| 381 unsigned maskRB = mask.fRowBytes - width; | 381 unsigned maskRB = mask.fRowBytes - width; |
| 382 uint32_t expanded32 = fExpandedRaw16; | 382 uint32_t expanded32 = fExpandedRaw16; |
| 383 | 383 |
| 384 #if SK_ARM_NEON_IS_ALWAYS && defined(SK_CPU_LENDIAN) | 384 #if defined(SK_ARM_HAS_NEON) && defined(SK_CPU_LENDIAN) |
| 385 #define UNROLL 8 | 385 #define UNROLL 8 |
| 386 do { | 386 do { |
| 387 int w = width; | 387 int w = width; |
| 388 if (w >= UNROLL) { | 388 if (w >= UNROLL) { |
| 389 uint32x4_t color, dev_lo, dev_hi; | 389 uint32x4_t color, dev_lo, dev_hi; |
| 390 uint32x4_t wn1, wn2, tmp; | 390 uint32x4_t wn1, wn2, tmp; |
| 391 uint32x4_t vmask_g16, vmask_ng16; | 391 uint32x4_t vmask_g16, vmask_ng16; |
| 392 uint16x8_t valpha, vdev; | 392 uint16x8_t valpha, vdev; |
| 393 uint16x4_t odev_lo, odev_hi, valpha_lo, valpha_hi; | 393 uint16x4_t odev_lo, odev_hi, valpha_lo, valpha_hi; |
| 394 | 394 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 } | 468 } |
| 469 | 469 |
| 470 void SkRGB16_Opaque_Blitter::blitV(int x, int y, int height, SkAlpha alpha) { | 470 void SkRGB16_Opaque_Blitter::blitV(int x, int y, int height, SkAlpha alpha) { |
| 471 uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y); | 471 uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y); |
| 472 size_t deviceRB = fDevice.rowBytes(); | 472 size_t deviceRB = fDevice.rowBytes(); |
| 473 | 473 |
| 474 // TODO: respect fDoDither | 474 // TODO: respect fDoDither |
| 475 unsigned scale5 = SkAlpha255To256(alpha) >> 3; | 475 unsigned scale5 = SkAlpha255To256(alpha) >> 3; |
| 476 uint32_t src32 = fExpandedRaw16 * scale5; | 476 uint32_t src32 = fExpandedRaw16 * scale5; |
| 477 scale5 = 32 - scale5; | 477 scale5 = 32 - scale5; |
| 478 #if SK_ARM_NEON_IS_ALWAYS && defined(SK_CPU_LENDIAN) | 478 #if defined(SK_ARM_HAS_NEON) && defined(SK_CPU_LENDIAN) |
| 479 SkRGB16BlitterBlitV_neon(device, height, deviceRB, scale5, src32); | 479 SkRGB16BlitterBlitV_neon(device, height, deviceRB, scale5, src32); |
| 480 #else | 480 #else |
| 481 do { | 481 do { |
| 482 uint32_t dst32 = SkExpand_rgb_16(*device) * scale5; | 482 uint32_t dst32 = SkExpand_rgb_16(*device) * scale5; |
| 483 *device = SkCompact_rgb_16((src32 + dst32) >> 5); | 483 *device = SkCompact_rgb_16((src32 + dst32) >> 5); |
| 484 device = (uint16_t*)((char*)device + deviceRB); | 484 device = (uint16_t*)((char*)device + deviceRB); |
| 485 } while (--height != 0); | 485 } while (--height != 0); |
| 486 #endif | 486 #endif |
| 487 } | 487 } |
| 488 | 488 |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 } | 647 } |
| 648 | 648 |
| 649 void SkRGB16_Blitter::blitV(int x, int y, int height, SkAlpha alpha) { | 649 void SkRGB16_Blitter::blitV(int x, int y, int height, SkAlpha alpha) { |
| 650 uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y); | 650 uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y); |
| 651 size_t deviceRB = fDevice.rowBytes(); | 651 size_t deviceRB = fDevice.rowBytes(); |
| 652 | 652 |
| 653 // TODO: respect fDoDither | 653 // TODO: respect fDoDither |
| 654 unsigned scale5 = SkAlpha255To256(alpha) * fScale >> (8 + 3); | 654 unsigned scale5 = SkAlpha255To256(alpha) * fScale >> (8 + 3); |
| 655 uint32_t src32 = fExpandedRaw16 * scale5; | 655 uint32_t src32 = fExpandedRaw16 * scale5; |
| 656 scale5 = 32 - scale5; | 656 scale5 = 32 - scale5; |
| 657 #if SK_ARM_NEON_IS_ALWAYS && defined(SK_CPU_LENDIAN) | 657 #if defined(SK_ARM_HAS_NEON) && defined(SK_CPU_LENDIAN) |
| 658 SkRGB16BlitterBlitV_neon(device, height, deviceRB, scale5, src32); | 658 SkRGB16BlitterBlitV_neon(device, height, deviceRB, scale5, src32); |
| 659 #else | 659 #else |
| 660 do { | 660 do { |
| 661 uint32_t dst32 = SkExpand_rgb_16(*device) * scale5; | 661 uint32_t dst32 = SkExpand_rgb_16(*device) * scale5; |
| 662 *device = SkCompact_rgb_16((src32 + dst32) >> 5); | 662 *device = SkCompact_rgb_16((src32 + dst32) >> 5); |
| 663 device = (uint16_t*)((char*)device + deviceRB); | 663 device = (uint16_t*)((char*)device + deviceRB); |
| 664 } while (--height != 0); | 664 } while (--height != 0); |
| 665 #endif | 665 #endif |
| 666 } | 666 } |
| 667 | 667 |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 921 #endif | 921 #endif |
| 922 } else if (0xFF == SkColorGetA(color)) { | 922 } else if (0xFF == SkColorGetA(color)) { |
| 923 blitter = allocator->createT<SkRGB16_Opaque_Blitter>(device, paint); | 923 blitter = allocator->createT<SkRGB16_Opaque_Blitter>(device, paint); |
| 924 } else { | 924 } else { |
| 925 blitter = allocator->createT<SkRGB16_Blitter>(device, paint); | 925 blitter = allocator->createT<SkRGB16_Blitter>(device, paint); |
| 926 } | 926 } |
| 927 } | 927 } |
| 928 | 928 |
| 929 return blitter; | 929 return blitter; |
| 930 } | 930 } |
| OLD | NEW |