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

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

Issue 1334523002: Revert of Port uses of SkLazyPtr to SkOncePtr. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 "SkOncePtr.h" 16 #include "SkLazyPtr.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 static int* get_SIMD_level() { 74 namespace { // get_SIMD_level() technically must have external linkage, so no s tatic.
75 int* get_SIMD_level() {
75 int cpu_info[4] = { 0, 0, 0, 0 }; 76 int cpu_info[4] = { 0, 0, 0, 0 };
76 getcpuid(1, cpu_info); 77 getcpuid(1, cpu_info);
77 78
78 int* level = new int; 79 int* level = new int;
79 80
80 if ((cpu_info[2] & (1<<20)) != 0) { 81 if ((cpu_info[2] & (1<<20)) != 0) {
81 *level = SK_CPU_SSE_LEVEL_SSE42; 82 *level = SK_CPU_SSE_LEVEL_SSE42;
82 } else if ((cpu_info[2] & (1<<19)) != 0) { 83 } else if ((cpu_info[2] & (1<<19)) != 0) {
83 *level = SK_CPU_SSE_LEVEL_SSE41; 84 *level = SK_CPU_SSE_LEVEL_SSE41;
84 } else if ((cpu_info[2] & (1<<9)) != 0) { 85 } else if ((cpu_info[2] & (1<<9)) != 0) {
85 *level = SK_CPU_SSE_LEVEL_SSSE3; 86 *level = SK_CPU_SSE_LEVEL_SSSE3;
86 } else if ((cpu_info[3] & (1<<26)) != 0) { 87 } else if ((cpu_info[3] & (1<<26)) != 0) {
87 *level = SK_CPU_SSE_LEVEL_SSE2; 88 *level = SK_CPU_SSE_LEVEL_SSE2;
88 } else { 89 } else {
89 *level = 0; 90 *level = 0;
90 } 91 }
91 return level; 92 return level;
92 } 93 }
94 } // namespace
93 95
94 SK_DECLARE_STATIC_ONCE_PTR(int, gSIMDLevel); 96 SK_DECLARE_STATIC_LAZY_PTR(int, gSIMDLevel, get_SIMD_level);
95 97
96 /* Verify that the requested SIMD level is supported in the build. 98 /* Verify that the requested SIMD level is supported in the build.
97 * If not, check if the platform supports it. 99 * If not, check if the platform supports it.
98 */ 100 */
99 static inline bool supports_simd(int minLevel) { 101 static inline bool supports_simd(int minLevel) {
100 #if defined(SK_CPU_SSE_LEVEL) 102 #if defined(SK_CPU_SSE_LEVEL)
101 if (minLevel <= SK_CPU_SSE_LEVEL) { 103 if (minLevel <= SK_CPU_SSE_LEVEL) {
102 return true; 104 return true;
103 } else 105 } else
104 #endif 106 #endif
105 { 107 {
106 #if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) 108 #if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK)
107 /* For the Android framework we should always know at compile time if th e device 109 /* For the Android framework we should always know at compile time if th e device
108 * we are building for supports SSSE3. The one exception to this rule i s on the 110 * we are building for supports SSSE3. The one exception to this rule i s on the
109 * emulator where we are compiled without the -mssse3 option (so we have no 111 * emulator where we are compiled without the -mssse3 option (so we have no
110 * SSSE3 procs) but can be run on a host machine that supports SSSE3 112 * SSSE3 procs) but can be run on a host machine that supports SSSE3
111 * instructions. So for that particular case we disable our SSSE3 option s. 113 * instructions. So for that particular case we disable our SSSE3 option s.
112 */ 114 */
113 return false; 115 return false;
114 #else 116 #else
115 return minLevel <= *gSIMDLevel.get(get_SIMD_level); 117 return minLevel <= *gSIMDLevel.get();
116 #endif 118 #endif
117 } 119 }
118 } 120 }
119 121
120 //////////////////////////////////////////////////////////////////////////////// 122 ////////////////////////////////////////////////////////////////////////////////
121 123
122 void SkBitmapScaler::PlatformConvolutionProcs(SkConvolutionProcs* procs) { 124 void SkBitmapScaler::PlatformConvolutionProcs(SkConvolutionProcs* procs) {
123 if (supports_simd(SK_CPU_SSE_LEVEL_SSE2)) { 125 if (supports_simd(SK_CPU_SSE_LEVEL_SSE2)) {
124 procs->fExtraHorizontalReads = 3; 126 procs->fExtraHorizontalReads = 3;
125 procs->fConvolveVertically = &convolveVertically_SSE2; 127 procs->fConvolveVertically = &convolveVertically_SSE2;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 } 261 }
260 } else { 262 } else {
261 return nullptr; 263 return nullptr;
262 } 264 }
263 265
264 } 266 }
265 267
266 SkBlitMask::RowProc SkBlitMask::PlatformRowProcs(SkColorType, SkMask::Format, Ro wFlags) { 268 SkBlitMask::RowProc SkBlitMask::PlatformRowProcs(SkColorType, SkMask::Format, Ro wFlags) {
267 return nullptr; 269 return nullptr;
268 } 270 }
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