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-06 14:53:32 +0000
committerGravatar digit@google.com <digit@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-06 14:53:32 +0000
commit157d94465a47a57e30e5cf49cd57dccd903e27e2 (patch)
treeb8a4f2bd2c2b03a88865a2c13e58173bfe2f6eba /src/core/SkUtilsArm.h
parentb932407520663c3b636fb6e6027dc53732a115fb (diff)
rm: Introduce SK_ARM_NEON_WRAP handy wrapper macro.
It is used to simplify arm/neon dispatch logic code. Review URL: https://codereview.appspot.com/6458060 git-svn-id: http://skia.googlecode.com/svn/trunk@4958 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkUtilsArm.h')
-rw-r--r--src/core/SkUtilsArm.h36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/core/SkUtilsArm.h b/src/core/SkUtilsArm.h
index 4562b01923..6a5aab8067 100644
--- a/src/core/SkUtilsArm.h
+++ b/src/core/SkUtilsArm.h
@@ -47,7 +47,41 @@ static bool sk_cpu_arm_has_neon(void) {
return true;
}
#else // SK_ARM_NEON_IS_DYNAMIC
-extern bool sk_cpu_arm_has_neon(void);
+
+extern bool sk_cpu_arm_has_neon(void) SK_PURE_FUNC;
+#endif
+
+// Use SK_ARM_NEON_WRAP(symbol) to map 'symbol' to a NEON-specific symbol
+// when applicable. This will transform 'symbol' differently depending on
+// the current NEON configuration, i.e.:
+//
+// NONE -> 'symbol'
+// ALWAYS -> 'symbol_neon'
+// DYNAMIC -> 'symbol' or 'symbol_neon' depending on runtime check.
+//
+// The goal is to simplify user code, for example:
+//
+// return SK_ARM_NEON_WRAP(do_something)(params);
+//
+// Replaces the equivalent:
+//
+// #if SK_ARM_NEON_IS_NONE
+// return do_something(params);
+// #elif SK_ARM_NEON_IS_ALWAYS
+// return do_something_neon(params);
+// #elif SK_ARM_NEON_IS_DYNAMIC
+// if (sk_cpu_arm_has_neon())
+// return do_something_neon(params);
+// else
+// return do_something(params);
+// #endif
+//
+#if SK_ARM_NEON_IS_NONE
+# define SK_ARM_NEON_WRAP(x) (x)
+#elif SK_ARM_NEON_IS_ALWAYS
+# define SK_ARM_NEON_WRAP(x) (x ## _neon)
+#elif SK_ARM_NEON_IS_DYNAMIC
+# define SK_ARM_NEON_WRAP(x) (sk_cpu_arm_has_neon() ? x ## _neon : x)
#endif
#endif // SkUtilsArm_DEFINED