Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(750)

Side by Side Diff: src/opts/SkBlitRow_opts_arm_neon.cpp

Issue 1104183004: De-proc Color32 (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: duh Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/opts/SkBlitRow_opts_arm_neon.h ('k') | src/opts/SkBlitRow_opts_mips_dsp.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The Android Open Source Project 2 * Copyright 2012 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_opts_arm_neon.h" 8 #include "SkBlitRow_opts_arm_neon.h"
9 9
10 #include "SkBlitMask.h" 10 #include "SkBlitMask.h"
(...skipping 1661 matching lines...) Expand 10 before | Expand all | Expand 10 after
1672 SkPMColorAssert(c); 1672 SkPMColorAssert(c);
1673 SkASSERT(SkGetPackedA32(c) == 255); 1673 SkASSERT(SkGetPackedA32(c) == 255);
1674 1674
1675 unsigned dither = DITHER_VALUE(x); 1675 unsigned dither = DITHER_VALUE(x);
1676 *dst++ = SkDitherRGB32To565(c, dither); 1676 *dst++ = SkDitherRGB32To565(c, dither);
1677 DITHER_INC_X(x); 1677 DITHER_INC_X(x);
1678 } while (--count != 0); 1678 } while (--count != 0);
1679 } 1679 }
1680 } 1680 }
1681 1681
1682 #define SK_SUPPORT_LEGACY_COLOR32_MATHx
1683
1684 // Color32 and its SIMD specializations use the blend_256_round_alt algorithm
1685 // from tests/BlendTest.cpp. It's not quite perfect, but it's never wrong in th e
1686 // interesting edge cases, and it's quite a bit faster than blend_perfect.
1687 //
1688 // blend_256_round_alt is our currently blessed algorithm. Please use it or an analogous one.
1689 void Color32_arm_neon(SkPMColor* dst, const SkPMColor* src, int count, SkPMColor color) {
1690 switch (SkGetPackedA32(color)) {
1691 case 0: memmove(dst, src, count * sizeof(SkPMColor)); return;
1692 case 255: sk_memset32(dst, color, count); return;
1693 }
1694
1695 uint16x8_t colorHigh = vshll_n_u8((uint8x8_t)vdup_n_u32(color), 8);
1696 #ifdef SK_SUPPORT_LEGACY_COLOR32_MATH // blend_256_plus1_trunc, busted
1697 uint16x8_t colorAndRound = colorHigh;
1698 #else // blend_256_round_alt, good
1699 uint16x8_t colorAndRound = vaddq_u16(colorHigh, vdupq_n_u16(128));
1700 #endif
1701
1702 unsigned invA = 255 - SkGetPackedA32(color);
1703 #ifdef SK_SUPPORT_LEGACY_COLOR32_MATH // blend_256_plus1_trunc, busted
1704 uint8x8_t invA8 = vdup_n_u8(invA);
1705 #else // blend_256_round_alt, good
1706 SkASSERT(invA + (invA >> 7) < 256); // This next part only works if alpha i s not 0.
1707 uint8x8_t invA8 = vdup_n_u8(invA + (invA >> 7));
1708 #endif
1709
1710 // Does the core work of blending color onto 4 pixels, returning the resulti ng 4 pixels.
1711 auto kernel = [&](const uint32x4_t& src4) -> uint32x4_t {
1712 uint16x8_t lo = vmull_u8(vget_low_u8( (uint8x16_t)src4), invA8),
1713 hi = vmull_u8(vget_high_u8((uint8x16_t)src4), invA8);
1714 return (uint32x4_t)
1715 vcombine_u8(vaddhn_u16(colorAndRound, lo), vaddhn_u16(colorAndRound, hi));
1716 };
1717
1718 while (count >= 8) {
1719 uint32x4_t dst0 = kernel(vld1q_u32(src+0)),
1720 dst4 = kernel(vld1q_u32(src+4));
1721 vst1q_u32(dst+0, dst0);
1722 vst1q_u32(dst+4, dst4);
1723 src += 8;
1724 dst += 8;
1725 count -= 8;
1726 }
1727 if (count >= 4) {
1728 vst1q_u32(dst, kernel(vld1q_u32(src)));
1729 src += 4;
1730 dst += 4;
1731 count -= 4;
1732 }
1733 if (count >= 2) {
1734 uint32x2_t src2 = vld1_u32(src);
1735 vst1_u32(dst, vget_low_u32(kernel(vcombine_u32(src2, src2))));
1736 src += 2;
1737 dst += 2;
1738 count -= 2;
1739 }
1740 if (count >= 1) {
1741 vst1q_lane_u32(dst, kernel(vdupq_n_u32(*src)), 0);
1742 }
1743 }
1744
1745 /////////////////////////////////////////////////////////////////////////////// 1682 ///////////////////////////////////////////////////////////////////////////////
1746 1683
1747 const SkBlitRow::Proc16 sk_blitrow_platform_565_procs_arm_neon[] = { 1684 const SkBlitRow::Proc16 sk_blitrow_platform_565_procs_arm_neon[] = {
1748 // no dither 1685 // no dither
1749 S32_D565_Opaque_neon, 1686 S32_D565_Opaque_neon,
1750 S32_D565_Blend_neon, 1687 S32_D565_Blend_neon,
1751 S32A_D565_Opaque_neon, 1688 S32A_D565_Opaque_neon,
1752 #if 0 1689 #if 0
1753 S32A_D565_Blend_neon, 1690 S32A_D565_Blend_neon,
1754 #else 1691 #else
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1786 S32A_Opaque_BlitRow32_neon_src_alpha, // S32A_Opaque, 1723 S32A_Opaque_BlitRow32_neon_src_alpha, // S32A_Opaque,
1787 #else 1724 #else
1788 S32A_Opaque_BlitRow32_neon, // S32A_Opaque, 1725 S32A_Opaque_BlitRow32_neon, // S32A_Opaque,
1789 #endif 1726 #endif
1790 #ifdef SK_CPU_ARM32 1727 #ifdef SK_CPU_ARM32
1791 S32A_Blend_BlitRow32_neon // S32A_Blend 1728 S32A_Blend_BlitRow32_neon // S32A_Blend
1792 #else 1729 #else
1793 NULL 1730 NULL
1794 #endif 1731 #endif
1795 }; 1732 };
OLDNEW
« no previous file with comments | « src/opts/SkBlitRow_opts_arm_neon.h ('k') | src/opts/SkBlitRow_opts_mips_dsp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698