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

Side by Side Diff: src/opts/Sk2x_none.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 | « src/opts/Sk2x_neon.h ('k') | src/opts/Sk2x_sse.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 // It is important _not_ to put header guards here.
9 // This file will be intentionally included three times.
10
11 #include "SkTypes.h" // Keep this before any #ifdef for skbug.com/3362
12
13 #if defined(SK2X_PREAMBLE)
14 #include "SkFloatingPoint.h"
15 #include <math.h>
16
17 #elif defined(SK2X_PRIVATE)
18 T fVec[2];
19
20 #else
21
22 #define M(...) template <typename T> __VA_ARGS__ Sk2x<T>::
23
24 M() Sk2x() {}
25 M() Sk2x(T val) { fVec[0] = fVec[1] = val; }
26 M() Sk2x(T a, T b) { fVec[0] = a; fVec[1] = b; }
27
28 M(Sk2x<T>&) operator=(const Sk2x<T>& o) {
29 fVec[0] = o.fVec[0];
30 fVec[1] = o.fVec[1];
31 return *this;
32 }
33
34 M(Sk2x<T>) Load(const T vals[2]) { return Sk2x<T>(vals[0], vals[1]); }
35 M(void) store(T vals[2]) const { vals[0] = fVec[0]; vals[1] = fVec[1]; }
36
37 M(Sk2x<T>) add(const Sk2x<T>& o) const {
38 return Sk2x<T>(fVec[0] + o.fVec[0], fVec[1] + o.fVec[1]);
39 }
40 M(Sk2x<T>) subtract(const Sk2x<T>& o) const {
41 return Sk2x<T>(fVec[0] - o.fVec[0], fVec[1] - o.fVec[1]);
42 }
43 M(Sk2x<T>) multiply(const Sk2x<T>& o) const {
44 return Sk2x<T>(fVec[0] * o.fVec[0], fVec[1] * o.fVec[1]);
45 }
46 M(Sk2x<T>) divide(const Sk2x<T>& o) const {
47 return Sk2x<T>(fVec[0] / o.fVec[0], fVec[1] / o.fVec[1]);
48 }
49
50 M(Sk2x<T>) Min(const Sk2x<T>& a, const Sk2x<T>& b) {
51 return Sk2x<T>(SkTMin(a.fVec[0], b.fVec[0]), SkTMin(a.fVec[1], b.fVec[1]));
52 }
53 M(Sk2x<T>) Max(const Sk2x<T>& a, const Sk2x<T>& b) {
54 return Sk2x<T>(SkTMax(a.fVec[0], b.fVec[0]), SkTMax(a.fVec[1], b.fVec[1]));
55 }
56
57 M(Sk2x<T>) invert() const { return Sk2x<T>((T)1.0 / fVec[0], (T)1.0 / fVec [1]); }
58 M(Sk2x<T>) approxInvert() const { return this->invert(); }
59
60 #undef M
61
62 #define M template <> inline
63
64 M Sk2f Sk2f::rsqrt() const { return Sk2f(sk_float_rsqrt(fVec[0]), sk_float_rsqrt (fVec[1])); }
65 M Sk2f Sk2f:: sqrt() const { return Sk2f( sqrtf(fVec[0]), sqrtf (fVec[1])); }
66
67 M Sk2d Sk2d::rsqrt() const { return Sk2d(1.0/::sqrt(fVec[0]), 1.0/::sqrt(fVec[1] )); }
68 M Sk2d Sk2d:: sqrt() const { return Sk2d( ::sqrt(fVec[0]), ::sqrt(fVec[1] )); }
69
70 #undef M
71
72 #endif
OLDNEW
« no previous file with comments | « src/opts/Sk2x_neon.h ('k') | src/opts/Sk2x_sse.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698