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

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

Issue 2145833002: Update SkOpts namespaces. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: static, just in case Created 4 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 unified diff | Download patch
« no previous file with comments | « bench/SkBlend_optsBench.cpp ('k') | src/opts/SkBlend_opts.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkCpu.h" 8 #include "SkCpu.h"
9 #include "SkHalf.h" 9 #include "SkHalf.h"
10 #include "SkOnce.h" 10 #include "SkOnce.h"
11 #include "SkOpts.h" 11 #include "SkOpts.h"
12 12
13 #define SK_OPTS_NS sk_default 13 #if defined(SK_ARM_HAS_NEON)
14 #define SK_OPTS_NS neon
15 #elif SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSSE3
16 #define SK_OPTS_NS ssse3
17 #elif SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE3
18 #define SK_OPTS_NS sse3
19 #elif SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2
20 #define SK_OPTS_NS sse2
21 #else
22 #define SK_OPTS_NS portable
23 #endif
24
14 #include "SkBlend_opts.h" 25 #include "SkBlend_opts.h"
15 #include "SkBlitMask_opts.h" 26 #include "SkBlitMask_opts.h"
16 #include "SkBlitRow_opts.h" 27 #include "SkBlitRow_opts.h"
17 #include "SkBlurImageFilter_opts.h" 28 #include "SkBlurImageFilter_opts.h"
18 #include "SkColorCubeFilter_opts.h" 29 #include "SkColorCubeFilter_opts.h"
19 #include "SkColorXform_opts.h" 30 #include "SkColorXform_opts.h"
20 #include "SkMorphologyImageFilter_opts.h" 31 #include "SkMorphologyImageFilter_opts.h"
21 #include "SkSwizzler_opts.h" 32 #include "SkSwizzler_opts.h"
22 #include "SkTextureCompressor_opts.h" 33 #include "SkTextureCompressor_opts.h"
23 #include "SkXfermode_opts.h" 34 #include "SkXfermode_opts.h"
24 35
25 namespace SK_OPTS_NS { 36 namespace SK_OPTS_NS {
26 static void float_to_half(uint16_t dst[], const float src[], int n) { 37 static void float_to_half(uint16_t dst[], const float src[], int n) {
27 while (n-->0) { 38 while (n-->0) {
28 *dst++ = SkFloatToHalf(*src++); 39 *dst++ = SkFloatToHalf(*src++);
29 } 40 }
30 } 41 }
31 static void half_to_float(float dst[], const uint16_t src[], int n) { 42 static void half_to_float(float dst[], const uint16_t src[], int n) {
32 while (n-->0) { 43 while (n-->0) {
33 *dst++ = SkHalfToFloat(*src++); 44 *dst++ = SkHalfToFloat(*src++);
34 } 45 }
35 } 46 }
36 } 47 }
37 48
38 namespace SkOpts { 49 namespace SkOpts {
39
40 // Define default function pointer values here... 50 // Define default function pointer values here...
41 // If our global compile options are set high enough, these defaults might e ven be 51 // If our global compile options are set high enough, these defaults might e ven be
42 // CPU-specialized, e.g. a typical x86-64 machine might start with SSE2 defa ults. 52 // CPU-specialized, e.g. a typical x86-64 machine might start with SSE2 defa ults.
43 // They'll still get a chance to be replaced with even better ones, e.g. usi ng SSE4.1. 53 // They'll still get a chance to be replaced with even better ones, e.g. usi ng SSE4.1.
44 decltype(create_xfermode) create_xfermode = sk_default::create_xfermode; 54 #define DEFINE_DEFAULT(name) decltype(name) name = SK_OPTS_NS::name
45 decltype(color_cube_filter_span) color_cube_filter_span = sk_default::color_ cube_filter_span; 55 DEFINE_DEFAULT(create_xfermode);
56 DEFINE_DEFAULT(color_cube_filter_span);
46 57
47 decltype(box_blur_xx) box_blur_xx = sk_default::box_blur_xx; 58 DEFINE_DEFAULT(box_blur_xx);
48 decltype(box_blur_xy) box_blur_xy = sk_default::box_blur_xy; 59 DEFINE_DEFAULT(box_blur_xy);
49 decltype(box_blur_yx) box_blur_yx = sk_default::box_blur_yx; 60 DEFINE_DEFAULT(box_blur_yx);
50 61
51 decltype(dilate_x) dilate_x = sk_default::dilate_x; 62 DEFINE_DEFAULT(dilate_x);
52 decltype(dilate_y) dilate_y = sk_default::dilate_y; 63 DEFINE_DEFAULT(dilate_y);
53 decltype( erode_x) erode_x = sk_default::erode_x; 64 DEFINE_DEFAULT( erode_x);
54 decltype( erode_y) erode_y = sk_default::erode_y; 65 DEFINE_DEFAULT( erode_y);
55 66
56 decltype(texture_compressor) texture_compressor = sk_default::texture_ compressor; 67 DEFINE_DEFAULT(texture_compressor);
57 decltype(fill_block_dimensions) fill_block_dimensions = sk_default::fill_blo ck_dimensions; 68 DEFINE_DEFAULT(fill_block_dimensions);
58 69
59 decltype(blit_mask_d32_a8) blit_mask_d32_a8 = sk_default::blit_mask_d32_a8; 70 DEFINE_DEFAULT(blit_mask_d32_a8);
60 71
61 decltype(blit_row_color32) blit_row_color32 = sk_default::blit_row_c olor32; 72 DEFINE_DEFAULT(blit_row_color32);
62 decltype(blit_row_s32a_opaque) blit_row_s32a_opaque = sk_default::blit_row_s 32a_opaque; 73 DEFINE_DEFAULT(blit_row_s32a_opaque);
63 74
64 decltype(RGBA_to_BGRA) RGBA_to_BGRA = sk_default::RGBA_to_ BGRA; 75 DEFINE_DEFAULT(RGBA_to_BGRA);
65 decltype(RGBA_to_rgbA) RGBA_to_rgbA = sk_default::RGBA_to_ rgbA; 76 DEFINE_DEFAULT(RGBA_to_rgbA);
66 decltype(RGBA_to_bgrA) RGBA_to_bgrA = sk_default::RGBA_to_ bgrA; 77 DEFINE_DEFAULT(RGBA_to_bgrA);
67 decltype(RGB_to_RGB1) RGB_to_RGB1 = sk_default::RGB_to_R GB1; 78 DEFINE_DEFAULT(RGB_to_RGB1);
68 decltype(RGB_to_BGR1) RGB_to_BGR1 = sk_default::RGB_to_B GR1; 79 DEFINE_DEFAULT(RGB_to_BGR1);
69 decltype(gray_to_RGB1) gray_to_RGB1 = sk_default::gray_to_ RGB1; 80 DEFINE_DEFAULT(gray_to_RGB1);
70 decltype(grayA_to_RGBA) grayA_to_RGBA = sk_default::grayA_to _RGBA; 81 DEFINE_DEFAULT(grayA_to_RGBA);
71 decltype(grayA_to_rgbA) grayA_to_rgbA = sk_default::grayA_to _rgbA; 82 DEFINE_DEFAULT(grayA_to_rgbA);
72 decltype(inverted_CMYK_to_RGB1) inverted_CMYK_to_RGB1 = sk_default::inverted _CMYK_to_RGB1; 83 DEFINE_DEFAULT(inverted_CMYK_to_RGB1);
73 decltype(inverted_CMYK_to_BGR1) inverted_CMYK_to_BGR1 = sk_default::inverted _CMYK_to_BGR1; 84 DEFINE_DEFAULT(inverted_CMYK_to_BGR1);
74 85
75 decltype(half_to_float) half_to_float = sk_default::half_to_float; 86 DEFINE_DEFAULT(half_to_float);
76 decltype(float_to_half) float_to_half = sk_default::float_to_half; 87 DEFINE_DEFAULT(float_to_half);
77 88
78 decltype(srcover_srgb_srgb) srcover_srgb_srgb = sk_default::srcover_srgb_srg b; 89 DEFINE_DEFAULT(srcover_srgb_srgb);
79 90
80 decltype(color_xform_RGB1_to_2dot2) color_xform_RGB1_to_2dot2 = 91 DEFINE_DEFAULT(color_xform_RGB1_to_2dot2);
81 sk_default::color_xform_RGB1_to_2dot2; 92 DEFINE_DEFAULT(color_xform_RGB1_to_srgb);
82 decltype(color_xform_RGB1_to_srgb) color_xform_RGB1_to_srgb = 93 DEFINE_DEFAULT(color_xform_RGB1_to_table);
83 sk_default::color_xform_RGB1_to_srgb; 94 #undef DEFINE_DEFAULT
84 decltype(color_xform_RGB1_to_table) color_xform_RGB1_to_table =
85 sk_default::color_xform_RGB1_to_table;
86 95
87 // Each Init_foo() is defined in src/opts/SkOpts_foo.cpp. 96 // Each Init_foo() is defined in src/opts/SkOpts_foo.cpp.
88 void Init_ssse3(); 97 void Init_ssse3();
89 void Init_sse41(); 98 void Init_sse41();
90 void Init_sse42() {} 99 void Init_sse42() {}
91 void Init_avx(); 100 void Init_avx();
92 void Init_avx2() {} 101 void Init_avx2() {}
93 102
94 static void init() { 103 static void init() {
95 #if defined(SK_CPU_X86) && !defined(SK_BUILD_NO_OPTS) 104 #if defined(SK_CPU_X86) && !defined(SK_BUILD_NO_OPTS)
96 if (SkCpu::Supports(SkCpu::SSSE3)) { Init_ssse3(); } 105 if (SkCpu::Supports(SkCpu::SSSE3)) { Init_ssse3(); }
97 if (SkCpu::Supports(SkCpu::SSE41)) { Init_sse41(); } 106 if (SkCpu::Supports(SkCpu::SSE41)) { Init_sse41(); }
98 if (SkCpu::Supports(SkCpu::SSE42)) { Init_sse42(); } 107 if (SkCpu::Supports(SkCpu::SSE42)) { Init_sse42(); }
99 if (SkCpu::Supports(SkCpu::AVX )) { Init_avx(); } 108 if (SkCpu::Supports(SkCpu::AVX )) { Init_avx(); }
100 if (SkCpu::Supports(SkCpu::AVX2 )) { Init_avx2(); } 109 if (SkCpu::Supports(SkCpu::AVX2 )) { Init_avx2(); }
101 #endif 110 #endif
102 } 111 }
103 112
104 void Init() { 113 void Init() {
105 static SkOnce once; 114 static SkOnce once;
106 once(init); 115 once(init);
107 } 116 }
108 } // namespace SkOpts 117 } // namespace SkOpts
OLDNEW
« no previous file with comments | « bench/SkBlend_optsBench.cpp ('k') | src/opts/SkBlend_opts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698