diff options
-rw-r--r-- | include/core/SkBlitRow.h | 3 | ||||
-rw-r--r-- | src/core/SkBlitRow_D32.cpp | 25 | ||||
-rw-r--r-- | src/core/SkOpts.cpp | 3 | ||||
-rw-r--r-- | src/core/SkOpts.h | 1 | ||||
-rw-r--r-- | src/opts/SkBlitRow_opts.h | 35 | ||||
-rw-r--r-- | src/opts/SkBlitRow_opts_arm.cpp | 5 | ||||
-rw-r--r-- | src/opts/SkBlitRow_opts_arm_neon.cpp | 17 | ||||
-rw-r--r-- | src/opts/SkBlitRow_opts_arm_neon.h | 2 | ||||
-rw-r--r-- | src/opts/SkBlitRow_opts_none.cpp | 2 | ||||
-rw-r--r-- | src/opts/SkOpts_neon.cpp | 3 |
10 files changed, 44 insertions, 52 deletions
diff --git a/include/core/SkBlitRow.h b/include/core/SkBlitRow.h index 8c7665ac54..56121eba78 100644 --- a/include/core/SkBlitRow.h +++ b/include/core/SkBlitRow.h @@ -82,9 +82,6 @@ public: static ColorProc16 PlatformColorFactory565(unsigned flags); private: - typedef void (*Color32Proc)(SkPMColor[], const SkPMColor[], int, SkPMColor); - static Color32Proc PlatformColor32Proc(); - enum { kFlags16_Mask = 7, kFlags32_Mask = 3 diff --git a/src/core/SkBlitRow_D32.cpp b/src/core/SkBlitRow_D32.cpp index 0f8cbe8104..75330ae337 100644 --- a/src/core/SkBlitRow_D32.cpp +++ b/src/core/SkBlitRow_D32.cpp @@ -8,6 +8,7 @@ #include "SkBlitRow.h" #include "SkBlitMask.h" #include "SkColorPriv.h" +#include "SkOpts.h" #include "SkUtils.h" #define UNROLL @@ -131,32 +132,10 @@ SkBlitRow::Proc32 SkBlitRow::Factory32(unsigned flags) { return proc; } -#include "Sk4px.h" - -// Color32 uses the blend_256_round_alt algorithm from tests/BlendTest.cpp. -// It's not quite perfect, but it's never wrong in the interesting edge cases, -// and it's quite a bit faster than blend_perfect. -// -// blend_256_round_alt is our currently blessed algorithm. Please use it or an analogous one. void SkBlitRow::Color32(SkPMColor dst[], const SkPMColor src[], int count, SkPMColor color) { switch (SkGetPackedA32(color)) { case 0: memmove(dst, src, count * sizeof(SkPMColor)); return; case 255: sk_memset32(dst, color, count); return; } - - // This Sk4px impl works great on other platforms or when we have NEON. -#if defined(SK_CPU_ARM32) && !defined(SK_ARM_HAS_NEON) - if (auto proc = PlatformColor32Proc()) { return proc(dst, src, count, color); } -#endif - - unsigned invA = 255 - SkGetPackedA32(color); - invA += invA >> 7; - SkASSERT(invA < 256); // We've already handled alpha == 0 above. - - Sk16h colorHighAndRound = Sk4px::DupPMColor(color).widenHi() + Sk16h(128); - Sk16b invA_16x(invA); - - Sk4px::MapSrc(count, dst, src, [&](const Sk4px& src4) -> Sk4px { - return (src4 * invA_16x).addNarrowHi(colorHighAndRound); - }); + return SkOpts::blit_row_color32(dst, src, count, color); } diff --git a/src/core/SkOpts.cpp b/src/core/SkOpts.cpp index 69373c0fd1..492fae3a6b 100644 --- a/src/core/SkOpts.cpp +++ b/src/core/SkOpts.cpp @@ -10,6 +10,7 @@ #define SK_OPTS_NS sk_default #include "SkBlitMask_opts.h" +#include "SkBlitRow_opts.h" #include "SkBlurImageFilter_opts.h" #include "SkColorCubeFilter_opts.h" #include "SkFloatingPoint_opts.h" @@ -55,6 +56,8 @@ namespace SkOpts { decltype(blit_mask_d32_a8) blit_mask_d32_a8 = sk_default::blit_mask_d32_a8; + decltype(blit_row_color32) blit_row_color32 = sk_default::blit_row_color32; + // Each Init_foo() is defined in src/opts/SkOpts_foo.cpp. void Init_ssse3(); void Init_sse41(); diff --git a/src/core/SkOpts.h b/src/core/SkOpts.h index 04aa9b1753..d73319a73c 100644 --- a/src/core/SkOpts.h +++ b/src/core/SkOpts.h @@ -44,6 +44,7 @@ namespace SkOpts { extern bool (*fill_block_dimensions)(SkTextureCompressor::Format, int* x, int* y); extern void (*blit_mask_d32_a8)(SkPMColor*, size_t, const SkAlpha*, size_t, SkColor, int, int); + extern void (*blit_row_color32)(SkPMColor*, const SkPMColor*, int, SkPMColor); // This function is an optimized version of SkColorCubeFilter::filterSpan extern void (*color_cube_filter_span)(const SkPMColor[], diff --git a/src/opts/SkBlitRow_opts.h b/src/opts/SkBlitRow_opts.h new file mode 100644 index 0000000000..f000f30fd0 --- /dev/null +++ b/src/opts/SkBlitRow_opts.h @@ -0,0 +1,35 @@ +/* + * Copyright 2015 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef SkBlitRow_opts_DEFINED +#define SkBlitRow_opts_DEFINED + +#include "Sk4px.h" + +namespace SK_OPTS_NS { + +// Color32 uses the blend_256_round_alt algorithm from tests/BlendTest.cpp. +// It's not quite perfect, but it's never wrong in the interesting edge cases, +// and it's quite a bit faster than blend_perfect. +// +// blend_256_round_alt is our currently blessed algorithm. Please use it or an analogous one. +static void blit_row_color32(SkPMColor* dst, const SkPMColor* src, int count, SkPMColor color) { + unsigned invA = 255 - SkGetPackedA32(color); + invA += invA >> 7; + SkASSERT(invA < 256); // We've should have already handled alpha == 0 externally. + + Sk16h colorHighAndRound = Sk4px::DupPMColor(color).widenHi() + Sk16h(128); + Sk16b invA_16x(invA); + + Sk4px::MapSrc(count, dst, src, [&](const Sk4px& src4) -> Sk4px { + return (src4 * invA_16x).addNarrowHi(colorHighAndRound); + }); +} + +} // SK_OPTS_NS + +#endif//SkBlitRow_opts_DEFINED diff --git a/src/opts/SkBlitRow_opts_arm.cpp b/src/opts/SkBlitRow_opts_arm.cpp index 5770c1f1d7..24566ba6c5 100644 --- a/src/opts/SkBlitRow_opts_arm.cpp +++ b/src/opts/SkBlitRow_opts_arm.cpp @@ -33,8 +33,3 @@ SkBlitRow::ColorProc16 SkBlitRow::PlatformColorFactory565(unsigned flags) { SkBlitRow::Proc32 SkBlitRow::PlatformProcs32(unsigned flags) { return SK_ARM_NEON_WRAP(sk_blitrow_platform_32_procs_arm)[flags]; } - -SkBlitRow::Color32Proc SkBlitRow::PlatformColor32Proc() { - #define sk_blitrow_color32_arm nullptr - return SK_ARM_NEON_WRAP(sk_blitrow_color32_arm); -} diff --git a/src/opts/SkBlitRow_opts_arm_neon.cpp b/src/opts/SkBlitRow_opts_arm_neon.cpp index d5260afd50..1f97971ee4 100644 --- a/src/opts/SkBlitRow_opts_arm_neon.cpp +++ b/src/opts/SkBlitRow_opts_arm_neon.cpp @@ -1582,20 +1582,3 @@ const SkBlitRow::Proc32 sk_blitrow_platform_32_procs_arm_neon[] = { nullptr #endif }; - -#include "Sk4px.h" - -void sk_blitrow_color32_arm_neon(SkPMColor* dst, const SkPMColor* src, int count, SkPMColor color) { - // Until it becomes a little more reasonable to assume we'll be built with NEON, - // we copy our Sk4px implementation of SkBlitRow::Color32 here so it picks up NEON at runtime. - unsigned invA = 255 - SkGetPackedA32(color); - invA += invA >> 7; - SkASSERT(invA < 256); // Our caller has already handled the alpha == 0 case. - - Sk16h colorHighAndRound = Sk4px::DupPMColor(color).widenHi() + Sk16h(128); - Sk16b invA_16x(invA); - - Sk4px::MapSrc(count, dst, src, [&](const Sk4px& src4) -> Sk4px { - return (src4 * invA_16x).addNarrowHi(colorHighAndRound); - }); -} diff --git a/src/opts/SkBlitRow_opts_arm_neon.h b/src/opts/SkBlitRow_opts_arm_neon.h index fb3d2e0a7b..159a466c98 100644 --- a/src/opts/SkBlitRow_opts_arm_neon.h +++ b/src/opts/SkBlitRow_opts_arm_neon.h @@ -13,6 +13,4 @@ extern const SkBlitRow::Proc16 sk_blitrow_platform_565_procs_arm_neon[]; extern const SkBlitRow::ColorProc16 sk_blitrow_platform_565_colorprocs_arm_neon[]; extern const SkBlitRow::Proc32 sk_blitrow_platform_32_procs_arm_neon[]; -extern void sk_blitrow_color32_arm_neon(SkPMColor[], const SkPMColor[], int, SkPMColor); - #endif diff --git a/src/opts/SkBlitRow_opts_none.cpp b/src/opts/SkBlitRow_opts_none.cpp index 03298e888e..a9abe06580 100644 --- a/src/opts/SkBlitRow_opts_none.cpp +++ b/src/opts/SkBlitRow_opts_none.cpp @@ -20,5 +20,3 @@ SkBlitRow::ColorProc16 SkBlitRow::PlatformColorFactory565(unsigned flags) { SkBlitRow::Proc32 SkBlitRow::PlatformProcs32(unsigned flags) { return nullptr; } - -SkBlitRow::Color32Proc SkBlitRow::PlatformColor32Proc() { return nullptr; } diff --git a/src/opts/SkOpts_neon.cpp b/src/opts/SkOpts_neon.cpp index a05df66762..802d83f69c 100644 --- a/src/opts/SkOpts_neon.cpp +++ b/src/opts/SkOpts_neon.cpp @@ -9,6 +9,7 @@ #define SK_OPTS_NS sk_neon #include "SkBlitMask_opts.h" +#include "SkBlitRow_opts.h" #include "SkBlurImageFilter_opts.h" #include "SkColorCubeFilter_opts.h" #include "SkFloatingPoint_opts.h" @@ -38,6 +39,8 @@ namespace SkOpts { blit_mask_d32_a8 = sk_neon::blit_mask_d32_a8; + blit_row_color32 = sk_neon::blit_row_color32; + color_cube_filter_span = sk_neon::color_cube_filter_span; } } |