1 /*
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.
6 */
7
8 #include "SkBitmapProcState_opts_SSE2.h"
9 #include "SkBitmapProcState_opts_SSSE3.h"
10 #include "SkBitmapScaler.h"
11 #include "SkBlitMask.h"
12 #include "SkBlitRow.h"
13 #include "SkBlitRow_opts_SSE2.h"
14 #include "SkCpu.h"
15
16
17 /*
18 *****************************************
19 *********This file is deprecated*********
20 *****************************************
21 * New CPU-specific work should be done in
22 * SkOpts framework. Run-time detection of
23 * available instruction set extensions is
24 * implemented in src/core/SkOpts.cpp file
25 *****************************************
26 */
27
28
29 /* This file must *not* be compiled with -msse or any other optional SIMD
30 extension, otherwise gcc may generate SIMD instructions even for scalar ops
31 (and thus give an invalid instruction on Pentium3 on the code below).
32 For example, only files named *_SSE2.cpp in this directory should be
33 compiled with -msse2 or higher. */
34
35 ////////////////////////////////////////////////////////////////////////////////
36
platformProcs()37 void SkBitmapProcState::platformProcs() {
38 /* Every optimization in the function requires at least SSE2 */
39 if (!SkCpu::Supports(SkCpu::SSE2)) {
40 return;
41 }
42 const bool ssse3 = SkCpu::Supports(SkCpu::SSSE3);
43
44 /* Check fSampleProc32 */
45 if (fSampleProc32 == S32_opaque_D32_filter_DX) {
46 if (ssse3) {
47 fSampleProc32 = S32_opaque_D32_filter_DX_SSSE3;
48 } else {
49 fSampleProc32 = S32_opaque_D32_filter_DX_SSE2;
50 }
51 } else if (fSampleProc32 == S32_opaque_D32_filter_DXDY) {
52 if (ssse3) {
53 fSampleProc32 = S32_opaque_D32_filter_DXDY_SSSE3;
54 }
55 } else if (fSampleProc32 == S32_alpha_D32_filter_DX) {
56 if (ssse3) {
57 fSampleProc32 = S32_alpha_D32_filter_DX_SSSE3;
58 } else {
59 fSampleProc32 = S32_alpha_D32_filter_DX_SSE2;
60 }
61 } else if (fSampleProc32 == S32_alpha_D32_filter_DXDY) {
62 if (ssse3) {
63 fSampleProc32 = S32_alpha_D32_filter_DXDY_SSSE3;
64 }
65 }
66
67 /* Check fMatrixProc */
68 if (fMatrixProc == ClampX_ClampY_filter_scale) {
69 fMatrixProc = ClampX_ClampY_filter_scale_SSE2;
70 } else if (fMatrixProc == ClampX_ClampY_nofilter_scale) {
71 fMatrixProc = ClampX_ClampY_nofilter_scale_SSE2;
72 } else if (fMatrixProc == ClampX_ClampY_filter_affine) {
73 fMatrixProc = ClampX_ClampY_filter_affine_SSE2;
74 } else if (fMatrixProc == ClampX_ClampY_nofilter_affine) {
75 fMatrixProc = ClampX_ClampY_nofilter_affine_SSE2;
76 }
77 }
78
79 ////////////////////////////////////////////////////////////////////////////////
80
81 static const SkBlitRow::Proc32 platform_32_procs_SSE2[] = {
82 nullptr, // S32_Opaque,
83 S32_Blend_BlitRow32_SSE2, // S32_Blend,
84 nullptr, // Ported to SkOpts
85 S32A_Blend_BlitRow32_SSE2, // S32A_Blend,
86 };
87
PlatformProcs32(unsigned flags)88 SkBlitRow::Proc32 SkBlitRow::PlatformProcs32(unsigned flags) {
89 if (SkCpu::Supports(SkCpu::SSE2)) {
90 return platform_32_procs_SSE2[flags];
91 } else {
92 return nullptr;
93 }
94 }
95
96 ////////////////////////////////////////////////////////////////////////////////
97
PlatformBlitRowProcs16(bool isOpaque)98 SkBlitMask::BlitLCD16RowProc SkBlitMask::PlatformBlitRowProcs16(bool isOpaque) {
99 if (SkCpu::Supports(SkCpu::SSE2)) {
100 if (isOpaque) {
101 return SkBlitLCD16OpaqueRow_SSE2;
102 } else {
103 return SkBlitLCD16Row_SSE2;
104 }
105 } else {
106 return nullptr;
107 }
108
109 }
110
PlatformRowProcs(SkColorType,SkMask::Format,RowFlags)111 SkBlitMask::RowProc SkBlitMask::PlatformRowProcs(SkColorType, SkMask::Format, RowFlags) {
112 return nullptr;
113 }
114