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

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

Issue 1167153002: Remove overly-promiscuous SkNx syntax sugar. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: update test Created 5 years, 6 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/SkGeometry.cpp ('k') | src/core/SkRect.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
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 // We do double sqrts natively, or via floats for any other type. 253 // We do double sqrts natively, or via floats for any other type.
254 template <typename U> 254 template <typename U>
255 static U Sqrt(U val) { return (U) ::sqrtf((float)val); } 255 static U Sqrt(U val) { return (U) ::sqrtf((float)val); }
256 static double Sqrt(double val) { return ::sqrt ( val); } 256 static double Sqrt(double val) { return ::sqrt ( val); }
257 257
258 T fVal; 258 T fVal;
259 }; 259 };
260 260
261 } // namespace 261 } // namespace
262 262
263 // Generic syntax sugar that should work equally well for all implementations.
264 template <typename T> T operator - (const T& l) { return T(0) - l; }
265
266 template <typename L, typename R> L& operator += (L& l, const R& r) { return (l = l + r); }
267 template <typename L, typename R> L& operator -= (L& l, const R& r) { return (l = l - r); }
268 template <typename L, typename R> L& operator *= (L& l, const R& r) { return (l = l * r); }
269 template <typename L, typename R> L& operator /= (L& l, const R& r) { return (l = l / r); }
270
271 template <typename L> L& operator <<= (L& l, int bits) { return (l = l << bits); }
272 template <typename L> L& operator >>= (L& l, int bits) { return (l = l >> bits); }
273
274 // Include platform specific specializations if available. 263 // Include platform specific specializations if available.
275 #ifndef SKNX_NO_SIMD 264 #ifndef SKNX_NO_SIMD
276 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2 265 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2
277 #include "../opts/SkNx_sse.h" 266 #include "../opts/SkNx_sse.h"
278 #elif defined(SK_ARM_HAS_NEON) 267 #elif defined(SK_ARM_HAS_NEON)
279 #include "../opts/SkNx_neon.h" 268 #include "../opts/SkNx_neon.h"
280 #endif 269 #endif
281 #endif 270 #endif
282 271
283 #undef REQUIRE 272 #undef REQUIRE
284 273
285 typedef SkNf<2, float> Sk2f; 274 typedef SkNf<2, float> Sk2f;
286 typedef SkNf<2, double> Sk2d; 275 typedef SkNf<2, double> Sk2d;
287 typedef SkNf<2, SkScalar> Sk2s; 276 typedef SkNf<2, SkScalar> Sk2s;
288 277
289 typedef SkNf<4, float> Sk4f; 278 typedef SkNf<4, float> Sk4f;
290 typedef SkNf<4, double> Sk4d; 279 typedef SkNf<4, double> Sk4d;
291 typedef SkNf<4, SkScalar> Sk4s; 280 typedef SkNf<4, SkScalar> Sk4s;
292 281
293 typedef SkNi<4, uint16_t> Sk4h; 282 typedef SkNi<4, uint16_t> Sk4h;
294 typedef SkNi<8, uint16_t> Sk8h; 283 typedef SkNi<8, uint16_t> Sk8h;
295 typedef SkNi<16, uint16_t> Sk16h; 284 typedef SkNi<16, uint16_t> Sk16h;
296 285
297 typedef SkNi<16, uint8_t> Sk16b; 286 typedef SkNi<16, uint8_t> Sk16b;
298 287
299 typedef SkNi<4, int32_t> Sk4i; 288 typedef SkNi<4, int32_t> Sk4i;
300 typedef SkNi<4, uint32_t> Sk4u; 289 typedef SkNi<4, uint32_t> Sk4u;
301 290
302 #endif//SkNx_DEFINED 291 #endif//SkNx_DEFINED
OLDNEW
« no previous file with comments | « src/core/SkGeometry.cpp ('k') | src/core/SkRect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698