diff options
author | mtklein <mtklein@chromium.org> | 2015-02-26 10:14:15 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-26 10:14:15 -0800 |
commit | e76161458afe25d987b97bf1ed40b03cdf2d7060 (patch) | |
tree | d49c8842bca917136730a799a4e2fbd756c53633 | |
parent | 7e051f9305ef2aec31167dfb8c18e59403701836 (diff) |
Spin off some fixes to land right away.
BUG=skia:
Review URL: https://codereview.chromium.org/960023002
-rw-r--r-- | include/core/SkPostConfig.h | 9 | ||||
-rw-r--r-- | src/core/Sk4x_sse.h | 24 | ||||
-rw-r--r-- | src/core/SkPMFloat.h | 10 | ||||
-rw-r--r-- | src/opts/SkPMFloat_SSE2.h | 1 | ||||
-rw-r--r-- | src/opts/SkPMFloat_neon.h | 1 | ||||
-rw-r--r-- | src/opts/SkPMFloat_none.h | 1 |
6 files changed, 22 insertions, 24 deletions
diff --git a/include/core/SkPostConfig.h b/include/core/SkPostConfig.h index 41ad930989..cf111af37c 100644 --- a/include/core/SkPostConfig.h +++ b/include/core/SkPostConfig.h @@ -68,6 +68,15 @@ # endif #endif +// As usual, there are two ways to increase alignment... the MSVC way and the everyone-else way. +#ifndef SK_STRUCT_ALIGN + #ifdef _MSC_VER + #define SK_STRUCT_ALIGN(N) __declspec(align(N)) + #else + #define SK_STRUCT_ALIGN(N) __attribute__((aligned(N))) + #endif +#endif + #if !defined(SK_SUPPORT_GPU) # define SK_SUPPORT_GPU 1 #endif diff --git a/src/core/Sk4x_sse.h b/src/core/Sk4x_sse.h index 246abd31f9..10a0a830df 100644 --- a/src/core/Sk4x_sse.h +++ b/src/core/Sk4x_sse.h @@ -21,10 +21,10 @@ // 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, @@ -83,11 +83,11 @@ M(Sk4f) LoadAligned(const float fs[4]) { return _mm_load_ps (fs); } 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. @@ -120,11 +120,11 @@ M(Sk4i) LoadAligned(const int32_t is[4]) { return _mm_load_si128 ((const __m128i 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)); } diff --git a/src/core/SkPMFloat.h b/src/core/SkPMFloat.h index 26bc9cce07..d2d83d0068 100644 --- a/src/core/SkPMFloat.h +++ b/src/core/SkPMFloat.h @@ -4,15 +4,8 @@ #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]; } @@ -37,7 +30,6 @@ struct ALIGN(16) SkPMFloat { && this->b() >= 0 && this->b() <= this->a(); } }; -#undef ALIGN #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2 #include "../opts/SkPMFloat_SSE2.h" diff --git a/src/opts/SkPMFloat_SSE2.h b/src/opts/SkPMFloat_SSE2.h index 7bacf56af7..c3dbbf2cb5 100644 --- a/src/opts/SkPMFloat_SSE2.h +++ b/src/opts/SkPMFloat_SSE2.h @@ -1,5 +1,4 @@ #include "SkColorPriv.h" -#include "SkPMFloat.h" #include <emmintrin.h> // For set(), we widen our 8 bit components (fix8) to 8-bit components in 16 bits (fix8_16), diff --git a/src/opts/SkPMFloat_neon.h b/src/opts/SkPMFloat_neon.h index f3d265573d..004b6588dd 100644 --- a/src/opts/SkPMFloat_neon.h +++ b/src/opts/SkPMFloat_neon.h @@ -1,5 +1,4 @@ #include "SkColorPriv.h" -#include "SkPMFloat.h" #include <arm_neon.h> // For set(), we widen our 8 bit components (fix8) to 8-bit components in 16 bits (fix8_16), diff --git a/src/opts/SkPMFloat_none.h b/src/opts/SkPMFloat_none.h index dee7ce6862..a11fe241cf 100644 --- a/src/opts/SkPMFloat_none.h +++ b/src/opts/SkPMFloat_none.h @@ -1,5 +1,4 @@ #include "SkColorPriv.h" -#include "SkPMFloat.h" inline void SkPMFloat::set(SkPMColor c) { float scale = 1.0f / 255.0f; |