senorblanco@chromium.org | 4e75355 | 2009-11-16 21:09:00 +0000 | [diff] [blame] | 1 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 2 | * Copyright 2009 The Android Open Source Project |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
senorblanco@chromium.org | 4e75355 | 2009-11-16 21:09:00 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
commit-bot@chromium.org | 8c4953c | 2014-04-30 14:58:46 +0000 | [diff] [blame] | 8 | #include "SkBitmapFilter_opts_SSE2.h" |
senorblanco@chromium.org | dc7de74 | 2009-11-30 20:00:29 +0000 | [diff] [blame] | 9 | #include "SkBitmapProcState_opts_SSE2.h" |
tomhudson@google.com | 95ad155 | 2012-02-14 18:28:54 +0000 | [diff] [blame] | 10 | #include "SkBitmapProcState_opts_SSSE3.h" |
humper | 4f96ab3 | 2014-06-27 11:27:03 -0700 | [diff] [blame] | 11 | #include "SkBitmapScaler.h" |
reed@google.com | 58af9a6 | 2011-10-12 13:43:52 +0000 | [diff] [blame] | 12 | #include "SkBlitMask.h" |
tomhudson@google.com | 8dd90a9 | 2012-03-19 13:49:50 +0000 | [diff] [blame] | 13 | #include "SkBlitRect_opts_SSE2.h" |
commit-bot@chromium.org | 8c4953c | 2014-04-30 14:58:46 +0000 | [diff] [blame] | 14 | #include "SkBlitRow.h" |
senorblanco@chromium.org | 4e75355 | 2009-11-16 21:09:00 +0000 | [diff] [blame] | 15 | #include "SkBlitRow_opts_SSE2.h" |
henrik.smiding | 3bb195e | 2014-06-27 08:03:17 -0700 | [diff] [blame] | 16 | #include "SkBlitRow_opts_SSE4.h" |
senorblanco@chromium.org | 27eec46 | 2013-11-08 20:49:04 +0000 | [diff] [blame] | 17 | #include "SkBlurImage_opts_SSE2.h" |
henrik.smiding | 2830632 | 2014-07-04 04:23:17 -0700 | [diff] [blame] | 18 | #include "SkBlurImage_opts_SSE4.h" |
senorblanco@chromium.org | 7a47ad3 | 2013-10-30 21:57:04 +0000 | [diff] [blame] | 19 | #include "SkMorphology_opts.h" |
| 20 | #include "SkMorphology_opts_SSE2.h" |
commit-bot@chromium.org | 8c4953c | 2014-04-30 14:58:46 +0000 | [diff] [blame] | 21 | #include "SkRTConf.h" |
| 22 | #include "SkUtils.h" |
| 23 | #include "SkUtils_opts_SSE2.h" |
commit-bot@chromium.org | c524e98 | 2014-04-09 15:43:46 +0000 | [diff] [blame] | 24 | #include "SkXfermode.h" |
| 25 | #include "SkXfermode_proccoeff.h" |
senorblanco@chromium.org | 4e75355 | 2009-11-16 21:09:00 +0000 | [diff] [blame] | 26 | |
tomhudson@google.com | ea85494 | 2012-05-17 15:09:17 +0000 | [diff] [blame] | 27 | #if defined(_MSC_VER) && defined(_WIN64) |
| 28 | #include <intrin.h> |
| 29 | #endif |
| 30 | |
commit-bot@chromium.org | ce4402c | 2014-05-12 14:16:19 +0000 | [diff] [blame] | 31 | /* This file must *not* be compiled with -msse or any other optional SIMD |
| 32 | extension, otherwise gcc may generate SIMD instructions even for scalar ops |
| 33 | (and thus give an invalid instruction on Pentium3 on the code below). |
| 34 | For example, only files named *_SSE2.cpp in this directory should be |
| 35 | compiled with -msse2 or higher. */ |
senorblanco@chromium.org | 4e75355 | 2009-11-16 21:09:00 +0000 | [diff] [blame] | 36 | |
tomhudson@google.com | 95ad155 | 2012-02-14 18:28:54 +0000 | [diff] [blame] | 37 | |
commit-bot@chromium.org | 8c4953c | 2014-04-30 14:58:46 +0000 | [diff] [blame] | 38 | /* Function to get the CPU SSE-level in runtime, for different compilers. */ |
senorblanco@chromium.org | 4e75355 | 2009-11-16 21:09:00 +0000 | [diff] [blame] | 39 | #ifdef _MSC_VER |
| 40 | static inline void getcpuid(int info_type, int info[4]) { |
tomhudson@google.com | ea85494 | 2012-05-17 15:09:17 +0000 | [diff] [blame] | 41 | #if defined(_WIN64) |
| 42 | __cpuid(info, info_type); |
| 43 | #else |
senorblanco@chromium.org | 4e75355 | 2009-11-16 21:09:00 +0000 | [diff] [blame] | 44 | __asm { |
| 45 | mov eax, [info_type] |
| 46 | cpuid |
| 47 | mov edi, [info] |
| 48 | mov [edi], eax |
| 49 | mov [edi+4], ebx |
| 50 | mov [edi+8], ecx |
| 51 | mov [edi+12], edx |
| 52 | } |
tomhudson@google.com | ea85494 | 2012-05-17 15:09:17 +0000 | [diff] [blame] | 53 | #endif |
senorblanco@chromium.org | 4e75355 | 2009-11-16 21:09:00 +0000 | [diff] [blame] | 54 | } |
commit-bot@chromium.org | ce4402c | 2014-05-12 14:16:19 +0000 | [diff] [blame] | 55 | #elif defined(__x86_64__) |
tomhudson@google.com | 95ad155 | 2012-02-14 18:28:54 +0000 | [diff] [blame] | 56 | static inline void getcpuid(int info_type, int info[4]) { |
| 57 | asm volatile ( |
| 58 | "cpuid \n\t" |
| 59 | : "=a"(info[0]), "=b"(info[1]), "=c"(info[2]), "=d"(info[3]) |
| 60 | : "a"(info_type) |
| 61 | ); |
| 62 | } |
| 63 | #else |
senorblanco@chromium.org | 4e75355 | 2009-11-16 21:09:00 +0000 | [diff] [blame] | 64 | static inline void getcpuid(int info_type, int info[4]) { |
| 65 | // We save and restore ebx, so this code can be compatible with -fPIC |
| 66 | asm volatile ( |
| 67 | "pushl %%ebx \n\t" |
| 68 | "cpuid \n\t" |
| 69 | "movl %%ebx, %1 \n\t" |
| 70 | "popl %%ebx \n\t" |
| 71 | : "=a"(info[0]), "=r"(info[1]), "=c"(info[2]), "=d"(info[3]) |
| 72 | : "a"(info_type) |
senorblanco@chromium.org | 4e75355 | 2009-11-16 21:09:00 +0000 | [diff] [blame] | 73 | ); |
| 74 | } |
| 75 | #endif |
tomhudson@google.com | 95ad155 | 2012-02-14 18:28:54 +0000 | [diff] [blame] | 76 | |
commit-bot@chromium.org | 8c4953c | 2014-04-30 14:58:46 +0000 | [diff] [blame] | 77 | //////////////////////////////////////////////////////////////////////////////// |
| 78 | |
commit-bot@chromium.org | ce4402c | 2014-05-12 14:16:19 +0000 | [diff] [blame] | 79 | /* Fetch the SIMD level directly from the CPU, at run-time. |
| 80 | * Only checks the levels needed by the optimizations in this file. |
commit-bot@chromium.org | 443c0a6 | 2014-05-08 15:27:52 +0000 | [diff] [blame] | 81 | */ |
commit-bot@chromium.org | ce4402c | 2014-05-12 14:16:19 +0000 | [diff] [blame] | 82 | static int get_SIMD_level() { |
commit-bot@chromium.org | 443c0a6 | 2014-05-08 15:27:52 +0000 | [diff] [blame] | 83 | int cpu_info[4] = { 0 }; |
commit-bot@chromium.org | ce4402c | 2014-05-12 14:16:19 +0000 | [diff] [blame] | 84 | |
commit-bot@chromium.org | 443c0a6 | 2014-05-08 15:27:52 +0000 | [diff] [blame] | 85 | getcpuid(1, cpu_info); |
commit-bot@chromium.org | ce4402c | 2014-05-12 14:16:19 +0000 | [diff] [blame] | 86 | if ((cpu_info[2] & (1<<20)) != 0) { |
| 87 | return SK_CPU_SSE_LEVEL_SSE42; |
henrik.smiding | 3bb195e | 2014-06-27 08:03:17 -0700 | [diff] [blame] | 88 | } else if ((cpu_info[2] & (1<<19)) != 0) { |
| 89 | return SK_CPU_SSE_LEVEL_SSE41; |
commit-bot@chromium.org | ce4402c | 2014-05-12 14:16:19 +0000 | [diff] [blame] | 90 | } else if ((cpu_info[2] & (1<<9)) != 0) { |
| 91 | return SK_CPU_SSE_LEVEL_SSSE3; |
| 92 | } else if ((cpu_info[3] & (1<<26)) != 0) { |
| 93 | return SK_CPU_SSE_LEVEL_SSE2; |
| 94 | } else { |
| 95 | return 0; |
| 96 | } |
commit-bot@chromium.org | 443c0a6 | 2014-05-08 15:27:52 +0000 | [diff] [blame] | 97 | } |
commit-bot@chromium.org | ce4402c | 2014-05-12 14:16:19 +0000 | [diff] [blame] | 98 | |
| 99 | /* Verify that the requested SIMD level is supported in the build. |
| 100 | * If not, check if the platform supports it. |
| 101 | */ |
| 102 | static inline bool supports_simd(int minLevel) { |
| 103 | #if defined(SK_CPU_SSE_LEVEL) |
| 104 | if (minLevel <= SK_CPU_SSE_LEVEL) { |
| 105 | return true; |
| 106 | } else |
commit-bot@chromium.org | 443c0a6 | 2014-05-08 15:27:52 +0000 | [diff] [blame] | 107 | #endif |
commit-bot@chromium.org | ce4402c | 2014-05-12 14:16:19 +0000 | [diff] [blame] | 108 | { |
| 109 | #if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) |
| 110 | /* For the Android framework we should always know at compile time if the device |
| 111 | * we are building for supports SSSE3. The one exception to this rule is on the |
| 112 | * emulator where we are compiled without the -mssse3 option (so we have no |
| 113 | * SSSE3 procs) but can be run on a host machine that supports SSSE3 |
| 114 | * instructions. So for that particular case we disable our SSSE3 options. |
| 115 | */ |
| 116 | return false; |
| 117 | #else |
| 118 | static int gSIMDLevel = get_SIMD_level(); |
| 119 | return (minLevel <= gSIMDLevel); |
| 120 | #endif |
| 121 | } |
tomhudson@google.com | 95ad155 | 2012-02-14 18:28:54 +0000 | [diff] [blame] | 122 | } |
| 123 | |
commit-bot@chromium.org | 8c4953c | 2014-04-30 14:58:46 +0000 | [diff] [blame] | 124 | //////////////////////////////////////////////////////////////////////////////// |
| 125 | |
humper@google.com | b088947 | 2013-07-09 21:37:14 +0000 | [diff] [blame] | 126 | SK_CONF_DECLARE( bool, c_hqfilter_sse, "bitmap.filter.highQualitySSE", false, "Use SSE optimized version of high quality image filters"); |
| 127 | |
humper | 4f96ab3 | 2014-06-27 11:27:03 -0700 | [diff] [blame] | 128 | void SkBitmapScaler::PlatformConvolutionProcs(SkConvolutionProcs* procs) { |
commit-bot@chromium.org | ce4402c | 2014-05-12 14:16:19 +0000 | [diff] [blame] | 129 | if (supports_simd(SK_CPU_SSE_LEVEL_SSE2)) { |
reed@google.com | fed04b3 | 2013-09-05 20:31:17 +0000 | [diff] [blame] | 130 | procs->fExtraHorizontalReads = 3; |
| 131 | procs->fConvolveVertically = &convolveVertically_SSE2; |
| 132 | procs->fConvolve4RowsHorizontally = &convolve4RowsHorizontally_SSE2; |
| 133 | procs->fConvolveHorizontally = &convolveHorizontally_SSE2; |
| 134 | procs->fApplySIMDPadding = &applySIMDPadding_SSE2; |
humper@google.com | 138ebc3 | 2013-07-19 20:20:04 +0000 | [diff] [blame] | 135 | } |
| 136 | } |
| 137 | |
commit-bot@chromium.org | 8c4953c | 2014-04-30 14:58:46 +0000 | [diff] [blame] | 138 | //////////////////////////////////////////////////////////////////////////////// |
| 139 | |
senorblanco@chromium.org | dc7de74 | 2009-11-30 20:00:29 +0000 | [diff] [blame] | 140 | void SkBitmapProcState::platformProcs() { |
commit-bot@chromium.org | 4b9b456 | 2014-04-28 15:07:50 +0000 | [diff] [blame] | 141 | /* Every optimization in the function requires at least SSE2 */ |
commit-bot@chromium.org | ce4402c | 2014-05-12 14:16:19 +0000 | [diff] [blame] | 142 | if (!supports_simd(SK_CPU_SSE_LEVEL_SSE2)) { |
commit-bot@chromium.org | 4b9b456 | 2014-04-28 15:07:50 +0000 | [diff] [blame] | 143 | return; |
| 144 | } |
commit-bot@chromium.org | c398f71 | 2014-04-23 20:07:19 +0000 | [diff] [blame] | 145 | |
commit-bot@chromium.org | 4b9b456 | 2014-04-28 15:07:50 +0000 | [diff] [blame] | 146 | /* Check fSampleProc32 */ |
| 147 | if (fSampleProc32 == S32_opaque_D32_filter_DX) { |
commit-bot@chromium.org | ce4402c | 2014-05-12 14:16:19 +0000 | [diff] [blame] | 148 | if (supports_simd(SK_CPU_SSE_LEVEL_SSSE3)) { |
commit-bot@chromium.org | 4b9b456 | 2014-04-28 15:07:50 +0000 | [diff] [blame] | 149 | fSampleProc32 = S32_opaque_D32_filter_DX_SSSE3; |
| 150 | } else { |
commit-bot@chromium.org | c398f71 | 2014-04-23 20:07:19 +0000 | [diff] [blame] | 151 | fSampleProc32 = S32_opaque_D32_filter_DX_SSE2; |
commit-bot@chromium.org | 4b9b456 | 2014-04-28 15:07:50 +0000 | [diff] [blame] | 152 | } |
| 153 | } else if (fSampleProc32 == S32_opaque_D32_filter_DXDY) { |
commit-bot@chromium.org | ce4402c | 2014-05-12 14:16:19 +0000 | [diff] [blame] | 154 | if (supports_simd(SK_CPU_SSE_LEVEL_SSSE3)) { |
commit-bot@chromium.org | 4b9b456 | 2014-04-28 15:07:50 +0000 | [diff] [blame] | 155 | fSampleProc32 = S32_opaque_D32_filter_DXDY_SSSE3; |
| 156 | } |
| 157 | } else if (fSampleProc32 == S32_alpha_D32_filter_DX) { |
commit-bot@chromium.org | ce4402c | 2014-05-12 14:16:19 +0000 | [diff] [blame] | 158 | if (supports_simd(SK_CPU_SSE_LEVEL_SSSE3)) { |
commit-bot@chromium.org | 4b9b456 | 2014-04-28 15:07:50 +0000 | [diff] [blame] | 159 | fSampleProc32 = S32_alpha_D32_filter_DX_SSSE3; |
| 160 | } else { |
commit-bot@chromium.org | c398f71 | 2014-04-23 20:07:19 +0000 | [diff] [blame] | 161 | fSampleProc32 = S32_alpha_D32_filter_DX_SSE2; |
| 162 | } |
commit-bot@chromium.org | 4b9b456 | 2014-04-28 15:07:50 +0000 | [diff] [blame] | 163 | } else if (fSampleProc32 == S32_alpha_D32_filter_DXDY) { |
commit-bot@chromium.org | ce4402c | 2014-05-12 14:16:19 +0000 | [diff] [blame] | 164 | if (supports_simd(SK_CPU_SSE_LEVEL_SSSE3)) { |
commit-bot@chromium.org | 4b9b456 | 2014-04-28 15:07:50 +0000 | [diff] [blame] | 165 | fSampleProc32 = S32_alpha_D32_filter_DXDY_SSSE3; |
commit-bot@chromium.org | c398f71 | 2014-04-23 20:07:19 +0000 | [diff] [blame] | 166 | } |
senorblanco@chromium.org | dc7de74 | 2009-11-30 20:00:29 +0000 | [diff] [blame] | 167 | } |
tomhudson@google.com | 06a7313 | 2012-02-22 18:30:43 +0000 | [diff] [blame] | 168 | |
commit-bot@chromium.org | 4b9b456 | 2014-04-28 15:07:50 +0000 | [diff] [blame] | 169 | /* Check fSampleProc16 */ |
| 170 | if (fSampleProc16 == S32_D16_filter_DX) { |
| 171 | fSampleProc16 = S32_D16_filter_DX_SSE2; |
| 172 | } |
tomhudson@google.com | 5efaf26 | 2012-02-28 15:41:49 +0000 | [diff] [blame] | 173 | |
commit-bot@chromium.org | 4b9b456 | 2014-04-28 15:07:50 +0000 | [diff] [blame] | 174 | /* Check fMatrixProc */ |
| 175 | if (fMatrixProc == ClampX_ClampY_filter_scale) { |
| 176 | fMatrixProc = ClampX_ClampY_filter_scale_SSE2; |
| 177 | } else if (fMatrixProc == ClampX_ClampY_nofilter_scale) { |
| 178 | fMatrixProc = ClampX_ClampY_nofilter_scale_SSE2; |
| 179 | } else if (fMatrixProc == ClampX_ClampY_filter_affine) { |
| 180 | fMatrixProc = ClampX_ClampY_filter_affine_SSE2; |
| 181 | } else if (fMatrixProc == ClampX_ClampY_nofilter_affine) { |
| 182 | fMatrixProc = ClampX_ClampY_nofilter_affine_SSE2; |
| 183 | } |
| 184 | |
| 185 | /* Check fShaderProc32 */ |
| 186 | if (c_hqfilter_sse) { |
| 187 | if (fShaderProc32 == highQualityFilter32) { |
| 188 | fShaderProc32 = highQualityFilter_SSE2; |
humper@google.com | b088947 | 2013-07-09 21:37:14 +0000 | [diff] [blame] | 189 | } |
tomhudson@google.com | 06a7313 | 2012-02-22 18:30:43 +0000 | [diff] [blame] | 190 | } |
senorblanco@chromium.org | dc7de74 | 2009-11-30 20:00:29 +0000 | [diff] [blame] | 191 | } |
| 192 | |
commit-bot@chromium.org | 8c4953c | 2014-04-30 14:58:46 +0000 | [diff] [blame] | 193 | //////////////////////////////////////////////////////////////////////////////// |
| 194 | |
commit-bot@chromium.org | 4759107 | 2014-02-19 03:09:52 +0000 | [diff] [blame] | 195 | static SkBlitRow::Proc platform_16_procs[] = { |
commit-bot@chromium.org | 39ce33a | 2014-02-24 04:23:39 +0000 | [diff] [blame] | 196 | S32_D565_Opaque_SSE2, // S32_D565_Opaque |
commit-bot@chromium.org | 4759107 | 2014-02-19 03:09:52 +0000 | [diff] [blame] | 197 | NULL, // S32_D565_Blend |
| 198 | S32A_D565_Opaque_SSE2, // S32A_D565_Opaque |
| 199 | NULL, // S32A_D565_Blend |
commit-bot@chromium.org | 2758047 | 2014-03-07 03:25:32 +0000 | [diff] [blame] | 200 | S32_D565_Opaque_Dither_SSE2, // S32_D565_Opaque_Dither |
commit-bot@chromium.org | 4759107 | 2014-02-19 03:09:52 +0000 | [diff] [blame] | 201 | NULL, // S32_D565_Blend_Dither |
commit-bot@chromium.org | fe089b3 | 2014-03-07 13:24:42 +0000 | [diff] [blame] | 202 | S32A_D565_Opaque_Dither_SSE2, // S32A_D565_Opaque_Dither |
commit-bot@chromium.org | 4759107 | 2014-02-19 03:09:52 +0000 | [diff] [blame] | 203 | NULL, // S32A_D565_Blend_Dither |
| 204 | }; |
| 205 | |
commit-bot@chromium.org | 8c4953c | 2014-04-30 14:58:46 +0000 | [diff] [blame] | 206 | SkBlitRow::Proc SkBlitRow::PlatformProcs565(unsigned flags) { |
commit-bot@chromium.org | ce4402c | 2014-05-12 14:16:19 +0000 | [diff] [blame] | 207 | if (supports_simd(SK_CPU_SSE_LEVEL_SSE2)) { |
commit-bot@chromium.org | 8c4953c | 2014-04-30 14:58:46 +0000 | [diff] [blame] | 208 | return platform_16_procs[flags]; |
| 209 | } else { |
| 210 | return NULL; |
| 211 | } |
| 212 | } |
| 213 | |
henrik.smiding | 3bb195e | 2014-06-27 08:03:17 -0700 | [diff] [blame] | 214 | static SkBlitRow::Proc32 platform_32_procs_SSE2[] = { |
senorblanco@chromium.org | 4e75355 | 2009-11-16 21:09:00 +0000 | [diff] [blame] | 215 | NULL, // S32_Opaque, |
| 216 | S32_Blend_BlitRow32_SSE2, // S32_Blend, |
| 217 | S32A_Opaque_BlitRow32_SSE2, // S32A_Opaque |
| 218 | S32A_Blend_BlitRow32_SSE2, // S32A_Blend, |
| 219 | }; |
| 220 | |
henrik.smiding | 3bb195e | 2014-06-27 08:03:17 -0700 | [diff] [blame] | 221 | #if defined(SK_ATT_ASM_SUPPORTED) |
| 222 | static SkBlitRow::Proc32 platform_32_procs_SSE4[] = { |
| 223 | NULL, // S32_Opaque, |
| 224 | S32_Blend_BlitRow32_SSE2, // S32_Blend, |
| 225 | S32A_Opaque_BlitRow32_SSE4_asm, // S32A_Opaque |
| 226 | S32A_Blend_BlitRow32_SSE2, // S32A_Blend, |
| 227 | }; |
| 228 | #endif |
| 229 | |
commit-bot@chromium.org | 8c4953c | 2014-04-30 14:58:46 +0000 | [diff] [blame] | 230 | SkBlitRow::Proc32 SkBlitRow::PlatformProcs32(unsigned flags) { |
henrik.smiding | 3bb195e | 2014-06-27 08:03:17 -0700 | [diff] [blame] | 231 | #if defined(SK_ATT_ASM_SUPPORTED) |
| 232 | if (supports_simd(SK_CPU_SSE_LEVEL_SSE41)) { |
| 233 | return platform_32_procs_SSE4[flags]; |
| 234 | } else |
| 235 | #endif |
commit-bot@chromium.org | ce4402c | 2014-05-12 14:16:19 +0000 | [diff] [blame] | 236 | if (supports_simd(SK_CPU_SSE_LEVEL_SSE2)) { |
henrik.smiding | 3bb195e | 2014-06-27 08:03:17 -0700 | [diff] [blame] | 237 | return platform_32_procs_SSE2[flags]; |
commit-bot@chromium.org | 4759107 | 2014-02-19 03:09:52 +0000 | [diff] [blame] | 238 | } else { |
| 239 | return NULL; |
| 240 | } |
senorblanco@chromium.org | 4e75355 | 2009-11-16 21:09:00 +0000 | [diff] [blame] | 241 | } |
| 242 | |
senorblanco@chromium.org | c385638 | 2010-12-13 15:27:20 +0000 | [diff] [blame] | 243 | SkBlitRow::ColorProc SkBlitRow::PlatformColorProc() { |
commit-bot@chromium.org | ce4402c | 2014-05-12 14:16:19 +0000 | [diff] [blame] | 244 | if (supports_simd(SK_CPU_SSE_LEVEL_SSE2)) { |
senorblanco@chromium.org | c385638 | 2010-12-13 15:27:20 +0000 | [diff] [blame] | 245 | return Color32_SSE2; |
| 246 | } else { |
| 247 | return NULL; |
| 248 | } |
| 249 | } |
| 250 | |
commit-bot@chromium.org | 8c4953c | 2014-04-30 14:58:46 +0000 | [diff] [blame] | 251 | SkBlitRow::ColorRectProc PlatformColorRectProcFactory(); // suppress warning |
| 252 | |
| 253 | SkBlitRow::ColorRectProc PlatformColorRectProcFactory() { |
| 254 | /* Return NULL for now, since the optimized path in ColorRect32_SSE2 is disabled. |
commit-bot@chromium.org | ce4402c | 2014-05-12 14:16:19 +0000 | [diff] [blame] | 255 | if (supports_simd(SK_CPU_SSE_LEVEL_SSE2)) { |
commit-bot@chromium.org | 8c4953c | 2014-04-30 14:58:46 +0000 | [diff] [blame] | 256 | return ColorRect32_SSE2; |
senorblanco@chromium.org | 4e75355 | 2009-11-16 21:09:00 +0000 | [diff] [blame] | 257 | } else { |
| 258 | return NULL; |
| 259 | } |
commit-bot@chromium.org | 8c4953c | 2014-04-30 14:58:46 +0000 | [diff] [blame] | 260 | */ |
| 261 | return NULL; |
senorblanco@chromium.org | 4e75355 | 2009-11-16 21:09:00 +0000 | [diff] [blame] | 262 | } |
| 263 | |
commit-bot@chromium.org | 8c4953c | 2014-04-30 14:58:46 +0000 | [diff] [blame] | 264 | //////////////////////////////////////////////////////////////////////////////// |
reed@google.com | 981d479 | 2011-03-09 12:55:47 +0000 | [diff] [blame] | 265 | |
commit-bot@chromium.org | cba7378 | 2014-05-29 15:57:47 +0000 | [diff] [blame] | 266 | SkBlitMask::ColorProc SkBlitMask::PlatformColorProcs(SkColorType dstCT, |
reed@google.com | e901b4c | 2011-11-14 21:56:45 +0000 | [diff] [blame] | 267 | SkMask::Format maskFormat, |
| 268 | SkColor color) { |
reed@google.com | edb606c | 2011-10-18 13:56:50 +0000 | [diff] [blame] | 269 | if (SkMask::kA8_Format != maskFormat) { |
| 270 | return NULL; |
| 271 | } |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 272 | |
reed@google.com | e901b4c | 2011-11-14 21:56:45 +0000 | [diff] [blame] | 273 | ColorProc proc = NULL; |
commit-bot@chromium.org | ce4402c | 2014-05-12 14:16:19 +0000 | [diff] [blame] | 274 | if (supports_simd(SK_CPU_SSE_LEVEL_SSE2)) { |
commit-bot@chromium.org | cba7378 | 2014-05-29 15:57:47 +0000 | [diff] [blame] | 275 | switch (dstCT) { |
| 276 | case kN32_SkColorType: |
reed@google.com | e6ea606 | 2011-07-07 19:12:50 +0000 | [diff] [blame] | 277 | // The SSE2 version is not (yet) faster for black, so we check |
| 278 | // for that. |
| 279 | if (SK_ColorBLACK != color) { |
reed@google.com | edb606c | 2011-10-18 13:56:50 +0000 | [diff] [blame] | 280 | proc = SkARGB32_A8_BlitMask_SSE2; |
reed@google.com | e6ea606 | 2011-07-07 19:12:50 +0000 | [diff] [blame] | 281 | } |
reed@google.com | 981d479 | 2011-03-09 12:55:47 +0000 | [diff] [blame] | 282 | break; |
| 283 | default: |
reed@google.com | e901b4c | 2011-11-14 21:56:45 +0000 | [diff] [blame] | 284 | break; |
reed@google.com | 981d479 | 2011-03-09 12:55:47 +0000 | [diff] [blame] | 285 | } |
| 286 | } |
| 287 | return proc; |
| 288 | } |
| 289 | |
tomhudson@google.com | d6770e6 | 2012-02-14 16:01:15 +0000 | [diff] [blame] | 290 | SkBlitMask::BlitLCD16RowProc SkBlitMask::PlatformBlitRowProcs16(bool isOpaque) { |
commit-bot@chromium.org | ce4402c | 2014-05-12 14:16:19 +0000 | [diff] [blame] | 291 | if (supports_simd(SK_CPU_SSE_LEVEL_SSE2)) { |
tomhudson@google.com | d6770e6 | 2012-02-14 16:01:15 +0000 | [diff] [blame] | 292 | if (isOpaque) { |
| 293 | return SkBlitLCD16OpaqueRow_SSE2; |
| 294 | } else { |
| 295 | return SkBlitLCD16Row_SSE2; |
| 296 | } |
| 297 | } else { |
| 298 | return NULL; |
| 299 | } |
| 300 | |
| 301 | } |
commit-bot@chromium.org | 8c4953c | 2014-04-30 14:58:46 +0000 | [diff] [blame] | 302 | |
commit-bot@chromium.org | cba7378 | 2014-05-29 15:57:47 +0000 | [diff] [blame] | 303 | SkBlitMask::RowProc SkBlitMask::PlatformRowProcs(SkColorType, SkMask::Format, RowFlags) { |
reed@google.com | e901b4c | 2011-11-14 21:56:45 +0000 | [diff] [blame] | 304 | return NULL; |
| 305 | } |
| 306 | |
commit-bot@chromium.org | 8c4953c | 2014-04-30 14:58:46 +0000 | [diff] [blame] | 307 | //////////////////////////////////////////////////////////////////////////////// |
| 308 | |
senorblanco@chromium.org | 4e75355 | 2009-11-16 21:09:00 +0000 | [diff] [blame] | 309 | SkMemset16Proc SkMemset16GetPlatformProc() { |
commit-bot@chromium.org | ce4402c | 2014-05-12 14:16:19 +0000 | [diff] [blame] | 310 | if (supports_simd(SK_CPU_SSE_LEVEL_SSE2)) { |
senorblanco@chromium.org | 4e75355 | 2009-11-16 21:09:00 +0000 | [diff] [blame] | 311 | return sk_memset16_SSE2; |
| 312 | } else { |
| 313 | return NULL; |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | SkMemset32Proc SkMemset32GetPlatformProc() { |
commit-bot@chromium.org | ce4402c | 2014-05-12 14:16:19 +0000 | [diff] [blame] | 318 | if (supports_simd(SK_CPU_SSE_LEVEL_SSE2)) { |
senorblanco@chromium.org | 4e75355 | 2009-11-16 21:09:00 +0000 | [diff] [blame] | 319 | return sk_memset32_SSE2; |
| 320 | } else { |
| 321 | return NULL; |
| 322 | } |
| 323 | } |
tomhudson@google.com | 8dd90a9 | 2012-03-19 13:49:50 +0000 | [diff] [blame] | 324 | |
commit-bot@chromium.org | f0ea77a | 2014-05-21 12:43:07 +0000 | [diff] [blame] | 325 | SkMemcpy32Proc SkMemcpy32GetPlatformProc() { |
| 326 | if (supports_simd(SK_CPU_SSE_LEVEL_SSE2)) { |
| 327 | return sk_memcpy32_SSE2; |
| 328 | } else { |
| 329 | return NULL; |
| 330 | } |
| 331 | } |
| 332 | |
commit-bot@chromium.org | 8c4953c | 2014-04-30 14:58:46 +0000 | [diff] [blame] | 333 | //////////////////////////////////////////////////////////////////////////////// |
| 334 | |
senorblanco@chromium.org | 0ded88d | 2014-01-24 15:43:50 +0000 | [diff] [blame] | 335 | SkMorphologyImageFilter::Proc SkMorphologyGetPlatformProc(SkMorphologyProcType type) { |
commit-bot@chromium.org | ce4402c | 2014-05-12 14:16:19 +0000 | [diff] [blame] | 336 | if (!supports_simd(SK_CPU_SSE_LEVEL_SSE2)) { |
senorblanco@chromium.org | 7a47ad3 | 2013-10-30 21:57:04 +0000 | [diff] [blame] | 337 | return NULL; |
| 338 | } |
| 339 | switch (type) { |
| 340 | case kDilateX_SkMorphologyProcType: |
| 341 | return SkDilateX_SSE2; |
| 342 | case kDilateY_SkMorphologyProcType: |
| 343 | return SkDilateY_SSE2; |
| 344 | case kErodeX_SkMorphologyProcType: |
| 345 | return SkErodeX_SSE2; |
| 346 | case kErodeY_SkMorphologyProcType: |
| 347 | return SkErodeY_SSE2; |
| 348 | default: |
| 349 | return NULL; |
| 350 | } |
| 351 | } |
| 352 | |
commit-bot@chromium.org | 8c4953c | 2014-04-30 14:58:46 +0000 | [diff] [blame] | 353 | //////////////////////////////////////////////////////////////////////////////// |
| 354 | |
senorblanco@chromium.org | 27eec46 | 2013-11-08 20:49:04 +0000 | [diff] [blame] | 355 | bool SkBoxBlurGetPlatformProcs(SkBoxBlurProc* boxBlurX, |
| 356 | SkBoxBlurProc* boxBlurY, |
senorblanco@chromium.org | 05edd02 | 2013-11-11 20:12:34 +0000 | [diff] [blame] | 357 | SkBoxBlurProc* boxBlurXY, |
| 358 | SkBoxBlurProc* boxBlurYX) { |
senorblanco@chromium.org | 27eec46 | 2013-11-08 20:49:04 +0000 | [diff] [blame] | 359 | #ifdef SK_DISABLE_BLUR_DIVISION_OPTIMIZATION |
| 360 | return false; |
| 361 | #else |
henrik.smiding | 2830632 | 2014-07-04 04:23:17 -0700 | [diff] [blame] | 362 | if (supports_simd(SK_CPU_SSE_LEVEL_SSE41)) { |
| 363 | return SkBoxBlurGetPlatformProcs_SSE4(boxBlurX, boxBlurY, boxBlurXY, boxBlurYX); |
senorblanco@chromium.org | 27eec46 | 2013-11-08 20:49:04 +0000 | [diff] [blame] | 364 | } |
henrik.smiding | 2830632 | 2014-07-04 04:23:17 -0700 | [diff] [blame] | 365 | else if (supports_simd(SK_CPU_SSE_LEVEL_SSE2)) { |
| 366 | return SkBoxBlurGetPlatformProcs_SSE2(boxBlurX, boxBlurY, boxBlurXY, boxBlurYX); |
| 367 | } |
| 368 | return false; |
senorblanco@chromium.org | 27eec46 | 2013-11-08 20:49:04 +0000 | [diff] [blame] | 369 | #endif |
| 370 | } |
| 371 | |
commit-bot@chromium.org | 8c4953c | 2014-04-30 14:58:46 +0000 | [diff] [blame] | 372 | //////////////////////////////////////////////////////////////////////////////// |
commit-bot@chromium.org | c524e98 | 2014-04-09 15:43:46 +0000 | [diff] [blame] | 373 | |
| 374 | extern SkProcCoeffXfermode* SkPlatformXfermodeFactory_impl_SSE2(const ProcCoeff& rec, |
| 375 | SkXfermode::Mode mode); |
| 376 | |
| 377 | SkProcCoeffXfermode* SkPlatformXfermodeFactory_impl(const ProcCoeff& rec, |
| 378 | SkXfermode::Mode mode); |
| 379 | |
| 380 | SkProcCoeffXfermode* SkPlatformXfermodeFactory_impl(const ProcCoeff& rec, |
| 381 | SkXfermode::Mode mode) { |
| 382 | return NULL; |
| 383 | } |
| 384 | |
| 385 | SkProcCoeffXfermode* SkPlatformXfermodeFactory(const ProcCoeff& rec, |
| 386 | SkXfermode::Mode mode); |
| 387 | |
| 388 | SkProcCoeffXfermode* SkPlatformXfermodeFactory(const ProcCoeff& rec, |
| 389 | SkXfermode::Mode mode) { |
commit-bot@chromium.org | ce4402c | 2014-05-12 14:16:19 +0000 | [diff] [blame] | 390 | if (supports_simd(SK_CPU_SSE_LEVEL_SSE2)) { |
commit-bot@chromium.org | c524e98 | 2014-04-09 15:43:46 +0000 | [diff] [blame] | 391 | return SkPlatformXfermodeFactory_impl_SSE2(rec, mode); |
| 392 | } else { |
| 393 | return SkPlatformXfermodeFactory_impl(rec, mode); |
| 394 | } |
| 395 | } |
| 396 | |
| 397 | SkXfermodeProc SkPlatformXfermodeProcFactory(SkXfermode::Mode mode); |
| 398 | |
| 399 | SkXfermodeProc SkPlatformXfermodeProcFactory(SkXfermode::Mode mode) { |
| 400 | return NULL; |
| 401 | } |