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

Side by Side Diff: skia/sgl/SkFilterProc.cpp

Issue 113827: Remove the remainder of the skia source code from the Chromium repo.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « skia/sgl/SkFilterProc.h ('k') | skia/sgl/SkFlattenable.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /* libs/graphics/sgl/SkFilterProc.cpp
2 **
3 ** Copyright 2006, The Android Open Source Project
4 **
5 ** Licensed under the Apache License, Version 2.0 (the "License");
6 ** you may not use this file except in compliance with the License.
7 ** You may obtain a copy of the License at
8 **
9 ** http://www.apache.org/licenses/LICENSE-2.0
10 **
11 ** Unless required by applicable law or agreed to in writing, software
12 ** distributed under the License is distributed on an "AS IS" BASIS,
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ** See the License for the specific language governing permissions and
15 ** limitations under the License.
16 */
17
18 #include "SkFilterProc.h"
19
20 /* [1-x 1-y] [x 1-y]
21 [1-x y] [x y]
22 */
23
24 static unsigned bilerp00(unsigned a00, unsigned a01, unsigned a10, unsigned a11) { return a00; }
25 static unsigned bilerp01(unsigned a00, unsigned a01, unsigned a10, unsigned a11) { return (3 * a00 + a01) >> 2; }
26 static unsigned bilerp02(unsigned a00, unsigned a01, unsigned a10, unsigned a11) { return (a00 + a01) >> 1; }
27 static unsigned bilerp03(unsigned a00, unsigned a01, unsigned a10, unsigned a11) { return (a00 + 3 * a01) >> 2; }
28
29 static unsigned bilerp10(unsigned a00, unsigned a01, unsigned a10, unsigned a11) { return (3 * a00 + a10) >> 2; }
30 static unsigned bilerp11(unsigned a00, unsigned a01, unsigned a10, unsigned a11) { return (9 * a00 + 3 * (a01 + a10) + a11) >> 4; }
31 static unsigned bilerp12(unsigned a00, unsigned a01, unsigned a10, unsigned a11) { return (3 * (a00 + a01) + a10 + a11) >> 3; }
32 static unsigned bilerp13(unsigned a00, unsigned a01, unsigned a10, unsigned a11) { return (9 * a01 + 3 * (a00 + a11) + a10) >> 4; }
33
34 static unsigned bilerp20(unsigned a00, unsigned a01, unsigned a10, unsigned a11) { return (a00 + a10) >> 1; }
35 static unsigned bilerp21(unsigned a00, unsigned a01, unsigned a10, unsigned a11) { return (3 * (a00 + a10) + a01 + a11) >> 3; }
36 static unsigned bilerp22(unsigned a00, unsigned a01, unsigned a10, unsigned a11) { return (a00 + a01 + a10 + a11) >> 2; }
37 static unsigned bilerp23(unsigned a00, unsigned a01, unsigned a10, unsigned a11) { return (3 * (a01 + a11) + a00 + a10) >> 3; }
38
39 static unsigned bilerp30(unsigned a00, unsigned a01, unsigned a10, unsigned a11) { return (a00 + 3 * a10) >> 2; }
40 static unsigned bilerp31(unsigned a00, unsigned a01, unsigned a10, unsigned a11) { return (9 * a10 + 3 * (a00 + a11) + a01) >> 4; }
41 static unsigned bilerp32(unsigned a00, unsigned a01, unsigned a10, unsigned a11) { return (3 * (a10 + a11) + a00 + a01) >> 3; }
42 static unsigned bilerp33(unsigned a00, unsigned a01, unsigned a10, unsigned a11) { return (9 * a11 + 3 * (a01 + a10) + a00) >> 4; }
43
44 static const SkFilterProc gBilerpProcs[4 * 4] = {
45 bilerp00, bilerp01, bilerp02, bilerp03,
46 bilerp10, bilerp11, bilerp12, bilerp13,
47 bilerp20, bilerp21, bilerp22, bilerp23,
48 bilerp30, bilerp31, bilerp32, bilerp33
49 };
50
51 const SkFilterProc* SkGetBilinearFilterProcTable()
52 {
53 return gBilerpProcs;
54 }
55
56 ///////////////////////////////////////////////////////////////////////////////
57 ///////////////////////////////////////////////////////////////////////////////
58
59 #define MASK 0xFF00FF
60 #define LO_PAIR(x) ((x) & MASK)
61 #define HI_PAIR(x) (((x) >> 8) & MASK)
62 #define COMBINE(lo, hi) (((lo) & ~0xFF00) | (((hi) & ~0xFF00) << 8))
63
64 ///////////////////////////////////////////////////////////////////////////////
65
66 static unsigned bilerp4_00(uint32_t c00, uint32_t c01, uint32_t c10, uint32_t c1 1) {
67 return c00;
68 }
69 static unsigned bilerp4_01(uint32_t c00, uint32_t c01, uint32_t c10, uint32_t c1 1) {
70 uint32_t lo = (3 * LO_PAIR(c00) + LO_PAIR(c01)) >> 2;
71 uint32_t hi = (3 * HI_PAIR(c00) + HI_PAIR(c01)) >> 2;
72 return COMBINE(lo, hi);
73 }
74 static unsigned bilerp4_02(uint32_t c00, uint32_t c01, uint32_t c10, uint32_t c1 1) {
75 uint32_t lo = (LO_PAIR(c00) + LO_PAIR(c01)) >> 1;
76 uint32_t hi = (HI_PAIR(c00) + HI_PAIR(c01)) >> 1;
77 return COMBINE(lo, hi);
78 }
79 static unsigned bilerp4_03(uint32_t c00, uint32_t c01, uint32_t c10, uint32_t c1 1) {
80 uint32_t lo = (LO_PAIR(c00) + 3 * LO_PAIR(c01)) >> 2;
81 uint32_t hi = (HI_PAIR(c00) + 3 * HI_PAIR(c01)) >> 2;
82 return COMBINE(lo, hi);
83 }
84
85 static unsigned bilerp4_10(uint32_t c00, uint32_t c01, uint32_t c10, uint32_t c1 1) {
86 uint32_t lo = (3 * LO_PAIR(c00) + LO_PAIR(c10)) >> 2;
87 uint32_t hi = (3 * HI_PAIR(c00) + HI_PAIR(c10)) >> 2;
88 return COMBINE(lo, hi);
89 }
90 static unsigned bilerp4_11(uint32_t c00, uint32_t c01, uint32_t c10, uint32_t c1 1) {
91 uint32_t lo = (9 * LO_PAIR(c00) + 3 * (LO_PAIR(c01) + LO_PAIR(c10)) + LO_PAI R(c11)) >> 4;
92 uint32_t hi = (9 * HI_PAIR(c00) + 3 * (HI_PAIR(c01) + HI_PAIR(c10)) + HI_PAI R(c11)) >> 4;
93 return COMBINE(lo, hi);
94 }
95 static unsigned bilerp4_12(uint32_t c00, uint32_t c01, uint32_t c10, uint32_t c1 1) {
96 uint32_t lo = (3 * (LO_PAIR(c00) + LO_PAIR(c01)) + LO_PAIR(c10) + LO_PAIR(c1 1)) >> 3;
97 uint32_t hi = (3 * (HI_PAIR(c00) + HI_PAIR(c01)) + HI_PAIR(c10) + HI_PAIR(c1 1)) >> 3;
98 return COMBINE(lo, hi);
99 }
100 static unsigned bilerp4_13(uint32_t c00, uint32_t c01, uint32_t c10, uint32_t c1 1) {
101 uint32_t lo = (9 * LO_PAIR(c01) + 3 * (LO_PAIR(c00) + LO_PAIR(c11)) + LO_PAI R(c10)) >> 4;
102 uint32_t hi = (9 * HI_PAIR(c01) + 3 * (HI_PAIR(c00) + HI_PAIR(c11)) + HI_PAI R(c10)) >> 4;
103 return COMBINE(lo, hi);
104 }
105
106 static unsigned bilerp4_20(uint32_t c00, uint32_t c01, uint32_t c10, uint32_t c1 1) {
107 uint32_t lo = (LO_PAIR(c00) + LO_PAIR(c10)) >> 1;
108 uint32_t hi = (HI_PAIR(c00) + HI_PAIR(c10)) >> 1;
109 return COMBINE(lo, hi);
110 }
111 static unsigned bilerp4_21(uint32_t c00, uint32_t c01, uint32_t c10, uint32_t c1 1) {
112 uint32_t lo = (3 * (LO_PAIR(c00) + LO_PAIR(c10)) + LO_PAIR(c01) + LO_PAIR(c1 1)) >> 3;
113 uint32_t hi = (3 * (HI_PAIR(c00) + HI_PAIR(c10)) + HI_PAIR(c01) + HI_PAIR(c1 1)) >> 3;
114 return COMBINE(lo, hi);
115 }
116 static unsigned bilerp4_22(uint32_t c00, uint32_t c01, uint32_t c10, uint32_t c1 1) {
117 uint32_t lo = (LO_PAIR(c00) + LO_PAIR(c01) + LO_PAIR(c10) + LO_PAIR(c11)) >> 2;
118 uint32_t hi = (HI_PAIR(c00) + HI_PAIR(c01) + HI_PAIR(c10) + HI_PAIR(c11)) >> 2;
119 return COMBINE(lo, hi);
120 }
121 static unsigned bilerp4_23(uint32_t c00, uint32_t c01, uint32_t c10, uint32_t c1 1) {
122 uint32_t lo = (3 * (LO_PAIR(c01) + LO_PAIR(c11)) + LO_PAIR(c00) + LO_PAIR(c1 0)) >> 3;
123 uint32_t hi = (3 * (HI_PAIR(c01) + HI_PAIR(c11)) + HI_PAIR(c00) + HI_PAIR(c1 0)) >> 3;
124 return COMBINE(lo, hi);
125 }
126
127 static unsigned bilerp4_30(uint32_t c00, uint32_t c01, uint32_t c10, uint32_t c1 1) {
128 uint32_t lo = (LO_PAIR(c00) + 3 * LO_PAIR(c10)) >> 2;
129 uint32_t hi = (HI_PAIR(c00) + 3 * HI_PAIR(c10)) >> 2;
130 return COMBINE(lo, hi);
131 }
132 static unsigned bilerp4_31(uint32_t c00, uint32_t c01, uint32_t c10, uint32_t c1 1) {
133 uint32_t lo = (9 * LO_PAIR(c10) + 3 * (LO_PAIR(c00) + LO_PAIR(c11)) + LO_PAI R(c01)) >> 4;
134 uint32_t hi = (9 * HI_PAIR(c10) + 3 * (HI_PAIR(c00) + HI_PAIR(c11)) + HI_PAI R(c01)) >> 4;
135 return COMBINE(lo, hi);
136 }
137 static unsigned bilerp4_32(uint32_t c00, uint32_t c01, uint32_t c10, uint32_t c1 1) {
138 uint32_t lo = (3 * (LO_PAIR(c10) + LO_PAIR(c11)) + LO_PAIR(c00) + LO_PAIR(c0 1)) >> 3;
139 uint32_t hi = (3 * (HI_PAIR(c10) + HI_PAIR(c11)) + HI_PAIR(c00) + HI_PAIR(c0 1)) >> 3;
140 return COMBINE(lo, hi);
141 }
142 static unsigned bilerp4_33(uint32_t c00, uint32_t c01, uint32_t c10, uint32_t c1 1) {
143 uint32_t lo = (9 * LO_PAIR(c11) + 3 * (LO_PAIR(c01) + LO_PAIR(c10)) + LO_PAI R(c00)) >> 4;
144 uint32_t hi = (9 * HI_PAIR(c11) + 3 * (HI_PAIR(c01) + HI_PAIR(c10)) + HI_PAI R(c00)) >> 4;
145 return COMBINE(lo, hi);
146 }
147
148 static const SkFilter32Proc gBilerp32Procs[4 * 4] = {
149 bilerp4_00, bilerp4_01, bilerp4_02, bilerp4_03,
150 bilerp4_10, bilerp4_11, bilerp4_12, bilerp4_13,
151 bilerp4_20, bilerp4_21, bilerp4_22, bilerp4_23,
152 bilerp4_30, bilerp4_31, bilerp4_32, bilerp4_33
153 };
154
155 const SkFilter32Proc* SkGetFilter32ProcTable()
156 {
157 return gBilerp32Procs;
158 }
159
160 ///////////////////////////////////////////////////////////////////////////////
161
162 static unsigned bilerptr00(const uint32_t* a00, const uint32_t* a01, const uint3 2_t* a10, const uint32_t* a11) {
163 return *a00;
164 }
165 static unsigned bilerptr01(const uint32_t* a00, const uint32_t* a01, const uint3 2_t* a10, const uint32_t* a11) {
166 uint32_t c00 = *a00;
167 uint32_t c01 = *a01;
168 uint32_t lo = (3 * LO_PAIR(c00) + LO_PAIR(c01)) >> 2;
169 uint32_t hi = (3 * HI_PAIR(c00) + HI_PAIR(c01)) >> 2;
170 return COMBINE(lo, hi);
171 }
172 static unsigned bilerptr02(const uint32_t* a00, const uint32_t* a01, const uint3 2_t* a10, const uint32_t* a11) {
173 uint32_t c00 = *a00;
174 uint32_t c01 = *a01;
175 uint32_t lo = (LO_PAIR(c00) + LO_PAIR(c01)) >> 1;
176 uint32_t hi = (HI_PAIR(c00) + HI_PAIR(c01)) >> 1;
177 return COMBINE(lo, hi);
178 }
179 static unsigned bilerptr03(const uint32_t* a00, const uint32_t* a01, const uint3 2_t* a10, const uint32_t* a11) {
180 uint32_t c00 = *a00;
181 uint32_t c01 = *a01;
182 uint32_t lo = (LO_PAIR(c00) + 3 * LO_PAIR(c01)) >> 2;
183 uint32_t hi = (HI_PAIR(c00) + 3 * HI_PAIR(c01)) >> 2;
184 return COMBINE(lo, hi);
185 }
186
187 static unsigned bilerptr10(const uint32_t* a00, const uint32_t* a01, const uint3 2_t* a10, const uint32_t* a11) {
188 uint32_t c00 = *a00;
189 uint32_t c10 = *a10;
190 uint32_t lo = (3 * LO_PAIR(c00) + LO_PAIR(c10)) >> 2;
191 uint32_t hi = (3 * HI_PAIR(c00) + HI_PAIR(c10)) >> 2;
192 return COMBINE(lo, hi);
193 }
194 static unsigned bilerptr11(const uint32_t* a00, const uint32_t* a01, const uint3 2_t* a10, const uint32_t* a11) {
195 uint32_t c00 = *a00;
196 uint32_t c01 = *a01;
197 uint32_t c10 = *a10;
198 uint32_t c11 = *a11;
199 uint32_t lo = (9 * LO_PAIR(c00) + 3 * (LO_PAIR(c01) + LO_PAIR(c10)) + LO_PAI R(c11)) >> 4;
200 uint32_t hi = (9 * HI_PAIR(c00) + 3 * (HI_PAIR(c01) + HI_PAIR(c10)) + HI_PAI R(c11)) >> 4;
201 return COMBINE(lo, hi);
202 }
203 static unsigned bilerptr12(const uint32_t* a00, const uint32_t* a01, const uint3 2_t* a10, const uint32_t* a11) {
204 uint32_t c00 = *a00;
205 uint32_t c01 = *a01;
206 uint32_t c10 = *a10;
207 uint32_t c11 = *a11;
208 uint32_t lo = (3 * (LO_PAIR(c00) + LO_PAIR(c01)) + LO_PAIR(c10) + LO_PAIR(c1 1)) >> 3;
209 uint32_t hi = (3 * (HI_PAIR(c00) + HI_PAIR(c01)) + HI_PAIR(c10) + HI_PAIR(c1 1)) >> 3;
210 return COMBINE(lo, hi);
211 }
212 static unsigned bilerptr13(const uint32_t* a00, const uint32_t* a01, const uint3 2_t* a10, const uint32_t* a11) {
213 uint32_t c00 = *a00;
214 uint32_t c01 = *a01;
215 uint32_t c10 = *a10;
216 uint32_t c11 = *a11;
217 uint32_t lo = (9 * LO_PAIR(c01) + 3 * (LO_PAIR(c00) + LO_PAIR(c11)) + LO_PAI R(c10)) >> 4;
218 uint32_t hi = (9 * HI_PAIR(c01) + 3 * (HI_PAIR(c00) + HI_PAIR(c11)) + HI_PAI R(c10)) >> 4;
219 return COMBINE(lo, hi);
220 }
221
222 static unsigned bilerptr20(const uint32_t* a00, const uint32_t* a01, const uint3 2_t* a10, const uint32_t* a11) {
223 uint32_t c00 = *a00;
224 uint32_t c10 = *a10;
225 uint32_t lo = (LO_PAIR(c00) + LO_PAIR(c10)) >> 1;
226 uint32_t hi = (HI_PAIR(c00) + HI_PAIR(c10)) >> 1;
227 return COMBINE(lo, hi);
228 }
229 static unsigned bilerptr21(const uint32_t* a00, const uint32_t* a01, const uint3 2_t* a10, const uint32_t* a11) {
230 uint32_t c00 = *a00;
231 uint32_t c01 = *a01;
232 uint32_t c10 = *a10;
233 uint32_t c11 = *a11;
234 uint32_t lo = (3 * (LO_PAIR(c00) + LO_PAIR(c10)) + LO_PAIR(c01) + LO_PAIR(c1 1)) >> 3;
235 uint32_t hi = (3 * (HI_PAIR(c00) + HI_PAIR(c10)) + HI_PAIR(c01) + HI_PAIR(c1 1)) >> 3;
236 return COMBINE(lo, hi);
237 }
238 static unsigned bilerptr22(const uint32_t* a00, const uint32_t* a01, const uint3 2_t* a10, const uint32_t* a11) {
239 uint32_t c00 = *a00;
240 uint32_t c01 = *a01;
241 uint32_t c10 = *a10;
242 uint32_t c11 = *a11;
243 uint32_t lo = (LO_PAIR(c00) + LO_PAIR(c01) + LO_PAIR(c10) + LO_PAIR(c11)) >> 2;
244 uint32_t hi = (HI_PAIR(c00) + HI_PAIR(c01) + HI_PAIR(c10) + HI_PAIR(c11)) >> 2;
245 return COMBINE(lo, hi);
246 }
247 static unsigned bilerptr23(const uint32_t* a00, const uint32_t* a01, const uint3 2_t* a10, const uint32_t* a11) {
248 uint32_t c00 = *a00;
249 uint32_t c01 = *a01;
250 uint32_t c10 = *a10;
251 uint32_t c11 = *a11;
252 uint32_t lo = (3 * (LO_PAIR(c01) + LO_PAIR(c11)) + LO_PAIR(c00) + LO_PAIR(c1 0)) >> 3;
253 uint32_t hi = (3 * (HI_PAIR(c01) + HI_PAIR(c11)) + HI_PAIR(c00) + HI_PAIR(c1 0)) >> 3;
254 return COMBINE(lo, hi);
255 }
256
257 static unsigned bilerptr30(const uint32_t* a00, const uint32_t* a01, const uint3 2_t* a10, const uint32_t* a11) {
258 uint32_t c00 = *a00;
259 uint32_t c10 = *a10;
260 uint32_t lo = (LO_PAIR(c00) + 3 * LO_PAIR(c10)) >> 2;
261 uint32_t hi = (HI_PAIR(c00) + 3 * HI_PAIR(c10)) >> 2;
262 return COMBINE(lo, hi);
263 }
264 static unsigned bilerptr31(const uint32_t* a00, const uint32_t* a01, const uint3 2_t* a10, const uint32_t* a11) {
265 uint32_t c00 = *a00;
266 uint32_t c01 = *a01;
267 uint32_t c10 = *a10;
268 uint32_t c11 = *a11;
269 uint32_t lo = (9 * LO_PAIR(c10) + 3 * (LO_PAIR(c00) + LO_PAIR(c11)) + LO_PAI R(c01)) >> 4;
270 uint32_t hi = (9 * HI_PAIR(c10) + 3 * (HI_PAIR(c00) + HI_PAIR(c11)) + HI_PAI R(c01)) >> 4;
271 return COMBINE(lo, hi);
272 }
273 static unsigned bilerptr32(const uint32_t* a00, const uint32_t* a01, const uint3 2_t* a10, const uint32_t* a11) {
274 uint32_t c00 = *a00;
275 uint32_t c01 = *a01;
276 uint32_t c10 = *a10;
277 uint32_t c11 = *a11;
278 uint32_t lo = (3 * (LO_PAIR(c10) + LO_PAIR(c11)) + LO_PAIR(c00) + LO_PAIR(c0 1)) >> 3;
279 uint32_t hi = (3 * (HI_PAIR(c10) + HI_PAIR(c11)) + HI_PAIR(c00) + HI_PAIR(c0 1)) >> 3;
280 return COMBINE(lo, hi);
281 }
282 static unsigned bilerptr33(const uint32_t* a00, const uint32_t* a01, const uint3 2_t* a10, const uint32_t* a11) {
283 uint32_t c00 = *a00;
284 uint32_t c01 = *a01;
285 uint32_t c10 = *a10;
286 uint32_t c11 = *a11;
287 uint32_t lo = (9 * LO_PAIR(c11) + 3 * (LO_PAIR(c01) + LO_PAIR(c10)) + LO_PAI R(c00)) >> 4;
288 uint32_t hi = (9 * HI_PAIR(c11) + 3 * (HI_PAIR(c01) + HI_PAIR(c10)) + HI_PAI R(c00)) >> 4;
289 return COMBINE(lo, hi);
290 }
291
292 static const SkFilterPtrProc gBilerpPtrProcs[4 * 4] = {
293 bilerptr00, bilerptr01, bilerptr02, bilerptr03,
294 bilerptr10, bilerptr11, bilerptr12, bilerptr13,
295 bilerptr20, bilerptr21, bilerptr22, bilerptr23,
296 bilerptr30, bilerptr31, bilerptr32, bilerptr33
297 };
298
299 const SkFilterPtrProc* SkGetBilinearFilterPtrProcTable()
300 {
301 return gBilerpPtrProcs;
302 }
303
OLDNEW
« no previous file with comments | « skia/sgl/SkFilterProc.h ('k') | skia/sgl/SkFlattenable.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698