| 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 sk_default | 11 #define SK_OPTS_NS sk_default |
| 12 #include "SkBlitMask_opts.h" | 12 #include "SkBlitMask_opts.h" |
| 13 #include "SkBlitRow_opts.h" | 13 #include "SkBlitRow_opts.h" |
| 14 #include "SkBlurImageFilter_opts.h" | 14 #include "SkBlurImageFilter_opts.h" |
| 15 #include "SkColorCubeFilter_opts.h" | 15 #include "SkColorCubeFilter_opts.h" |
| 16 #include "SkFloatingPoint_opts.h" | 16 #include "SkFloatingPoint_opts.h" |
| 17 #include "SkMatrix_opts.h" | 17 #include "SkMatrix_opts.h" |
| 18 #include "SkMorphologyImageFilter_opts.h" | 18 #include "SkMorphologyImageFilter_opts.h" |
| 19 #include "SkSwizzler_opts.h" |
| 19 #include "SkTextureCompressor_opts.h" | 20 #include "SkTextureCompressor_opts.h" |
| 20 #include "SkUtils_opts.h" | 21 #include "SkUtils_opts.h" |
| 21 #include "SkXfermode_opts.h" | 22 #include "SkXfermode_opts.h" |
| 22 | 23 |
| 23 #if defined(SK_CPU_X86) && !defined(SK_BUILD_FOR_IOS) | 24 #if defined(SK_CPU_X86) && !defined(SK_BUILD_FOR_IOS) |
| 24 #if defined(SK_BUILD_FOR_WIN32) | 25 #if defined(SK_BUILD_FOR_WIN32) |
| 25 #include <intrin.h> | 26 #include <intrin.h> |
| 26 static void cpuid (uint32_t abcd[4]) { __cpuid ((int*)abcd, 1); } | 27 static void cpuid (uint32_t abcd[4]) { __cpuid ((int*)abcd, 1); } |
| 27 static void cpuid7(uint32_t abcd[4]) { __cpuidex((int*)abcd, 7, 0); } | 28 static void cpuid7(uint32_t abcd[4]) { __cpuidex((int*)abcd, 7, 0); } |
| 28 static uint64_t xgetbv(uint32_t xcr) { return _xgetbv(xcr); } | 29 static uint64_t xgetbv(uint32_t xcr) { return _xgetbv(xcr); } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 42 return (uint64_t)(edx) << 32 | eax; | 43 return (uint64_t)(edx) << 32 | eax; |
| 43 } | 44 } |
| 44 #endif | 45 #endif |
| 45 #elif !defined(SK_ARM_HAS_NEON) && \ | 46 #elif !defined(SK_ARM_HAS_NEON) && \ |
| 46 defined(SK_CPU_ARM32) && \ | 47 defined(SK_CPU_ARM32) && \ |
| 47 defined(SK_BUILD_FOR_ANDROID) && \ | 48 defined(SK_BUILD_FOR_ANDROID) && \ |
| 48 !defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) | 49 !defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) |
| 49 #include <cpu-features.h> | 50 #include <cpu-features.h> |
| 50 #endif | 51 #endif |
| 51 | 52 |
| 52 namespace sk_default { | |
| 53 | |
| 54 // These variable names in these functions just pretend the input is BGRA. | |
| 55 // They work fine with both RGBA and BGRA. | |
| 56 | |
| 57 static void premul_xxxa(uint32_t dst[], const uint32_t src[], int count) { | |
| 58 for (int i = 0; i < count; i++) { | |
| 59 uint8_t a = src[i] >> 24, | |
| 60 r = src[i] >> 16, | |
| 61 g = src[i] >> 8, | |
| 62 b = src[i] >> 0; | |
| 63 r = (r*a+127)/255; | |
| 64 g = (g*a+127)/255; | |
| 65 b = (b*a+127)/255; | |
| 66 dst[i] = (uint32_t)a << 24 | |
| 67 | (uint32_t)r << 16 | |
| 68 | (uint32_t)g << 8 | |
| 69 | (uint32_t)b << 0; | |
| 70 } | |
| 71 } | |
| 72 | |
| 73 static void swaprb_xxxa(uint32_t dst[], const uint32_t src[], int count) { | |
| 74 for (int i = 0; i < count; i++) { | |
| 75 uint8_t a = src[i] >> 24, | |
| 76 r = src[i] >> 16, | |
| 77 g = src[i] >> 8, | |
| 78 b = src[i] >> 0; | |
| 79 dst[i] = (uint32_t)a << 24 | |
| 80 | (uint32_t)b << 16 | |
| 81 | (uint32_t)g << 8 | |
| 82 | (uint32_t)r << 0; | |
| 83 } | |
| 84 } | |
| 85 | |
| 86 static void premul_swaprb_xxxa(uint32_t dst[], const uint32_t src[], int count)
{ | |
| 87 for (int i = 0; i < count; i++) { | |
| 88 uint8_t a = src[i] >> 24, | |
| 89 r = src[i] >> 16, | |
| 90 g = src[i] >> 8, | |
| 91 b = src[i] >> 0; | |
| 92 r = (r*a+127)/255; | |
| 93 g = (g*a+127)/255; | |
| 94 b = (b*a+127)/255; | |
| 95 dst[i] = (uint32_t)a << 24 | |
| 96 | (uint32_t)b << 16 | |
| 97 | (uint32_t)g << 8 | |
| 98 | (uint32_t)r << 0; | |
| 99 } | |
| 100 } | |
| 101 | |
| 102 } // namespace sk_default | |
| 103 | |
| 104 namespace SkOpts { | 53 namespace SkOpts { |
| 105 // Define default function pointer values here... | 54 // Define default function pointer values here... |
| 106 // If our global compile options are set high enough, these defaults might e
ven be | 55 // If our global compile options are set high enough, these defaults might e
ven be |
| 107 // CPU-specialized, e.g. a typical x86-64 machine might start with SSE2 defa
ults. | 56 // CPU-specialized, e.g. a typical x86-64 machine might start with SSE2 defa
ults. |
| 108 // They'll still get a chance to be replaced with even better ones, e.g. usi
ng SSE4.1. | 57 // They'll still get a chance to be replaced with even better ones, e.g. usi
ng SSE4.1. |
| 109 decltype(rsqrt) rsqrt = sk_default::rsqrt; | 58 decltype(rsqrt) rsqrt = sk_default::rsqrt; |
| 110 decltype(memset16) memset16 = sk_default::memset16; | 59 decltype(memset16) memset16 = sk_default::memset16; |
| 111 decltype(memset32) memset32 = sk_default::memset32; | 60 decltype(memset32) memset32 = sk_default::memset32; |
| 112 decltype(create_xfermode) create_xfermode = sk_default::create_xfermode; | 61 decltype(create_xfermode) create_xfermode = sk_default::create_xfermode; |
| 113 decltype(color_cube_filter_span) color_cube_filter_span = sk_default::color_
cube_filter_span; | 62 decltype(color_cube_filter_span) color_cube_filter_span = sk_default::color_
cube_filter_span; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 | 123 |
| 175 SK_DECLARE_STATIC_ONCE(gInitOnce); | 124 SK_DECLARE_STATIC_ONCE(gInitOnce); |
| 176 void Init() { SkOnce(&gInitOnce, init); } | 125 void Init() { SkOnce(&gInitOnce, init); } |
| 177 | 126 |
| 178 #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS | 127 #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS |
| 179 static struct AutoInit { | 128 static struct AutoInit { |
| 180 AutoInit() { Init(); } | 129 AutoInit() { Init(); } |
| 181 } gAutoInit; | 130 } gAutoInit; |
| 182 #endif | 131 #endif |
| 183 } | 132 } |
| OLD | NEW |