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