OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009 The Android Open Source Project | 2 * Copyright 2009 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 "SkBitmapFilter_opts_SSE2.h" | 8 #include "SkBitmapFilter_opts_SSE2.h" |
9 #include "SkBitmapProcState_opts_SSE2.h" | 9 #include "SkBitmapProcState_opts_SSE2.h" |
10 #include "SkBitmapProcState_opts_SSSE3.h" | 10 #include "SkBitmapProcState_opts_SSSE3.h" |
11 #include "SkBlitMask.h" | 11 #include "SkBlitMask.h" |
12 #include "SkBlitRect_opts_SSE2.h" | 12 #include "SkBlitRect_opts_SSE2.h" |
13 #include "SkBlitRow.h" | 13 #include "SkBlitRow.h" |
14 #include "SkBlitRow_opts_SSE2.h" | 14 #include "SkBlitRow_opts_SSE2.h" |
15 #include "SkBlurImage_opts_SSE2.h" | 15 #include "SkBlurImage_opts_SSE2.h" |
16 #include "SkMorphology_opts.h" | 16 #include "SkMorphology_opts.h" |
17 #include "SkMorphology_opts_SSE2.h" | 17 #include "SkMorphology_opts_SSE2.h" |
18 #include "SkRTConf.h" | 18 #include "SkRTConf.h" |
19 #include "SkUtils.h" | 19 #include "SkUtils.h" |
20 #include "SkUtils_opts_SSE2.h" | 20 #include "SkUtils_opts_SSE2.h" |
21 #include "SkXfermode.h" | 21 #include "SkXfermode.h" |
22 #include "SkXfermode_proccoeff.h" | 22 #include "SkXfermode_proccoeff.h" |
23 | 23 |
24 #if defined(_MSC_VER) && defined(_WIN64) | 24 #if defined(_MSC_VER) && defined(_WIN64) |
25 #include <intrin.h> | 25 #include <intrin.h> |
26 #endif | 26 #endif |
27 | 27 |
28 /* This file must *not* be compiled with -msse or any other optional SIMD | 28 /* This file must *not* be compiled with -msse or -msse2, otherwise |
29 extension, otherwise gcc may generate SIMD instructions even for scalar ops | 29 gcc may generate sse2 even for scalar ops (and thus give an invalid |
30 (and thus give an invalid instruction on Pentium3 on the code below). | 30 instruction on Pentium3 on the code below). Only files named *_SSE2.cpp |
31 For example, only files named *_SSE2.cpp in this directory should be | 31 in this directory should be compiled with -msse2. */ |
32 compiled with -msse2 or higher. */ | |
33 | 32 |
34 | 33 |
35 /* Function to get the CPU SSE-level in runtime, for different compilers. */ | 34 /* Function to get the CPU SSE-level in runtime, for different compilers. */ |
36 #ifdef _MSC_VER | 35 #ifdef _MSC_VER |
37 static inline void getcpuid(int info_type, int info[4]) { | 36 static inline void getcpuid(int info_type, int info[4]) { |
38 #if defined(_WIN64) | 37 #if defined(_WIN64) |
39 __cpuid(info, info_type); | 38 __cpuid(info, info_type); |
40 #else | 39 #else |
41 __asm { | 40 __asm { |
42 mov eax, [info_type] | 41 mov eax, [info_type] |
43 cpuid | 42 cpuid |
44 mov edi, [info] | 43 mov edi, [info] |
45 mov [edi], eax | 44 mov [edi], eax |
46 mov [edi+4], ebx | 45 mov [edi+4], ebx |
47 mov [edi+8], ecx | 46 mov [edi+8], ecx |
48 mov [edi+12], edx | 47 mov [edi+12], edx |
49 } | 48 } |
50 #endif | 49 #endif |
51 } | 50 } |
52 #elif defined(__x86_64__) | 51 #else |
| 52 #if defined(__x86_64__) |
53 static inline void getcpuid(int info_type, int info[4]) { | 53 static inline void getcpuid(int info_type, int info[4]) { |
54 asm volatile ( | 54 asm volatile ( |
55 "cpuid \n\t" | 55 "cpuid \n\t" |
56 : "=a"(info[0]), "=b"(info[1]), "=c"(info[2]), "=d"(info[3]) | 56 : "=a"(info[0]), "=b"(info[1]), "=c"(info[2]), "=d"(info[3]) |
57 : "a"(info_type) | 57 : "a"(info_type) |
58 ); | 58 ); |
59 } | 59 } |
60 #else | 60 #else |
61 static inline void getcpuid(int info_type, int info[4]) { | 61 static inline void getcpuid(int info_type, int info[4]) { |
62 // We save and restore ebx, so this code can be compatible with -fPIC | 62 // We save and restore ebx, so this code can be compatible with -fPIC |
63 asm volatile ( | 63 asm volatile ( |
64 "pushl %%ebx \n\t" | 64 "pushl %%ebx \n\t" |
65 "cpuid \n\t" | 65 "cpuid \n\t" |
66 "movl %%ebx, %1 \n\t" | 66 "movl %%ebx, %1 \n\t" |
67 "popl %%ebx \n\t" | 67 "popl %%ebx \n\t" |
68 : "=a"(info[0]), "=r"(info[1]), "=c"(info[2]), "=d"(info[3]) | 68 : "=a"(info[0]), "=r"(info[1]), "=c"(info[2]), "=d"(info[3]) |
69 : "a"(info_type) | 69 : "a"(info_type) |
70 ); | 70 ); |
71 } | 71 } |
72 #endif | 72 #endif |
| 73 #endif |
73 | 74 |
74 //////////////////////////////////////////////////////////////////////////////// | 75 //////////////////////////////////////////////////////////////////////////////// |
75 | 76 |
76 /* Fetch the SIMD level directly from the CPU, at run-time. | 77 #if defined(__x86_64__) || defined(_WIN64) || SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEV
EL_SSE2 |
77 * Only checks the levels needed by the optimizations in this file. | 78 /* All x86_64 machines have SSE2, or we know it's supported at compile time, so
don't even bother checking. */ |
| 79 static inline bool hasSSE2() { |
| 80 return true; |
| 81 } |
| 82 #else |
| 83 |
| 84 static inline bool hasSSE2() { |
| 85 int cpu_info[4] = { 0 }; |
| 86 getcpuid(1, cpu_info); |
| 87 return (cpu_info[3] & (1<<26)) != 0; |
| 88 } |
| 89 #endif |
| 90 |
| 91 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSSE3 |
| 92 /* If we know SSSE3 is supported at compile time, don't even bother checking. */ |
| 93 static inline bool hasSSSE3() { |
| 94 return true; |
| 95 } |
| 96 #elif defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) |
| 97 /* For the Android framework we should always know at compile time if the device |
| 98 * we are building for supports SSSE3. The one exception to this rule is on the |
| 99 * emulator where we are compiled without the -msse3 option (so we have no SSSE3 |
| 100 * procs) but can be run on a host machine that supports SSSE3 instructions. So |
| 101 * for that particular case we disable our SSSE3 options. |
78 */ | 102 */ |
79 static int get_SIMD_level() { | 103 static inline bool hasSSSE3() { |
| 104 return false; |
| 105 } |
| 106 #else |
| 107 |
| 108 static inline bool hasSSSE3() { |
80 int cpu_info[4] = { 0 }; | 109 int cpu_info[4] = { 0 }; |
| 110 getcpuid(1, cpu_info); |
| 111 return (cpu_info[2] & 0x200) != 0; |
| 112 } |
| 113 #endif |
81 | 114 |
82 getcpuid(1, cpu_info); | 115 static bool cachedHasSSE2() { |
83 if ((cpu_info[2] & (1<<20)) != 0) { | 116 static bool gHasSSE2 = hasSSE2(); |
84 return SK_CPU_SSE_LEVEL_SSE42; | 117 return gHasSSE2; |
85 } else if ((cpu_info[2] & (1<<9)) != 0) { | |
86 return SK_CPU_SSE_LEVEL_SSSE3; | |
87 } else if ((cpu_info[3] & (1<<26)) != 0) { | |
88 return SK_CPU_SSE_LEVEL_SSE2; | |
89 } else { | |
90 return 0; | |
91 } | |
92 } | 118 } |
93 | 119 |
94 /* Verify that the requested SIMD level exists in the build. | 120 static bool cachedHasSSSE3() { |
95 * If not, check if the platform supports it. | 121 static bool gHasSSSE3 = hasSSSE3(); |
96 */ | 122 return gHasSSSE3; |
97 static inline bool supports_simd(int minLevel) { | |
98 if (minLevel <= SK_CPU_SSE_LEVEL) { | |
99 return true; | |
100 } else { | |
101 #if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) | |
102 /* For the Android framework we should always know at compile time if th
e device | |
103 * we are building for supports SSSE3. The one exception to this rule i
s on the | |
104 * emulator where we are compiled without the -mssse3 option (so we have
no | |
105 * SSSE3 procs) but can be run on a host machine that supports SSSE3 | |
106 * instructions. So for that particular case we disable our SSSE3 option
s. | |
107 */ | |
108 return false; | |
109 #else | |
110 static int gSIMDLevel = get_SIMD_level(); | |
111 return (minLevel <= gSIMDLevel); | |
112 #endif | |
113 } | |
114 } | 123 } |
115 | 124 |
116 //////////////////////////////////////////////////////////////////////////////// | 125 //////////////////////////////////////////////////////////////////////////////// |
117 | 126 |
118 SK_CONF_DECLARE( bool, c_hqfilter_sse, "bitmap.filter.highQualitySSE", false, "U
se SSE optimized version of high quality image filters"); | 127 SK_CONF_DECLARE( bool, c_hqfilter_sse, "bitmap.filter.highQualitySSE", false, "U
se SSE optimized version of high quality image filters"); |
119 | 128 |
120 void SkBitmapProcState::platformConvolutionProcs(SkConvolutionProcs* procs) { | 129 void SkBitmapProcState::platformConvolutionProcs(SkConvolutionProcs* procs) { |
121 if (supports_simd(SK_CPU_SSE_LEVEL_SSE2)) { | 130 if (cachedHasSSE2()) { |
122 procs->fExtraHorizontalReads = 3; | 131 procs->fExtraHorizontalReads = 3; |
123 procs->fConvolveVertically = &convolveVertically_SSE2; | 132 procs->fConvolveVertically = &convolveVertically_SSE2; |
124 procs->fConvolve4RowsHorizontally = &convolve4RowsHorizontally_SSE2; | 133 procs->fConvolve4RowsHorizontally = &convolve4RowsHorizontally_SSE2; |
125 procs->fConvolveHorizontally = &convolveHorizontally_SSE2; | 134 procs->fConvolveHorizontally = &convolveHorizontally_SSE2; |
126 procs->fApplySIMDPadding = &applySIMDPadding_SSE2; | 135 procs->fApplySIMDPadding = &applySIMDPadding_SSE2; |
127 } | 136 } |
128 } | 137 } |
129 | 138 |
130 //////////////////////////////////////////////////////////////////////////////// | 139 //////////////////////////////////////////////////////////////////////////////// |
131 | 140 |
132 void SkBitmapProcState::platformProcs() { | 141 void SkBitmapProcState::platformProcs() { |
133 /* Every optimization in the function requires at least SSE2 */ | 142 /* Every optimization in the function requires at least SSE2 */ |
134 if (!supports_simd(SK_CPU_SSE_LEVEL_SSE2)) { | 143 if (!cachedHasSSE2()) { |
135 return; | 144 return; |
136 } | 145 } |
137 | 146 |
138 /* Check fSampleProc32 */ | 147 /* Check fSampleProc32 */ |
139 if (fSampleProc32 == S32_opaque_D32_filter_DX) { | 148 if (fSampleProc32 == S32_opaque_D32_filter_DX) { |
140 if (supports_simd(SK_CPU_SSE_LEVEL_SSSE3)) { | 149 if (cachedHasSSSE3()) { |
141 fSampleProc32 = S32_opaque_D32_filter_DX_SSSE3; | 150 fSampleProc32 = S32_opaque_D32_filter_DX_SSSE3; |
142 } else { | 151 } else { |
143 fSampleProc32 = S32_opaque_D32_filter_DX_SSE2; | 152 fSampleProc32 = S32_opaque_D32_filter_DX_SSE2; |
144 } | 153 } |
145 } else if (fSampleProc32 == S32_opaque_D32_filter_DXDY) { | 154 } else if (fSampleProc32 == S32_opaque_D32_filter_DXDY) { |
146 if (supports_simd(SK_CPU_SSE_LEVEL_SSSE3)) { | 155 if (cachedHasSSSE3()) { |
147 fSampleProc32 = S32_opaque_D32_filter_DXDY_SSSE3; | 156 fSampleProc32 = S32_opaque_D32_filter_DXDY_SSSE3; |
148 } | 157 } |
149 } else if (fSampleProc32 == S32_alpha_D32_filter_DX) { | 158 } else if (fSampleProc32 == S32_alpha_D32_filter_DX) { |
150 if (supports_simd(SK_CPU_SSE_LEVEL_SSSE3)) { | 159 if (cachedHasSSSE3()) { |
151 fSampleProc32 = S32_alpha_D32_filter_DX_SSSE3; | 160 fSampleProc32 = S32_alpha_D32_filter_DX_SSSE3; |
152 } else { | 161 } else { |
153 fSampleProc32 = S32_alpha_D32_filter_DX_SSE2; | 162 fSampleProc32 = S32_alpha_D32_filter_DX_SSE2; |
154 } | 163 } |
155 } else if (fSampleProc32 == S32_alpha_D32_filter_DXDY) { | 164 } else if (fSampleProc32 == S32_alpha_D32_filter_DXDY) { |
156 if (supports_simd(SK_CPU_SSE_LEVEL_SSSE3)) { | 165 if (cachedHasSSSE3()) { |
157 fSampleProc32 = S32_alpha_D32_filter_DXDY_SSSE3; | 166 fSampleProc32 = S32_alpha_D32_filter_DXDY_SSSE3; |
158 } | 167 } |
159 } | 168 } |
160 | 169 |
161 /* Check fSampleProc16 */ | 170 /* Check fSampleProc16 */ |
162 if (fSampleProc16 == S32_D16_filter_DX) { | 171 if (fSampleProc16 == S32_D16_filter_DX) { |
163 fSampleProc16 = S32_D16_filter_DX_SSE2; | 172 fSampleProc16 = S32_D16_filter_DX_SSE2; |
164 } | 173 } |
165 | 174 |
166 /* Check fMatrixProc */ | 175 /* Check fMatrixProc */ |
(...skipping 22 matching lines...) Expand all Loading... |
189 NULL, // S32_D565_Blend | 198 NULL, // S32_D565_Blend |
190 S32A_D565_Opaque_SSE2, // S32A_D565_Opaque | 199 S32A_D565_Opaque_SSE2, // S32A_D565_Opaque |
191 NULL, // S32A_D565_Blend | 200 NULL, // S32A_D565_Blend |
192 S32_D565_Opaque_Dither_SSE2, // S32_D565_Opaque_Dither | 201 S32_D565_Opaque_Dither_SSE2, // S32_D565_Opaque_Dither |
193 NULL, // S32_D565_Blend_Dither | 202 NULL, // S32_D565_Blend_Dither |
194 S32A_D565_Opaque_Dither_SSE2, // S32A_D565_Opaque_Dither | 203 S32A_D565_Opaque_Dither_SSE2, // S32A_D565_Opaque_Dither |
195 NULL, // S32A_D565_Blend_Dither | 204 NULL, // S32A_D565_Blend_Dither |
196 }; | 205 }; |
197 | 206 |
198 SkBlitRow::Proc SkBlitRow::PlatformProcs565(unsigned flags) { | 207 SkBlitRow::Proc SkBlitRow::PlatformProcs565(unsigned flags) { |
199 if (supports_simd(SK_CPU_SSE_LEVEL_SSE2)) { | 208 if (cachedHasSSE2()) { |
200 return platform_16_procs[flags]; | 209 return platform_16_procs[flags]; |
201 } else { | 210 } else { |
202 return NULL; | 211 return NULL; |
203 } | 212 } |
204 } | 213 } |
205 | 214 |
206 static SkBlitRow::Proc32 platform_32_procs[] = { | 215 static SkBlitRow::Proc32 platform_32_procs[] = { |
207 NULL, // S32_Opaque, | 216 NULL, // S32_Opaque, |
208 S32_Blend_BlitRow32_SSE2, // S32_Blend, | 217 S32_Blend_BlitRow32_SSE2, // S32_Blend, |
209 S32A_Opaque_BlitRow32_SSE2, // S32A_Opaque | 218 S32A_Opaque_BlitRow32_SSE2, // S32A_Opaque |
210 S32A_Blend_BlitRow32_SSE2, // S32A_Blend, | 219 S32A_Blend_BlitRow32_SSE2, // S32A_Blend, |
211 }; | 220 }; |
212 | 221 |
213 SkBlitRow::Proc32 SkBlitRow::PlatformProcs32(unsigned flags) { | 222 SkBlitRow::Proc32 SkBlitRow::PlatformProcs32(unsigned flags) { |
214 if (supports_simd(SK_CPU_SSE_LEVEL_SSE2)) { | 223 if (cachedHasSSE2()) { |
215 return platform_32_procs[flags]; | 224 return platform_32_procs[flags]; |
216 } else { | 225 } else { |
217 return NULL; | 226 return NULL; |
218 } | 227 } |
219 } | 228 } |
220 | 229 |
221 SkBlitRow::ColorProc SkBlitRow::PlatformColorProc() { | 230 SkBlitRow::ColorProc SkBlitRow::PlatformColorProc() { |
222 if (supports_simd(SK_CPU_SSE_LEVEL_SSE2)) { | 231 if (cachedHasSSE2()) { |
223 return Color32_SSE2; | 232 return Color32_SSE2; |
224 } else { | 233 } else { |
225 return NULL; | 234 return NULL; |
226 } | 235 } |
227 } | 236 } |
228 | 237 |
229 SkBlitRow::ColorRectProc PlatformColorRectProcFactory(); // suppress warning | 238 SkBlitRow::ColorRectProc PlatformColorRectProcFactory(); // suppress warning |
230 | 239 |
231 SkBlitRow::ColorRectProc PlatformColorRectProcFactory() { | 240 SkBlitRow::ColorRectProc PlatformColorRectProcFactory() { |
232 /* Return NULL for now, since the optimized path in ColorRect32_SSE2 is disabled
. | 241 /* Return NULL for now, since the optimized path in ColorRect32_SSE2 is disabled
. |
233 if (supports_simd(SK_CPU_SSE_LEVEL_SSE2)) { | 242 if (cachedHasSSE2()) { |
234 return ColorRect32_SSE2; | 243 return ColorRect32_SSE2; |
235 } else { | 244 } else { |
236 return NULL; | 245 return NULL; |
237 } | 246 } |
238 */ | 247 */ |
239 return NULL; | 248 return NULL; |
240 } | 249 } |
241 | 250 |
242 //////////////////////////////////////////////////////////////////////////////// | 251 //////////////////////////////////////////////////////////////////////////////// |
243 | 252 |
244 SkBlitMask::ColorProc SkBlitMask::PlatformColorProcs(SkBitmap::Config dstConfig, | 253 SkBlitMask::ColorProc SkBlitMask::PlatformColorProcs(SkBitmap::Config dstConfig, |
245 SkMask::Format maskFormat, | 254 SkMask::Format maskFormat, |
246 SkColor color) { | 255 SkColor color) { |
247 if (SkMask::kA8_Format != maskFormat) { | 256 if (SkMask::kA8_Format != maskFormat) { |
248 return NULL; | 257 return NULL; |
249 } | 258 } |
250 | 259 |
251 ColorProc proc = NULL; | 260 ColorProc proc = NULL; |
252 if (supports_simd(SK_CPU_SSE_LEVEL_SSE2)) { | 261 if (cachedHasSSE2()) { |
253 switch (dstConfig) { | 262 switch (dstConfig) { |
254 case SkBitmap::kARGB_8888_Config: | 263 case SkBitmap::kARGB_8888_Config: |
255 // The SSE2 version is not (yet) faster for black, so we check | 264 // The SSE2 version is not (yet) faster for black, so we check |
256 // for that. | 265 // for that. |
257 if (SK_ColorBLACK != color) { | 266 if (SK_ColorBLACK != color) { |
258 proc = SkARGB32_A8_BlitMask_SSE2; | 267 proc = SkARGB32_A8_BlitMask_SSE2; |
259 } | 268 } |
260 break; | 269 break; |
261 default: | 270 default: |
262 break; | 271 break; |
263 } | 272 } |
264 } | 273 } |
265 return proc; | 274 return proc; |
266 } | 275 } |
267 | 276 |
268 SkBlitMask::BlitLCD16RowProc SkBlitMask::PlatformBlitRowProcs16(bool isOpaque) { | 277 SkBlitMask::BlitLCD16RowProc SkBlitMask::PlatformBlitRowProcs16(bool isOpaque) { |
269 if (supports_simd(SK_CPU_SSE_LEVEL_SSE2)) { | 278 if (cachedHasSSE2()) { |
270 if (isOpaque) { | 279 if (isOpaque) { |
271 return SkBlitLCD16OpaqueRow_SSE2; | 280 return SkBlitLCD16OpaqueRow_SSE2; |
272 } else { | 281 } else { |
273 return SkBlitLCD16Row_SSE2; | 282 return SkBlitLCD16Row_SSE2; |
274 } | 283 } |
275 } else { | 284 } else { |
276 return NULL; | 285 return NULL; |
277 } | 286 } |
278 | 287 |
279 } | 288 } |
280 | 289 |
281 SkBlitMask::RowProc SkBlitMask::PlatformRowProcs(SkBitmap::Config dstConfig, | 290 SkBlitMask::RowProc SkBlitMask::PlatformRowProcs(SkBitmap::Config dstConfig, |
282 SkMask::Format maskFormat, | 291 SkMask::Format maskFormat, |
283 RowFlags flags) { | 292 RowFlags flags) { |
284 return NULL; | 293 return NULL; |
285 } | 294 } |
286 | 295 |
287 //////////////////////////////////////////////////////////////////////////////// | 296 //////////////////////////////////////////////////////////////////////////////// |
288 | 297 |
289 SkMemset16Proc SkMemset16GetPlatformProc() { | 298 SkMemset16Proc SkMemset16GetPlatformProc() { |
290 if (supports_simd(SK_CPU_SSE_LEVEL_SSE2)) { | 299 if (cachedHasSSE2()) { |
291 return sk_memset16_SSE2; | 300 return sk_memset16_SSE2; |
292 } else { | 301 } else { |
293 return NULL; | 302 return NULL; |
294 } | 303 } |
295 } | 304 } |
296 | 305 |
297 SkMemset32Proc SkMemset32GetPlatformProc() { | 306 SkMemset32Proc SkMemset32GetPlatformProc() { |
298 if (supports_simd(SK_CPU_SSE_LEVEL_SSE2)) { | 307 if (cachedHasSSE2()) { |
299 return sk_memset32_SSE2; | 308 return sk_memset32_SSE2; |
300 } else { | 309 } else { |
301 return NULL; | 310 return NULL; |
302 } | 311 } |
303 } | 312 } |
304 | 313 |
305 //////////////////////////////////////////////////////////////////////////////// | 314 //////////////////////////////////////////////////////////////////////////////// |
306 | 315 |
307 SkMorphologyImageFilter::Proc SkMorphologyGetPlatformProc(SkMorphologyProcType t
ype) { | 316 SkMorphologyImageFilter::Proc SkMorphologyGetPlatformProc(SkMorphologyProcType t
ype) { |
308 if (!supports_simd(SK_CPU_SSE_LEVEL_SSE2)) { | 317 if (!cachedHasSSE2()) { |
309 return NULL; | 318 return NULL; |
310 } | 319 } |
311 switch (type) { | 320 switch (type) { |
312 case kDilateX_SkMorphologyProcType: | 321 case kDilateX_SkMorphologyProcType: |
313 return SkDilateX_SSE2; | 322 return SkDilateX_SSE2; |
314 case kDilateY_SkMorphologyProcType: | 323 case kDilateY_SkMorphologyProcType: |
315 return SkDilateY_SSE2; | 324 return SkDilateY_SSE2; |
316 case kErodeX_SkMorphologyProcType: | 325 case kErodeX_SkMorphologyProcType: |
317 return SkErodeX_SSE2; | 326 return SkErodeX_SSE2; |
318 case kErodeY_SkMorphologyProcType: | 327 case kErodeY_SkMorphologyProcType: |
319 return SkErodeY_SSE2; | 328 return SkErodeY_SSE2; |
320 default: | 329 default: |
321 return NULL; | 330 return NULL; |
322 } | 331 } |
323 } | 332 } |
324 | 333 |
325 //////////////////////////////////////////////////////////////////////////////// | 334 //////////////////////////////////////////////////////////////////////////////// |
326 | 335 |
327 bool SkBoxBlurGetPlatformProcs(SkBoxBlurProc* boxBlurX, | 336 bool SkBoxBlurGetPlatformProcs(SkBoxBlurProc* boxBlurX, |
328 SkBoxBlurProc* boxBlurY, | 337 SkBoxBlurProc* boxBlurY, |
329 SkBoxBlurProc* boxBlurXY, | 338 SkBoxBlurProc* boxBlurXY, |
330 SkBoxBlurProc* boxBlurYX) { | 339 SkBoxBlurProc* boxBlurYX) { |
331 #ifdef SK_DISABLE_BLUR_DIVISION_OPTIMIZATION | 340 #ifdef SK_DISABLE_BLUR_DIVISION_OPTIMIZATION |
332 return false; | 341 return false; |
333 #else | 342 #else |
334 if (!supports_simd(SK_CPU_SSE_LEVEL_SSE2)) { | 343 if (!cachedHasSSE2()) { |
335 return false; | 344 return false; |
336 } | 345 } |
337 return SkBoxBlurGetPlatformProcs_SSE2(boxBlurX, boxBlurY, boxBlurXY, boxBlur
YX); | 346 return SkBoxBlurGetPlatformProcs_SSE2(boxBlurX, boxBlurY, boxBlurXY, boxBlur
YX); |
338 #endif | 347 #endif |
339 } | 348 } |
340 | 349 |
341 //////////////////////////////////////////////////////////////////////////////// | 350 //////////////////////////////////////////////////////////////////////////////// |
342 | 351 |
343 extern SkProcCoeffXfermode* SkPlatformXfermodeFactory_impl_SSE2(const ProcCoeff&
rec, | 352 extern SkProcCoeffXfermode* SkPlatformXfermodeFactory_impl_SSE2(const ProcCoeff&
rec, |
344 SkXfermode::Mode
mode); | 353 SkXfermode::Mode
mode); |
345 | 354 |
346 SkProcCoeffXfermode* SkPlatformXfermodeFactory_impl(const ProcCoeff& rec, | 355 SkProcCoeffXfermode* SkPlatformXfermodeFactory_impl(const ProcCoeff& rec, |
347 SkXfermode::Mode mode); | 356 SkXfermode::Mode mode); |
348 | 357 |
349 SkProcCoeffXfermode* SkPlatformXfermodeFactory_impl(const ProcCoeff& rec, | 358 SkProcCoeffXfermode* SkPlatformXfermodeFactory_impl(const ProcCoeff& rec, |
350 SkXfermode::Mode mode) { | 359 SkXfermode::Mode mode) { |
351 return NULL; | 360 return NULL; |
352 } | 361 } |
353 | 362 |
354 SkProcCoeffXfermode* SkPlatformXfermodeFactory(const ProcCoeff& rec, | 363 SkProcCoeffXfermode* SkPlatformXfermodeFactory(const ProcCoeff& rec, |
355 SkXfermode::Mode mode); | 364 SkXfermode::Mode mode); |
356 | 365 |
357 SkProcCoeffXfermode* SkPlatformXfermodeFactory(const ProcCoeff& rec, | 366 SkProcCoeffXfermode* SkPlatformXfermodeFactory(const ProcCoeff& rec, |
358 SkXfermode::Mode mode) { | 367 SkXfermode::Mode mode) { |
359 if (supports_simd(SK_CPU_SSE_LEVEL_SSE2)) { | 368 if (cachedHasSSE2()) { |
360 return SkPlatformXfermodeFactory_impl_SSE2(rec, mode); | 369 return SkPlatformXfermodeFactory_impl_SSE2(rec, mode); |
361 } else { | 370 } else { |
362 return SkPlatformXfermodeFactory_impl(rec, mode); | 371 return SkPlatformXfermodeFactory_impl(rec, mode); |
363 } | 372 } |
364 } | 373 } |
365 | 374 |
366 SkXfermodeProc SkPlatformXfermodeProcFactory(SkXfermode::Mode mode); | 375 SkXfermodeProc SkPlatformXfermodeProcFactory(SkXfermode::Mode mode); |
367 | 376 |
368 SkXfermodeProc SkPlatformXfermodeProcFactory(SkXfermode::Mode mode) { | 377 SkXfermodeProc SkPlatformXfermodeProcFactory(SkXfermode::Mode mode) { |
369 return NULL; | 378 return NULL; |
370 } | 379 } |
OLD | NEW |