diff --git a/src/core/SkMipMap.cpp b/src/core/SkMipMap.cpp index 987949fea0..ba3cb18749 100644 --- a/src/core/SkMipMap.cpp +++ b/src/core/SkMipMap.cpp @@ -23,6 +23,7 @@ struct ColorTypeFilter_8888 { typedef uint32_t Type; +#if defined(SKNX_IS_FAST) static Sk4h Expand(uint32_t x) { return SkNx_cast(Sk4b::Load(&x)); } @@ -31,6 +32,14 @@ struct ColorTypeFilter_8888 { SkNx_cast(x).store(&r); return r; } +#else + static uint64_t Expand(uint32_t x) { + return (x & 0xFF00FF) | ((uint64_t)(x & 0xFF00FF00) << 24); + } + static uint32_t Compact(uint64_t x) { + return (uint32_t)((x & 0xFF00FF) | ((x >> 24) & 0xFF00FF00)); + } +#endif }; struct ColorTypeFilter_S32 { diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp index 4bb640de91..5994fd6d0c 100644 --- a/src/effects/gradients/SkLinearGradient.cpp +++ b/src/effects/gradients/SkLinearGradient.cpp @@ -276,12 +276,15 @@ void SkLinearGradient::LinearGradientContext::shadeSpan(int x, int y, SkPMColor* SkASSERT(count > 0); const SkLinearGradient& linearGradient = static_cast(fShader); +// Only use the Sk4f impl when known to be fast. +#if defined(SKNX_IS_FAST) if (SkShader::kClamp_TileMode == linearGradient.fTileMode && kLinear_MatrixClass == fDstToIndexClass) { this->shade4_clamp(x, y, dstC, count); return; } +#endif SkPoint srcPt; SkMatrix::MapXYProc dstProc = fDstToIndexProc; diff --git a/src/opts/SkNx_neon.h b/src/opts/SkNx_neon.h index 6836a527e7..83873a76e1 100644 --- a/src/opts/SkNx_neon.h +++ b/src/opts/SkNx_neon.h @@ -10,6 +10,8 @@ #include +#define SKNX_IS_FAST + namespace { // ARMv8 has vrndmq_f32 to floor 4 floats. Here we emulate it: diff --git a/src/opts/SkNx_sse.h b/src/opts/SkNx_sse.h index 394115626e..554d65d5ce 100644 --- a/src/opts/SkNx_sse.h +++ b/src/opts/SkNx_sse.h @@ -13,6 +13,8 @@ // This file may assume <= SSE2, but must check SK_CPU_SSE_LEVEL for anything more recent. // If you do, make sure this is in a static inline function... anywhere else risks violating ODR. +#define SKNX_IS_FAST + namespace { template <>