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

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

Issue 1569013002: Set up some hooks for premul/swizzzle opts. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 11 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') | no next file » | 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 "SkOnce.h" 8 #include "SkOnce.h"
9 #include "SkOpts.h" 9 #include "SkOpts.h"
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 return (uint64_t)(edx) << 32 | eax; 42 return (uint64_t)(edx) << 32 | eax;
43 } 43 }
44 #endif 44 #endif
45 #elif !defined(SK_ARM_HAS_NEON) && \ 45 #elif !defined(SK_ARM_HAS_NEON) && \
46 defined(SK_CPU_ARM32) && \ 46 defined(SK_CPU_ARM32) && \
47 defined(SK_BUILD_FOR_ANDROID) && \ 47 defined(SK_BUILD_FOR_ANDROID) && \
48 !defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) 48 !defined(SK_BUILD_FOR_ANDROID_FRAMEWORK)
49 #include <cpu-features.h> 49 #include <cpu-features.h>
50 #endif 50 #endif
51 51
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;
msarett 2016/01/07 21:35:06 Currently, we use this: static inline U8CPU SkMul
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
52 namespace SkOpts { 104 namespace SkOpts {
53 // Define default function pointer values here... 105 // Define default function pointer values here...
54 // If our global compile options are set high enough, these defaults might e ven be 106 // If our global compile options are set high enough, these defaults might e ven be
55 // CPU-specialized, e.g. a typical x86-64 machine might start with SSE2 defa ults. 107 // CPU-specialized, e.g. a typical x86-64 machine might start with SSE2 defa ults.
56 // They'll still get a chance to be replaced with even better ones, e.g. usi ng SSE4.1. 108 // They'll still get a chance to be replaced with even better ones, e.g. usi ng SSE4.1.
57 decltype(rsqrt) rsqrt = sk_default::rsqrt; 109 decltype(rsqrt) rsqrt = sk_default::rsqrt;
58 decltype(memset16) memset16 = sk_default::memset16; 110 decltype(memset16) memset16 = sk_default::memset16;
59 decltype(memset32) memset32 = sk_default::memset32; 111 decltype(memset32) memset32 = sk_default::memset32;
60 decltype(create_xfermode) create_xfermode = sk_default::create_xfermode; 112 decltype(create_xfermode) create_xfermode = sk_default::create_xfermode;
61 decltype(color_cube_filter_span) color_cube_filter_span = sk_default::color_ cube_filter_span; 113 decltype(color_cube_filter_span) color_cube_filter_span = sk_default::color_ cube_filter_span;
(...skipping 11 matching lines...) Expand all
73 decltype(fill_block_dimensions) fill_block_dimensions = sk_default::fill_blo ck_dimensions; 125 decltype(fill_block_dimensions) fill_block_dimensions = sk_default::fill_blo ck_dimensions;
74 126
75 decltype(blit_mask_d32_a8) blit_mask_d32_a8 = sk_default::blit_mask_d32_a8; 127 decltype(blit_mask_d32_a8) blit_mask_d32_a8 = sk_default::blit_mask_d32_a8;
76 128
77 decltype(blit_row_color32) blit_row_color32 = sk_default::blit_row_color32; 129 decltype(blit_row_color32) blit_row_color32 = sk_default::blit_row_color32;
78 130
79 decltype(matrix_translate) matrix_translate = sk_default::matrix _translate; 131 decltype(matrix_translate) matrix_translate = sk_default::matrix _translate;
80 decltype(matrix_scale_translate) matrix_scale_translate = sk_default::matrix _scale_translate; 132 decltype(matrix_scale_translate) matrix_scale_translate = sk_default::matrix _scale_translate;
81 decltype(matrix_affine) matrix_affine = sk_default::matrix _affine; 133 decltype(matrix_affine) matrix_affine = sk_default::matrix _affine;
82 134
135 decltype( premul_xxxa) premul_xxxa = sk_default:: premul_ xxxa;
136 decltype( swaprb_xxxa) swaprb_xxxa = sk_default:: swaprb_ xxxa;
137 decltype(premul_swaprb_xxxa) premul_swaprb_xxxa = sk_default::premul_swaprb_ xxxa;
138
83 // Each Init_foo() is defined in src/opts/SkOpts_foo.cpp. 139 // Each Init_foo() is defined in src/opts/SkOpts_foo.cpp.
84 void Init_ssse3(); 140 void Init_ssse3();
85 void Init_sse41(); 141 void Init_sse41();
86 void Init_sse42() {} 142 void Init_sse42() {}
87 void Init_avx(); 143 void Init_avx();
88 void Init_avx2() {} 144 void Init_avx2() {}
89 void Init_neon(); 145 void Init_neon();
90 146
91 static void init() { 147 static void init() {
92 // TODO: Chrome's not linking _sse* opts on iOS simulator builds. Bug o r feature? 148 // TODO: Chrome's not linking _sse* opts on iOS simulator builds. Bug o r feature?
(...skipping 25 matching lines...) Expand all
118 174
119 SK_DECLARE_STATIC_ONCE(gInitOnce); 175 SK_DECLARE_STATIC_ONCE(gInitOnce);
120 void Init() { SkOnce(&gInitOnce, init); } 176 void Init() { SkOnce(&gInitOnce, init); }
121 177
122 #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS 178 #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
123 static struct AutoInit { 179 static struct AutoInit {
124 AutoInit() { Init(); } 180 AutoInit() { Init(); }
125 } gAutoInit; 181 } gAutoInit;
126 #endif 182 #endif
127 } 183 }
OLDNEW
« no previous file with comments | « src/core/SkOpts.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698