| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 The Android Open Source Project | 2 * Copyright 2013 The Android Open Source Project |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 | 8 #include <emmintrin.h> |
| 9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
| 10 #include "SkMorphology_opts_SSE2.h" | 10 #include "SkMorphology_opts_SSE2.h" |
| 11 | 11 |
| 12 #include <emmintrin.h> | |
| 13 | |
| 14 /* SSE2 version of dilateX, dilateY, erodeX, erodeY. | 12 /* SSE2 version of dilateX, dilateY, erodeX, erodeY. |
| 15 * portable versions are in src/effects/SkMorphologyImageFilter.cpp. | 13 * portable versions are in src/effects/SkMorphologyImageFilter.cpp. |
| 16 */ | 14 */ |
| 17 | 15 |
| 18 enum MorphType { | 16 enum MorphType { |
| 19 kDilate, kErode | 17 kDilate, kErode |
| 20 }; | 18 }; |
| 21 | 19 |
| 22 enum MorphDirection { | 20 enum MorphDirection { |
| 23 kX, kY | 21 kX, kY |
| (...skipping 17 matching lines...) Expand all Loading... |
| 41 __m128i max = type == kDilate ? _mm_setzero_si128() : _mm_set1_epi32
(0xFFFFFFFF); | 39 __m128i max = type == kDilate ? _mm_setzero_si128() : _mm_set1_epi32
(0xFFFFFFFF); |
| 42 for (const SkPMColor* p = lp; p <= up; p += srcStrideX) { | 40 for (const SkPMColor* p = lp; p <= up; p += srcStrideX) { |
| 43 __m128i src_pixel = _mm_cvtsi32_si128(*p); | 41 __m128i src_pixel = _mm_cvtsi32_si128(*p); |
| 44 max = type == kDilate ? _mm_max_epu8(src_pixel, max) : _mm_min_e
pu8(src_pixel, max); | 42 max = type == kDilate ? _mm_max_epu8(src_pixel, max) : _mm_min_e
pu8(src_pixel, max); |
| 45 } | 43 } |
| 46 *dptr = _mm_cvtsi128_si32(max); | 44 *dptr = _mm_cvtsi128_si32(max); |
| 47 dptr += dstStrideY; | 45 dptr += dstStrideY; |
| 48 lp += srcStrideY; | 46 lp += srcStrideY; |
| 49 up += srcStrideY; | 47 up += srcStrideY; |
| 50 } | 48 } |
| 51 if (x >= radius) src += srcStrideX; | 49 if (x >= radius) { |
| 52 if (x + radius < width - 1) upperSrc += srcStrideX; | 50 src += srcStrideX; |
| 51 } |
| 52 if (x + radius < width - 1) { |
| 53 upperSrc += srcStrideX; |
| 54 } |
| 53 dst += dstStrideX; | 55 dst += dstStrideX; |
| 54 } | 56 } |
| 55 } | 57 } |
| 56 | 58 |
| 57 void SkDilateX_SSE2(const SkPMColor* src, SkPMColor* dst, int radius, | 59 void SkDilateX_SSE2(const SkPMColor* src, SkPMColor* dst, int radius, |
| 58 int width, int height, int srcStride, int dstStride) | 60 int width, int height, int srcStride, int dstStride) |
| 59 { | 61 { |
| 60 SkMorph_SSE2<kDilate, kX>(src, dst, radius, width, height, srcStride, dstStr
ide); | 62 SkMorph_SSE2<kDilate, kX>(src, dst, radius, width, height, srcStride, dstStr
ide); |
| 61 } | 63 } |
| 62 | 64 |
| 63 void SkErodeX_SSE2(const SkPMColor* src, SkPMColor* dst, int radius, | 65 void SkErodeX_SSE2(const SkPMColor* src, SkPMColor* dst, int radius, |
| 64 int width, int height, int srcStride, int dstStride) | 66 int width, int height, int srcStride, int dstStride) |
| 65 { | 67 { |
| 66 SkMorph_SSE2<kErode, kX>(src, dst, radius, width, height, srcStride, dstStri
de); | 68 SkMorph_SSE2<kErode, kX>(src, dst, radius, width, height, srcStride, dstStri
de); |
| 67 } | 69 } |
| 68 | 70 |
| 69 void SkDilateY_SSE2(const SkPMColor* src, SkPMColor* dst, int radius, | 71 void SkDilateY_SSE2(const SkPMColor* src, SkPMColor* dst, int radius, |
| 70 int width, int height, int srcStride, int dstStride) | 72 int width, int height, int srcStride, int dstStride) |
| 71 { | 73 { |
| 72 SkMorph_SSE2<kDilate, kY>(src, dst, radius, width, height, srcStride, dstStr
ide); | 74 SkMorph_SSE2<kDilate, kY>(src, dst, radius, width, height, srcStride, dstStr
ide); |
| 73 } | 75 } |
| 74 | 76 |
| 75 void SkErodeY_SSE2(const SkPMColor* src, SkPMColor* dst, int radius, | 77 void SkErodeY_SSE2(const SkPMColor* src, SkPMColor* dst, int radius, |
| 76 int width, int height, int srcStride, int dstStride) | 78 int width, int height, int srcStride, int dstStride) |
| 77 { | 79 { |
| 78 SkMorph_SSE2<kErode, kY>(src, dst, radius, width, height, srcStride, dstStri
de); | 80 SkMorph_SSE2<kErode, kY>(src, dst, radius, width, height, srcStride, dstStri
de); |
| 79 } | 81 } |
| OLD | NEW |