Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Unified Diff: src/core/SkOpts.cpp

Issue 1255193002: Lay groundwork for SkOpts. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: typo Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkOpts.h ('k') | src/opts/SkOpts_neon.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkOpts.cpp
diff --git a/src/core/SkOpts.cpp b/src/core/SkOpts.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..09fe2de1c43c84e6bf94d0827c09173519003ffe
--- /dev/null
+++ b/src/core/SkOpts.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkOpts.h"
+
+#if defined(SK_CPU_X86)
+ #if defined(SK_BUILD_FOR_WIN32)
+ #include <intrin.h>
+ static void cpuid(uint32_t abcd[4]) { __cpuid((int*)abcd, 1); }
+ #else
+ #include <cpuid.h>
+ static void cpuid(uint32_t abcd[4]) { __get_cpuid(1, abcd+0, abcd+1, abcd+2, abcd+3); }
+ #endif
+#elif defined(SK_BUILD_FOR_ANDROID)
+ #include <cpu-features.h>
+#endif
+
+namespace SkOpts {
+ // (Define default function pointer values here...)
+
+ // Each Init_foo() is defined in src/opts/SkOpts_foo.cpp.
+ void Init_sse2();
+ void Init_ssse3();
+ void Init_sse41();
+ void Init_neon();
+ //TODO: _dsp2, _armv7, _armv8, _x86, _x86_64, _sse42, _avx, avx2, ... ?
+
+ void Init() {
+ #if defined(SK_CPU_X86)
+ uint32_t abcd[] = {0,0,0,0};
+ cpuid(abcd);
+ if (abcd[3] & (1<<26)) { Init_sse2(); }
+ if (abcd[2] & (1<< 9)) { Init_ssse3(); }
+ if (abcd[2] & (1<<19)) { Init_sse41(); }
+
+ #elif defined(SK_BUILD_FOR_ANDROID)
+ if (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) { Init_neon(); }
+
+ #elif defined(SK_CPU_ARM32) || defined(SK_CPU_ARM64)
+ // We just assume NEON for non-Android ARM platforms.
djsollen 2015/07/27 17:38:02 instead of assuming neon for 32-bit arm devices wh
+ Init_neon();
+
+ #endif
+ }
+}
« no previous file with comments | « src/core/SkOpts.h ('k') | src/opts/SkOpts_neon.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698