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
This commit is contained in:
parent
147dc06f3b
commit
082e329887
@ -12,6 +12,13 @@
|
|||||||
#include "SkColor.h"
|
#include "SkColor.h"
|
||||||
#include "SkColorPriv.h"
|
#include "SkColorPriv.h"
|
||||||
|
|
||||||
|
// This file may be included multiple times by .cpp files with different flags, leading
|
||||||
|
// to different definitions. Usually that doesn't matter because it's all inlined, but
|
||||||
|
// in Debug modes the compilers may not inline everything. So wrap everything in an
|
||||||
|
// anonymous namespace to give each includer their own silo of this code (or the linker
|
||||||
|
// will probably pick one randomly for us, which is rarely correct).
|
||||||
|
namespace {
|
||||||
|
|
||||||
// 1, 2 or 4 SkPMColors, generally vectorized.
|
// 1, 2 or 4 SkPMColors, generally vectorized.
|
||||||
class Sk4px : public Sk16b {
|
class Sk4px : public Sk16b {
|
||||||
public:
|
public:
|
||||||
@ -219,6 +226,8 @@ private:
|
|||||||
typedef Sk16b INHERITED;
|
typedef Sk16b INHERITED;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
#ifdef SKNX_NO_SIMD
|
#ifdef SKNX_NO_SIMD
|
||||||
#include "../opts/Sk4px_none.h"
|
#include "../opts/Sk4px_none.h"
|
||||||
#else
|
#else
|
||||||
|
@ -17,6 +17,13 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#define REQUIRE(x) static_assert(x, #x)
|
#define REQUIRE(x) static_assert(x, #x)
|
||||||
|
|
||||||
|
// This file may be included multiple times by .cpp files with different flags, leading
|
||||||
|
// to different definitions. Usually that doesn't matter because it's all inlined, but
|
||||||
|
// in Debug modes the compilers may not inline everything. So wrap everything in an
|
||||||
|
// anonymous namespace to give each includer their own silo of this code (or the linker
|
||||||
|
// will probably pick one randomly for us, which is rarely correct).
|
||||||
|
namespace {
|
||||||
|
|
||||||
// The default implementations just fall back on a pair of size N/2.
|
// The default implementations just fall back on a pair of size N/2.
|
||||||
|
|
||||||
template <int N, typename T>
|
template <int N, typename T>
|
||||||
@ -245,6 +252,8 @@ protected:
|
|||||||
T fVal;
|
T fVal;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
// Include platform specific specializations if available.
|
// Include platform specific specializations if available.
|
||||||
#ifndef SKNX_NO_SIMD
|
#ifndef SKNX_NO_SIMD
|
||||||
#if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2
|
#if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2
|
||||||
|
@ -37,7 +37,7 @@ namespace SkOpts {
|
|||||||
decltype(rsqrt) rsqrt = portable::rsqrt;
|
decltype(rsqrt) rsqrt = portable::rsqrt;
|
||||||
decltype(memset16) memset16 = portable::memset16;
|
decltype(memset16) memset16 = portable::memset16;
|
||||||
decltype(memset32) memset32 = portable::memset32;
|
decltype(memset32) memset32 = portable::memset32;
|
||||||
decltype(create_xfermode) create_xfermode = portable::create_xfermode;
|
decltype(create_xfermode) create_xfermode = SkCreate4pxXfermode;
|
||||||
|
|
||||||
decltype(box_blur_xx) box_blur_xx = portable::box_blur_xx;
|
decltype(box_blur_xx) box_blur_xx = portable::box_blur_xx;
|
||||||
decltype(box_blur_xy) box_blur_xy = portable::box_blur_xy;
|
decltype(box_blur_xy) box_blur_xy = portable::box_blur_xy;
|
||||||
|
@ -13,6 +13,13 @@
|
|||||||
#include "SkColorPriv.h"
|
#include "SkColorPriv.h"
|
||||||
#include "SkNx.h"
|
#include "SkNx.h"
|
||||||
|
|
||||||
|
// This file may be included multiple times by .cpp files with different flags, leading
|
||||||
|
// to different definitions. Usually that doesn't matter because it's all inlined, but
|
||||||
|
// in Debug modes the compilers may not inline everything. So wrap everything in an
|
||||||
|
// anonymous namespace to give each includer their own silo of this code (or the linker
|
||||||
|
// will probably pick one randomly for us, which is rarely correct).
|
||||||
|
namespace {
|
||||||
|
|
||||||
// A pre-multiplied color storing each component in the same order as SkPMColor,
|
// A pre-multiplied color storing each component in the same order as SkPMColor,
|
||||||
// but as a float in the range [0, 1].
|
// but as a float in the range [0, 1].
|
||||||
class SkPMFloat : public Sk4f {
|
class SkPMFloat : public Sk4f {
|
||||||
@ -52,6 +59,8 @@ private:
|
|||||||
typedef Sk4f INHERITED;
|
typedef Sk4f INHERITED;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
#ifdef SKNX_NO_SIMD
|
#ifdef SKNX_NO_SIMD
|
||||||
// Platform implementations of SkPMFloat assume Sk4f uses SSE or NEON. _none is generic.
|
// Platform implementations of SkPMFloat assume Sk4f uses SSE or NEON. _none is generic.
|
||||||
#include "../opts/SkPMFloat_none.h"
|
#include "../opts/SkPMFloat_none.h"
|
||||||
|
@ -5,64 +5,64 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
SK_ALWAYS_INLINE Sk4px Sk4px::DupPMColor(SkPMColor px) {
|
namespace { // See Sk4px.h
|
||||||
return Sk16b((uint8x16_t)vdupq_n_u32(px));
|
|
||||||
}
|
|
||||||
|
|
||||||
SK_ALWAYS_INLINE Sk4px Sk4px::Load4(const SkPMColor px[4]) {
|
inline Sk4px Sk4px::DupPMColor(SkPMColor px) { return Sk16b((uint8x16_t)vdupq_n_u32(px)); }
|
||||||
|
|
||||||
|
inline Sk4px Sk4px::Load4(const SkPMColor px[4]) {
|
||||||
return Sk16b((uint8x16_t)vld1q_u32(px));
|
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);
|
uint32x2_t px2 = vld1_u32(px);
|
||||||
return Sk16b((uint8x16_t)vcombine_u32(px2, px2));
|
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));
|
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);
|
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));
|
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);
|
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)),
|
return Sk16h(vmovl_u8(vget_low_u8 (this->fVec)),
|
||||||
vmovl_u8(vget_high_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),
|
return Sk16h(vshll_n_u8(vget_low_u8 (this->fVec), 8),
|
||||||
vshll_n_u8(vget_high_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);
|
auto zipped = vzipq_u8(this->fVec, this->fVec);
|
||||||
return Sk16h((uint16x8_t)zipped.val[0],
|
return Sk16h((uint16x8_t)zipped.val[0],
|
||||||
(uint16x8_t)zipped.val[1]);
|
(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)),
|
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)));
|
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.
|
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),
|
return Sk16b(vcombine_u8(vaddhn_u16(this->fLo.fVec, o.fLo.fVec),
|
||||||
vaddhn_u16(this->fHi.fVec, o.fHi.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
|
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
|
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); // ____ ____ ____ ____
|
uint8x16_t a8 = vdupq_n_u8(0); // ____ ____ ____ ____
|
||||||
a8 = vld1q_lane_u8(a+0, a8, 0); // ____ ____ ____ ___0
|
a8 = vld1q_lane_u8(a+0, a8, 0); // ____ ____ ____ ___0
|
||||||
a8 = vld1q_lane_u8(a+1, a8, 4); // ____ ____ ___1 ___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
|
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); // ____ ____ ____ ____
|
uint8x16_t a8 = vdupq_n_u8(0); // ____ ____ ____ ____
|
||||||
a8 = vld1q_lane_u8(a+0, a8, 0); // ____ ____ ____ ___0
|
a8 = vld1q_lane_u8(a+0, a8, 0); // ____ ____ ____ ___0
|
||||||
a8 = vld1q_lane_u8(a+1, a8, 4); // ____ ____ ___1 ___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
|
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)));
|
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
|
// vbic(a,b) == a & ~b
|
||||||
return Sk16b(vbicq_u8(this->fVec, (uint8x16_t)vdupq_n_u32(0xFF << SK_A32_SHIFT)));
|
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....|
|
// RGB565 format: |R....|G.....|B....|
|
||||||
// Bit: 16 11 5 0
|
// 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))));
|
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;
|
uint32x4_t w = (uint32x4_t)w8x16;
|
||||||
|
|
||||||
// Extract out top RGB 565 bits of each pixel, with no rounding.
|
// 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)));
|
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] )
|
auto src2 = ((uint32_t)src[0] )
|
||||||
| ((uint32_t)src[1] << 16);
|
| ((uint32_t)src[1] << 16);
|
||||||
return Sk16b(widen_to_8888(vcreate_u16(src2)));
|
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])));
|
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));
|
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);
|
auto v = narrow_to_565(this->fVec);
|
||||||
dst[0] = vget_lane_u16(v, 0);
|
dst[0] = vget_lane_u16(v, 0);
|
||||||
dst[1] = vget_lane_u16(v, 1);
|
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);
|
dst[0] = vget_lane_u16(narrow_to_565(this->fVec), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
@ -5,46 +5,42 @@
|
|||||||
* found in the LICENSE file.
|
* 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));
|
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));
|
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 {
|
inline void Sk4px::store4(SkPMColor px[4]) const { _mm_storeu_si128((__m128i*)px, this->fVec); }
|
||||||
_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 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
SK_ALWAYS_INLINE Sk4px::Wide Sk4px::widenLo() const {
|
inline Sk4px::Wide Sk4px::widenLo() const {
|
||||||
return Sk16h(_mm_unpacklo_epi8(this->fVec, _mm_setzero_si128()),
|
return Sk16h(_mm_unpacklo_epi8(this->fVec, _mm_setzero_si128()),
|
||||||
_mm_unpackhi_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),
|
return Sk16h(_mm_unpacklo_epi8(_mm_setzero_si128(), this->fVec),
|
||||||
_mm_unpackhi_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),
|
return Sk16h(_mm_unpacklo_epi8(this->fVec, this->fVec),
|
||||||
_mm_unpackhi_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();
|
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;
|
Sk4px::Wide r = (*this + other) >> 8;
|
||||||
return Sk4px(_mm_packus_epi16(r.fLo.fVec, r.fHi.fVec));
|
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.
|
// These are safe on x86, often with no speed penalty.
|
||||||
|
|
||||||
#if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSSE3
|
#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.");
|
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);
|
__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));
|
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;
|
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);
|
__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));
|
return Sk16b(_mm_shuffle_epi8(_mm_cvtsi32_si128(as), splat));
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
SK_ALWAYS_INLINE Sk4px Sk4px::alphas() const {
|
inline Sk4px Sk4px::alphas() const {
|
||||||
static_assert(SK_A32_SHIFT == 24, "Intel's always little-endian.");
|
static_assert(SK_A32_SHIFT == 24, "Intel's always little-endian.");
|
||||||
__m128i as = _mm_srli_epi32(this->fVec, 24); // ___3 ___2 ___1 ___0
|
__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
|
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);
|
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
|
__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_epi8 (as, _mm_setzero_si128()); // ____ ____ _3_2 _1_0
|
||||||
as = _mm_unpacklo_epi16(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
|
#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
|
uint32_t as = *(const uint16_t*)a; // Aa -> Aa00
|
||||||
return Load4Alphas((const SkAlpha*)&as);
|
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));
|
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
|
// andnot(a,b) == ~a & b
|
||||||
return Sk16b(_mm_andnot_si128(_mm_set1_epi32(0xFF << SK_A32_SHIFT), this->fVec));
|
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....|
|
// RGB565 format: |R....|G.....|B....|
|
||||||
// Bit: 16 11 5 0
|
// 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))));
|
_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.
|
// 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)),
|
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)),
|
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;
|
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)));
|
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] )
|
auto src2 = ((uint32_t)src[0] )
|
||||||
| ((uint32_t)src[1] << 16);
|
| ((uint32_t)src[1] << 16);
|
||||||
return Sk16b(widen_low_half_to_8888(_mm_cvtsi32_si128(src2)));
|
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)));
|
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));
|
_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));
|
uint32_t dst2 = _mm_cvtsi128_si32(narrow_to_565(this->fVec));
|
||||||
dst[0] = dst2;
|
dst[0] = dst2;
|
||||||
dst[1] = dst2 >> 16;
|
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));
|
uint32_t dst2 = _mm_cvtsi128_si32(narrow_to_565(this->fVec));
|
||||||
dst[0] = dst2;
|
dst[0] = dst2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
@ -7,52 +7,54 @@
|
|||||||
|
|
||||||
#include "SkUtils.h"
|
#include "SkUtils.h"
|
||||||
|
|
||||||
|
namespace { // See Sk4px.h
|
||||||
|
|
||||||
static_assert(sizeof(Sk4px) == 16, "This file uses memcpy / sk_memset32, so exact size matters.");
|
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();
|
Sk4px px4 = Sk16b();
|
||||||
sk_memset32((uint32_t*)&px4, px, 4);
|
sk_memset32((uint32_t*)&px4, px, 4);
|
||||||
return px4;
|
return px4;
|
||||||
}
|
}
|
||||||
|
|
||||||
SK_ALWAYS_INLINE Sk4px Sk4px::Load4(const SkPMColor px[4]) {
|
inline Sk4px Sk4px::Load4(const SkPMColor px[4]) {
|
||||||
Sk4px px4 = Sk16b();
|
Sk4px px4 = Sk16b();
|
||||||
memcpy(&px4, px, 16);
|
memcpy(&px4, px, 16);
|
||||||
return px4;
|
return px4;
|
||||||
}
|
}
|
||||||
|
|
||||||
SK_ALWAYS_INLINE Sk4px Sk4px::Load2(const SkPMColor px[2]) {
|
inline Sk4px Sk4px::Load2(const SkPMColor px[2]) {
|
||||||
Sk4px px2 = Sk16b();
|
Sk4px px2 = Sk16b();
|
||||||
memcpy(&px2, px, 8);
|
memcpy(&px2, px, 8);
|
||||||
return px2;
|
return px2;
|
||||||
}
|
}
|
||||||
|
|
||||||
SK_ALWAYS_INLINE Sk4px Sk4px::Load1(const SkPMColor px[1]) {
|
inline Sk4px Sk4px::Load1(const SkPMColor px[1]) {
|
||||||
Sk4px px1 = Sk16b();
|
Sk4px px1 = Sk16b();
|
||||||
memcpy(&px1, px, 4);
|
memcpy(&px1, px, 4);
|
||||||
return px1;
|
return px1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SK_ALWAYS_INLINE void Sk4px::store4(SkPMColor px[4]) const { memcpy(px, this, 16); }
|
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); }
|
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::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>(),
|
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< 4>(), this->kth< 5>(), this->kth< 6>(), this->kth< 7>(),
|
||||||
this->kth< 8>(), this->kth< 9>(), this->kth<10>(), this->kth<11>(),
|
this->kth< 8>(), this->kth< 9>(), this->kth<10>(), this->kth<11>(),
|
||||||
this->kth<12>(), this->kth<13>(), this->kth<14>(), this->kth<15>());
|
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();
|
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;
|
Sk4px::Wide r = (*this + other) >> 8;
|
||||||
return Sk16b(r.kth< 0>(), r.kth< 1>(), r.kth< 2>(), r.kth< 3>(),
|
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>(),
|
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>());
|
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.");
|
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>(),
|
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>(),
|
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>());
|
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],
|
return Sk16b(a[0], a[0], a[0], a[0],
|
||||||
a[1], a[1], a[1], a[1],
|
a[1], a[1], a[1], a[1],
|
||||||
a[2], a[2], a[2], a[2],
|
a[2], a[2], a[2], a[2],
|
||||||
a[3], a[3], a[3], a[3]);
|
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],
|
return Sk16b(a[0], a[0], a[0], a[0],
|
||||||
a[1], a[1], a[1], a[1],
|
a[1], a[1], a[1], a[1],
|
||||||
0,0,0,0,
|
0,0,0,0,
|
||||||
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.");
|
static_assert(SK_A32_SHIFT == 24, "This method assumes little-endian.");
|
||||||
return Sk16b(this->kth< 0>(), this->kth< 1>(), this->kth< 2>(), 0,
|
return Sk16b(this->kth< 0>(), this->kth< 1>(), this->kth< 2>(), 0,
|
||||||
this->kth< 4>(), this->kth< 5>(), this->kth< 6>(), 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);
|
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.");
|
static_assert(SK_A32_SHIFT == 24, "This method assumes little-endian.");
|
||||||
return Sk16b(0,0,0, this->kth< 3>(),
|
return Sk16b(0,0,0, this->kth< 3>(),
|
||||||
0,0,0, this->kth< 7>(),
|
0,0,0, this->kth< 7>(),
|
||||||
@ -98,33 +100,35 @@ SK_ALWAYS_INLINE Sk4px Sk4px::zeroColors() const {
|
|||||||
0,0,0, this->kth<15>());
|
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];
|
SkPMColor src32[4];
|
||||||
for (int i = 0; i < 4; i++) { src32[i] = SkPixel16ToPixel32(src[i]); }
|
for (int i = 0; i < 4; i++) { src32[i] = SkPixel16ToPixel32(src[i]); }
|
||||||
return Load4(src32);
|
return Load4(src32);
|
||||||
}
|
}
|
||||||
SK_ALWAYS_INLINE Sk4px Sk4px::Load2(const SkPMColor16 src[2]) {
|
inline Sk4px Sk4px::Load2(const SkPMColor16 src[2]) {
|
||||||
SkPMColor src32[2];
|
SkPMColor src32[2];
|
||||||
for (int i = 0; i < 2; i++) { src32[i] = SkPixel16ToPixel32(src[i]); }
|
for (int i = 0; i < 2; i++) { src32[i] = SkPixel16ToPixel32(src[i]); }
|
||||||
return Load2(src32);
|
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]);
|
SkPMColor src32 = SkPixel16ToPixel32(src[0]);
|
||||||
return Load1(&src32);
|
return Load1(&src32);
|
||||||
}
|
}
|
||||||
|
|
||||||
SK_ALWAYS_INLINE void Sk4px::store4(SkPMColor16 dst[4]) const {
|
inline void Sk4px::store4(SkPMColor16 dst[4]) const {
|
||||||
SkPMColor dst32[4];
|
SkPMColor dst32[4];
|
||||||
this->store4(dst32);
|
this->store4(dst32);
|
||||||
for (int i = 0; i < 4; i++) { dst[i] = SkPixel32ToPixel16(dst32[i]); }
|
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];
|
SkPMColor dst32[2];
|
||||||
this->store2(dst32);
|
this->store2(dst32);
|
||||||
for (int i = 0; i < 2; i++) { dst[i] = SkPixel32ToPixel16(dst32[i]); }
|
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;
|
SkPMColor dst32;
|
||||||
this->store1(&dst32);
|
this->store1(&dst32);
|
||||||
dst[0] = SkPixel32ToPixel16(dst32);
|
dst[0] = SkPixel32ToPixel16(dst32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
#ifndef SkNx_neon_DEFINED
|
#ifndef SkNx_neon_DEFINED
|
||||||
#define SkNx_neon_DEFINED
|
#define SkNx_neon_DEFINED
|
||||||
|
|
||||||
|
namespace { // See SkNx.h
|
||||||
|
|
||||||
// Well, this is absurd. The shifts require compile-time constant arguments.
|
// Well, this is absurd. The shifts require compile-time constant arguments.
|
||||||
|
|
||||||
#define SHIFT8(op, v, bits) switch(bits) { \
|
#define SHIFT8(op, v, bits) switch(bits) { \
|
||||||
@ -381,4 +383,6 @@ public:
|
|||||||
#undef SHIFT16
|
#undef SHIFT16
|
||||||
#undef SHIFT8
|
#undef SHIFT8
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
#endif//SkNx_neon_DEFINED
|
#endif//SkNx_neon_DEFINED
|
||||||
|
@ -10,6 +10,9 @@
|
|||||||
|
|
||||||
// This file may assume <= SSE2, but must check SK_CPU_SSE_LEVEL for anything more recent.
|
// This file may assume <= SSE2, but must check SK_CPU_SSE_LEVEL for anything more recent.
|
||||||
|
|
||||||
|
namespace { // See SkNx.h
|
||||||
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
class SkNf<2, float> {
|
class SkNf<2, float> {
|
||||||
public:
|
public:
|
||||||
@ -310,4 +313,6 @@ public:
|
|||||||
__m128i fVec;
|
__m128i fVec;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
#endif//SkNx_sse_DEFINED
|
#endif//SkNx_sse_DEFINED
|
||||||
|
@ -21,7 +21,7 @@ namespace SkOpts {
|
|||||||
rsqrt = neon::rsqrt;
|
rsqrt = neon::rsqrt;
|
||||||
memset16 = neon::memset16;
|
memset16 = neon::memset16;
|
||||||
memset32 = neon::memset32;
|
memset32 = neon::memset32;
|
||||||
create_xfermode = neon::create_xfermode;
|
create_xfermode = SkCreate4pxXfermode;
|
||||||
|
|
||||||
box_blur_xx = neon::box_blur_xx;
|
box_blur_xx = neon::box_blur_xx;
|
||||||
box_blur_xy = neon::box_blur_xy;
|
box_blur_xy = neon::box_blur_xy;
|
||||||
|
@ -18,7 +18,7 @@ namespace SkOpts {
|
|||||||
void Init_sse2() {
|
void Init_sse2() {
|
||||||
memset16 = sse2::memset16;
|
memset16 = sse2::memset16;
|
||||||
memset32 = sse2::memset32;
|
memset32 = sse2::memset32;
|
||||||
create_xfermode = sse2::create_xfermode;
|
create_xfermode = SkCreate4pxXfermode;
|
||||||
|
|
||||||
box_blur_xx = sse2::box_blur_xx;
|
box_blur_xx = sse2::box_blur_xx;
|
||||||
box_blur_xy = sse2::box_blur_xy;
|
box_blur_xy = sse2::box_blur_xy;
|
||||||
|
@ -5,7 +5,9 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
SK_ALWAYS_INLINE SkPMFloat::SkPMFloat(SkPMColor c) {
|
namespace { // See SkPMFloat.h
|
||||||
|
|
||||||
|
inline SkPMFloat::SkPMFloat(SkPMColor c) {
|
||||||
SkPMColorAssert(c);
|
SkPMColorAssert(c);
|
||||||
uint8x8_t fix8 = (uint8x8_t)vdup_n_u32(c);
|
uint8x8_t fix8 = (uint8x8_t)vdup_n_u32(c);
|
||||||
uint16x8_t fix8_16 = vmovl_u8(fix8);
|
uint16x8_t fix8_16 = vmovl_u8(fix8);
|
||||||
@ -14,7 +16,7 @@ SK_ALWAYS_INLINE SkPMFloat::SkPMFloat(SkPMColor c) {
|
|||||||
SkASSERT(this->isValid());
|
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.
|
// 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));
|
float32x4_t rounded = vmlaq_f32(vdupq_n_f32(0.5f), fVec, vdupq_n_f32(255));
|
||||||
uint32x4_t fix8_32 = vcvtq_u32_f32(rounded);
|
uint32x4_t fix8_32 = vcvtq_u32_f32(rounded);
|
||||||
@ -25,7 +27,9 @@ SK_ALWAYS_INLINE SkPMColor SkPMFloat::round() const {
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
SK_ALWAYS_INLINE Sk4f SkPMFloat::alphas() const {
|
inline Sk4f SkPMFloat::alphas() const {
|
||||||
static_assert(SK_A32_SHIFT == 24, "Assuming little-endian.");
|
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.
|
return vdupq_lane_f32(vget_high_f32(fVec), 1); // Duplicate high lane of high half i.e. lane 3.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
@ -5,7 +5,9 @@
|
|||||||
* found in the LICENSE file.
|
* 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;
|
float inv255 = 1.0f/255;
|
||||||
*this = SkPMFloat::FromARGB(SkGetPackedA32(c) * inv255,
|
*this = SkPMFloat::FromARGB(SkGetPackedA32(c) * inv255,
|
||||||
SkGetPackedR32(c) * inv255,
|
SkGetPackedR32(c) * inv255,
|
||||||
@ -14,7 +16,7 @@ SK_ALWAYS_INLINE SkPMFloat::SkPMFloat(SkPMColor c) {
|
|||||||
SkASSERT(this->isValid());
|
SkASSERT(this->isValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
SK_ALWAYS_INLINE SkPMColor SkPMFloat::round() const {
|
inline SkPMColor SkPMFloat::round() const {
|
||||||
float a = this->a(),
|
float a = this->a(),
|
||||||
r = this->r(),
|
r = this->r(),
|
||||||
g = this->g(),
|
g = this->g(),
|
||||||
@ -28,6 +30,8 @@ SK_ALWAYS_INLINE SkPMColor SkPMFloat::round() const {
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
SK_ALWAYS_INLINE Sk4f SkPMFloat::alphas() const {
|
inline Sk4f SkPMFloat::alphas() const {
|
||||||
return Sk4f(this->a());
|
return Sk4f(this->a());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
@ -5,7 +5,9 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
SK_ALWAYS_INLINE SkPMFloat::SkPMFloat(SkPMColor c) {
|
namespace { // See SkPMFloat.h
|
||||||
|
|
||||||
|
inline SkPMFloat::SkPMFloat(SkPMColor c) {
|
||||||
SkPMColorAssert(c);
|
SkPMColorAssert(c);
|
||||||
#if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSSE3
|
#if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSSE3
|
||||||
const int _ = 255; // Zero these bytes.
|
const int _ = 255; // Zero these bytes.
|
||||||
@ -20,7 +22,7 @@ SK_ALWAYS_INLINE SkPMFloat::SkPMFloat(SkPMColor c) {
|
|||||||
SkASSERT(this->isValid());
|
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).
|
// 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);
|
__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)),
|
__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;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
SK_ALWAYS_INLINE Sk4f SkPMFloat::alphas() const {
|
inline Sk4f SkPMFloat::alphas() const {
|
||||||
static_assert(SK_A32_SHIFT == 24, "");
|
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.
|
return _mm_shuffle_ps(fVec, fVec, 0xff); // Read as 11 11 11 11, copying lane 3 to all lanes.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include "SkPMFloat.h"
|
#include "SkPMFloat.h"
|
||||||
#include "SkXfermode_proccoeff.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.
|
// 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)
|
#define XFERMODE(Name) static Sk4px SK_VECTORCALL Name(Sk4px d, Sk4px s)
|
||||||
@ -264,7 +264,7 @@ private:
|
|||||||
typedef SkProcCoeffXfermode INHERITED;
|
typedef SkProcCoeffXfermode INHERITED;
|
||||||
};
|
};
|
||||||
|
|
||||||
static SkXfermode* create_xfermode(const ProcCoeff& rec, SkXfermode::Mode mode) {
|
static SkXfermode* SkCreate4pxXfermode(const ProcCoeff& rec, SkXfermode::Mode mode) {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
#define CASE(Mode) case SkXfermode::k##Mode##_Mode: \
|
#define CASE(Mode) case SkXfermode::k##Mode##_Mode: \
|
||||||
return SkNEW_ARGS(Sk4pxXfermode, (rec, mode, &Mode, &xfer_aa<Mode>))
|
return SkNEW_ARGS(Sk4pxXfermode, (rec, mode, &Mode, &xfer_aa<Mode>))
|
||||||
|
Loading…
Reference in New Issue
Block a user