aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar djsollen <djsollen@google.com>2014-08-26 11:30:15 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-08-26 11:30:15 -0700
commitad726a319613c7fe2d9b3d61205366dee04861d4 (patch)
tree9abdaf9d51c2be6ccb76d2c54d0b92906b8dc1d5 /src/core
parent99ae881a7f55a03c2b16fb5704e6e90ea86d965d (diff)
Always use cpu-features library on android.
This CL also removes the debug capability of runtime switching in/out of NEON mode as it uses deprecated APIs. BUG=skia:1061 R=tomhudson@google.com Author: djsollen@google.com Review URL: https://codereview.chromium.org/506033003
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkUtilsArm.cpp73
1 files changed, 10 insertions, 63 deletions
diff --git a/src/core/SkUtilsArm.cpp b/src/core/SkUtilsArm.cpp
index 58cf1157c3..1ff5bf0d65 100644
--- a/src/core/SkUtilsArm.cpp
+++ b/src/core/SkUtilsArm.cpp
@@ -16,73 +16,24 @@
#include <string.h>
#include <pthread.h>
-// Set USE_ANDROID_NDK_CPU_FEATURES to use the Android NDK's
-// cpu-features helper library to detect NEON at runtime. See
-// http://crbug.com/164154 to see why this is needed in Chromium
-// for Android.
-#if !defined(USE_ANDROID_NDK_CPU_FEATURES)
-# if defined(SK_BUILD_FOR_ANDROID)
-# define USE_ANDROID_NDK_CPU_FEATURES 1
-# else
-# define USE_ANDROID_NDK_CPU_FEATURES 0
-# endif
-#endif
-
-#if USE_ANDROID_NDK_CPU_FEATURES
+#if SK_BUILD_FOR_ANDROID
# include <cpu-features.h>
#endif
-// Set NEON_DEBUG to 1 to allow debugging of the CPU features probing.
-// For now, we always set it for SK_DEBUG builds.
-#ifdef SK_DEBUG
-# define NEON_DEBUG 1
-#else
-# define NEON_DEBUG 0
-#endif
-
-#if NEON_DEBUG
-# ifdef SK_BUILD_FOR_ANDROID
- // used to declare PROP_VALUE_MAX and __system_property_get()
-# include <sys/system_properties.h>
-# endif
-#endif
-
// A function used to determine at runtime if the target CPU supports
// the ARM NEON instruction set. This implementation is Linux-specific.
static bool sk_cpu_arm_check_neon(void) {
+ // If we fail any of the following, assume we don't have NEON instructions
+ // This allows us to return immediately in case of error.
bool result = false;
-#if NEON_DEBUG
- // Allow forcing the mode through the environment during debugging.
-# ifdef SK_BUILD_FOR_ANDROID
- // On Android, we use a system property
-# define PROP_NAME "debug.skia.arm_neon_mode"
- char prop[PROP_VALUE_MAX];
- if (__system_property_get(PROP_NAME, prop) > 0) {
-# else
-# define PROP_NAME "SKIA_ARM_NEON_MODE"
- // On ARM Linux, we use an environment variable
- const char* prop = getenv(PROP_NAME);
- if (prop != NULL) {
-# endif
- SkDebugf("%s: %s", PROP_NAME, prop);
- if (!strcmp(prop, "1")) {
- SkDebugf("Forcing ARM Neon mode to full!\n");
- return true;
- }
- if (!strcmp(prop, "0")) {
- SkDebugf("Disabling ARM NEON mode\n");
- return false;
- }
- }
- SkDebugf("Running dynamic CPU feature detection\n");
-#endif
-
-#if USE_ANDROID_NDK_CPU_FEATURES
+// Use the Android NDK's cpu-features helper library to detect NEON at runtime.
+// See http://crbug.com/164154 to see why this is needed in Chromium for Android.
+#ifdef SK_BUILD_FOR_ANDROID
result = (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0;
-#else // USE_ANDROID_NDK_CPU_FEATURES
+#else // SK_BUILD_FOR_ANDROID
// There is no user-accessible CPUID instruction on ARM that we can use.
// Instead, we must parse /proc/cpuinfo and look for the 'neon' feature.
@@ -103,10 +54,6 @@ static bool sk_cpu_arm_check_neon(void) {
*/
char buffer[4096];
- // If we fail any of the following, assume we don't have NEON instructions
- // This allows us to return immediately in case of error.
- result = false;
-
do {
// open /proc/cpuinfo
int fd = TEMP_FAILURE_RETRY(open("/proc/cpuinfo", O_RDONLY));
@@ -173,12 +120,12 @@ static bool sk_cpu_arm_check_neon(void) {
} while (0);
-#endif // USE_ANDROID_NDK_CPU_FEATURES
+#endif // SK_BUILD_FOR_ANDROID
if (result) {
- SkDebugf("Device supports ARM NEON instructions!\n");
+ SkDEBUGF(("Device supports ARM NEON instructions!\n"));
} else {
- SkDebugf("Device does NOT support ARM NEON instructions!\n");
+ SkDEBUGF(("Device does NOT support ARM NEON instructions!\n"));
}
return result;
}