Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: src/opts/opts_check_x86.cpp

Issue 1322933005: Port uses of SkLazyPtr to SkOncePtr. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: name Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/lazy/SkDiscardableMemoryPool.cpp ('k') | src/pdf/SkPDFGraphicState.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkBitmapScaler.h" 11 #include "SkBitmapScaler.h"
12 #include "SkBlitMask.h" 12 #include "SkBlitMask.h"
13 #include "SkBlitRow.h" 13 #include "SkBlitRow.h"
14 #include "SkBlitRow_opts_SSE2.h" 14 #include "SkBlitRow_opts_SSE2.h"
15 #include "SkBlitRow_opts_SSE4.h" 15 #include "SkBlitRow_opts_SSE4.h"
16 #include "SkLazyPtr.h" 16 #include "SkOncePtr.h"
17 #include "SkRTConf.h" 17 #include "SkRTConf.h"
18 18
19 #if defined(_MSC_VER) && defined(_WIN64) 19 #if defined(_MSC_VER) && defined(_WIN64)
20 #include <intrin.h> 20 #include <intrin.h>
21 #endif 21 #endif
22 22
23 /* This file must *not* be compiled with -msse or any other optional SIMD 23 /* This file must *not* be compiled with -msse or any other optional SIMD
24 extension, otherwise gcc may generate SIMD instructions even for scalar ops 24 extension, otherwise gcc may generate SIMD instructions even for scalar ops
25 (and thus give an invalid instruction on Pentium3 on the code below). 25 (and thus give an invalid instruction on Pentium3 on the code below).
26 For example, only files named *_SSE2.cpp in this directory should be 26 For example, only files named *_SSE2.cpp in this directory should be
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 : "a"(info_type) 64 : "a"(info_type)
65 ); 65 );
66 } 66 }
67 #endif 67 #endif
68 68
69 //////////////////////////////////////////////////////////////////////////////// 69 ////////////////////////////////////////////////////////////////////////////////
70 70
71 /* Fetch the SIMD level directly from the CPU, at run-time. 71 /* Fetch the SIMD level directly from the CPU, at run-time.
72 * Only checks the levels needed by the optimizations in this file. 72 * Only checks the levels needed by the optimizations in this file.
73 */ 73 */
74 namespace { // get_SIMD_level() technically must have external linkage, so no s tatic. 74 static int* get_SIMD_level() {
75 int* get_SIMD_level() {
76 int cpu_info[4] = { 0, 0, 0, 0 }; 75 int cpu_info[4] = { 0, 0, 0, 0 };
77 getcpuid(1, cpu_info); 76 getcpuid(1, cpu_info);
78 77
79 int* level = new int; 78 int* level = new int;
80 79
81 if ((cpu_info[2] & (1<<20)) != 0) { 80 if ((cpu_info[2] & (1<<20)) != 0) {
82 *level = SK_CPU_SSE_LEVEL_SSE42; 81 *level = SK_CPU_SSE_LEVEL_SSE42;
83 } else if ((cpu_info[2] & (1<<19)) != 0) { 82 } else if ((cpu_info[2] & (1<<19)) != 0) {
84 *level = SK_CPU_SSE_LEVEL_SSE41; 83 *level = SK_CPU_SSE_LEVEL_SSE41;
85 } else if ((cpu_info[2] & (1<<9)) != 0) { 84 } else if ((cpu_info[2] & (1<<9)) != 0) {
86 *level = SK_CPU_SSE_LEVEL_SSSE3; 85 *level = SK_CPU_SSE_LEVEL_SSSE3;
87 } else if ((cpu_info[3] & (1<<26)) != 0) { 86 } else if ((cpu_info[3] & (1<<26)) != 0) {
88 *level = SK_CPU_SSE_LEVEL_SSE2; 87 *level = SK_CPU_SSE_LEVEL_SSE2;
89 } else { 88 } else {
90 *level = 0; 89 *level = 0;
91 } 90 }
92 return level; 91 return level;
93 } 92 }
94 } // namespace
95 93
96 SK_DECLARE_STATIC_LAZY_PTR(int, gSIMDLevel, get_SIMD_level); 94 SK_DECLARE_STATIC_ONCE_PTR(int, gSIMDLevel);
97 95
98 /* Verify that the requested SIMD level is supported in the build. 96 /* Verify that the requested SIMD level is supported in the build.
99 * If not, check if the platform supports it. 97 * If not, check if the platform supports it.
100 */ 98 */
101 static inline bool supports_simd(int minLevel) { 99 static inline bool supports_simd(int minLevel) {
102 #if defined(SK_CPU_SSE_LEVEL) 100 #if defined(SK_CPU_SSE_LEVEL)
103 if (minLevel <= SK_CPU_SSE_LEVEL) { 101 if (minLevel <= SK_CPU_SSE_LEVEL) {
104 return true; 102 return true;
105 } else 103 } else
106 #endif 104 #endif
107 { 105 {
108 #if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) 106 #if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK)
109 /* For the Android framework we should always know at compile time if th e device 107 /* For the Android framework we should always know at compile time if th e device
110 * we are building for supports SSSE3. The one exception to this rule i s on the 108 * we are building for supports SSSE3. The one exception to this rule i s on the
111 * emulator where we are compiled without the -mssse3 option (so we have no 109 * emulator where we are compiled without the -mssse3 option (so we have no
112 * SSSE3 procs) but can be run on a host machine that supports SSSE3 110 * SSSE3 procs) but can be run on a host machine that supports SSSE3
113 * instructions. So for that particular case we disable our SSSE3 option s. 111 * instructions. So for that particular case we disable our SSSE3 option s.
114 */ 112 */
115 return false; 113 return false;
116 #else 114 #else
117 return minLevel <= *gSIMDLevel.get(); 115 return minLevel <= *gSIMDLevel.get(get_SIMD_level);
118 #endif 116 #endif
119 } 117 }
120 } 118 }
121 119
122 //////////////////////////////////////////////////////////////////////////////// 120 ////////////////////////////////////////////////////////////////////////////////
123 121
124 void SkBitmapScaler::PlatformConvolutionProcs(SkConvolutionProcs* procs) { 122 void SkBitmapScaler::PlatformConvolutionProcs(SkConvolutionProcs* procs) {
125 if (supports_simd(SK_CPU_SSE_LEVEL_SSE2)) { 123 if (supports_simd(SK_CPU_SSE_LEVEL_SSE2)) {
126 procs->fExtraHorizontalReads = 3; 124 procs->fExtraHorizontalReads = 3;
127 procs->fConvolveVertically = &convolveVertically_SSE2; 125 procs->fConvolveVertically = &convolveVertically_SSE2;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 } 259 }
262 } else { 260 } else {
263 return nullptr; 261 return nullptr;
264 } 262 }
265 263
266 } 264 }
267 265
268 SkBlitMask::RowProc SkBlitMask::PlatformRowProcs(SkColorType, SkMask::Format, Ro wFlags) { 266 SkBlitMask::RowProc SkBlitMask::PlatformRowProcs(SkColorType, SkMask::Format, Ro wFlags) {
269 return nullptr; 267 return nullptr;
270 } 268 }
OLDNEW
« no previous file with comments | « src/lazy/SkDiscardableMemoryPool.cpp ('k') | src/pdf/SkPDFGraphicState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698