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" |
commit-bot@chromium.org | 8c4953c | 2014-04-30 14:58:46 +0000 | [diff] [blame] | 13 | #include "SkBlitRow.h" |
senorblanco@chromium.org | 4e75355 | 2009-11-16 21:09:00 +0000 | [diff] [blame] | 14 | #include "SkBlitRow_opts_SSE2.h" |
mtklein | 4311f01 | 2016-04-19 14:00:13 -0700 | [diff] [blame] | 15 | #include "SkCpu.h" |
reed | 959a293 | 2016-05-05 01:36:43 -0700 | [diff] [blame^] | 16 | #include "SkOncePtr.h" |
commit-bot@chromium.org | 8c4953c | 2014-04-30 14:58:46 +0000 | [diff] [blame] | 17 | #include "SkRTConf.h" |
senorblanco@chromium.org | 4e75355 | 2009-11-16 21:09:00 +0000 | [diff] [blame] | 18 | |
Melnikov.Sergey.V | 601e36a | 2016-04-08 15:31:45 -0700 | [diff] [blame] | 19 | |
| 20 | /* |
| 21 | ***************************************** |
| 22 | *********This file is deprecated********* |
| 23 | ***************************************** |
| 24 | * New CPU-specific work should be done in |
| 25 | * SkOpts framework. Run-time detection of |
| 26 | * available instruction set extensions is |
| 27 | * implemented in src/core/SkOpts.cpp file |
| 28 | ***************************************** |
| 29 | */ |
| 30 | |
| 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 | |
commit-bot@chromium.org | 8c4953c | 2014-04-30 14:58:46 +0000 | [diff] [blame] | 38 | //////////////////////////////////////////////////////////////////////////////// |
| 39 | |
humper | 4f96ab3 | 2014-06-27 11:27:03 -0700 | [diff] [blame] | 40 | void SkBitmapScaler::PlatformConvolutionProcs(SkConvolutionProcs* procs) { |
mtklein | 4311f01 | 2016-04-19 14:00:13 -0700 | [diff] [blame] | 41 | if (SkCpu::Supports(SkCpu::SSE2)) { |
reed@google.com | fed04b3 | 2013-09-05 20:31:17 +0000 | [diff] [blame] | 42 | procs->fExtraHorizontalReads = 3; |
| 43 | procs->fConvolveVertically = &convolveVertically_SSE2; |
| 44 | procs->fConvolve4RowsHorizontally = &convolve4RowsHorizontally_SSE2; |
| 45 | procs->fConvolveHorizontally = &convolveHorizontally_SSE2; |
| 46 | procs->fApplySIMDPadding = &applySIMDPadding_SSE2; |
humper@google.com | 138ebc3 | 2013-07-19 20:20:04 +0000 | [diff] [blame] | 47 | } |
| 48 | } |
| 49 | |
commit-bot@chromium.org | 8c4953c | 2014-04-30 14:58:46 +0000 | [diff] [blame] | 50 | //////////////////////////////////////////////////////////////////////////////// |
| 51 | |
senorblanco@chromium.org | dc7de74 | 2009-11-30 20:00:29 +0000 | [diff] [blame] | 52 | void SkBitmapProcState::platformProcs() { |
commit-bot@chromium.org | 4b9b456 | 2014-04-28 15:07:50 +0000 | [diff] [blame] | 53 | /* Every optimization in the function requires at least SSE2 */ |
mtklein | 4311f01 | 2016-04-19 14:00:13 -0700 | [diff] [blame] | 54 | if (!SkCpu::Supports(SkCpu::SSE2)) { |
commit-bot@chromium.org | 4b9b456 | 2014-04-28 15:07:50 +0000 | [diff] [blame] | 55 | return; |
| 56 | } |
mtklein | 4311f01 | 2016-04-19 14:00:13 -0700 | [diff] [blame] | 57 | const bool ssse3 = SkCpu::Supports(SkCpu::SSSE3); |
commit-bot@chromium.org | c398f71 | 2014-04-23 20:07:19 +0000 | [diff] [blame] | 58 | |
commit-bot@chromium.org | 4b9b456 | 2014-04-28 15:07:50 +0000 | [diff] [blame] | 59 | /* Check fSampleProc32 */ |
| 60 | if (fSampleProc32 == S32_opaque_D32_filter_DX) { |
qiankun.miao | 60f3c65 | 2014-12-04 06:27:03 -0800 | [diff] [blame] | 61 | if (ssse3) { |
commit-bot@chromium.org | 4b9b456 | 2014-04-28 15:07:50 +0000 | [diff] [blame] | 62 | fSampleProc32 = S32_opaque_D32_filter_DX_SSSE3; |
| 63 | } else { |
commit-bot@chromium.org | c398f71 | 2014-04-23 20:07:19 +0000 | [diff] [blame] | 64 | fSampleProc32 = S32_opaque_D32_filter_DX_SSE2; |
commit-bot@chromium.org | 4b9b456 | 2014-04-28 15:07:50 +0000 | [diff] [blame] | 65 | } |
| 66 | } else if (fSampleProc32 == S32_opaque_D32_filter_DXDY) { |
qiankun.miao | 60f3c65 | 2014-12-04 06:27:03 -0800 | [diff] [blame] | 67 | if (ssse3) { |
commit-bot@chromium.org | 4b9b456 | 2014-04-28 15:07:50 +0000 | [diff] [blame] | 68 | fSampleProc32 = S32_opaque_D32_filter_DXDY_SSSE3; |
| 69 | } |
| 70 | } else if (fSampleProc32 == S32_alpha_D32_filter_DX) { |
qiankun.miao | 60f3c65 | 2014-12-04 06:27:03 -0800 | [diff] [blame] | 71 | if (ssse3) { |
commit-bot@chromium.org | 4b9b456 | 2014-04-28 15:07:50 +0000 | [diff] [blame] | 72 | fSampleProc32 = S32_alpha_D32_filter_DX_SSSE3; |
| 73 | } else { |
commit-bot@chromium.org | c398f71 | 2014-04-23 20:07:19 +0000 | [diff] [blame] | 74 | fSampleProc32 = S32_alpha_D32_filter_DX_SSE2; |
| 75 | } |
commit-bot@chromium.org | 4b9b456 | 2014-04-28 15:07:50 +0000 | [diff] [blame] | 76 | } else if (fSampleProc32 == S32_alpha_D32_filter_DXDY) { |
qiankun.miao | 60f3c65 | 2014-12-04 06:27:03 -0800 | [diff] [blame] | 77 | if (ssse3) { |
commit-bot@chromium.org | 4b9b456 | 2014-04-28 15:07:50 +0000 | [diff] [blame] | 78 | fSampleProc32 = S32_alpha_D32_filter_DXDY_SSSE3; |
commit-bot@chromium.org | c398f71 | 2014-04-23 20:07:19 +0000 | [diff] [blame] | 79 | } |
senorblanco@chromium.org | dc7de74 | 2009-11-30 20:00:29 +0000 | [diff] [blame] | 80 | } |
tomhudson@google.com | 06a7313 | 2012-02-22 18:30:43 +0000 | [diff] [blame] | 81 | |
commit-bot@chromium.org | 4b9b456 | 2014-04-28 15:07:50 +0000 | [diff] [blame] | 82 | /* Check fMatrixProc */ |
| 83 | if (fMatrixProc == ClampX_ClampY_filter_scale) { |
| 84 | fMatrixProc = ClampX_ClampY_filter_scale_SSE2; |
| 85 | } else if (fMatrixProc == ClampX_ClampY_nofilter_scale) { |
| 86 | fMatrixProc = ClampX_ClampY_nofilter_scale_SSE2; |
| 87 | } else if (fMatrixProc == ClampX_ClampY_filter_affine) { |
| 88 | fMatrixProc = ClampX_ClampY_filter_affine_SSE2; |
| 89 | } else if (fMatrixProc == ClampX_ClampY_nofilter_affine) { |
| 90 | fMatrixProc = ClampX_ClampY_nofilter_affine_SSE2; |
| 91 | } |
senorblanco@chromium.org | dc7de74 | 2009-11-30 20:00:29 +0000 | [diff] [blame] | 92 | } |
| 93 | |
commit-bot@chromium.org | 8c4953c | 2014-04-30 14:58:46 +0000 | [diff] [blame] | 94 | //////////////////////////////////////////////////////////////////////////////// |
| 95 | |
henrik.smiding | 4e65473 | 2015-02-10 09:42:33 -0800 | [diff] [blame] | 96 | static const SkBlitRow::Proc16 platform_16_procs[] = { |
commit-bot@chromium.org | 39ce33a | 2014-02-24 04:23:39 +0000 | [diff] [blame] | 97 | S32_D565_Opaque_SSE2, // S32_D565_Opaque |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 98 | nullptr, // S32_D565_Blend |
commit-bot@chromium.org | 4759107 | 2014-02-19 03:09:52 +0000 | [diff] [blame] | 99 | S32A_D565_Opaque_SSE2, // S32A_D565_Opaque |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 100 | nullptr, // S32A_D565_Blend |
commit-bot@chromium.org | 2758047 | 2014-03-07 03:25:32 +0000 | [diff] [blame] | 101 | S32_D565_Opaque_Dither_SSE2, // S32_D565_Opaque_Dither |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 102 | nullptr, // S32_D565_Blend_Dither |
commit-bot@chromium.org | fe089b3 | 2014-03-07 13:24:42 +0000 | [diff] [blame] | 103 | S32A_D565_Opaque_Dither_SSE2, // S32A_D565_Opaque_Dither |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 104 | nullptr, // S32A_D565_Blend_Dither |
commit-bot@chromium.org | 4759107 | 2014-02-19 03:09:52 +0000 | [diff] [blame] | 105 | }; |
| 106 | |
reed | a7f1191 | 2015-01-13 13:51:00 -0800 | [diff] [blame] | 107 | SkBlitRow::Proc16 SkBlitRow::PlatformFactory565(unsigned flags) { |
mtklein | 4311f01 | 2016-04-19 14:00:13 -0700 | [diff] [blame] | 108 | if (SkCpu::Supports(SkCpu::SSE2)) { |
commit-bot@chromium.org | 8c4953c | 2014-04-30 14:58:46 +0000 | [diff] [blame] | 109 | return platform_16_procs[flags]; |
| 110 | } else { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 111 | return nullptr; |
commit-bot@chromium.org | 8c4953c | 2014-04-30 14:58:46 +0000 | [diff] [blame] | 112 | } |
| 113 | } |
| 114 | |
henrik.smiding | 70840cb | 2015-03-20 09:20:46 -0700 | [diff] [blame] | 115 | static const SkBlitRow::ColorProc16 platform_565_colorprocs_SSE2[] = { |
| 116 | Color32A_D565_SSE2, // Color32A_D565, |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 117 | nullptr, // Color32A_D565_Dither |
henrik.smiding | 4e65473 | 2015-02-10 09:42:33 -0800 | [diff] [blame] | 118 | }; |
| 119 | |
reed | a7f1191 | 2015-01-13 13:51:00 -0800 | [diff] [blame] | 120 | SkBlitRow::ColorProc16 SkBlitRow::PlatformColorFactory565(unsigned flags) { |
henrik.smiding | 70840cb | 2015-03-20 09:20:46 -0700 | [diff] [blame] | 121 | /* If you're thinking about writing an SSE4 version of this, do check it's |
| 122 | * actually faster on Atom. Our original SSE4 version was slower than this |
| 123 | * SSE2 version on Silvermont, and only marginally faster on a Core i7, |
| 124 | * mainly due to the MULLD timings. |
| 125 | */ |
mtklein | 4311f01 | 2016-04-19 14:00:13 -0700 | [diff] [blame] | 126 | if (SkCpu::Supports(SkCpu::SSE2)) { |
henrik.smiding | 70840cb | 2015-03-20 09:20:46 -0700 | [diff] [blame] | 127 | return platform_565_colorprocs_SSE2[flags]; |
henrik.smiding | 4e65473 | 2015-02-10 09:42:33 -0800 | [diff] [blame] | 128 | } else { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 129 | return nullptr; |
henrik.smiding | 4e65473 | 2015-02-10 09:42:33 -0800 | [diff] [blame] | 130 | } |
reed | a7f1191 | 2015-01-13 13:51:00 -0800 | [diff] [blame] | 131 | } |
| 132 | |
henrik.smiding | 4e65473 | 2015-02-10 09:42:33 -0800 | [diff] [blame] | 133 | static const SkBlitRow::Proc32 platform_32_procs_SSE2[] = { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 134 | nullptr, // S32_Opaque, |
senorblanco@chromium.org | 4e75355 | 2009-11-16 21:09:00 +0000 | [diff] [blame] | 135 | S32_Blend_BlitRow32_SSE2, // S32_Blend, |
mtklein | b4a7dc9 | 2016-03-23 06:29:12 -0700 | [diff] [blame] | 136 | nullptr, // Ported to SkOpts |
henrik.smiding | 3bb195e | 2014-06-27 08:03:17 -0700 | [diff] [blame] | 137 | S32A_Blend_BlitRow32_SSE2, // S32A_Blend, |
| 138 | }; |
henrik.smiding | 3bb195e | 2014-06-27 08:03:17 -0700 | [diff] [blame] | 139 | |
commit-bot@chromium.org | 8c4953c | 2014-04-30 14:58:46 +0000 | [diff] [blame] | 140 | SkBlitRow::Proc32 SkBlitRow::PlatformProcs32(unsigned flags) { |
mtklein | 4311f01 | 2016-04-19 14:00:13 -0700 | [diff] [blame] | 141 | if (SkCpu::Supports(SkCpu::SSE2)) { |
henrik.smiding | 3bb195e | 2014-06-27 08:03:17 -0700 | [diff] [blame] | 142 | return platform_32_procs_SSE2[flags]; |
commit-bot@chromium.org | 4759107 | 2014-02-19 03:09:52 +0000 | [diff] [blame] | 143 | } else { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 144 | return nullptr; |
commit-bot@chromium.org | 4759107 | 2014-02-19 03:09:52 +0000 | [diff] [blame] | 145 | } |
senorblanco@chromium.org | 4e75355 | 2009-11-16 21:09:00 +0000 | [diff] [blame] | 146 | } |
| 147 | |
commit-bot@chromium.org | 8c4953c | 2014-04-30 14:58:46 +0000 | [diff] [blame] | 148 | //////////////////////////////////////////////////////////////////////////////// |
reed@google.com | 981d479 | 2011-03-09 12:55:47 +0000 | [diff] [blame] | 149 | |
tomhudson@google.com | d6770e6 | 2012-02-14 16:01:15 +0000 | [diff] [blame] | 150 | SkBlitMask::BlitLCD16RowProc SkBlitMask::PlatformBlitRowProcs16(bool isOpaque) { |
mtklein | 4311f01 | 2016-04-19 14:00:13 -0700 | [diff] [blame] | 151 | if (SkCpu::Supports(SkCpu::SSE2)) { |
tomhudson@google.com | d6770e6 | 2012-02-14 16:01:15 +0000 | [diff] [blame] | 152 | if (isOpaque) { |
| 153 | return SkBlitLCD16OpaqueRow_SSE2; |
| 154 | } else { |
| 155 | return SkBlitLCD16Row_SSE2; |
| 156 | } |
| 157 | } else { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 158 | return nullptr; |
tomhudson@google.com | d6770e6 | 2012-02-14 16:01:15 +0000 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | } |
commit-bot@chromium.org | 8c4953c | 2014-04-30 14:58:46 +0000 | [diff] [blame] | 162 | |
commit-bot@chromium.org | cba7378 | 2014-05-29 15:57:47 +0000 | [diff] [blame] | 163 | SkBlitMask::RowProc SkBlitMask::PlatformRowProcs(SkColorType, SkMask::Format, RowFlags) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 164 | return nullptr; |
reed@google.com | e901b4c | 2011-11-14 21:56:45 +0000 | [diff] [blame] | 165 | } |