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

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

Issue 1048593002: Refactor Sk2x<T> + Sk4x<T> into SkNf<N,T> and SkNi<N,T> (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: This is actually faster 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 | « include/effects/SkColorMatrixFilter.h ('k') | src/core/Sk4x.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef Sk2x_DEFINED
9 #define Sk2x_DEFINED
10
11 #include "SkTypes.h"
12 #include "SkNx.h"
13
14 #define SK2X_PREAMBLE 1
15 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2 && !defined(SKNX_NO_SIMD)
16 #include "../opts/Sk2x_sse.h"
17 #elif defined(SK_ARM_HAS_NEON) && !defined(SKNX_NO_SIMD)
18 #include "../opts/Sk2x_neon.h"
19 #else
20 #include "../opts/Sk2x_none.h"
21 #endif
22 #undef SK2X_PREAMBLE
23
24 template <typename T> class Sk2x;
25 typedef Sk2x<float> Sk2f;
26 typedef Sk2x<double> Sk2d;
27
28 #if SK_SCALAR_IS_FLOAT
29 typedef Sk2f Sk2s;
30 #elif SK_SCALAR_IS_DOUBLE
31 typedef Sk2d Sk2s;
32 #endif
33
34 // This API is meant to be manageably small, not comprehensive.
35 // Please talk to mtklein if you find yourself wanting more.
36 template <typename T> class Sk2x {
37 public:
38 Sk2x(); // Uninitialized; use Sk2x(0) for zero.
39 explicit Sk2x(T); // Same as Sk2x(T,T);
40 Sk2x(T, T);
41
42 Sk2x(const Sk2x& o) { *this = o; }
43 Sk2x& operator=(const Sk2x&);
44
45 // These assume no particular alignment.
46 static Sk2x Load(const T[2]);
47 void store(T[2]) const;
48
49 Sk2x add(const Sk2x&) const;
50 Sk2x subtract(const Sk2x&) const;
51 Sk2x multiply(const Sk2x&) const;
52 Sk2x divide(const Sk2x&) const;
53
54 Sk2x operator +(const Sk2x& o) const { return this->add(o); }
55 Sk2x operator -(const Sk2x& o) const { return this->subtract(o); }
56 Sk2x operator *(const Sk2x& o) const { return this->multiply(o); }
57 Sk2x operator /(const Sk2x& o) const { return this->divide(o); }
58
59 Sk2x& operator +=(const Sk2x& o) { return (*this = *this + o); }
60 Sk2x& operator -=(const Sk2x& o) { return (*this = *this - o); }
61 Sk2x& operator *=(const Sk2x& o) { return (*this = *this * o); }
62 Sk2x& operator /=(const Sk2x& o) { return (*this = *this / o); }
63
64 Sk2x negate() const { return Sk2x((T)0) - *this; }
65 Sk2x operator -() const { return this->negate(); }
66
67 Sk2x rsqrt() const; // Approximate 1/this->sqrt().
68 Sk2x sqrt() const; // this->multiply(this->rsqrt()) may be faster, but le ss precise.
69
70 Sk2x invert() const; // 1/this.
71 Sk2x approxInvert() const; // Approximate 1/this, usually faster but less p recise.
72
73 static Sk2x Min(const Sk2x&, const Sk2x&);
74 static Sk2x Max(const Sk2x&, const Sk2x&);
75
76 private:
77 #define SK2X_PRIVATE 1
78 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2 && !defined(SKNX_NO_SIMD)
79 #include "../opts/Sk2x_sse.h"
80 #elif defined(SK_ARM_HAS_NEON) && !defined(SKNX_NO_SIMD)
81 #include "../opts/Sk2x_neon.h"
82 #else
83 #include "../opts/Sk2x_none.h"
84 #endif
85 #undef SK2X_PRIVATE
86 };
87
88 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2 && !defined(SKNX_NO_SIMD)
89 #include "../opts/Sk2x_sse.h"
90 #elif defined(SK_ARM_HAS_NEON) && !defined(SKNX_NO_SIMD)
91 #include "../opts/Sk2x_neon.h"
92 #else
93 #include "../opts/Sk2x_none.h"
94 #endif
95
96 #endif//Sk2x_DEFINED
OLDNEW
« no previous file with comments | « include/effects/SkColorMatrixFilter.h ('k') | src/core/Sk4x.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698