Chromium Code Reviews| 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 |
| 11 #define SK_OPTS_NS portable | 11 #define SK_OPTS_NS portable |
| 12 #include "SkBlurImageFilter_opts.h" | 12 #include "SkBlurImageFilter_opts.h" |
| 13 #include "SkFloatingPoint_opts.h" | 13 #include "SkFloatingPoint_opts.h" |
| 14 #include "SkMorphologyImageFilter_opts.h" | |
| 14 #include "SkUtils_opts.h" | 15 #include "SkUtils_opts.h" |
| 15 #include "SkXfermode_opts.h" | 16 #include "SkXfermode_opts.h" |
| 16 | 17 |
| 17 #if defined(SK_CPU_X86) | 18 #if defined(SK_CPU_X86) |
| 18 #if defined(SK_BUILD_FOR_WIN32) | 19 #if defined(SK_BUILD_FOR_WIN32) |
| 19 #include <intrin.h> | 20 #include <intrin.h> |
| 20 static void cpuid(uint32_t abcd[4]) { __cpuid((int*)abcd, 1); } | 21 static void cpuid(uint32_t abcd[4]) { __cpuid((int*)abcd, 1); } |
| 21 #else | 22 #else |
| 22 #include <cpuid.h> | 23 #include <cpuid.h> |
| 23 static void cpuid(uint32_t abcd[4]) { __get_cpuid(1, abcd+0, abcd+1, abc d+2, abcd+3); } | 24 static void cpuid(uint32_t abcd[4]) { __get_cpuid(1, abcd+0, abcd+1, abc d+2, abcd+3); } |
| 24 #endif | 25 #endif |
| 25 #elif !defined(SK_ARM_HAS_NEON) && defined(SK_CPU_ARM32) && defined(SK_BUILD_FOR _ANDROID) | 26 #elif !defined(SK_ARM_HAS_NEON) && defined(SK_CPU_ARM32) && defined(SK_BUILD_FOR _ANDROID) |
| 26 #include <cpu-features.h> | 27 #include <cpu-features.h> |
| 27 #endif | 28 #endif |
| 28 | 29 |
| 29 namespace SkOpts { | 30 namespace SkOpts { |
| 30 // Define default function pointer values here... | 31 // Define default function pointer values here... |
| 31 // If our global compile options are set high enough, these 'portable' defau lts might | 32 // If our global compile options are set high enough, these 'portable' defau lts might |
| 32 // even be CPU-specialized, e.g. a typical x86-64 machine might start with S SE2 defaults. | 33 // even be CPU-specialized, e.g. a typical x86-64 machine might start with S SE2 defaults. |
| 33 // They'll still get a chance to be replaced with even better ones, e.g. usi ng SSE4.1. | 34 // They'll still get a chance to be replaced with even better ones, e.g. usi ng SSE4.1. |
| 34 decltype(rsqrt) rsqrt = portable::rsqrt; | 35 decltype(rsqrt) rsqrt = portable::rsqrt; |
| 35 decltype(memset16) memset16 = portable::memset16; | 36 decltype(memset16) memset16 = portable::memset16; |
| 36 decltype(memset32) memset32 = portable::memset32; | 37 decltype(memset32) memset32 = portable::memset32; |
| 37 decltype(create_xfermode) create_xfermode = SkCreate4pxXfermode; | 38 decltype(create_xfermode) create_xfermode = SkCreate4pxXfermode; |
| 38 | 39 |
| 39 static const auto x = portable::kX, y = portable::kY; | 40 decltype(box_blur_xx) box_blur_xx = portable::box_blur_xx; |
|
djsollen
2015/08/04 19:38:12
why not
static const auto blur_x = portable::Blur
mtklein_C
2015/08/04 19:41:48
This is mostly a style / layering thing. I notice
| |
| 40 decltype(box_blur_xx) box_blur_xx = portable::box_blur<x,x>; | 41 decltype(box_blur_xy) box_blur_xy = portable::box_blur_xy; |
| 41 decltype(box_blur_xy) box_blur_xy = portable::box_blur<x,y>; | 42 decltype(box_blur_yx) box_blur_yx = portable::box_blur_yx; |
| 42 decltype(box_blur_yx) box_blur_yx = portable::box_blur<y,x>; | 43 |
| 44 decltype(dilate_x) dilate_x = portable::dilate_x; | |
|
djsollen
2015/08/04 19:38:12
does decltype really help here? It seems that Mor
mtklein_C
2015/08/04 19:41:48
Either would be fine. On the other hand, decltype
| |
| 45 decltype(dilate_y) dilate_y = portable::dilate_y; | |
| 46 decltype( erode_x) erode_x = portable::erode_x; | |
| 47 decltype( erode_y) erode_y = portable::erode_y; | |
| 43 | 48 |
| 44 // Each Init_foo() is defined in src/opts/SkOpts_foo.cpp. | 49 // Each Init_foo() is defined in src/opts/SkOpts_foo.cpp. |
| 45 void Init_sse2(); | 50 void Init_sse2(); |
| 46 void Init_ssse3(); | 51 void Init_ssse3(); |
| 47 void Init_sse41(); | 52 void Init_sse41(); |
| 48 void Init_neon(); | 53 void Init_neon(); |
| 49 //TODO: _dsp2, _armv7, _armv8, _x86, _x86_64, _sse42, _avx, avx2, ... ? | 54 //TODO: _dsp2, _armv7, _armv8, _x86, _x86_64, _sse42, _avx, avx2, ... ? |
| 50 | 55 |
| 51 static void init() { | 56 static void init() { |
| 52 // TODO: Chrome's not linking _sse* opts on iOS simulator builds. Bug o r feature? | 57 // TODO: Chrome's not linking _sse* opts on iOS simulator builds. Bug o r feature? |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 65 | 70 |
| 66 SK_DECLARE_STATIC_ONCE(gInitOnce); | 71 SK_DECLARE_STATIC_ONCE(gInitOnce); |
| 67 void Init() { SkOnce(&gInitOnce, init); } | 72 void Init() { SkOnce(&gInitOnce, init); } |
| 68 | 73 |
| 69 #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS | 74 #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS |
| 70 static struct AutoInit { | 75 static struct AutoInit { |
| 71 AutoInit() { Init(); } | 76 AutoInit() { Init(); } |
| 72 } gAutoInit; | 77 } gAutoInit; |
| 73 #endif | 78 #endif |
| 74 } | 79 } |
| OLD | NEW |