aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkMipMap.cpp
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2016-01-20 11:55:51 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-01-20 11:55:51 -0800
commit550e9b0ef1c0fba42e2e902a467af322ad2413da (patch)
tree6e032834e21c115c024c539e7b60ad4c7ad209d9 /src/core/SkMipMap.cpp
parent88651aeb551fb02003a7600679e8e7df8a589e7f (diff)
SkNx miplevel building
All sizes approximately twice as fast. Before: micros bench 1649.35 mipmap_build_512x512 nonrendering 1824.42 mipmap_build_511x512 nonrendering 2100.66 ? mipmap_build_512x511 nonrendering 2375.94 mipmap_build_511x511 nonrendering After: micros bench 730.32 ! mipmap_build_512x512 nonrendering 922.12 mipmap_build_511x512 nonrendering 999.07 mipmap_build_512x511 nonrendering 1342.93 ! mipmap_build_511x511 nonrendering BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1606013003 CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot Committed: https://skia.googlesource.com/skia/+/3bd5aba2a0e165997f683cf3aa306661e71464f6 Review URL: https://codereview.chromium.org/1606013003
Diffstat (limited to 'src/core/SkMipMap.cpp')
-rw-r--r--src/core/SkMipMap.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/core/SkMipMap.cpp b/src/core/SkMipMap.cpp
index d468507ac7..14e87a33a3 100644
--- a/src/core/SkMipMap.cpp
+++ b/src/core/SkMipMap.cpp
@@ -8,6 +8,7 @@
#include "SkMipMap.h"
#include "SkBitmap.h"
#include "SkColorPriv.h"
+#include "SkNx.h"
//
// ColorTypeFilter is the "Type" we pass to some downsample template functions.
@@ -18,12 +19,23 @@
struct ColorTypeFilter_8888 {
typedef uint32_t Type;
+#if defined(SKNX_IS_FAST)
+ static Sk4h Expand(uint32_t x) {
+ return SkNx_cast<uint16_t>(Sk4b::Load((const uint8_t*)&x));
+ }
+ static uint32_t Compact(const Sk4h& x) {
+ uint32_t r;
+ SkNx_cast<uint8_t>(x).store((uint8_t*)&r);
+ return r;
+ }
+#else
static uint64_t Expand(uint32_t x) {
return (x & 0xFF00FF) | ((uint64_t)(x & 0xFF00FF00) << 24);
}
static uint32_t Compact(uint64_t x) {
return (uint32_t)((x & 0xFF00FF) | ((x >> 24) & 0xFF00FF00));
}
+#endif
};
struct ColorTypeFilter_565 {
@@ -56,7 +68,7 @@ struct ColorTypeFilter_8 {
}
};
-template <typename T> T add_121(T a, T b, T c) {
+template <typename T> T add_121(const T& a, const T& b, const T& c) {
return a + b + b + c;
}
@@ -93,7 +105,7 @@ template <typename F> void downsample_3_2(void* dst, const void* src, size_t src
auto p0 = static_cast<const typename F::Type*>(src);
auto p1 = (const typename F::Type*)((const char*)p0 + srcRB);
auto d = static_cast<typename F::Type*>(dst);
-
+
auto c02 = F::Expand(p0[0]);
auto c12 = F::Expand(p1[0]);
for (int i = 0; i < count; ++i) {
@@ -116,7 +128,7 @@ template <typename F> void downsample_2_3(void* dst, const void* src, size_t src
auto p1 = (const typename F::Type*)((const char*)p0 + srcRB);
auto p2 = (const typename F::Type*)((const char*)p1 + srcRB);
auto d = static_cast<typename F::Type*>(dst);
-
+
for (int i = 0; i < count; ++i) {
auto c00 = F::Expand(p0[0]);
auto c01 = F::Expand(p0[1]);