diff options
author | mtklein <mtklein@google.com> | 2015-08-12 11:56:43 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-12 11:56:43 -0700 |
commit | 082e329887a8f1efe4e1020f0a0a6ea09961712d (patch) | |
tree | ef1018c577771f493bc499c341c701becb12b617 /src/opts | |
parent | 147dc06f3bda762f948cfdcc3fc43cecbf32e826 (diff) |
Revert of Refactor to put SkXfermode_opts inside SK_OPTS_NS. (patchset #1 id:1 of https://codereview.chromium.org/1286093004/ )
Reason for revert:
Maybe causing test / gold problems?
Original issue's description:
> Refactor to put SkXfermode_opts inside SK_OPTS_NS.
>
> Without this refactor I was getting warnings previously about having code
> inside namespace SK_OPTS_NS (e.g. namespace sse2, namespace neon) referring to
> code inside an anonymous namespace (Sk4px, SkPMFloat, Sk4f, etc) [1].
>
> That low-level code was in an anonymous namespace to allow multiple independent
> copies of its methods to be instantiated without the linker getting confused /
> offended about violating the One Definition Rule. This was only happening in
> Debug mode where the methods were not being inlined.
>
> To fix this all, I've force-inlined the methods of the low-level code and
> removed the anonymous namespace.
>
> BUG=skia:4117
>
>
> [1] Here is what those errors looked like:
>
> In file included from ../../../../src/core/SkOpts.cpp:18:0:
> ../../../../src/opts/SkXfermode_opts.h:193:7: error: 'portable::Sk4pxXfermode' has a field 'portable::Sk4pxXfermode::fProc4' whose type uses the anonymous namespace [-Werror]
> class Sk4pxXfermode : public SkProcCoeffXfermode {
> ^
> ../../../../src/opts/SkXfermode_opts.h:193:7: error: 'portable::Sk4pxXfermode' has a field 'portable::Sk4pxXfermode::fAAProc4' whose type uses the anonymous namespace [-Werror]
> ../../../../src/opts/SkXfermode_opts.h:235:7: error: 'portable::SkPMFloatXfermode' has a field 'portable::SkPMFloatXfermode::fProcF' whose type uses the anonymous namespace [-Werror]
> class SkPMFloatXfermode : public SkProcCoeffXfermode {
> ^
> cc1plus: all warnings being treated as errors
>
> Committed: https://skia.googlesource.com/skia/+/b07bee3121680b53b98b780ac08d14d374dd4c6f
TBR=djsollen@google.com,mtklein@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:4117
Review URL: https://codereview.chromium.org/1284333002
Diffstat (limited to 'src/opts')
-rw-r--r-- | src/opts/Sk4px_NEON.h | 56 | ||||
-rw-r--r-- | src/opts/Sk4px_SSE2.h | 64 | ||||
-rw-r--r-- | src/opts/Sk4px_none.h | 50 | ||||
-rw-r--r-- | src/opts/SkNx_neon.h | 4 | ||||
-rw-r--r-- | src/opts/SkNx_sse.h | 5 | ||||
-rw-r--r-- | src/opts/SkOpts_neon.cpp | 2 | ||||
-rw-r--r-- | src/opts/SkOpts_sse2.cpp | 2 | ||||
-rw-r--r-- | src/opts/SkPMFloat_neon.h | 10 | ||||
-rw-r--r-- | src/opts/SkPMFloat_none.h | 10 | ||||
-rw-r--r-- | src/opts/SkPMFloat_sse.h | 10 | ||||
-rw-r--r-- | src/opts/SkXfermode_opts.h | 4 |
11 files changed, 121 insertions, 96 deletions
diff --git a/src/opts/Sk4px_NEON.h b/src/opts/Sk4px_NEON.h index e88771d2a4..89841d927e 100644 --- a/src/opts/Sk4px_NEON.h +++ b/src/opts/Sk4px_NEON.h @@ -5,64 +5,64 @@ * found in the LICENSE file. */ -SK_ALWAYS_INLINE Sk4px Sk4px::DupPMColor(SkPMColor px) { - return Sk16b((uint8x16_t)vdupq_n_u32(px)); -} +namespace { // See Sk4px.h + +inline Sk4px Sk4px::DupPMColor(SkPMColor px) { return Sk16b((uint8x16_t)vdupq_n_u32(px)); } -SK_ALWAYS_INLINE Sk4px Sk4px::Load4(const SkPMColor px[4]) { +inline Sk4px Sk4px::Load4(const SkPMColor px[4]) { return Sk16b((uint8x16_t)vld1q_u32(px)); } -SK_ALWAYS_INLINE Sk4px Sk4px::Load2(const SkPMColor px[2]) { +inline Sk4px Sk4px::Load2(const SkPMColor px[2]) { uint32x2_t px2 = vld1_u32(px); return Sk16b((uint8x16_t)vcombine_u32(px2, px2)); } -SK_ALWAYS_INLINE Sk4px Sk4px::Load1(const SkPMColor px[1]) { +inline Sk4px Sk4px::Load1(const SkPMColor px[1]) { return Sk16b((uint8x16_t)vdupq_n_u32(*px)); } -SK_ALWAYS_INLINE void Sk4px::store4(SkPMColor px[4]) const { +inline void Sk4px::store4(SkPMColor px[4]) const { vst1q_u32(px, (uint32x4_t)this->fVec); } -SK_ALWAYS_INLINE void Sk4px::store2(SkPMColor px[2]) const { +inline void Sk4px::store2(SkPMColor px[2]) const { vst1_u32(px, (uint32x2_t)vget_low_u8(this->fVec)); } -SK_ALWAYS_INLINE void Sk4px::store1(SkPMColor px[1]) const { +inline void Sk4px::store1(SkPMColor px[1]) const { vst1q_lane_u32(px, (uint32x4_t)this->fVec, 0); } -SK_ALWAYS_INLINE Sk4px::Wide Sk4px::widenLo() const { +inline Sk4px::Wide Sk4px::widenLo() const { return Sk16h(vmovl_u8(vget_low_u8 (this->fVec)), vmovl_u8(vget_high_u8(this->fVec))); } -SK_ALWAYS_INLINE Sk4px::Wide Sk4px::widenHi() const { +inline Sk4px::Wide Sk4px::widenHi() const { return Sk16h(vshll_n_u8(vget_low_u8 (this->fVec), 8), vshll_n_u8(vget_high_u8(this->fVec), 8)); } -SK_ALWAYS_INLINE Sk4px::Wide Sk4px::widenLoHi() const { +inline Sk4px::Wide Sk4px::widenLoHi() const { auto zipped = vzipq_u8(this->fVec, this->fVec); return Sk16h((uint16x8_t)zipped.val[0], (uint16x8_t)zipped.val[1]); } -SK_ALWAYS_INLINE Sk4px::Wide Sk4px::mulWiden(const Sk16b& other) const { +inline Sk4px::Wide Sk4px::mulWiden(const Sk16b& other) const { return Sk16h(vmull_u8(vget_low_u8 (this->fVec), vget_low_u8 (other.fVec)), vmull_u8(vget_high_u8(this->fVec), vget_high_u8(other.fVec))); } -SK_ALWAYS_INLINE Sk4px Sk4px::Wide::addNarrowHi(const Sk16h& other) const { +inline Sk4px Sk4px::Wide::addNarrowHi(const Sk16h& other) const { const Sk4px::Wide o(other); // Should be no code, but allows us to access fLo, fHi. return Sk16b(vcombine_u8(vaddhn_u16(this->fLo.fVec, o.fLo.fVec), vaddhn_u16(this->fHi.fVec, o.fHi.fVec))); } -SK_ALWAYS_INLINE Sk4px Sk4px::alphas() const { +inline Sk4px Sk4px::alphas() const { auto as = vshrq_n_u32((uint32x4_t)fVec, SK_A32_SHIFT); // ___3 ___2 ___1 ___0 return Sk16b((uint8x16_t)vmulq_n_u32(as, 0x01010101)); // 3333 2222 1111 0000 } -SK_ALWAYS_INLINE Sk4px Sk4px::Load4Alphas(const SkAlpha a[4]) { +inline Sk4px Sk4px::Load4Alphas(const SkAlpha a[4]) { uint8x16_t a8 = vdupq_n_u8(0); // ____ ____ ____ ____ a8 = vld1q_lane_u8(a+0, a8, 0); // ____ ____ ____ ___0 a8 = vld1q_lane_u8(a+1, a8, 4); // ____ ____ ___1 ___0 @@ -72,7 +72,7 @@ SK_ALWAYS_INLINE Sk4px Sk4px::Load4Alphas(const SkAlpha a[4]) { return Sk16b((uint8x16_t)vmulq_n_u32(a32, 0x01010101)); // 3333 2222 1111 0000 } -SK_ALWAYS_INLINE Sk4px Sk4px::Load2Alphas(const SkAlpha a[2]) { +inline Sk4px Sk4px::Load2Alphas(const SkAlpha a[2]) { uint8x16_t a8 = vdupq_n_u8(0); // ____ ____ ____ ____ a8 = vld1q_lane_u8(a+0, a8, 0); // ____ ____ ____ ___0 a8 = vld1q_lane_u8(a+1, a8, 4); // ____ ____ ___1 ___0 @@ -80,16 +80,16 @@ SK_ALWAYS_INLINE Sk4px Sk4px::Load2Alphas(const SkAlpha a[2]) { return Sk16b((uint8x16_t)vmulq_n_u32(a32, 0x01010101)); // ____ ____ 1111 0000 } -SK_ALWAYS_INLINE Sk4px Sk4px::zeroColors() const { +inline Sk4px Sk4px::zeroColors() const { return Sk16b(vandq_u8(this->fVec, (uint8x16_t)vdupq_n_u32(0xFF << SK_A32_SHIFT))); } -SK_ALWAYS_INLINE Sk4px Sk4px::zeroAlphas() const { +inline Sk4px Sk4px::zeroAlphas() const { // vbic(a,b) == a & ~b return Sk16b(vbicq_u8(this->fVec, (uint8x16_t)vdupq_n_u32(0xFF << SK_A32_SHIFT))); } -static SK_ALWAYS_INLINE uint8x16_t widen_to_8888(uint16x4_t v) { +static inline uint8x16_t widen_to_8888(uint16x4_t v) { // RGB565 format: |R....|G.....|B....| // Bit: 16 11 5 0 @@ -115,7 +115,7 @@ static SK_ALWAYS_INLINE uint8x16_t widen_to_8888(uint16x4_t v) { vdupq_n_u32(0xFF << SK_A32_SHIFT)))); } -static SK_ALWAYS_INLINE uint16x4_t narrow_to_565(uint8x16_t w8x16) { +static inline uint16x4_t narrow_to_565(uint8x16_t w8x16) { uint32x4_t w = (uint32x4_t)w8x16; // Extract out top RGB 565 bits of each pixel, with no rounding. @@ -136,27 +136,29 @@ static SK_ALWAYS_INLINE uint16x4_t narrow_to_565(uint8x16_t w8x16) { } -SK_ALWAYS_INLINE Sk4px Sk4px::Load4(const SkPMColor16 src[4]) { +inline Sk4px Sk4px::Load4(const SkPMColor16 src[4]) { return Sk16b(widen_to_8888(vld1_u16(src))); } -SK_ALWAYS_INLINE Sk4px Sk4px::Load2(const SkPMColor16 src[2]) { +inline Sk4px Sk4px::Load2(const SkPMColor16 src[2]) { auto src2 = ((uint32_t)src[0] ) | ((uint32_t)src[1] << 16); return Sk16b(widen_to_8888(vcreate_u16(src2))); } -SK_ALWAYS_INLINE Sk4px Sk4px::Load1(const SkPMColor16 src[1]) { +inline Sk4px Sk4px::Load1(const SkPMColor16 src[1]) { return Sk16b(widen_to_8888(vcreate_u16(src[0]))); } -SK_ALWAYS_INLINE void Sk4px::store4(SkPMColor16 dst[4]) const { +inline void Sk4px::store4(SkPMColor16 dst[4]) const { vst1_u16(dst, narrow_to_565(this->fVec)); } -SK_ALWAYS_INLINE void Sk4px::store2(SkPMColor16 dst[2]) const { +inline void Sk4px::store2(SkPMColor16 dst[2]) const { auto v = narrow_to_565(this->fVec); dst[0] = vget_lane_u16(v, 0); dst[1] = vget_lane_u16(v, 1); } -SK_ALWAYS_INLINE void Sk4px::store1(SkPMColor16 dst[1]) const { +inline void Sk4px::store1(SkPMColor16 dst[1]) const { dst[0] = vget_lane_u16(narrow_to_565(this->fVec), 0); } +} // namespace + diff --git a/src/opts/Sk4px_SSE2.h b/src/opts/Sk4px_SSE2.h index f235a1560e..5e97abf308 100644 --- a/src/opts/Sk4px_SSE2.h +++ b/src/opts/Sk4px_SSE2.h @@ -5,46 +5,42 @@ * found in the LICENSE file. */ -SK_ALWAYS_INLINE Sk4px Sk4px::DupPMColor(SkPMColor px) { return Sk16b(_mm_set1_epi32(px)); } +namespace { // See Sk4px.h -SK_ALWAYS_INLINE Sk4px Sk4px::Load4(const SkPMColor px[4]) { +inline Sk4px Sk4px::DupPMColor(SkPMColor px) { return Sk16b(_mm_set1_epi32(px)); } + +inline Sk4px Sk4px::Load4(const SkPMColor px[4]) { return Sk16b(_mm_loadu_si128((const __m128i*)px)); } -SK_ALWAYS_INLINE Sk4px Sk4px::Load2(const SkPMColor px[2]) { +inline Sk4px Sk4px::Load2(const SkPMColor px[2]) { return Sk16b(_mm_loadl_epi64((const __m128i*)px)); } -SK_ALWAYS_INLINE Sk4px Sk4px::Load1(const SkPMColor px[1]) { return Sk16b(_mm_cvtsi32_si128(*px)); } +inline Sk4px Sk4px::Load1(const SkPMColor px[1]) { return Sk16b(_mm_cvtsi32_si128(*px)); } -SK_ALWAYS_INLINE void Sk4px::store4(SkPMColor px[4]) const { - _mm_storeu_si128((__m128i*)px, this->fVec); -} -SK_ALWAYS_INLINE void Sk4px::store2(SkPMColor px[2]) const { - _mm_storel_epi64((__m128i*)px, this->fVec); -} -SK_ALWAYS_INLINE void Sk4px::store1(SkPMColor px[1]) const { - *px = _mm_cvtsi128_si32(this->fVec); -} +inline void Sk4px::store4(SkPMColor px[4]) const { _mm_storeu_si128((__m128i*)px, this->fVec); } +inline void Sk4px::store2(SkPMColor px[2]) const { _mm_storel_epi64((__m128i*)px, this->fVec); } +inline void Sk4px::store1(SkPMColor px[1]) const { *px = _mm_cvtsi128_si32(this->fVec); } -SK_ALWAYS_INLINE Sk4px::Wide Sk4px::widenLo() const { +inline Sk4px::Wide Sk4px::widenLo() const { return Sk16h(_mm_unpacklo_epi8(this->fVec, _mm_setzero_si128()), _mm_unpackhi_epi8(this->fVec, _mm_setzero_si128())); } -SK_ALWAYS_INLINE Sk4px::Wide Sk4px::widenHi() const { +inline Sk4px::Wide Sk4px::widenHi() const { return Sk16h(_mm_unpacklo_epi8(_mm_setzero_si128(), this->fVec), _mm_unpackhi_epi8(_mm_setzero_si128(), this->fVec)); } -SK_ALWAYS_INLINE Sk4px::Wide Sk4px::widenLoHi() const { +inline Sk4px::Wide Sk4px::widenLoHi() const { return Sk16h(_mm_unpacklo_epi8(this->fVec, this->fVec), _mm_unpackhi_epi8(this->fVec, this->fVec)); } -SK_ALWAYS_INLINE Sk4px::Wide Sk4px::mulWiden(const Sk16b& other) const { +inline Sk4px::Wide Sk4px::mulWiden(const Sk16b& other) const { return this->widenLo() * Sk4px(other).widenLo(); } -SK_ALWAYS_INLINE Sk4px Sk4px::Wide::addNarrowHi(const Sk16h& other) const { +inline Sk4px Sk4px::Wide::addNarrowHi(const Sk16h& other) const { Sk4px::Wide r = (*this + other) >> 8; return Sk4px(_mm_packus_epi16(r.fLo.fVec, r.fHi.fVec)); } @@ -53,19 +49,19 @@ SK_ALWAYS_INLINE Sk4px Sk4px::Wide::addNarrowHi(const Sk16h& other) const { // These are safe on x86, often with no speed penalty. #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSSE3 - SK_ALWAYS_INLINE Sk4px Sk4px::alphas() const { + inline Sk4px Sk4px::alphas() const { static_assert(SK_A32_SHIFT == 24, "Intel's always little-endian."); __m128i splat = _mm_set_epi8(15,15,15,15, 11,11,11,11, 7,7,7,7, 3,3,3,3); return Sk16b(_mm_shuffle_epi8(this->fVec, splat)); } - SK_ALWAYS_INLINE Sk4px Sk4px::Load4Alphas(const SkAlpha a[4]) { + inline Sk4px Sk4px::Load4Alphas(const SkAlpha a[4]) { uint32_t as = *(const uint32_t*)a; __m128i splat = _mm_set_epi8(3,3,3,3, 2,2,2,2, 1,1,1,1, 0,0,0,0); return Sk16b(_mm_shuffle_epi8(_mm_cvtsi32_si128(as), splat)); } #else - SK_ALWAYS_INLINE Sk4px Sk4px::alphas() const { + inline Sk4px Sk4px::alphas() const { static_assert(SK_A32_SHIFT == 24, "Intel's always little-endian."); __m128i as = _mm_srli_epi32(this->fVec, 24); // ___3 ___2 ___1 ___0 as = _mm_or_si128(as, _mm_slli_si128(as, 1)); // __33 __22 __11 __00 @@ -73,7 +69,7 @@ SK_ALWAYS_INLINE Sk4px Sk4px::Wide::addNarrowHi(const Sk16h& other) const { return Sk16b(as); } - SK_ALWAYS_INLINE Sk4px Sk4px::Load4Alphas(const SkAlpha a[4]) { + inline Sk4px Sk4px::Load4Alphas(const SkAlpha a[4]) { __m128i as = _mm_cvtsi32_si128(*(const uint32_t*)a); // ____ ____ ____ 3210 as = _mm_unpacklo_epi8 (as, _mm_setzero_si128()); // ____ ____ _3_2 _1_0 as = _mm_unpacklo_epi16(as, _mm_setzero_si128()); // ___3 ___2 ___1 ___0 @@ -83,21 +79,21 @@ SK_ALWAYS_INLINE Sk4px Sk4px::Wide::addNarrowHi(const Sk16h& other) const { } #endif -SK_ALWAYS_INLINE Sk4px Sk4px::Load2Alphas(const SkAlpha a[2]) { +inline Sk4px Sk4px::Load2Alphas(const SkAlpha a[2]) { uint32_t as = *(const uint16_t*)a; // Aa -> Aa00 return Load4Alphas((const SkAlpha*)&as); } -SK_ALWAYS_INLINE Sk4px Sk4px::zeroColors() const { +inline Sk4px Sk4px::zeroColors() const { return Sk16b(_mm_and_si128(_mm_set1_epi32(0xFF << SK_A32_SHIFT), this->fVec)); } -SK_ALWAYS_INLINE Sk4px Sk4px::zeroAlphas() const { +inline Sk4px Sk4px::zeroAlphas() const { // andnot(a,b) == ~a & b return Sk16b(_mm_andnot_si128(_mm_set1_epi32(0xFF << SK_A32_SHIFT), this->fVec)); } -static SK_ALWAYS_INLINE __m128i widen_low_half_to_8888(__m128i v) { +static inline __m128i widen_low_half_to_8888(__m128i v) { // RGB565 format: |R....|G.....|B....| // Bit: 16 11 5 0 @@ -123,7 +119,7 @@ static SK_ALWAYS_INLINE __m128i widen_low_half_to_8888(__m128i v) { _mm_set1_epi32(0xFF << SK_A32_SHIFT)))); } -static SK_ALWAYS_INLINE __m128i narrow_to_565(__m128i w) { +static inline __m128i narrow_to_565(__m128i w) { // Extract out top RGB 565 bits of each pixel, with no rounding. auto r5 = _mm_and_si128(_mm_set1_epi32(31), _mm_srli_epi32(w, SK_R32_SHIFT + 3)), g6 = _mm_and_si128(_mm_set1_epi32(63), _mm_srli_epi32(w, SK_G32_SHIFT + 2)), @@ -147,27 +143,29 @@ static SK_ALWAYS_INLINE __m128i narrow_to_565(__m128i w) { return v; } -SK_ALWAYS_INLINE Sk4px Sk4px::Load4(const SkPMColor16 src[4]) { +inline Sk4px Sk4px::Load4(const SkPMColor16 src[4]) { return Sk16b(widen_low_half_to_8888(_mm_loadl_epi64((const __m128i*)src))); } -SK_ALWAYS_INLINE Sk4px Sk4px::Load2(const SkPMColor16 src[2]) { +inline Sk4px Sk4px::Load2(const SkPMColor16 src[2]) { auto src2 = ((uint32_t)src[0] ) | ((uint32_t)src[1] << 16); return Sk16b(widen_low_half_to_8888(_mm_cvtsi32_si128(src2))); } -SK_ALWAYS_INLINE Sk4px Sk4px::Load1(const SkPMColor16 src[1]) { +inline Sk4px Sk4px::Load1(const SkPMColor16 src[1]) { return Sk16b(widen_low_half_to_8888(_mm_insert_epi16(_mm_setzero_si128(), src[0], 0))); } -SK_ALWAYS_INLINE void Sk4px::store4(SkPMColor16 dst[4]) const { +inline void Sk4px::store4(SkPMColor16 dst[4]) const { _mm_storel_epi64((__m128i*)dst, narrow_to_565(this->fVec)); } -SK_ALWAYS_INLINE void Sk4px::store2(SkPMColor16 dst[2]) const { +inline void Sk4px::store2(SkPMColor16 dst[2]) const { uint32_t dst2 = _mm_cvtsi128_si32(narrow_to_565(this->fVec)); dst[0] = dst2; dst[1] = dst2 >> 16; } -SK_ALWAYS_INLINE void Sk4px::store1(SkPMColor16 dst[1]) const { +inline void Sk4px::store1(SkPMColor16 dst[1]) const { uint32_t dst2 = _mm_cvtsi128_si32(narrow_to_565(this->fVec)); dst[0] = dst2; } + +} // namespace diff --git a/src/opts/Sk4px_none.h b/src/opts/Sk4px_none.h index d2231c9ba1..540edb821d 100644 --- a/src/opts/Sk4px_none.h +++ b/src/opts/Sk4px_none.h @@ -7,52 +7,54 @@ #include "SkUtils.h" +namespace { // See Sk4px.h + static_assert(sizeof(Sk4px) == 16, "This file uses memcpy / sk_memset32, so exact size matters."); -SK_ALWAYS_INLINE Sk4px Sk4px::DupPMColor(SkPMColor px) { +inline Sk4px Sk4px::DupPMColor(SkPMColor px) { Sk4px px4 = Sk16b(); sk_memset32((uint32_t*)&px4, px, 4); return px4; } -SK_ALWAYS_INLINE Sk4px Sk4px::Load4(const SkPMColor px[4]) { +inline Sk4px Sk4px::Load4(const SkPMColor px[4]) { Sk4px px4 = Sk16b(); memcpy(&px4, px, 16); return px4; } -SK_ALWAYS_INLINE Sk4px Sk4px::Load2(const SkPMColor px[2]) { +inline Sk4px Sk4px::Load2(const SkPMColor px[2]) { Sk4px px2 = Sk16b(); memcpy(&px2, px, 8); return px2; } -SK_ALWAYS_INLINE Sk4px Sk4px::Load1(const SkPMColor px[1]) { +inline Sk4px Sk4px::Load1(const SkPMColor px[1]) { Sk4px px1 = Sk16b(); memcpy(&px1, px, 4); return px1; } -SK_ALWAYS_INLINE void Sk4px::store4(SkPMColor px[4]) const { memcpy(px, this, 16); } -SK_ALWAYS_INLINE void Sk4px::store2(SkPMColor px[2]) const { memcpy(px, this, 8); } -SK_ALWAYS_INLINE void Sk4px::store1(SkPMColor px[1]) const { memcpy(px, this, 4); } +inline void Sk4px::store4(SkPMColor px[4]) const { memcpy(px, this, 16); } +inline void Sk4px::store2(SkPMColor px[2]) const { memcpy(px, this, 8); } +inline void Sk4px::store1(SkPMColor px[1]) const { memcpy(px, this, 4); } -SK_ALWAYS_INLINE Sk4px::Wide Sk4px::widenLo() const { +inline Sk4px::Wide Sk4px::widenLo() const { return Sk16h(this->kth< 0>(), this->kth< 1>(), this->kth< 2>(), this->kth< 3>(), this->kth< 4>(), this->kth< 5>(), this->kth< 6>(), this->kth< 7>(), this->kth< 8>(), this->kth< 9>(), this->kth<10>(), this->kth<11>(), this->kth<12>(), this->kth<13>(), this->kth<14>(), this->kth<15>()); } -SK_ALWAYS_INLINE Sk4px::Wide Sk4px::widenHi() const { return this->widenLo() << 8; } +inline Sk4px::Wide Sk4px::widenHi() const { return this->widenLo() << 8; } -SK_ALWAYS_INLINE Sk4px::Wide Sk4px::widenLoHi() const { return this->widenLo() + this->widenHi(); } +inline Sk4px::Wide Sk4px::widenLoHi() const { return this->widenLo() + this->widenHi(); } -SK_ALWAYS_INLINE Sk4px::Wide Sk4px::mulWiden(const Sk16b& other) const { +inline Sk4px::Wide Sk4px::mulWiden(const Sk16b& other) const { return this->widenLo() * Sk4px(other).widenLo(); } -SK_ALWAYS_INLINE Sk4px Sk4px::Wide::addNarrowHi(const Sk16h& other) const { +inline Sk4px Sk4px::Wide::addNarrowHi(const Sk16h& other) const { Sk4px::Wide r = (*this + other) >> 8; return Sk16b(r.kth< 0>(), r.kth< 1>(), r.kth< 2>(), r.kth< 3>(), r.kth< 4>(), r.kth< 5>(), r.kth< 6>(), r.kth< 7>(), @@ -60,7 +62,7 @@ SK_ALWAYS_INLINE Sk4px Sk4px::Wide::addNarrowHi(const Sk16h& other) const { r.kth<12>(), r.kth<13>(), r.kth<14>(), r.kth<15>()); } -SK_ALWAYS_INLINE Sk4px Sk4px::alphas() const { +inline Sk4px Sk4px::alphas() const { static_assert(SK_A32_SHIFT == 24, "This method assumes little-endian."); return Sk16b(this->kth< 3>(), this->kth< 3>(), this->kth< 3>(), this->kth< 3>(), this->kth< 7>(), this->kth< 7>(), this->kth< 7>(), this->kth< 7>(), @@ -68,21 +70,21 @@ SK_ALWAYS_INLINE Sk4px Sk4px::alphas() const { this->kth<15>(), this->kth<15>(), this->kth<15>(), this->kth<15>()); } -SK_ALWAYS_INLINE Sk4px Sk4px::Load4Alphas(const SkAlpha a[4]) { +inline Sk4px Sk4px::Load4Alphas(const SkAlpha a[4]) { return Sk16b(a[0], a[0], a[0], a[0], a[1], a[1], a[1], a[1], a[2], a[2], a[2], a[2], a[3], a[3], a[3], a[3]); } -SK_ALWAYS_INLINE Sk4px Sk4px::Load2Alphas(const SkAlpha a[2]) { +inline Sk4px Sk4px::Load2Alphas(const SkAlpha a[2]) { return Sk16b(a[0], a[0], a[0], a[0], a[1], a[1], a[1], a[1], 0,0,0,0, 0,0,0,0); } -SK_ALWAYS_INLINE Sk4px Sk4px::zeroAlphas() const { +inline Sk4px Sk4px::zeroAlphas() const { static_assert(SK_A32_SHIFT == 24, "This method assumes little-endian."); return Sk16b(this->kth< 0>(), this->kth< 1>(), this->kth< 2>(), 0, this->kth< 4>(), this->kth< 5>(), this->kth< 6>(), 0, @@ -90,7 +92,7 @@ SK_ALWAYS_INLINE Sk4px Sk4px::zeroAlphas() const { this->kth<12>(), this->kth<13>(), this->kth<14>(), 0); } -SK_ALWAYS_INLINE Sk4px Sk4px::zeroColors() const { +inline Sk4px Sk4px::zeroColors() const { static_assert(SK_A32_SHIFT == 24, "This method assumes little-endian."); return Sk16b(0,0,0, this->kth< 3>(), 0,0,0, this->kth< 7>(), @@ -98,33 +100,35 @@ SK_ALWAYS_INLINE Sk4px Sk4px::zeroColors() const { 0,0,0, this->kth<15>()); } -SK_ALWAYS_INLINE Sk4px Sk4px::Load4(const SkPMColor16 src[4]) { +inline Sk4px Sk4px::Load4(const SkPMColor16 src[4]) { SkPMColor src32[4]; for (int i = 0; i < 4; i++) { src32[i] = SkPixel16ToPixel32(src[i]); } return Load4(src32); } -SK_ALWAYS_INLINE Sk4px Sk4px::Load2(const SkPMColor16 src[2]) { +inline Sk4px Sk4px::Load2(const SkPMColor16 src[2]) { SkPMColor src32[2]; for (int i = 0; i < 2; i++) { src32[i] = SkPixel16ToPixel32(src[i]); } return Load2(src32); } -SK_ALWAYS_INLINE Sk4px Sk4px::Load1(const SkPMColor16 src[1]) { +inline Sk4px Sk4px::Load1(const SkPMColor16 src[1]) { SkPMColor src32 = SkPixel16ToPixel32(src[0]); return Load1(&src32); } -SK_ALWAYS_INLINE void Sk4px::store4(SkPMColor16 dst[4]) const { +inline void Sk4px::store4(SkPMColor16 dst[4]) const { SkPMColor dst32[4]; this->store4(dst32); for (int i = 0; i < 4; i++) { dst[i] = SkPixel32ToPixel16(dst32[i]); } } -SK_ALWAYS_INLINE void Sk4px::store2(SkPMColor16 dst[2]) const { +inline void Sk4px::store2(SkPMColor16 dst[2]) const { SkPMColor dst32[2]; this->store2(dst32); for (int i = 0; i < 2; i++) { dst[i] = SkPixel32ToPixel16(dst32[i]); } } -SK_ALWAYS_INLINE void Sk4px::store1(SkPMColor16 dst[1]) const { +inline void Sk4px::store1(SkPMColor16 dst[1]) const { SkPMColor dst32; this->store1(&dst32); dst[0] = SkPixel32ToPixel16(dst32); } + +} // namespace diff --git a/src/opts/SkNx_neon.h b/src/opts/SkNx_neon.h index e9e7bf5230..660b92c6b0 100644 --- a/src/opts/SkNx_neon.h +++ b/src/opts/SkNx_neon.h @@ -8,6 +8,8 @@ #ifndef SkNx_neon_DEFINED #define SkNx_neon_DEFINED +namespace { // See SkNx.h + // Well, this is absurd. The shifts require compile-time constant arguments. #define SHIFT8(op, v, bits) switch(bits) { \ @@ -381,4 +383,6 @@ public: #undef SHIFT16 #undef SHIFT8 +} // namespace + #endif//SkNx_neon_DEFINED diff --git a/src/opts/SkNx_sse.h b/src/opts/SkNx_sse.h index 75b35845a8..e165f58737 100644 --- a/src/opts/SkNx_sse.h +++ b/src/opts/SkNx_sse.h @@ -10,6 +10,9 @@ // This file may assume <= SSE2, but must check SK_CPU_SSE_LEVEL for anything more recent. +namespace { // See SkNx.h + + template <> class SkNf<2, float> { public: @@ -310,4 +313,6 @@ public: __m128i fVec; }; +} // namespace + #endif//SkNx_sse_DEFINED diff --git a/src/opts/SkOpts_neon.cpp b/src/opts/SkOpts_neon.cpp index a6d3f00d20..789a977238 100644 --- a/src/opts/SkOpts_neon.cpp +++ b/src/opts/SkOpts_neon.cpp @@ -21,7 +21,7 @@ namespace SkOpts { rsqrt = neon::rsqrt; memset16 = neon::memset16; memset32 = neon::memset32; - create_xfermode = neon::create_xfermode; + create_xfermode = SkCreate4pxXfermode; box_blur_xx = neon::box_blur_xx; box_blur_xy = neon::box_blur_xy; diff --git a/src/opts/SkOpts_sse2.cpp b/src/opts/SkOpts_sse2.cpp index b2f0262263..3440676935 100644 --- a/src/opts/SkOpts_sse2.cpp +++ b/src/opts/SkOpts_sse2.cpp @@ -18,7 +18,7 @@ namespace SkOpts { void Init_sse2() { memset16 = sse2::memset16; memset32 = sse2::memset32; - create_xfermode = sse2::create_xfermode; + create_xfermode = SkCreate4pxXfermode; box_blur_xx = sse2::box_blur_xx; box_blur_xy = sse2::box_blur_xy; diff --git a/src/opts/SkPMFloat_neon.h b/src/opts/SkPMFloat_neon.h index edbbc58b5a..8bee5b551a 100644 --- a/src/opts/SkPMFloat_neon.h +++ b/src/opts/SkPMFloat_neon.h @@ -5,7 +5,9 @@ * found in the LICENSE file. */ -SK_ALWAYS_INLINE SkPMFloat::SkPMFloat(SkPMColor c) { +namespace { // See SkPMFloat.h + +inline SkPMFloat::SkPMFloat(SkPMColor c) { SkPMColorAssert(c); uint8x8_t fix8 = (uint8x8_t)vdup_n_u32(c); uint16x8_t fix8_16 = vmovl_u8(fix8); @@ -14,7 +16,7 @@ SK_ALWAYS_INLINE SkPMFloat::SkPMFloat(SkPMColor c) { SkASSERT(this->isValid()); } -SK_ALWAYS_INLINE SkPMColor SkPMFloat::round() const { +inline SkPMColor SkPMFloat::round() const { // vcvt_u32_f32 truncates, so we round manually by adding a half before converting. float32x4_t rounded = vmlaq_f32(vdupq_n_f32(0.5f), fVec, vdupq_n_f32(255)); uint32x4_t fix8_32 = vcvtq_u32_f32(rounded); @@ -25,7 +27,9 @@ SK_ALWAYS_INLINE SkPMColor SkPMFloat::round() const { return c; } -SK_ALWAYS_INLINE Sk4f SkPMFloat::alphas() const { +inline Sk4f SkPMFloat::alphas() const { static_assert(SK_A32_SHIFT == 24, "Assuming little-endian."); return vdupq_lane_f32(vget_high_f32(fVec), 1); // Duplicate high lane of high half i.e. lane 3. } + +} // namespace diff --git a/src/opts/SkPMFloat_none.h b/src/opts/SkPMFloat_none.h index ca98b1ab7e..518ad159ff 100644 --- a/src/opts/SkPMFloat_none.h +++ b/src/opts/SkPMFloat_none.h @@ -5,7 +5,9 @@ * found in the LICENSE file. */ -SK_ALWAYS_INLINE SkPMFloat::SkPMFloat(SkPMColor c) { +namespace { // See SkPMFloat.h + +inline SkPMFloat::SkPMFloat(SkPMColor c) { float inv255 = 1.0f/255; *this = SkPMFloat::FromARGB(SkGetPackedA32(c) * inv255, SkGetPackedR32(c) * inv255, @@ -14,7 +16,7 @@ SK_ALWAYS_INLINE SkPMFloat::SkPMFloat(SkPMColor c) { SkASSERT(this->isValid()); } -SK_ALWAYS_INLINE SkPMColor SkPMFloat::round() const { +inline SkPMColor SkPMFloat::round() const { float a = this->a(), r = this->r(), g = this->g(), @@ -28,6 +30,8 @@ SK_ALWAYS_INLINE SkPMColor SkPMFloat::round() const { return c; } -SK_ALWAYS_INLINE Sk4f SkPMFloat::alphas() const { +inline Sk4f SkPMFloat::alphas() const { return Sk4f(this->a()); } + +} // namespace diff --git a/src/opts/SkPMFloat_sse.h b/src/opts/SkPMFloat_sse.h index 016644e052..28aa90bf29 100644 --- a/src/opts/SkPMFloat_sse.h +++ b/src/opts/SkPMFloat_sse.h @@ -5,7 +5,9 @@ * found in the LICENSE file. */ -SK_ALWAYS_INLINE SkPMFloat::SkPMFloat(SkPMColor c) { +namespace { // See SkPMFloat.h + +inline SkPMFloat::SkPMFloat(SkPMColor c) { SkPMColorAssert(c); #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSSE3 const int _ = 255; // Zero these bytes. @@ -20,7 +22,7 @@ SK_ALWAYS_INLINE SkPMFloat::SkPMFloat(SkPMColor c) { SkASSERT(this->isValid()); } -SK_ALWAYS_INLINE SkPMColor SkPMFloat::round() const { +inline SkPMColor SkPMFloat::round() const { // We don't use _mm_cvtps_epi32, because we want precise control over how 0.5 rounds (up). __m128 scaled = _mm_mul_ps(_mm_set1_ps(255), fVec); __m128i fix8_32 = _mm_cvttps_epi32(_mm_add_ps(_mm_set1_ps(0.5f), scaled)), @@ -31,7 +33,9 @@ SK_ALWAYS_INLINE SkPMColor SkPMFloat::round() const { return c; } -SK_ALWAYS_INLINE Sk4f SkPMFloat::alphas() const { +inline Sk4f SkPMFloat::alphas() const { static_assert(SK_A32_SHIFT == 24, ""); return _mm_shuffle_ps(fVec, fVec, 0xff); // Read as 11 11 11 11, copying lane 3 to all lanes. } + +} // namespace diff --git a/src/opts/SkXfermode_opts.h b/src/opts/SkXfermode_opts.h index 97c0243053..c11f6c0e81 100644 --- a/src/opts/SkXfermode_opts.h +++ b/src/opts/SkXfermode_opts.h @@ -12,7 +12,7 @@ #include "SkPMFloat.h" #include "SkXfermode_proccoeff.h" -namespace SK_OPTS_NS { +namespace /* TODO: SK_OPTS_NS */ { // Most xfermodes can be done most efficiently 4 pixels at a time in 8 or 16-bit fixed point. #define XFERMODE(Name) static Sk4px SK_VECTORCALL Name(Sk4px d, Sk4px s) @@ -264,7 +264,7 @@ private: typedef SkProcCoeffXfermode INHERITED; }; -static SkXfermode* create_xfermode(const ProcCoeff& rec, SkXfermode::Mode mode) { +static SkXfermode* SkCreate4pxXfermode(const ProcCoeff& rec, SkXfermode::Mode mode) { switch (mode) { #define CASE(Mode) case SkXfermode::k##Mode##_Mode: \ return SkNEW_ARGS(Sk4pxXfermode, (rec, mode, &Mode, &xfer_aa<Mode>)) |