Index: src/opts/SkMorphology_opts_neon.cpp |
diff --git a/src/opts/SkMorphology_opts_SSE2.cpp b/src/opts/SkMorphology_opts_neon.cpp |
similarity index 63% |
copy from src/opts/SkMorphology_opts_SSE2.cpp |
copy to src/opts/SkMorphology_opts_neon.cpp |
index b58fced2c12718f8b84b42f948b8f85a6b914415..571b5c8b178b6463705a4b9b3b22e10423485667 100644 |
--- a/src/opts/SkMorphology_opts_SSE2.cpp |
+++ b/src/opts/SkMorphology_opts_neon.cpp |
@@ -7,11 +7,12 @@ |
#include "SkColorPriv.h" |
-#include "SkMorphology_opts_SSE2.h" |
+#include "SkMorphology_opts.h" |
+#include "SkMorphology_opts_neon.h" |
-#include <emmintrin.h> |
+#include <arm_neon.h> |
-/* SSE2 version of dilateX, dilateY, erodeX, erodeY. |
+/* neon version of dilateX, dilateY, erodeX, erodeY. |
* portable versions are in src/effects/SkMorphologyImageFilter.cpp. |
*/ |
@@ -24,7 +25,7 @@ enum MorphDirection { |
}; |
template<MorphType type, MorphDirection direction> |
-static void SkMorph_SSE2(const SkPMColor* src, SkPMColor* dst, int radius, |
+static void SkMorph_neon(const SkPMColor* src, SkPMColor* dst, int radius, |
int width, int height, int srcStride, int dstStride) |
{ |
const int srcStrideX = direction == kX ? 1 : srcStride; |
@@ -38,12 +39,12 @@ static void SkMorph_SSE2(const SkPMColor* src, SkPMColor* dst, int radius, |
const SkPMColor* up = upperSrc; |
SkPMColor* dptr = dst; |
for (int y = 0; y < height; ++y) { |
- __m128i max = type == kDilate ? _mm_setzero_si128() : _mm_set1_epi32(0xFFFFFFFF); |
+ uint8x8_t max = vdup_n_u8(type == kDilate ? 0 : 255); |
for (const SkPMColor* p = lp; p <= up; p += srcStrideX) { |
- __m128i src_pixel = _mm_cvtsi32_si128(*p); |
- max = type == kDilate ? _mm_max_epu8(src_pixel, max) : _mm_min_epu8(src_pixel, max); |
+ uint8x8_t src_pixel = vreinterpret_u8_u32(vdup_n_u32(*p)); |
+ max = type == kDilate ? vmax_u8(src_pixel, max) : vmin_u8(src_pixel, max); |
} |
- *dptr = _mm_cvtsi128_si32(max); |
+ *dptr = vget_lane_u32(vreinterpret_u32_u8(max), 0); |
dptr += dstStrideY; |
lp += srcStrideY; |
up += srcStrideY; |
@@ -54,26 +55,26 @@ static void SkMorph_SSE2(const SkPMColor* src, SkPMColor* dst, int radius, |
} |
} |
-void SkDilateX_SSE2(const SkPMColor* src, SkPMColor* dst, int radius, |
+void SkDilateX_neon(const SkPMColor* src, SkPMColor* dst, int radius, |
int width, int height, int srcStride, int dstStride) |
{ |
- SkMorph_SSE2<kDilate, kX>(src, dst, radius, width, height, srcStride, dstStride); |
+ SkMorph_neon<kDilate, kX>(src, dst, radius, width, height, srcStride, dstStride); |
} |
-void SkErodeX_SSE2(const SkPMColor* src, SkPMColor* dst, int radius, |
+void SkErodeX_neon(const SkPMColor* src, SkPMColor* dst, int radius, |
int width, int height, int srcStride, int dstStride) |
{ |
- SkMorph_SSE2<kErode, kX>(src, dst, radius, width, height, srcStride, dstStride); |
+ SkMorph_neon<kErode, kX>(src, dst, radius, width, height, srcStride, dstStride); |
} |
-void SkDilateY_SSE2(const SkPMColor* src, SkPMColor* dst, int radius, |
+void SkDilateY_neon(const SkPMColor* src, SkPMColor* dst, int radius, |
int width, int height, int srcStride, int dstStride) |
{ |
- SkMorph_SSE2<kDilate, kY>(src, dst, radius, width, height, srcStride, dstStride); |
+ SkMorph_neon<kDilate, kY>(src, dst, radius, width, height, srcStride, dstStride); |
} |
-void SkErodeY_SSE2(const SkPMColor* src, SkPMColor* dst, int radius, |
+void SkErodeY_neon(const SkPMColor* src, SkPMColor* dst, int radius, |
int width, int height, int srcStride, int dstStride) |
{ |
- SkMorph_SSE2<kErode, kY>(src, dst, radius, width, height, srcStride, dstStride); |
+ SkMorph_neon<kErode, kY>(src, dst, radius, width, height, srcStride, dstStride); |
} |