| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2012 The Android Open Source Project | 3 * Copyright 2012 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "SkUtilsArm.h" | 9 #include "SkUtilsArm.h" |
| 10 | 10 |
| 11 #if SK_ARM_NEON_IS_DYNAMIC | 11 #if SK_ARM_NEON_IS_DYNAMIC |
| 12 | 12 |
| 13 #include <unistd.h> | 13 #include <unistd.h> |
| 14 #include <fcntl.h> | 14 #include <fcntl.h> |
| 15 #include <errno.h> | 15 #include <errno.h> |
| 16 #include <string.h> | 16 #include <string.h> |
| 17 #include <pthread.h> | 17 #include <pthread.h> |
| 18 | 18 |
| 19 // Set USE_ANDROID_NDK_CPU_FEATURES to use the Android NDK's | 19 // Set USE_ANDROID_NDK_CPU_FEATURES to use the Android NDK's |
| 20 // cpu-features helper library to detect NEON at runtime. See | 20 // cpu-features helper library to detect NEON at runtime. See |
| 21 // http://crbug.com/164154 to see why this is needed in Chromium | 21 // http://crbug.com/164154 to see why this is needed in Chromium |
| 22 // for Android. | 22 // for Android. |
| 23 #if defined(SK_BUILD_FOR_ANDROID) | 23 #if !defined(USE_ANDROID_NDK_CPU_FEATURES) |
| 24 # define USE_ANDROID_NDK_CPU_FEATURES 1 | 24 # if defined(SK_BUILD_FOR_ANDROID) |
| 25 #else | 25 # define USE_ANDROID_NDK_CPU_FEATURES 1 |
| 26 # define USE_ANDROID_NDK_CPU_FEATURES 0 | 26 # else |
| 27 # define USE_ANDROID_NDK_CPU_FEATURES 0 |
| 28 # endif |
| 27 #endif | 29 #endif |
| 28 | 30 |
| 29 #if USE_ANDROID_NDK_CPU_FEATURES | 31 #if USE_ANDROID_NDK_CPU_FEATURES |
| 30 # include <cpu-features.h> | 32 # include <cpu-features.h> |
| 31 #endif | 33 #endif |
| 32 | 34 |
| 33 // Set NEON_DEBUG to 1 to allow debugging of the CPU features probing. | 35 // Set NEON_DEBUG to 1 to allow debugging of the CPU features probing. |
| 34 // For now, we always set it for SK_DEBUG builds. | 36 // For now, we always set it for SK_DEBUG builds. |
| 35 #ifdef SK_DEBUG | 37 #ifdef SK_DEBUG |
| 36 # define NEON_DEBUG 1 | 38 # define NEON_DEBUG 1 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 void sk_cpu_arm_probe_features(void) { | 190 void sk_cpu_arm_probe_features(void) { |
| 189 sHasArmNeon = sk_cpu_arm_check_neon(); | 191 sHasArmNeon = sk_cpu_arm_check_neon(); |
| 190 } | 192 } |
| 191 | 193 |
| 192 bool sk_cpu_arm_has_neon(void) { | 194 bool sk_cpu_arm_has_neon(void) { |
| 193 pthread_once(&sOnce, sk_cpu_arm_probe_features); | 195 pthread_once(&sOnce, sk_cpu_arm_probe_features); |
| 194 return sHasArmNeon; | 196 return sHasArmNeon; |
| 195 } | 197 } |
| 196 | 198 |
| 197 #endif // SK_ARM_NEON_IS_DYNAMIC | 199 #endif // SK_ARM_NEON_IS_DYNAMIC |
| OLD | NEW |