// These are all free, zero instructions.
// MSVC insists we use _mm_castA_B(a) instead of (B)a.
- static __m128 as_4f(__m128i v) { return _mm_castsi128_ps(v); }
- static __m128 as_4f(__m128 v) { return v ; }
- static __m128i as_4i(__m128i v) { return v ; }
- static __m128i as_4i(__m128 v) { return _mm_castps_si128(v); }
+ static inline __m128 as_4f(__m128i v) { return _mm_castsi128_ps(v); }
+ static inline __m128 as_4f(__m128 v) { return v ; }
+ static inline __m128i as_4i(__m128i v) { return v ; }
+ static inline __m128i as_4i(__m128 v) { return _mm_castps_si128(v); }
#elif defined(SK4X_PRIVATE)
// It'd be slightly faster to call _mm_cmpeq_epi32() on an unintialized register and itself,
M(void) store (float fs[4]) const { _mm_storeu_ps(fs, fVec); }
M(void) storeAligned(float fs[4]) const { _mm_store_ps (fs, fVec); }
-template <> template <>
-Sk4i Sk4f::reinterpret<Sk4i>() const { return as_4i(fVec); }
+template <>
+M(Sk4i) reinterpret<Sk4i>() const { return as_4i(fVec); }
-template <> template <>
-Sk4i Sk4f::cast<Sk4i>() const { return _mm_cvtps_epi32(fVec); }
+template <>
+M(Sk4i) cast<Sk4i>() const { return _mm_cvtps_epi32(fVec); }
// We're going to try a little experiment here and skip allTrue(), anyTrue(), and bit-manipulators
// for Sk4f. Code that calls them probably does so accidentally.
M(void) store (int32_t is[4]) const { _mm_storeu_si128((__m128i*)is, fVec); }
M(void) storeAligned(int32_t is[4]) const { _mm_store_si128 ((__m128i*)is, fVec); }
-template <> template <>
-Sk4f Sk4i::reinterpret<Sk4f>() const { return as_4f(fVec); }
+template <>
+M(Sk4f) reinterpret<Sk4f>() const { return as_4f(fVec); }
-template <> template <>
-Sk4f Sk4i::cast<Sk4f>() const { return _mm_cvtepi32_ps(fVec); }
+template <>
+M(Sk4f) cast<Sk4f>() const { return _mm_cvtepi32_ps(fVec); }
M(bool) allTrue() const { return 0xf == _mm_movemask_ps(as_4f(fVec)); }
M(bool) anyTrue() const { return 0x0 != _mm_movemask_ps(as_4f(fVec)); }
#include "SkTypes.h"
#include "SkColor.h"
-// As usual, there are two ways to increase alignment... the MSVC way and the everyone-else way.
-#ifdef _MSC_VER
- #define ALIGN(N) __declspec(align(N))
-#else
- #define ALIGN(N) __attribute__((aligned(N)))
-#endif
-
// A pre-multiplied color in the same order as SkPMColor storing each component as a float.
-struct ALIGN(16) SkPMFloat {
+struct SK_STRUCT_ALIGN(16) SkPMFloat {
float fColor[4];
float a() const { return fColor[SK_A32_SHIFT / 8]; }
&& this->b() >= 0 && this->b() <= this->a();
}
};
-#undef ALIGN
#if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2
#include "../opts/SkPMFloat_SSE2.h"