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

Unified Diff: src/core/SkNx.h

Issue 1109643002: Mike's radial gradient CL with better float -> int. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: build fixes 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gm/gradients.cpp ('k') | src/effects/gradients/SkRadialGradient.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkNx.h
diff --git a/src/core/SkNx.h b/src/core/SkNx.h
index 8244e9026cc69436ca754761dea60797250d538a..65b5b97a83e536cc928b897f17653b8c5622143f 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
« no previous file with comments | « gm/gradients.cpp ('k') | src/effects/gradients/SkRadialGradient.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698