| OLD | NEW |
| (Empty) |
| 1 #ifndef Sk4x_DEFINED | |
| 2 #define Sk4x_DEFINED | |
| 3 | |
| 4 #include "SkTypes.h" | |
| 5 #include "SkNx.h" | |
| 6 | |
| 7 #define SK4X_PREAMBLE 1 | |
| 8 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2 && !defined(SKNX_NO_SIMD) | |
| 9 #include "../opts/Sk4x_sse.h" | |
| 10 #elif defined(SK_ARM_HAS_NEON) && !defined(SKNX_NO_SIMD) | |
| 11 #include "../opts/Sk4x_neon.h" | |
| 12 #else | |
| 13 #include "../opts/Sk4x_none.h" | |
| 14 #endif | |
| 15 #undef SK4X_PREAMBLE | |
| 16 | |
| 17 template <typename T> class Sk4x; | |
| 18 typedef Sk4x<float> Sk4f; | |
| 19 typedef Sk4x<int32_t> Sk4i; | |
| 20 | |
| 21 // Some Sk4x methods are implemented only for Sk4f or Sk4i. | |
| 22 // They might be unavailable, really slow, or just a bad idea. | |
| 23 // Talk to mtklein if you find yourself unable to link and | |
| 24 // really need one of those methods. | |
| 25 | |
| 26 template <typename T> class Sk4x { | |
| 27 public: | |
| 28 Sk4x(); // Uninitialized; use Sk4x(0) for zero. | |
| 29 explicit Sk4x(T); // Same as Sk4x(T,T,T,T); | |
| 30 Sk4x(T, T, T, T); | |
| 31 | |
| 32 Sk4x(const Sk4x&); | |
| 33 Sk4x& operator=(const Sk4x&); | |
| 34 | |
| 35 static Sk4x Load (const T[4]); | |
| 36 static Sk4x LoadAligned(const T[4]); | |
| 37 | |
| 38 void store (T[4]) const; | |
| 39 void storeAligned(T[4]) const; | |
| 40 | |
| 41 template <typename Dst> Dst reinterpret() const; | |
| 42 template <typename Dst> Dst cast() const; | |
| 43 | |
| 44 bool allTrue() const; | |
| 45 bool anyTrue() const; | |
| 46 | |
| 47 Sk4x bitNot() const; | |
| 48 Sk4x bitAnd(const Sk4x&) const; | |
| 49 Sk4x bitOr(const Sk4x&) const; | |
| 50 // TODO: Sk4x bitAndNot(const Sk4x&) const; is efficient in SSE. | |
| 51 Sk4x add(const Sk4x&) const; | |
| 52 Sk4x subtract(const Sk4x&) const; | |
| 53 Sk4x multiply(const Sk4x&) const; | |
| 54 Sk4x divide(const Sk4x&) const; | |
| 55 | |
| 56 // TODO: why doesn't MSVC like operator~() ? | |
| 57 //Sk4x operator ~() const { return this->bitNot(); } | |
| 58 Sk4x operator &(const Sk4x& o) const { return this->bitAnd(o); } | |
| 59 Sk4x operator |(const Sk4x& o) const { return this->bitOr (o); } | |
| 60 Sk4x operator +(const Sk4x& o) const { return this->add(o); } | |
| 61 Sk4x operator -(const Sk4x& o) const { return this->subtract(o); } | |
| 62 Sk4x operator *(const Sk4x& o) const { return this->multiply(o); } | |
| 63 Sk4x operator /(const Sk4x& o) const { return this->divide(o); } | |
| 64 | |
| 65 Sk4x& operator &=(const Sk4x& o) { return (*this = *this & o); } | |
| 66 Sk4x& operator |=(const Sk4x& o) { return (*this = *this | o); } | |
| 67 Sk4x& operator +=(const Sk4x& o) { return (*this = *this + o); } | |
| 68 Sk4x& operator -=(const Sk4x& o) { return (*this = *this - o); } | |
| 69 Sk4x& operator *=(const Sk4x& o) { return (*this = *this * o); } | |
| 70 Sk4x& operator /=(const Sk4x& o) { return (*this = *this / o); } | |
| 71 | |
| 72 Sk4x negate() const { return Sk4x((T)0) - *this; } | |
| 73 Sk4x operator -() const { return this->negate(); } | |
| 74 | |
| 75 Sk4x rsqrt() const; // Approximate reciprocal sqrt(). | |
| 76 Sk4x sqrt() const; // this->multiply(this->rsqrt()) may be faster, but le
ss precise. | |
| 77 | |
| 78 Sk4i equal(const Sk4x&) const; | |
| 79 Sk4i notEqual(const Sk4x&) const; | |
| 80 Sk4i lessThan(const Sk4x&) const; | |
| 81 Sk4i greaterThan(const Sk4x&) const; | |
| 82 Sk4i lessThanEqual(const Sk4x&) const; | |
| 83 Sk4i greaterThanEqual(const Sk4x&) const; | |
| 84 | |
| 85 Sk4i operator ==(const Sk4x& o) const { return this->equal(o); } | |
| 86 Sk4i operator !=(const Sk4x& o) const { return this->notEqual(o); } | |
| 87 Sk4i operator <(const Sk4x& o) const { return this->lessThan(o); } | |
| 88 Sk4i operator >(const Sk4x& o) const { return this->greaterThan(o); } | |
| 89 Sk4i operator <=(const Sk4x& o) const { return this->lessThanEqual(o); } | |
| 90 Sk4i operator >=(const Sk4x& o) const { return this->greaterThanEqual(o); } | |
| 91 | |
| 92 static Sk4x Min(const Sk4x& a, const Sk4x& b); | |
| 93 static Sk4x Max(const Sk4x& a, const Sk4x& b); | |
| 94 | |
| 95 // Swizzles, where this == abcd. | |
| 96 Sk4x aacc() const; | |
| 97 Sk4x bbdd() const; | |
| 98 Sk4x badc() const; | |
| 99 | |
| 100 private: | |
| 101 // It's handy to have Sk4f and Sk4i be mutual friends. | |
| 102 template <typename S> friend class Sk4x; | |
| 103 | |
| 104 #define SK4X_PRIVATE 1 | |
| 105 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2 && !defined(SKNX_NO_SIMD) | |
| 106 #include "../opts/Sk4x_sse.h" | |
| 107 #elif defined(SK_ARM_HAS_NEON) && !defined(SKNX_NO_SIMD) | |
| 108 #include "../opts/Sk4x_neon.h" | |
| 109 #else | |
| 110 #include "../opts/Sk4x_none.h" | |
| 111 #endif | |
| 112 #undef SK4X_PRIVATE | |
| 113 }; | |
| 114 | |
| 115 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2 && !defined(SKNX_NO_SIMD) | |
| 116 #include "../opts/Sk4x_sse.h" | |
| 117 #elif defined(SK_ARM_HAS_NEON) && !defined(SKNX_NO_SIMD) | |
| 118 #include "../opts/Sk4x_neon.h" | |
| 119 #else | |
| 120 #include "../opts/Sk4x_none.h" | |
| 121 #endif | |
| 122 | |
| 123 #endif//Sk4x_DEFINED | |
| OLD | NEW |