| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
| 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 #define SkCpu_IMPL | |
| 9 #include "SkCpu.h" | 8 #include "SkCpu.h" |
| 10 #include "SkOnce.h" | 9 #include "SkOnce.h" |
| 11 | 10 |
| 12 #if defined(SK_CPU_X86) | 11 #if defined(SK_CPU_X86) |
| 13 #if defined(SK_BUILD_FOR_WIN32) | 12 #if defined(SK_BUILD_FOR_WIN32) |
| 14 #include <intrin.h> | 13 #include <intrin.h> |
| 15 static void cpuid (uint32_t abcd[4]) { __cpuid ((int*)abcd, 1); } | 14 static void cpuid (uint32_t abcd[4]) { __cpuid ((int*)abcd, 1); } |
| 16 static void cpuid7(uint32_t abcd[4]) { __cpuidex((int*)abcd, 7, 0); } | 15 static void cpuid7(uint32_t abcd[4]) { __cpuidex((int*)abcd, 7, 0); } |
| 17 static uint64_t xgetbv(uint32_t xcr) { return _xgetbv(xcr); } | 16 static uint64_t xgetbv(uint32_t xcr) { return _xgetbv(xcr); } |
| 18 #else | 17 #else |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 return features; | 71 return features; |
| 73 } | 72 } |
| 74 | 73 |
| 75 #else | 74 #else |
| 76 static uint32_t read_cpu_features() { | 75 static uint32_t read_cpu_features() { |
| 77 return 0; | 76 return 0; |
| 78 } | 77 } |
| 79 | 78 |
| 80 #endif | 79 #endif |
| 81 | 80 |
| 82 #if defined(_MSC_VER) | 81 uint32_t SkCpu::gCachedFeatures = 0; |
| 83 const uint32_t SkCpu::gCachedFeatures = read_cpu_features(); | |
| 84 | 82 |
| 85 void SkCpu::CacheRuntimeFeatures() {} | 83 void SkCpu::CacheRuntimeFeatures() { |
| 86 | 84 static SkOnce once; |
| 87 #else | 85 once([] { gCachedFeatures = read_cpu_features(); }); |
| 88 uint32_t SkCpu::gCachedFeatures = 0; | 86 } |
| 89 | |
| 90 void SkCpu::CacheRuntimeFeatures() { | |
| 91 static SkOnce once; | |
| 92 once([] { gCachedFeatures = read_cpu_features(); }); | |
| 93 } | |
| 94 | |
| 95 #endif | |
| OLD | NEW |