diff options
Diffstat (limited to 'libraries/evas/src/lib/engines/common_16/evas_soft16_scanline_blend.c')
-rw-r--r-- | libraries/evas/src/lib/engines/common_16/evas_soft16_scanline_blend.c | 353 |
1 files changed, 353 insertions, 0 deletions
diff --git a/libraries/evas/src/lib/engines/common_16/evas_soft16_scanline_blend.c b/libraries/evas/src/lib/engines/common_16/evas_soft16_scanline_blend.c new file mode 100644 index 0000000..c89eeaa --- /dev/null +++ b/libraries/evas/src/lib/engines/common_16/evas_soft16_scanline_blend.c | |||
@@ -0,0 +1,353 @@ | |||
1 | /** NOTE: This file is meant to be included by users **/ | ||
2 | |||
3 | /** NOTE2: r, g, b parameters are 16bits, so you can pass 0 to 256 inclusive. | ||
4 | ** this is due our division by 256 when multiplying the color. | ||
5 | **/ | ||
6 | |||
7 | /***************************************************************************** | ||
8 | * Scanline processing | ||
9 | * | ||
10 | * _soft16_scanline_<description>_<src>_<dst>[_<modifier>]() | ||
11 | * | ||
12 | ****************************************************************************/ | ||
13 | |||
14 | #include "evas_soft16_point_blend.c" | ||
15 | |||
16 | /*********************************************************************** | ||
17 | * Regular blend operations | ||
18 | */ | ||
19 | static void | ||
20 | _soft16_scanline_blend_transp_solid(DATA16 *src, DATA8 *alpha, DATA16 *dst, int size) | ||
21 | { | ||
22 | DATA16 *start, *end; | ||
23 | |||
24 | start = dst; | ||
25 | end = start + (size & ~7); | ||
26 | |||
27 | pld(alpha, 0); | ||
28 | pld(src, 0); | ||
29 | |||
30 | /* work on 8 pixels per time, do data preload */ | ||
31 | while (start < end) | ||
32 | { | ||
33 | DATA8 alpha1, alpha2; | ||
34 | |||
35 | alpha1 = alpha[0]; | ||
36 | alpha += 8; | ||
37 | |||
38 | /* empirical tests show these give the best performance */ | ||
39 | pld(alpha, 8); | ||
40 | pld(src, 32); | ||
41 | |||
42 | src += 8; | ||
43 | start += 8; | ||
44 | |||
45 | alpha2 = alpha[-7]; | ||
46 | _soft16_pt_blend_transp_solid(start - 8, src[-8], alpha1); | ||
47 | |||
48 | alpha1 = alpha[-6]; | ||
49 | _soft16_pt_blend_transp_solid(start - 7, src[-7], alpha2); | ||
50 | |||
51 | alpha2 = alpha[-5]; | ||
52 | _soft16_pt_blend_transp_solid(start - 6, src[-6], alpha1); | ||
53 | |||
54 | alpha1 = alpha[-4]; | ||
55 | _soft16_pt_blend_transp_solid(start - 5, src[-5], alpha2); | ||
56 | |||
57 | alpha2 = alpha[-3]; | ||
58 | _soft16_pt_blend_transp_solid(start - 4, src[-4], alpha1); | ||
59 | |||
60 | alpha1 = alpha[-2]; | ||
61 | _soft16_pt_blend_transp_solid(start - 3, src[-3], alpha2); | ||
62 | |||
63 | alpha2 = alpha[-1]; | ||
64 | _soft16_pt_blend_transp_solid(start - 2, src[-2], alpha1); | ||
65 | |||
66 | _soft16_pt_blend_transp_solid(start - 1, src[-1], alpha2); | ||
67 | } | ||
68 | |||
69 | /* remaining pixels (up to 7) */ | ||
70 | end = start + (size & 7); | ||
71 | for (; start < end; start++, src++, alpha++) | ||
72 | _soft16_pt_blend_transp_solid(start, *src, *alpha); | ||
73 | } | ||
74 | |||
75 | static inline void | ||
76 | _soft16_scanline_blend_solid_solid(DATA16 *src, DATA16 *dst, int size) | ||
77 | { | ||
78 | memcpy(dst, src, size * sizeof(DATA16)); | ||
79 | } | ||
80 | |||
81 | /*********************************************************************** | ||
82 | * Blend operations taking an extra alpha (fade in, out) | ||
83 | */ | ||
84 | |||
85 | static void | ||
86 | _soft16_scanline_blend_transp_solid_mul_alpha(DATA16 *src, DATA8 *alpha, DATA16 *dst, int size, const DATA8 rel_alpha) | ||
87 | { | ||
88 | DATA16 *start, *end; | ||
89 | |||
90 | start = dst; | ||
91 | end = start + (size & ~7); | ||
92 | |||
93 | pld(alpha, 0); | ||
94 | pld(src, 0); | ||
95 | |||
96 | while (start < end) | ||
97 | { | ||
98 | DATA8 alpha1, alpha2; | ||
99 | |||
100 | alpha1 = alpha[0]; | ||
101 | alpha += 8; | ||
102 | |||
103 | pld(alpha, 8); | ||
104 | pld(src, 32); | ||
105 | |||
106 | src += 8; | ||
107 | start += 8; | ||
108 | |||
109 | alpha2 = alpha[-7]; | ||
110 | _soft16_pt_blend_transp_solid_mul_alpha | ||
111 | (start - 8, src[-8], alpha1, rel_alpha); | ||
112 | |||
113 | alpha1 = alpha[-6]; | ||
114 | _soft16_pt_blend_transp_solid_mul_alpha | ||
115 | (start - 7, src[-7], alpha2, rel_alpha); | ||
116 | |||
117 | alpha2 = alpha[-5]; | ||
118 | _soft16_pt_blend_transp_solid_mul_alpha | ||
119 | (start - 6, src[-6], alpha1, rel_alpha); | ||
120 | |||
121 | alpha1 = alpha[-4]; | ||
122 | _soft16_pt_blend_transp_solid_mul_alpha | ||
123 | (start - 5, src[-5], alpha2, rel_alpha); | ||
124 | |||
125 | alpha2 = alpha[-3]; | ||
126 | _soft16_pt_blend_transp_solid_mul_alpha | ||
127 | (start - 4, src[-4], alpha1, rel_alpha); | ||
128 | |||
129 | alpha1 = alpha[-2]; | ||
130 | _soft16_pt_blend_transp_solid_mul_alpha | ||
131 | (start - 3, src[-3], alpha2, rel_alpha); | ||
132 | |||
133 | alpha2 = alpha[-1]; | ||
134 | _soft16_pt_blend_transp_solid_mul_alpha | ||
135 | (start - 2, src[-2], alpha1, rel_alpha); | ||
136 | |||
137 | _soft16_pt_blend_transp_solid_mul_alpha | ||
138 | (start - 1, src[-1], alpha2, rel_alpha); | ||
139 | } | ||
140 | |||
141 | end = start + (size & 7); | ||
142 | for (; start < end; start++, src++, alpha++) | ||
143 | _soft16_pt_blend_transp_solid_mul_alpha(start, *src, *alpha, rel_alpha); | ||
144 | } | ||
145 | |||
146 | static void | ||
147 | _soft16_scanline_blend_solid_solid_mul_alpha(DATA16 *src, DATA16 *dst, int size, DATA8 rel_alpha) | ||
148 | { | ||
149 | DATA16 *start, *end; | ||
150 | |||
151 | start = dst; | ||
152 | end = start + (size & ~7); | ||
153 | |||
154 | pld(src, 0); | ||
155 | |||
156 | while (start < end) | ||
157 | { | ||
158 | pld(src, 32); | ||
159 | UNROLL8({ | ||
160 | _soft16_pt_blend_solid_solid_mul_alpha(start, *src, rel_alpha); | ||
161 | start++; | ||
162 | src++; | ||
163 | }); | ||
164 | } | ||
165 | |||
166 | end = start + (size & 7); | ||
167 | for (; start < end; start++, src++) | ||
168 | _soft16_pt_blend_solid_solid_mul_alpha(start, *src, rel_alpha); | ||
169 | } | ||
170 | |||
171 | /*********************************************************************** | ||
172 | * Blend operations with extra alpha and multiply color | ||
173 | */ | ||
174 | |||
175 | static void | ||
176 | _soft16_scanline_blend_transp_solid_mul_color_transp(DATA16 *src, DATA8 *alpha, DATA16 *dst, int size, DATA8 rel_alpha, DATA16 r, DATA16 g, DATA16 b) | ||
177 | { | ||
178 | DATA16 *start, *end; | ||
179 | |||
180 | start = dst; | ||
181 | end = start + (size & ~7); | ||
182 | |||
183 | pld(alpha, 0); | ||
184 | pld(src, 0); | ||
185 | |||
186 | while (start < end) | ||
187 | { | ||
188 | DATA8 alpha1, alpha2; | ||
189 | |||
190 | alpha1 = alpha[0]; | ||
191 | alpha += 8; | ||
192 | |||
193 | pld(src, 32); | ||
194 | pld(start, 32); | ||
195 | |||
196 | src += 8; | ||
197 | start += 8; | ||
198 | |||
199 | alpha2 = alpha[-7]; | ||
200 | _soft16_pt_blend_transp_solid_mul_color_transp | ||
201 | (start - 8, src[-8], alpha1, rel_alpha, r, g, b); | ||
202 | |||
203 | alpha1 = alpha[-6]; | ||
204 | _soft16_pt_blend_transp_solid_mul_color_transp | ||
205 | (start - 7, src[-7], alpha2, rel_alpha, r, g, b); | ||
206 | |||
207 | alpha2 = alpha[-5]; | ||
208 | _soft16_pt_blend_transp_solid_mul_color_transp | ||
209 | (start - 6, src[-6], alpha1, rel_alpha, r, g, b); | ||
210 | |||
211 | alpha1 = alpha[-4]; | ||
212 | _soft16_pt_blend_transp_solid_mul_color_transp | ||
213 | (start - 5, src[-5], alpha2, rel_alpha, r, g, b); | ||
214 | |||
215 | alpha2 = alpha[-3]; | ||
216 | _soft16_pt_blend_transp_solid_mul_color_transp | ||
217 | (start - 4, src[-4], alpha1, rel_alpha, r, g, b); | ||
218 | |||
219 | alpha1 = alpha[-2]; | ||
220 | _soft16_pt_blend_transp_solid_mul_color_transp | ||
221 | (start - 3, src[-3], alpha2, rel_alpha, r, g, b); | ||
222 | |||
223 | alpha2 = alpha[-1]; | ||
224 | _soft16_pt_blend_transp_solid_mul_color_transp | ||
225 | (start - 2, src[-2], alpha1, rel_alpha, r, g, b); | ||
226 | |||
227 | _soft16_pt_blend_transp_solid_mul_color_transp | ||
228 | (start - 1, src[-1], alpha2, rel_alpha, r, g, b); | ||
229 | } | ||
230 | |||
231 | end = start + (size & 7); | ||
232 | for (; start < end; start++, src++, alpha++) | ||
233 | _soft16_pt_blend_transp_solid_mul_color_transp | ||
234 | (start, *src, *alpha, rel_alpha, r, g, b); | ||
235 | } | ||
236 | |||
237 | static void | ||
238 | _soft16_scanline_blend_solid_solid_mul_color_transp(DATA16 *src, DATA16 *dst, int size, DATA8 rel_alpha, DATA16 r, DATA16 g, DATA16 b) | ||
239 | { | ||
240 | DATA16 *start, *end; | ||
241 | |||
242 | start = dst; | ||
243 | end = start + (size & ~7); | ||
244 | |||
245 | pld(src, 0); | ||
246 | |||
247 | while (start < end) | ||
248 | { | ||
249 | pld(src, 32); | ||
250 | UNROLL8({ | ||
251 | _soft16_pt_blend_solid_solid_mul_color_transp | ||
252 | (start, *src, rel_alpha, r, g, b); | ||
253 | start++; | ||
254 | src++; | ||
255 | }); | ||
256 | } | ||
257 | |||
258 | end = start + (size & 7); | ||
259 | for (; start < end; start++, src++) | ||
260 | _soft16_pt_blend_solid_solid_mul_color_transp | ||
261 | (start, *src, rel_alpha, r, g, b); | ||
262 | } | ||
263 | |||
264 | /*********************************************************************** | ||
265 | * Blend operations with extra multiply color | ||
266 | */ | ||
267 | |||
268 | static void | ||
269 | _soft16_scanline_blend_transp_solid_mul_color_solid(DATA16 *src, DATA8 *alpha, DATA16 *dst, int size, DATA16 r, DATA16 g, DATA16 b) | ||
270 | { | ||
271 | DATA16 *start, *end; | ||
272 | |||
273 | start = dst; | ||
274 | end = start + (size & ~7); | ||
275 | |||
276 | pld(alpha, 0); | ||
277 | pld(src, 0); | ||
278 | |||
279 | while (start < end) | ||
280 | { | ||
281 | DATA8 alpha1, alpha2; | ||
282 | |||
283 | alpha1 = alpha[0]; | ||
284 | alpha += 8; | ||
285 | |||
286 | pld(alpha, 8); | ||
287 | pld(src, 32); | ||
288 | |||
289 | src += 8; | ||
290 | start += 8; | ||
291 | |||
292 | alpha2 = alpha[-7]; | ||
293 | _soft16_pt_blend_transp_solid_mul_color_solid | ||
294 | (start - 8, src[-8], alpha1, r, g, b); | ||
295 | |||
296 | alpha1 = alpha[-6]; | ||
297 | _soft16_pt_blend_transp_solid_mul_color_solid | ||
298 | (start - 7, src[-7], alpha2, r, g, b); | ||
299 | |||
300 | alpha2 = alpha[-5]; | ||
301 | _soft16_pt_blend_transp_solid_mul_color_solid | ||
302 | (start - 6, src[-6], alpha1, r, g, b); | ||
303 | |||
304 | alpha1 = alpha[-4]; | ||
305 | _soft16_pt_blend_transp_solid_mul_color_solid | ||
306 | (start - 5, src[-5], alpha2, r, g, b); | ||
307 | |||
308 | alpha2 = alpha[-3]; | ||
309 | _soft16_pt_blend_transp_solid_mul_color_solid | ||
310 | (start - 4, src[-4], alpha1, r, g, b); | ||
311 | |||
312 | alpha1 = alpha[-2]; | ||
313 | _soft16_pt_blend_transp_solid_mul_color_solid | ||
314 | (start - 3, src[-3], alpha2, r, g, b); | ||
315 | |||
316 | alpha2 = alpha[-1]; | ||
317 | _soft16_pt_blend_transp_solid_mul_color_solid | ||
318 | (start - 2, src[-2], alpha1, r, g, b); | ||
319 | |||
320 | _soft16_pt_blend_transp_solid_mul_color_solid | ||
321 | (start - 1, src[-1], alpha2, r, g, b); | ||
322 | } | ||
323 | |||
324 | end = start + (size & 7); | ||
325 | for (; start < end; start++, src++, alpha++) | ||
326 | _soft16_pt_blend_transp_solid_mul_color_solid | ||
327 | (start, *src, *alpha, r, g, b); | ||
328 | } | ||
329 | |||
330 | static void | ||
331 | _soft16_scanline_blend_solid_solid_mul_color_solid(DATA16 *src, DATA16 *dst, int size, DATA8 r, DATA8 g, DATA8 b) | ||
332 | { | ||
333 | DATA16 *start, *end; | ||
334 | |||
335 | start = dst; | ||
336 | end = start + (size & ~7); | ||
337 | |||
338 | pld(src, 0); | ||
339 | |||
340 | while (start < end) | ||
341 | { | ||
342 | pld(src, 32); | ||
343 | UNROLL8({ | ||
344 | _soft16_pt_blend_solid_solid_mul_color_solid(start, *src, r, g, b); | ||
345 | start++; | ||
346 | src++; | ||
347 | }); | ||
348 | } | ||
349 | |||
350 | end = start + (size & 7); | ||
351 | for (; start < end; start++, src++) | ||
352 | _soft16_pt_blend_solid_solid_mul_color_solid(start, *src, r, g, b); | ||
353 | } | ||