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

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

Issue 1083923006: Revert of Convert Color32 code to perfect blend. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 5 years, 8 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_SSE2.cpp ('k') | no next file » | 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 1663 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 1682 #define SK_SUPPORT_LEGACY_COLOR32_MATHx
1683 1683
1684 /* NEON version of Color32(), portable version is in core/SkBlitRow_D32.cpp */ 1684 // Color32 and its SIMD specializations use the blend_256_round_alt algorithm
1685 // Color32 and its SIMD specializations use the blend_perfect algorithm from tes ts/BlendTest.cpp. 1685 // from tests/BlendTest.cpp. It's not quite perfect, but it's never wrong in th e
1686 // An acceptable alternative is blend_256_round_alt, which is faster but not qui te perfect. 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.
1687 void Color32_arm_neon(SkPMColor* dst, const SkPMColor* src, int count, SkPMColor color) { 1689 void Color32_arm_neon(SkPMColor* dst, const SkPMColor* src, int count, SkPMColor color) {
1688 switch (SkGetPackedA32(color)) { 1690 switch (SkGetPackedA32(color)) {
1689 case 0: memmove(dst, src, count * sizeof(SkPMColor)); return; 1691 case 0: memmove(dst, src, count * sizeof(SkPMColor)); return;
1690 case 255: sk_memset32(dst, color, count); return; 1692 case 255: sk_memset32(dst, color, count); return;
1691 } 1693 }
1692 1694
1693 uint16x8_t color_2x_high = vshll_n_u8((uint8x8_t)vdup_n_u32(color), 8); 1695 uint16x8_t colorHigh = vshll_n_u8((uint8x8_t)vdup_n_u32(color), 8);
1694 uint8x8_t invA_8x = vdup_n_u8(255 - SkGetPackedA32(color)); 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
1695 1709
1696 // Does the core work of blending color onto 4 pixels, returning the resulti ng 4 pixels. 1710 // Does the core work of blending color onto 4 pixels, returning the resulti ng 4 pixels.
1697 auto kernel = [&](const uint32x4_t& src4) -> uint32x4_t { 1711 auto kernel = [&](const uint32x4_t& src4) -> uint32x4_t {
1698 uint16x8_t lo = vmull_u8(vget_low_u8( (uint8x16_t)src4), invA_8x), 1712 uint16x8_t lo = vmull_u8(vget_low_u8( (uint8x16_t)src4), invA8),
1699 hi = vmull_u8(vget_high_u8((uint8x16_t)src4), invA_8x); 1713 hi = vmull_u8(vget_high_u8((uint8x16_t)src4), invA8);
1700 #ifndef SK_SUPPORT_LEGACY_COLOR32_MATH
1701 lo = vaddq_u16(lo, vdupq_n_u16(128));
1702 hi = vaddq_u16(hi, vdupq_n_u16(128));
1703 lo = vaddq_u16(lo, vshrq_n_u16(lo, 8));
1704 hi = vaddq_u16(hi, vshrq_n_u16(hi, 8));
1705 #endif
1706 return (uint32x4_t) 1714 return (uint32x4_t)
1707 vcombine_u8(vaddhn_u16(color_2x_high, lo), vaddhn_u16(color_2x_high, hi)); 1715 vcombine_u8(vaddhn_u16(colorAndRound, lo), vaddhn_u16(colorAndRound, hi));
1708 }; 1716 };
1709 1717
1710 while (count >= 8) { 1718 while (count >= 8) {
1711 uint32x4_t dst0 = kernel(vld1q_u32(src+0)), 1719 uint32x4_t dst0 = kernel(vld1q_u32(src+0)),
1712 dst4 = kernel(vld1q_u32(src+4)); 1720 dst4 = kernel(vld1q_u32(src+4));
1713 vst1q_u32(dst+0, dst0); 1721 vst1q_u32(dst+0, dst0);
1714 vst1q_u32(dst+4, dst4); 1722 vst1q_u32(dst+4, dst4);
1715 src += 8; 1723 src += 8;
1716 dst += 8; 1724 dst += 8;
1717 count -= 8; 1725 count -= 8;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1778 S32A_Opaque_BlitRow32_neon_src_alpha, // S32A_Opaque, 1786 S32A_Opaque_BlitRow32_neon_src_alpha, // S32A_Opaque,
1779 #else 1787 #else
1780 S32A_Opaque_BlitRow32_neon, // S32A_Opaque, 1788 S32A_Opaque_BlitRow32_neon, // S32A_Opaque,
1781 #endif 1789 #endif
1782 #ifdef SK_CPU_ARM32 1790 #ifdef SK_CPU_ARM32
1783 S32A_Blend_BlitRow32_neon // S32A_Blend 1791 S32A_Blend_BlitRow32_neon // S32A_Blend
1784 #else 1792 #else
1785 NULL 1793 NULL
1786 #endif 1794 #endif
1787 }; 1795 };
OLDNEW
« no previous file with comments | « src/opts/SkBlitRow_opts_SSE2.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698