aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkUtilsArm.h
diff options
context:
space:
mode:
authorGravatar digit@google.com <digit@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-01 15:58:41 +0000
committerGravatar digit@google.com <digit@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-01 15:58:41 +0000
commitfbf31949ac31271362750168ffcb13a04408b721 (patch)
treee9b0ce53067795fec7404cb28ae96e4beb7d3af5 /src/core/SkUtilsArm.h
parent830b8793bb1646bb76817bdc228dd8e2a92bef7d (diff)
arm: Move SkUtilsArm.h from include/core to src/core
There is no reason to make this visible to client code. Review URL: https://codereview.appspot.com/6441082 git-svn-id: http://skia.googlecode.com/svn/trunk@4892 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkUtilsArm.h')
-rw-r--r--src/core/SkUtilsArm.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/core/SkUtilsArm.h b/src/core/SkUtilsArm.h
new file mode 100644
index 0000000000..4562b01923
--- /dev/null
+++ b/src/core/SkUtilsArm.h
@@ -0,0 +1,53 @@
+
+/*
+ * Copyright 2012 The Android Open Source Project
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkUtilsArm_DEFINED
+#define SkUtilsArm_DEFINED
+
+#include "SkUtils.h"
+
+// Define SK_ARM_NEON_MODE to one of the following values
+// corresponding respectively to:
+// - No ARM Neon support at all (not targetting ARMv7-A, or don't have NEON)
+// - Full ARM Neon support (i.e. assume the CPU always supports it)
+// - Optional ARM Neon support (i.e. probe CPU at runtime)
+//
+#define SK_ARM_NEON_MODE_NONE 0
+#define SK_ARM_NEON_MODE_ALWAYS 1
+#define SK_ARM_NEON_MODE_DYNAMIC 2
+
+#if defined(__arm__) && defined(__ARM_HAVE_OPTIONAL_NEON_SUPPORT)
+# define SK_ARM_NEON_MODE SK_ARM_NEON_MODE_DYNAMIC
+#elif defined(__arm__) && defined(__ARM_HAVE_NEON)
+# define SK_ARM_NEON_MODE SK_ARM_NEON_MODE_ALWAYS
+#else
+# define SK_ARM_NEON_MODE SK_ARM_NEON_MODE_NONE
+#endif
+
+// Convenience test macros, always defined as 0 or 1
+#define SK_ARM_NEON_IS_NONE (SK_ARM_NEON_MODE == SK_ARM_NEON_MODE_NONE)
+#define SK_ARM_NEON_IS_ALWAYS (SK_ARM_NEON_MODE == SK_ARM_NEON_MODE_ALWAYS)
+#define SK_ARM_NEON_IS_DYNAMIC (SK_ARM_NEON_MODE == SK_ARM_NEON_MODE_DYNAMIC)
+
+// The sk_cpu_arm_has_neon() function returns true iff the target device
+// is ARMv7-A and supports Neon instructions. In DYNAMIC mode, this actually
+// probes the CPU at runtime (and caches the result).
+
+#if SK_ARM_NEON_IS_NONE
+static bool sk_cpu_arm_has_neon(void) {
+ return false;
+}
+#elif SK_ARM_NEON_IS_ALWAYS
+static bool sk_cpu_arm_has_neon(void) {
+ return true;
+}
+#else // SK_ARM_NEON_IS_DYNAMIC
+extern bool sk_cpu_arm_has_neon(void);
+#endif
+
+#endif // SkUtilsArm_DEFINED