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

Side by Side Diff: src/core/SkOpts.cpp

Issue 1255193002: Lay groundwork for SkOpts. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « src/core/SkOpts.h ('k') | src/opts/SkOpts_neon.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "SkOnce.h"
9 #include "SkOpts.h"
10
11 #if defined(SK_CPU_X86)
12 #if defined(SK_BUILD_FOR_WIN32)
13 #include <intrin.h>
14 static void cpuid(uint32_t abcd[4]) { __cpuid((int*)abcd, 1); }
15 #else
16 #include <cpuid.h>
17 static void cpuid(uint32_t abcd[4]) { __get_cpuid(1, abcd+0, abcd+1, abc d+2, abcd+3); }
18 #endif
19 #elif !defined(SK_ARM_HAS_NEON) && defined(SK_CPU_ARM32) && defined(SK_BUILD_FOR _ANDROID)
20 #include <cpu-features.h>
21 #endif
22
23 namespace SkOpts {
24 // (Define default function pointer values here...)
25
26 // Each Init_foo() is defined in src/opts/SkOpts_foo.cpp.
27 void Init_sse2();
28 void Init_ssse3();
29 void Init_sse41();
30 void Init_neon();
31 //TODO: _dsp2, _armv7, _armv8, _x86, _x86_64, _sse42, _avx, avx2, ... ?
32
33 static void init() {
34 #if defined(SK_CPU_X86)
35 uint32_t abcd[] = {0,0,0,0};
36 cpuid(abcd);
37 if (abcd[3] & (1<<26)) { Init_sse2(); }
38 if (abcd[2] & (1<< 9)) { Init_ssse3(); }
39 if (abcd[2] & (1<<19)) { Init_sse41(); }
40 #elif defined(SK_ARM_HAS_NEON)
41 Init_neon();
42 #elif defined(SK_CPU_ARM32) && defined(SK_BUILD_FOR_ANDROID)
43 if (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) { Init_neon (); }
44 #endif
45 }
46
47 SK_DECLARE_STATIC_ONCE(gInitOnce);
48 void Init() { SkOnce(&gInitOnce, init); }
49
50 #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
51 static struct AutoInit {
52 AutoInit() { Init(); }
53 } gAutoInit;
54 #endif
55 }
OLDNEW
« 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