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

Side by Side Diff: src/opts/SkNx_sse.h

Issue 1056143004: Revert of Code's more readable when SkPMFloat is an Sk4f. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « src/opts/SkNx_neon.h ('k') | src/opts/SkPMFloat_SSE2.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkNx_sse_DEFINED 8 #ifndef SkNx_sse_DEFINED
9 #define SkNx_sse_DEFINED 9 #define SkNx_sse_DEFINED
10 10
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 139
140 private: 140 private:
141 __m128d fVec; 141 __m128d fVec;
142 }; 142 };
143 143
144 template <> 144 template <>
145 class SkNf<4, float> { 145 class SkNf<4, float> {
146 typedef SkNi<4, int32_t> Ni; 146 typedef SkNi<4, int32_t> Ni;
147 public: 147 public:
148 SkNf(const __m128& vec) : fVec(vec) {} 148 SkNf(const __m128& vec) : fVec(vec) {}
149 __m128 vec() const { return fVec; }
149 150
150 SkNf() {} 151 SkNf() {}
151 explicit SkNf(float val) : fVec( _mm_set1_ps(val) ) {} 152 explicit SkNf(float val) : fVec( _mm_set1_ps(val) ) {}
152 static SkNf Load(const float vals[4]) { return _mm_loadu_ps(vals); } 153 static SkNf Load(const float vals[4]) { return _mm_loadu_ps(vals); }
153 SkNf(float a, float b, float c, float d) : fVec(_mm_setr_ps(a,b,c,d)) {} 154 SkNf(float a, float b, float c, float d) : fVec(_mm_setr_ps(a,b,c,d)) {}
154 155
155 void store(float vals[4]) const { _mm_storeu_ps(vals, fVec); } 156 void store(float vals[4]) const { _mm_storeu_ps(vals, fVec); }
156 157
157 SkNf operator + (const SkNf& o) const { return _mm_add_ps(fVec, o.fVec); } 158 SkNf operator + (const SkNf& o) const { return _mm_add_ps(fVec, o.fVec); }
158 SkNf operator - (const SkNf& o) const { return _mm_sub_ps(fVec, o.fVec); } 159 SkNf operator - (const SkNf& o) const { return _mm_sub_ps(fVec, o.fVec); }
(...skipping 15 matching lines...) Expand all
174 175
175 SkNf invert() const { return SkNf(1) / *this; } 176 SkNf invert() const { return SkNf(1) / *this; }
176 SkNf approxInvert() const { return _mm_rcp_ps(fVec); } 177 SkNf approxInvert() const { return _mm_rcp_ps(fVec); }
177 178
178 template <int k> float kth() const { 179 template <int k> float kth() const {
179 SkASSERT(0 <= k && k < 4); 180 SkASSERT(0 <= k && k < 4);
180 union { __m128 v; float fs[4]; } pun = {fVec}; 181 union { __m128 v; float fs[4]; } pun = {fVec};
181 return pun.fs[k&3]; 182 return pun.fs[k&3];
182 } 183 }
183 184
184 protected: 185 private:
185 __m128 fVec; 186 __m128 fVec;
186 }; 187 };
187 188
188 189
189 #endif//SkNx_sse_DEFINED 190 #endif//SkNx_sse_DEFINED
OLDNEW
« no previous file with comments | « src/opts/SkNx_neon.h ('k') | src/opts/SkPMFloat_SSE2.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698