OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
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 "SkOpts.h" | 8 #include "SkOpts.h" |
9 | 9 |
10 #define SK_OPTS_NS sse2 | 10 #define SK_OPTS_NS sse2 |
11 #include "SkBlurImageFilter_opts.h" | 11 #include "SkBlurImageFilter_opts.h" |
| 12 #include "SkUtils_opts.h" |
12 #include "SkXfermode_opts.h" | 13 #include "SkXfermode_opts.h" |
13 | 14 |
14 namespace sse2 { // This helps identify methods from this file when debugging /
profiling. | |
15 | |
16 static void memset16(uint16_t* dst, uint16_t val, int n) { | |
17 auto dst8 = (__m128i*)dst; | |
18 auto val8 = _mm_set1_epi16(val); | |
19 for ( ; n >= 8; n -= 8) { | |
20 _mm_storeu_si128(dst8++, val8); | |
21 } | |
22 dst = (uint16_t*)dst8; | |
23 if (n & 4) { | |
24 _mm_storel_epi64((__m128i*)dst, val8); | |
25 dst += 4; | |
26 } | |
27 if (n & 2) { | |
28 *(uint32_t*)dst = _mm_cvtsi128_si32(val8); | |
29 dst += 2; | |
30 } | |
31 if (n & 1) { | |
32 *dst = val; | |
33 } | |
34 } | |
35 | |
36 static void memset32(uint32_t* dst, uint32_t val, int n) { | |
37 auto dst4 = (__m128i*)dst; | |
38 auto val4 = _mm_set1_epi32(val); | |
39 for ( ; n >= 4; n -= 4) { | |
40 _mm_storeu_si128(dst4++, val4); | |
41 } | |
42 dst = (uint32_t*)dst4; | |
43 if (n & 2) { | |
44 _mm_storel_epi64((__m128i*)dst, val4); | |
45 dst += 2; | |
46 } | |
47 if (n & 1) { | |
48 *dst = val; | |
49 } | |
50 } | |
51 | |
52 } // namespace sse2 | |
53 | |
54 namespace SkOpts { | 15 namespace SkOpts { |
55 void Init_sse2() { | 16 void Init_sse2() { |
56 memset16 = sse2::memset16; | 17 memset16 = sse2::memset16; |
57 memset32 = sse2::memset32; | 18 memset32 = sse2::memset32; |
58 create_xfermode = SkCreate4pxXfermode; | 19 create_xfermode = SkCreate4pxXfermode; |
59 | 20 |
60 static const auto x = sse2::kX, y = sse2::kY; | 21 static const auto x = sse2::kX, y = sse2::kY; |
61 box_blur_xx = sse2::box_blur<x,x>; | 22 box_blur_xx = sse2::box_blur<x,x>; |
62 box_blur_xy = sse2::box_blur<x,y>; | 23 box_blur_xy = sse2::box_blur<x,y>; |
63 box_blur_yx = sse2::box_blur<y,x>; | 24 box_blur_yx = sse2::box_blur<y,x>; |
64 } | 25 } |
65 } | 26 } |
OLD | NEW |