| 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 #include "SkCpu.h" | 8 #include "SkCpu.h" |
| 9 #include "SkOnce.h" | 9 #include "SkOnce.h" |
| 10 | 10 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 static uint32_t read_cpu_features() { | 64 static uint32_t read_cpu_features() { |
| 65 uint32_t features = 0; | 65 uint32_t features = 0; |
| 66 | 66 |
| 67 uint64_t android_features = android_getCpuFeatures(); | 67 uint64_t android_features = android_getCpuFeatures(); |
| 68 if (android_features & ANDROID_CPU_ARM_FEATURE_NEON ) { features |= S
kCpu::NEON ; } | 68 if (android_features & ANDROID_CPU_ARM_FEATURE_NEON ) { features |= S
kCpu::NEON ; } |
| 69 if (android_features & ANDROID_CPU_ARM_FEATURE_NEON_FMA) { features |= S
kCpu::NEON_FMA; } | 69 if (android_features & ANDROID_CPU_ARM_FEATURE_NEON_FMA) { features |= S
kCpu::NEON_FMA; } |
| 70 if (android_features & ANDROID_CPU_ARM_FEATURE_VFP_FP16) { features |= S
kCpu::VFP_FP16; } | 70 if (android_features & ANDROID_CPU_ARM_FEATURE_VFP_FP16) { features |= S
kCpu::VFP_FP16; } |
| 71 return features; | 71 return features; |
| 72 } | 72 } |
| 73 | 73 |
| 74 #elif defined(SK_CPU_ARM64) && \ |
| 75 defined(SK_BUILD_FOR_ANDROID) && \ |
| 76 !defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) |
| 77 #include <cpu-features.h> |
| 78 |
| 79 static uint32_t read_cpu_features() { |
| 80 uint32_t features = 0; |
| 81 |
| 82 uint64_t android_features = android_getCpuFeatures(); |
| 83 if (android_features & ANDROID_CPU_ARM64_FEATURE_CRC32) { features |= Sk
Cpu::CRC32; } |
| 84 return features; |
| 85 } |
| 86 |
| 74 #else | 87 #else |
| 75 static uint32_t read_cpu_features() { | 88 static uint32_t read_cpu_features() { |
| 76 return 0; | 89 return 0; |
| 77 } | 90 } |
| 78 | 91 |
| 79 #endif | 92 #endif |
| 80 | 93 |
| 81 uint32_t SkCpu::gCachedFeatures = 0; | 94 uint32_t SkCpu::gCachedFeatures = 0; |
| 82 | 95 |
| 83 void SkCpu::CacheRuntimeFeatures() { | 96 void SkCpu::CacheRuntimeFeatures() { |
| 84 static SkOnce once; | 97 static SkOnce once; |
| 85 once([] { gCachedFeatures = read_cpu_features(); }); | 98 once([] { gCachedFeatures = read_cpu_features(); }); |
| 86 } | 99 } |
| OLD | NEW |