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

Side by Side Diff: src/core/SkNx.h

Issue 1286093004: Refactor to put SkXfermode_opts inside SK_OPTS_NS. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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/core/Sk4px.h ('k') | src/core/SkOpts.cpp » ('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_DEFINED 8 #ifndef SkNx_DEFINED
9 #define SkNx_DEFINED 9 #define SkNx_DEFINED
10 10
11 11
12 #define SKNX_NO_SIMDx // Remove the x to disable SIMD for all SkNx types. 12 #define SKNX_NO_SIMDx // Remove the x to disable SIMD for all SkNx types.
13 13
14 14
15 #include "SkScalar.h" 15 #include "SkScalar.h"
16 #include "SkTypes.h" 16 #include "SkTypes.h"
17 #include <math.h> 17 #include <math.h>
18 #define REQUIRE(x) static_assert(x, #x) 18 #define REQUIRE(x) static_assert(x, #x)
19 19
20 // This file may be included multiple times by .cpp files with different flags, leading
21 // to different definitions. Usually that doesn't matter because it's all inlin ed, but
22 // in Debug modes the compilers may not inline everything. So wrap everything i n an
23 // anonymous namespace to give each includer their own silo of this code (or the linker
24 // will probably pick one randomly for us, which is rarely correct).
25 namespace {
26
27 // The default implementations just fall back on a pair of size N/2. 20 // The default implementations just fall back on a pair of size N/2.
28 21
29 template <int N, typename T> 22 template <int N, typename T>
30 class SkNi { 23 class SkNi {
31 public: 24 public:
32 SkNi() {} 25 SkNi() {}
33 SkNi(const SkNi<N/2, T>& lo, const SkNi<N/2, T>& hi) : fLo(lo), fHi(hi) {} 26 SkNi(const SkNi<N/2, T>& lo, const SkNi<N/2, T>& hi) : fLo(lo), fHi(hi) {}
34 explicit SkNi(T val) : fLo(val), fHi(val) {} 27 explicit SkNi(T val) : fLo(val), fHi(val) {}
35 static SkNi Load(const T vals[N]) { 28 static SkNi Load(const T vals[N]) {
36 return SkNi(SkNi<N/2,T>::Load(vals), SkNi<N/2,T>::Load(vals+N/2)); 29 return SkNi(SkNi<N/2,T>::Load(vals), SkNi<N/2,T>::Load(vals+N/2));
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 static double Sqrt(double val) { return ::sqrt ( val); } 238 static double Sqrt(double val) { return ::sqrt ( val); }
246 239
247 I pun() const { 240 I pun() const {
248 union { T f; I i; } pun = { fVal }; 241 union { T f; I i; } pun = { fVal };
249 return pun.i; 242 return pun.i;
250 } 243 }
251 244
252 T fVal; 245 T fVal;
253 }; 246 };
254 247
255 } // namespace
256
257 // Include platform specific specializations if available. 248 // Include platform specific specializations if available.
258 #ifndef SKNX_NO_SIMD 249 #ifndef SKNX_NO_SIMD
259 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2 250 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2
260 #include "../opts/SkNx_sse.h" 251 #include "../opts/SkNx_sse.h"
261 #elif defined(SK_ARM_HAS_NEON) 252 #elif defined(SK_ARM_HAS_NEON)
262 #include "../opts/SkNx_neon.h" 253 #include "../opts/SkNx_neon.h"
263 #endif 254 #endif
264 #endif 255 #endif
265 256
266 #undef REQUIRE 257 #undef REQUIRE
267 258
268 typedef SkNf<2, float> Sk2f; 259 typedef SkNf<2, float> Sk2f;
269 typedef SkNf<2, double> Sk2d; 260 typedef SkNf<2, double> Sk2d;
270 typedef SkNf<2, SkScalar> Sk2s; 261 typedef SkNf<2, SkScalar> Sk2s;
271 262
272 typedef SkNf<4, float> Sk4f; 263 typedef SkNf<4, float> Sk4f;
273 typedef SkNf<4, double> Sk4d; 264 typedef SkNf<4, double> Sk4d;
274 typedef SkNf<4, SkScalar> Sk4s; 265 typedef SkNf<4, SkScalar> Sk4s;
275 266
276 typedef SkNi<4, uint16_t> Sk4h; 267 typedef SkNi<4, uint16_t> Sk4h;
277 typedef SkNi<8, uint16_t> Sk8h; 268 typedef SkNi<8, uint16_t> Sk8h;
278 typedef SkNi<16, uint16_t> Sk16h; 269 typedef SkNi<16, uint16_t> Sk16h;
279 270
280 typedef SkNi<16, uint8_t> Sk16b; 271 typedef SkNi<16, uint8_t> Sk16b;
281 272
282 typedef SkNi<4, int32_t> Sk4i; 273 typedef SkNi<4, int32_t> Sk4i;
283 typedef SkNi<4, uint32_t> Sk4u; 274 typedef SkNi<4, uint32_t> Sk4u;
284 275
285 #endif//SkNx_DEFINED 276 #endif//SkNx_DEFINED
OLDNEW
« no previous file with comments | « src/core/Sk4px.h ('k') | src/core/SkOpts.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698