OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkOnce.h" | 8 #include "SkOnce.h" |
9 #include "SkOpts.h" | 9 #include "SkOpts.h" |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "SkXfermode_opts.h" | 21 #include "SkXfermode_opts.h" |
22 | 22 |
23 #if defined(SK_CPU_X86) | 23 #if defined(SK_CPU_X86) |
24 #if defined(SK_BUILD_FOR_WIN32) | 24 #if defined(SK_BUILD_FOR_WIN32) |
25 #include <intrin.h> | 25 #include <intrin.h> |
26 static void cpuid(uint32_t abcd[4]) { __cpuid((int*)abcd, 1); } | 26 static void cpuid(uint32_t abcd[4]) { __cpuid((int*)abcd, 1); } |
27 #else | 27 #else |
28 #include <cpuid.h> | 28 #include <cpuid.h> |
29 static void cpuid(uint32_t abcd[4]) { __get_cpuid(1, abcd+0, abcd+1, abc
d+2, abcd+3); } | 29 static void cpuid(uint32_t abcd[4]) { __get_cpuid(1, abcd+0, abcd+1, abc
d+2, abcd+3); } |
30 #endif | 30 #endif |
31 #elif !defined(SK_ARM_HAS_NEON) && defined(SK_CPU_ARM32) && defined(SK_BUILD_FOR
_ANDROID) | 31 #elif !defined(SK_ARM_HAS_NEON) && \ |
| 32 defined(SK_CPU_ARM32) && \ |
| 33 defined(SK_BUILD_FOR_ANDROID) && \ |
| 34 !defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) |
32 #include <cpu-features.h> | 35 #include <cpu-features.h> |
33 #endif | 36 #endif |
34 | 37 |
35 namespace SkOpts { | 38 namespace SkOpts { |
36 // Define default function pointer values here... | 39 // Define default function pointer values here... |
37 // If our global compile options are set high enough, these defaults might e
ven be | 40 // If our global compile options are set high enough, these defaults might e
ven be |
38 // CPU-specialized, e.g. a typical x86-64 machine might start with SSE2 defa
ults. | 41 // CPU-specialized, e.g. a typical x86-64 machine might start with SSE2 defa
ults. |
39 // They'll still get a chance to be replaced with even better ones, e.g. usi
ng SSE4.1. | 42 // They'll still get a chance to be replaced with even better ones, e.g. usi
ng SSE4.1. |
40 decltype(rsqrt) rsqrt = sk_default::rsqrt; | 43 decltype(rsqrt) rsqrt = sk_default::rsqrt; |
41 decltype(memset16) memset16 = sk_default::memset16; | 44 decltype(memset16) memset16 = sk_default::memset16; |
(...skipping 27 matching lines...) Expand all Loading... |
69 void Init_neon(); | 72 void Init_neon(); |
70 //TODO: _dsp2, _armv7, _armv8, _x86, _x86_64, _sse42, _avx, avx2, ... ? | 73 //TODO: _dsp2, _armv7, _armv8, _x86, _x86_64, _sse42, _avx, avx2, ... ? |
71 | 74 |
72 static void init() { | 75 static void init() { |
73 // TODO: Chrome's not linking _sse* opts on iOS simulator builds. Bug o
r feature? | 76 // TODO: Chrome's not linking _sse* opts on iOS simulator builds. Bug o
r feature? |
74 #if defined(SK_CPU_X86) && !defined(SK_BUILD_FOR_IOS) | 77 #if defined(SK_CPU_X86) && !defined(SK_BUILD_FOR_IOS) |
75 uint32_t abcd[] = {0,0,0,0}; | 78 uint32_t abcd[] = {0,0,0,0}; |
76 cpuid(abcd); | 79 cpuid(abcd); |
77 if (abcd[2] & (1<< 9)) { Init_ssse3(); } | 80 if (abcd[2] & (1<< 9)) { Init_ssse3(); } |
78 if (abcd[2] & (1<<19)) { Init_sse41(); } | 81 if (abcd[2] & (1<<19)) { Init_sse41(); } |
79 #elif !defined(SK_ARM_HAS_NEON) && defined(SK_CPU_ARM32) && defined(SK_BUILD
_FOR_ANDROID) | 82 #elif !defined(SK_ARM_HAS_NEON) && \ |
| 83 defined(SK_CPU_ARM32) && \ |
| 84 defined(SK_BUILD_FOR_ANDROID) && \ |
| 85 !defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) |
80 if (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) { Init_neon
(); } | 86 if (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) { Init_neon
(); } |
81 #endif | 87 #endif |
82 } | 88 } |
83 | 89 |
84 SK_DECLARE_STATIC_ONCE(gInitOnce); | 90 SK_DECLARE_STATIC_ONCE(gInitOnce); |
85 void Init() { SkOnce(&gInitOnce, init); } | 91 void Init() { SkOnce(&gInitOnce, init); } |
86 | 92 |
87 #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS | 93 #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS |
88 static struct AutoInit { | 94 static struct AutoInit { |
89 AutoInit() { Init(); } | 95 AutoInit() { Init(); } |
90 } gAutoInit; | 96 } gAutoInit; |
91 #endif | 97 #endif |
92 } | 98 } |
OLD | NEW |