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 #include <emmintrin.h> | 8 #include <emmintrin.h> |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkBlurImage_opts_SSE2.h" | 10 #include "SkBlurImage_opts_SSE2.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 __m128i sum = zero; | 48 __m128i sum = zero; |
49 const SkPMColor* p = src; | 49 const SkPMColor* p = src; |
50 for (int i = 0; i < rightBorder; ++i) { | 50 for (int i = 0; i < rightBorder; ++i) { |
51 sum = _mm_add_epi32(sum, expand(*p)); | 51 sum = _mm_add_epi32(sum, expand(*p)); |
52 p += srcStrideX; | 52 p += srcStrideX; |
53 } | 53 } |
54 | 54 |
55 const SkPMColor* sptr = src; | 55 const SkPMColor* sptr = src; |
56 SkColor* dptr = dst; | 56 SkColor* dptr = dst; |
57 for (int x = 0; x < width; ++x) { | 57 for (int x = 0; x < width; ++x) { |
58 // SSE2 has no PMULLUD, so we must do AG and RB separately. | 58 #if 0 |
| 59 // In SSE4.1, this would be |
| 60 __m128i result = _mm_mullo_epi32(sum, scale); |
| 61 #else |
| 62 // But SSE2 has no PMULLUD, so we must do AG and RB separately. |
59 __m128i tmp1 = _mm_mul_epu32(sum, scale); | 63 __m128i tmp1 = _mm_mul_epu32(sum, scale); |
60 __m128i tmp2 = _mm_mul_epu32(_mm_srli_si128(sum, 4), | 64 __m128i tmp2 = _mm_mul_epu32(_mm_srli_si128(sum, 4), |
61 _mm_srli_si128(scale, 4)); | 65 _mm_srli_si128(scale, 4)); |
62 __m128i result = _mm_unpacklo_epi32(_mm_shuffle_epi32(tmp1, _MM_SHUF
FLE(0,0,2,0)), | 66 __m128i result = _mm_unpacklo_epi32(_mm_shuffle_epi32(tmp1, _MM_SHUF
FLE(0,0,2,0)), |
63 _mm_shuffle_epi32(tmp2, _MM_SHUF
FLE(0,0,2,0))); | 67 _mm_shuffle_epi32(tmp2, _MM_SHUF
FLE(0,0,2,0))); |
64 | 68 #endif |
65 // sumA*scale+.5 sumB*scale+.5 sumG*scale+.5 sumB*scale+.5 | 69 // sumA*scale+.5 sumB*scale+.5 sumG*scale+.5 sumB*scale+.5 |
66 result = _mm_add_epi32(result, half); | 70 result = _mm_add_epi32(result, half); |
67 | 71 |
68 // 0 0 0 A 0 0 0 R 0 0 0 G 0 0 0 B | 72 // 0 0 0 A 0 0 0 R 0 0 0 G 0 0 0 B |
69 result = _mm_srli_epi32(result, 24); | 73 result = _mm_srli_epi32(result, 24); |
70 | 74 |
71 // 0 0 0 0 0 0 0 0 0 A 0 R 0 G 0 B | 75 // 0 0 0 0 0 0 0 0 0 A 0 R 0 G 0 B |
72 result = _mm_packs_epi32(result, zero); | 76 result = _mm_packs_epi32(result, zero); |
73 | 77 |
74 // 0 0 0 0 0 0 0 0 0 0 0 0 A R G B | 78 // 0 0 0 0 0 0 0 0 0 0 0 0 A R G B |
(...skipping 24 matching lines...) Expand all Loading... |
99 bool SkBoxBlurGetPlatformProcs_SSE2(SkBoxBlurProc* boxBlurX, | 103 bool SkBoxBlurGetPlatformProcs_SSE2(SkBoxBlurProc* boxBlurX, |
100 SkBoxBlurProc* boxBlurY, | 104 SkBoxBlurProc* boxBlurY, |
101 SkBoxBlurProc* boxBlurXY, | 105 SkBoxBlurProc* boxBlurXY, |
102 SkBoxBlurProc* boxBlurYX) { | 106 SkBoxBlurProc* boxBlurYX) { |
103 *boxBlurX = SkBoxBlur_SSE2<kX, kX>; | 107 *boxBlurX = SkBoxBlur_SSE2<kX, kX>; |
104 *boxBlurY = SkBoxBlur_SSE2<kY, kY>; | 108 *boxBlurY = SkBoxBlur_SSE2<kY, kY>; |
105 *boxBlurXY = SkBoxBlur_SSE2<kX, kY>; | 109 *boxBlurXY = SkBoxBlur_SSE2<kX, kY>; |
106 *boxBlurYX = SkBoxBlur_SSE2<kY, kX>; | 110 *boxBlurYX = SkBoxBlur_SSE2<kY, kX>; |
107 return true; | 111 return true; |
108 } | 112 } |
OLD | NEW |