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

Unified Diff: src/core/SkNx.h

Issue 1059743002: Use switch operator[](int) to kth<int>() so we can use vget_lane. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 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 | « no previous file | src/core/SkPMFloat.h » ('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 e0a4aa56ecdb6adabc50d529e65264b60f4c593c..23e78f3f229dfa7a52744572924ffb75c41f754d 100644
--- a/src/core/SkNx.h
+++ b/src/core/SkNx.h
@@ -78,9 +78,9 @@ public:
SkNf invert() const { return SkNf(fLo. invert(), fHi. invert()); }
SkNf approxInvert() const { return SkNf(fLo.approxInvert(), fHi.approxInvert()); }
- T operator[] (int k) const {
+ template <int k> T kth() const {
SkASSERT(0 <= k && k < N);
- return k < N/2 ? fLo[k] : fHi[k-N/2];
+ return k < N/2 ? fLo.template kth<k>() : fHi.template kth<k-N/2>();
}
private:
@@ -137,7 +137,7 @@ public:
SkNf invert() const { return SkNf((T)1 / fVal); }
SkNf approxInvert() const { return this->invert(); }
- T operator[] (int SkDEBUGCODE(k)) const {
+ template <int k> T kth() const {
SkASSERT(k == 0);
return fVal;
}
@@ -153,7 +153,7 @@ private:
// Generic syntax sugar that should work equally well for all SkNi and SkNf implementations.
-template <typename SkNx> SkNx operator - (const SkNx& l) { return SkNx((decltype(l[0]))0) - l; }
+template <typename SkNx> SkNx operator - (const SkNx& l) { return SkNx(0) - l; }
template <typename SkNx> SkNx& operator += (SkNx& l, const SkNx& r) { return (l = l + r); }
template <typename SkNx> SkNx& operator -= (SkNx& l, const SkNx& r) { return (l = l - r); }
« no previous file with comments | « no previous file | src/core/SkPMFloat.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698