aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2015-04-27 11:13:53 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-04-27 11:13:53 -0700
commitabf6c5cf95e921fae59efb487480e5b5081cf0ec (patch)
treef6f319b0a0d029afccc91b83d4ec7e45327c005c /src/core
parenta3a8eb6f630c5e163ce45503b970ea993737780d (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.android:Test-Android-GCC-Nexus5-CPU-NEON-Arm7-Debug-Trybot,Test-Android-GCC-Nexus9-CPU-Denver-Arm64-Debug-Trybot Review URL: https://codereview.chromium.org/1109643002
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkNx.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/core/SkNx.h b/src/core/SkNx.h
index 8244e9026c..5b2110bdac 100644
--- a/src/core/SkNx.h
+++ b/src/core/SkNx.h
@@ -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