diff options
author | mtklein <mtklein@chromium.org> | 2015-04-27 12:08:01 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-27 12:08:01 -0700 |
commit | 1113da72eced20480491bb87ade0ffcff4eb8ea7 (patch) | |
tree | 7b786633c6b4cb7ef365af83f6ff2f0cdf72dc87 /src/core/SkNx.h | |
parent | 0dcb8e32dda93b098d19892a62a528dc6ae1017b (diff) |
Mike's radial gradient CL with better float -> int.
patch from issue 1072303005 at patchset 40001 (http://crrev.com/1072303005#ps40001)
This looks quite launchable. radial_gradient3, min of 100 samples:
N5: 985µs -> 946µs
MBP: 395µs -> 279µs
On my MBP, most of the meat looks like it's now in reading the cache and writing to dst one color at a time. Is that something we could do in float math rather than with a lookup table?
BUG=skia:
CQ_EXTRA_TRYBOTS=client.skia.compile:Build-Mac10.8-Clang-Arm7-Debug-Android-Trybot,Build-Ubuntu-GCC-Arm7-Release-Android_NoNeon-Trybot
Committed: https://skia.googlesource.com/skia/+/abf6c5cf95e921fae59efb487480e5b5081cf0ec
Review URL: https://codereview.chromium.org/1109643002
Diffstat (limited to 'src/core/SkNx.h')
-rw-r--r-- | src/core/SkNx.h | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/core/SkNx.h b/src/core/SkNx.h index 8244e9026c..65b5b97a83 100644 --- a/src/core/SkNx.h +++ b/src/core/SkNx.h @@ -39,6 +39,7 @@ template <int N, typename T> class SkNi { public: SkNi() {} + SkNi(const SkNi<N/2, T>& lo, const SkNi<N/2, T>& hi) : fLo(lo), fHi(hi) {} explicit SkNi(T val) : fLo(val), fHi(val) {} static SkNi Load(const T vals[N]) { return SkNi(SkNi<N/2,T>::Load(vals), SkNi<N/2,T>::Load(vals+N/2)); @@ -69,7 +70,6 @@ public: private: REQUIRE(0 == (N & (N-1))); - SkNi(const SkNi<N/2, T>& lo, const SkNi<N/2, T>& hi) : fLo(lo), fHi(hi) {} SkNi<N/2, T> fLo, fHi; }; @@ -77,6 +77,10 @@ private: template <int N, typename T> class SkNf { typedef SkNb<N, sizeof(T)> Nb; + + static int32_t MyNi(float); + static int64_t MyNi(double); + typedef SkNi<N, decltype(MyNi(T()))> Ni; public: SkNf() {} explicit SkNf(T val) : fLo(val), fHi(val) {} @@ -93,6 +97,8 @@ public: fHi.store(vals+N/2); } + Ni castTrunc() const { return Ni(fLo.castTrunc(), fHi.castTrunc()); } + SkNf operator + (const SkNf& o) const { return SkNf(fLo + o.fLo, fHi + o.fHi); } SkNf operator - (const SkNf& o) const { return SkNf(fLo - o.fLo, fHi - o.fHi); } SkNf operator * (const SkNf& o) const { return SkNf(fLo * o.fLo, fHi * o.fHi); } @@ -172,6 +178,10 @@ private: template <typename T> class SkNf<1,T> { typedef SkNb<1, sizeof(T)> Nb; + + static int32_t MyNi(float); + static int64_t MyNi(double); + typedef SkNi<1, decltype(MyNi(T()))> Ni; public: SkNf() {} explicit SkNf(T val) : fVal(val) {} @@ -179,6 +189,8 @@ public: void store(T vals[1]) const { vals[0] = fVal; } + Ni castTrunc() const { return Ni(fVal); } + SkNf operator + (const SkNf& o) const { return SkNf(fVal + o.fVal); } SkNf operator - (const SkNf& o) const { return SkNf(fVal - o.fVal); } SkNf operator * (const SkNf& o) const { return SkNf(fVal * o.fVal); } @@ -248,4 +260,6 @@ typedef SkNf<4, SkScalar> Sk4s; typedef SkNi<4, uint16_t> Sk4h; typedef SkNi<8, uint16_t> Sk8h; +typedef SkNi<4, int> Sk4i; + #endif//SkNx_DEFINED |