diff options
author | David Walter Seikel | 2012-01-04 18:41:13 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-04 18:41:13 +1000 |
commit | dd7595a3475407a7fa96a97393bae8c5220e8762 (patch) | |
tree | e341e911d7eb911a51684a7412ef7f7c7605d28e /libraries/evas/src/lib/engines/common_16/evas_soft16_image_scaled_sampled.c | |
parent | Add the skeleton. (diff) | |
download | SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.zip SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.gz SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.bz2 SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.xz |
Add the base Enlightenment Foundation Libraries - eina, eet, evas, ecore, embryo, and edje.
Note that embryo wont be used, but I'm not sure yet if you can build edje without it.
Diffstat (limited to 'libraries/evas/src/lib/engines/common_16/evas_soft16_image_scaled_sampled.c')
-rw-r--r-- | libraries/evas/src/lib/engines/common_16/evas_soft16_image_scaled_sampled.c | 471 |
1 files changed, 471 insertions, 0 deletions
diff --git a/libraries/evas/src/lib/engines/common_16/evas_soft16_image_scaled_sampled.c b/libraries/evas/src/lib/engines/common_16/evas_soft16_image_scaled_sampled.c new file mode 100644 index 0000000..9c9f03c --- /dev/null +++ b/libraries/evas/src/lib/engines/common_16/evas_soft16_image_scaled_sampled.c | |||
@@ -0,0 +1,471 @@ | |||
1 | #include "evas_common_soft16.h" | ||
2 | #include "evas_soft16_point_blend.c" | ||
3 | |||
4 | static void | ||
5 | _soft16_image_draw_scaled_solid_solid(Soft16_Image *src, | ||
6 | Soft16_Image *dst, | ||
7 | RGBA_Draw_Context *dc __UNUSED__, | ||
8 | int dst_offset, int w, int h, | ||
9 | int *offset_x, int *offset_y) | ||
10 | { | ||
11 | DATA16 *dst_itr; | ||
12 | int y, w_align; | ||
13 | |||
14 | w_align = w & ~7; | ||
15 | |||
16 | dst_itr = dst->pixels + dst_offset; | ||
17 | for (y = 0; y < h; y++, dst_itr += dst->stride) | ||
18 | { | ||
19 | DATA16 *d, *s; | ||
20 | int x; | ||
21 | |||
22 | s = src->pixels + offset_y[y]; | ||
23 | pld(s, 0); | ||
24 | pld(offset_x, 0); | ||
25 | |||
26 | d = dst_itr; | ||
27 | x = 0; | ||
28 | while (x < w_align) | ||
29 | { | ||
30 | pld(s, 32); | ||
31 | pld(offset_x + x, 32); | ||
32 | |||
33 | UNROLL8({ | ||
34 | _soft16_pt_blend_solid_solid(d, s[offset_x[x]]); | ||
35 | x++; | ||
36 | d++; | ||
37 | }); | ||
38 | } | ||
39 | |||
40 | for (; x < w; x++, d++) | ||
41 | _soft16_pt_blend_solid_solid(d, s[offset_x[x]]); | ||
42 | } | ||
43 | } | ||
44 | static void | ||
45 | _soft16_image_draw_scaled_transp_solid(Soft16_Image *src, | ||
46 | Soft16_Image *dst, | ||
47 | RGBA_Draw_Context *dc __UNUSED__, | ||
48 | int dst_offset, int w, int h, | ||
49 | int *offset_x, int *offset_y) | ||
50 | { | ||
51 | DATA16 *dst_itr; | ||
52 | int y, w_align; | ||
53 | |||
54 | w_align = w & ~7; | ||
55 | |||
56 | dst_itr = dst->pixels + dst_offset; | ||
57 | for (y = 0; y < h; y++, dst_itr += dst->stride) | ||
58 | { | ||
59 | DATA16 *d, *s; | ||
60 | DATA8 *a; | ||
61 | int x; | ||
62 | |||
63 | s = src->pixels + offset_y[y]; | ||
64 | a = src->alpha + offset_y[y]; | ||
65 | pld(s, 0); | ||
66 | pld(a, 0); | ||
67 | pld(offset_x, 0); | ||
68 | |||
69 | d = dst_itr; | ||
70 | x = 0; | ||
71 | while (x < w_align) | ||
72 | { | ||
73 | pld(s, 32); | ||
74 | pld(a, 8); | ||
75 | pld(offset_x + x, 32); | ||
76 | |||
77 | UNROLL8({ | ||
78 | int off_x = offset_x[x]; | ||
79 | _soft16_pt_blend_transp_solid(d, s[off_x], a[off_x]); | ||
80 | x++; | ||
81 | d++; | ||
82 | }); | ||
83 | } | ||
84 | |||
85 | for (; x < w; x++, d++) | ||
86 | _soft16_pt_blend_transp_solid(d, s[offset_x[x]], a[offset_x[x]]); | ||
87 | } | ||
88 | } | ||
89 | |||
90 | static inline void | ||
91 | _soft16_image_draw_scaled_no_mul(Soft16_Image *src, Soft16_Image *dst, | ||
92 | RGBA_Draw_Context *dc, | ||
93 | int dst_offset, int w, int h, | ||
94 | int *offset_x, int *offset_y) | ||
95 | { | ||
96 | if ((src->cache_entry.flags.alpha && src->alpha) && | ||
97 | (!dst->cache_entry.flags.alpha)) | ||
98 | _soft16_image_draw_scaled_transp_solid | ||
99 | (src, dst, dc, dst_offset, w, h, offset_x, offset_y); | ||
100 | else if (!dst->cache_entry.flags.alpha) | ||
101 | _soft16_image_draw_scaled_solid_solid | ||
102 | (src, dst, dc, dst_offset, w, h, offset_x, offset_y); | ||
103 | else | ||
104 | ERR("Unsupported draw of scaled images src->cache_entry.flags.alpha=%d, " | ||
105 | "dst->cache_entry.flags.alpha=%d, WITHOUT COLOR MUL", | ||
106 | src->cache_entry.flags.alpha, dst->cache_entry.flags.alpha); | ||
107 | } | ||
108 | |||
109 | static void | ||
110 | _soft16_image_draw_scaled_solid_solid_mul_alpha(Soft16_Image *src, | ||
111 | Soft16_Image *dst, | ||
112 | RGBA_Draw_Context *dc __UNUSED__, | ||
113 | int dst_offset, int w, int h, | ||
114 | int *offset_x, int *offset_y, | ||
115 | DATA8 alpha) | ||
116 | { | ||
117 | DATA16 *dst_itr; | ||
118 | int y, w_align; | ||
119 | |||
120 | w_align = w & ~7; | ||
121 | |||
122 | dst_itr = dst->pixels + dst_offset; | ||
123 | for (y = 0; y < h; y++, dst_itr += dst->stride) | ||
124 | { | ||
125 | DATA16 *d, *s; | ||
126 | int x; | ||
127 | |||
128 | s = src->pixels + offset_y[y]; | ||
129 | pld(s, 0); | ||
130 | pld(offset_x, 0); | ||
131 | |||
132 | d = dst_itr; | ||
133 | x = 0; | ||
134 | while (x < w_align) | ||
135 | { | ||
136 | pld(s, 32); | ||
137 | pld(offset_x + x, 32); | ||
138 | |||
139 | UNROLL8({ | ||
140 | _soft16_pt_blend_solid_solid_mul_alpha | ||
141 | (d, s[offset_x[x]], alpha); | ||
142 | x++; | ||
143 | d++; | ||
144 | }); | ||
145 | } | ||
146 | |||
147 | for (; x < w; x++, d++) | ||
148 | _soft16_pt_blend_solid_solid_mul_alpha | ||
149 | (d, s[offset_x[x]], alpha); | ||
150 | } | ||
151 | } | ||
152 | |||
153 | static void | ||
154 | _soft16_image_draw_scaled_transp_solid_mul_alpha(Soft16_Image *src, | ||
155 | Soft16_Image *dst, | ||
156 | RGBA_Draw_Context *dc __UNUSED__, | ||
157 | int dst_offset, int w, int h, | ||
158 | int *offset_x, int *offset_y, | ||
159 | DATA8 alpha) | ||
160 | { | ||
161 | DATA16 *dst_itr; | ||
162 | int y, w_align; | ||
163 | |||
164 | w_align = w & ~7; | ||
165 | |||
166 | dst_itr = dst->pixels + dst_offset; | ||
167 | for (y = 0; y < h; y++, dst_itr += dst->stride) | ||
168 | { | ||
169 | DATA16 *d, *s; | ||
170 | DATA8 *a; | ||
171 | int x; | ||
172 | |||
173 | s = src->pixels + offset_y[y]; | ||
174 | a = src->alpha + offset_y[y]; | ||
175 | pld(s, 0); | ||
176 | pld(a, 0); | ||
177 | pld(offset_x, 0); | ||
178 | |||
179 | d = dst_itr; | ||
180 | x = 0; | ||
181 | while (x < w_align) | ||
182 | { | ||
183 | pld(s, 32); | ||
184 | pld(a, 8); | ||
185 | pld(offset_x + x, 32); | ||
186 | |||
187 | UNROLL8({ | ||
188 | int off_x = offset_x[x]; | ||
189 | _soft16_pt_blend_transp_solid_mul_alpha | ||
190 | (d, s[off_x], a[off_x], alpha); | ||
191 | x++; | ||
192 | d++; | ||
193 | }); | ||
194 | } | ||
195 | |||
196 | for (; x < w; x++, d++) | ||
197 | _soft16_pt_blend_transp_solid_mul_alpha | ||
198 | (d, s[offset_x[x]], a[offset_x[x]], alpha); | ||
199 | } | ||
200 | } | ||
201 | |||
202 | static inline void | ||
203 | _soft16_image_draw_scaled_mul_alpha(Soft16_Image *src, Soft16_Image *dst, | ||
204 | RGBA_Draw_Context *dc, | ||
205 | int dst_offset, int w, int h, | ||
206 | int *offset_x, int *offset_y, DATA8 a) | ||
207 | { | ||
208 | if ((src->cache_entry.flags.alpha && src->alpha) && | ||
209 | (!dst->cache_entry.flags.alpha)) | ||
210 | _soft16_image_draw_scaled_transp_solid_mul_alpha | ||
211 | (src, dst, dc, dst_offset, w, h, offset_x, offset_y, a); | ||
212 | else if (!dst->cache_entry.flags.alpha) | ||
213 | _soft16_image_draw_scaled_solid_solid_mul_alpha | ||
214 | (src, dst, dc, dst_offset, w, h, offset_x, offset_y, a); | ||
215 | else | ||
216 | ERR("Unsupported draw of scaled images src->cache_entry.flags.alpha=%d, " | ||
217 | "dst->cache_entry.flags.alpha=%d, WITH ALPHA MUL %d", | ||
218 | src->cache_entry.flags.alpha, dst->cache_entry.flags.alpha, A_VAL(&dc->mul.col)); | ||
219 | } | ||
220 | |||
221 | static void | ||
222 | _soft16_image_draw_scaled_solid_solid_mul_color(Soft16_Image *src, | ||
223 | Soft16_Image *dst, | ||
224 | RGBA_Draw_Context *dc __UNUSED__, | ||
225 | int dst_offset, int w, int h, | ||
226 | int *offset_x, int *offset_y, | ||
227 | DATA8 r, DATA8 g, DATA8 b, | ||
228 | DATA8 alpha) | ||
229 | { | ||
230 | DATA16 *dst_itr; | ||
231 | int y, w_align; | ||
232 | |||
233 | w_align = w & ~7; | ||
234 | |||
235 | dst_itr = dst->pixels + dst_offset; | ||
236 | |||
237 | if (alpha == 31) | ||
238 | for (y = 0; y < h; y++, dst_itr += dst->stride) | ||
239 | { | ||
240 | DATA16 *d, *s; | ||
241 | int x; | ||
242 | |||
243 | s = src->pixels + offset_y[y]; | ||
244 | pld(s, 0); | ||
245 | pld(offset_x, 0); | ||
246 | |||
247 | d = dst_itr; | ||
248 | x = 0; | ||
249 | while (x < w_align) | ||
250 | { | ||
251 | pld(s, 32); | ||
252 | pld(offset_x + x, 32); | ||
253 | |||
254 | UNROLL8({ | ||
255 | _soft16_pt_blend_solid_solid_mul_color_solid | ||
256 | (d, s[offset_x[x]], r, g, b); | ||
257 | x++; | ||
258 | d++; | ||
259 | }); | ||
260 | } | ||
261 | |||
262 | for (; x < w; x++, d++) | ||
263 | _soft16_pt_blend_solid_solid_mul_color_solid | ||
264 | (d, s[offset_x[x]], r, g, b); | ||
265 | } | ||
266 | else | ||
267 | for (y = 0; y < h; y++, dst_itr += dst->stride) | ||
268 | { | ||
269 | DATA16 *d, *s; | ||
270 | int x; | ||
271 | |||
272 | s = src->pixels + offset_y[y]; | ||
273 | pld(s, 0); | ||
274 | pld(offset_x, 0); | ||
275 | |||
276 | d = dst_itr; | ||
277 | x = 0; | ||
278 | while (x < w_align) | ||
279 | { | ||
280 | pld(s, 32); | ||
281 | pld(offset_x + x, 32); | ||
282 | |||
283 | UNROLL8({ | ||
284 | _soft16_pt_blend_solid_solid_mul_color_transp | ||
285 | (d, s[offset_x[x]], alpha, r, g, b); | ||
286 | x++; | ||
287 | d++; | ||
288 | }); | ||
289 | } | ||
290 | |||
291 | for (; x < w; x++, d++) | ||
292 | _soft16_pt_blend_solid_solid_mul_color_transp | ||
293 | (d, s[offset_x[x]], alpha, r, g, b); | ||
294 | } | ||
295 | } | ||
296 | |||
297 | static void | ||
298 | _soft16_image_draw_scaled_transp_solid_mul_color(Soft16_Image *src, | ||
299 | Soft16_Image *dst, | ||
300 | RGBA_Draw_Context *dc __UNUSED__, | ||
301 | int dst_offset, int w, int h, | ||
302 | int *offset_x, int *offset_y, | ||
303 | DATA8 r, DATA8 g, DATA8 b, | ||
304 | DATA8 alpha) | ||
305 | { | ||
306 | DATA16 *dst_itr; | ||
307 | int y, w_align; | ||
308 | |||
309 | w_align = w & ~7; | ||
310 | |||
311 | dst_itr = dst->pixels + dst_offset; | ||
312 | |||
313 | if (alpha == 31) | ||
314 | for (y = 0; y < h; y++, dst_itr += dst->stride) | ||
315 | { | ||
316 | DATA16 *d, *s; | ||
317 | DATA8 *a; | ||
318 | int x; | ||
319 | |||
320 | s = src->pixels + offset_y[y]; | ||
321 | a = src->alpha + offset_y[y]; | ||
322 | pld(s, 0); | ||
323 | pld(a, 0); | ||
324 | pld(offset_x, 0); | ||
325 | |||
326 | d = dst_itr; | ||
327 | x = 0; | ||
328 | while (x < w_align) | ||
329 | { | ||
330 | pld(s, 32); | ||
331 | pld(a, 8); | ||
332 | pld(offset_x + x, 32); | ||
333 | |||
334 | UNROLL8({ | ||
335 | int off_x = offset_x[x]; | ||
336 | _soft16_pt_blend_transp_solid_mul_color_solid | ||
337 | (d, s[off_x], a[off_x], r, g, b); | ||
338 | x++; | ||
339 | d++; | ||
340 | }); | ||
341 | } | ||
342 | |||
343 | for (; x < w; x++, d++) | ||
344 | _soft16_pt_blend_transp_solid_mul_color_solid | ||
345 | (d, s[offset_x[x]], a[offset_x[x]], r, g, b); | ||
346 | } | ||
347 | else | ||
348 | for (y = 0; y < h; y++, dst_itr += dst->stride) | ||
349 | { | ||
350 | DATA16 *d, *s; | ||
351 | DATA8 *a; | ||
352 | int x; | ||
353 | |||
354 | s = src->pixels + offset_y[y]; | ||
355 | a = src->alpha + offset_y[y]; | ||
356 | pld(s, 0); | ||
357 | pld(a, 0); | ||
358 | pld(offset_x, 0); | ||
359 | |||
360 | d = dst_itr; | ||
361 | x = 0; | ||
362 | while (x < w_align) | ||
363 | { | ||
364 | pld(s, 32); | ||
365 | pld(a, 8); | ||
366 | pld(offset_x + x, 32); | ||
367 | |||
368 | UNROLL8({ | ||
369 | int off_x = offset_x[x]; | ||
370 | _soft16_pt_blend_transp_solid_mul_color_transp | ||
371 | (d, s[off_x], a[off_x], alpha, r, g, b); | ||
372 | x++; | ||
373 | d++; | ||
374 | }); | ||
375 | } | ||
376 | |||
377 | for (; x < w; x++, d++) | ||
378 | _soft16_pt_blend_transp_solid_mul_color_transp | ||
379 | (d, s[offset_x[x]], a[offset_x[x]], alpha, r, g, b); | ||
380 | } | ||
381 | } | ||
382 | |||
383 | static inline void | ||
384 | _soft16_image_draw_scaled_mul_color(Soft16_Image *src, Soft16_Image *dst, | ||
385 | RGBA_Draw_Context *dc, | ||
386 | int dst_offset, int w, int h, | ||
387 | int *offset_x, int *offset_y, | ||
388 | DATA8 r, DATA8 g, DATA8 b, DATA8 a) | ||
389 | { | ||
390 | if ((src->cache_entry.flags.alpha && src->alpha) && | ||
391 | (!dst->cache_entry.flags.alpha)) | ||
392 | _soft16_image_draw_scaled_transp_solid_mul_color | ||
393 | (src, dst, dc, dst_offset, w, h, offset_x, offset_y, r, g, b, a); | ||
394 | else if (!dst->cache_entry.flags.alpha) | ||
395 | _soft16_image_draw_scaled_solid_solid_mul_color | ||
396 | (src, dst, dc, dst_offset, w, h, offset_x, offset_y, r, g, b, a); | ||
397 | else | ||
398 | ERR("Unsupported draw of scaled images src->cache_entry.flags.alpha=%d, " | ||
399 | "dst->cache_entry.flags.alpha=%d, WITH COLOR MUL 0x%08x", | ||
400 | src->cache_entry.flags.alpha, dst->cache_entry.flags.alpha, dc->mul.col); | ||
401 | } | ||
402 | |||
403 | static inline void | ||
404 | _soft16_image_draw_scaled_mul(Soft16_Image *src, Soft16_Image *dst, | ||
405 | RGBA_Draw_Context *dc, | ||
406 | int dst_offset, int w, int h, | ||
407 | int *offset_x, int *offset_y, DATA8 r, DATA8 g, | ||
408 | DATA8 b, DATA8 a) | ||
409 | { | ||
410 | if ((a == r) && (a == (g >> 1)) && (a == b)) | ||
411 | _soft16_image_draw_scaled_mul_alpha | ||
412 | (src, dst, dc, dst_offset, w, h, offset_x, offset_y, a); | ||
413 | else | ||
414 | _soft16_image_draw_scaled_mul_color | ||
415 | (src, dst, dc, dst_offset, w, h, offset_x, offset_y, r, g, b, a); | ||
416 | } | ||
417 | |||
418 | void | ||
419 | evas_common_soft16_image_draw_scaled_sampled(Soft16_Image *src, Soft16_Image *dst, | ||
420 | RGBA_Draw_Context *dc, | ||
421 | const Eina_Rectangle sr, | ||
422 | const Eina_Rectangle dr, | ||
423 | const Eina_Rectangle cr) | ||
424 | { | ||
425 | int x, y, dst_offset, *offset_x, *offset_y; | ||
426 | DATA16 mul_rgb565; | ||
427 | DATA8 r, g, b, a; | ||
428 | |||
429 | if (!dc->mul.use) | ||
430 | { | ||
431 | r = b = a = 31; | ||
432 | g = 63; | ||
433 | mul_rgb565 = 0xffff; | ||
434 | } | ||
435 | else | ||
436 | { | ||
437 | a = A_VAL(&dc->mul.col) >> 3; | ||
438 | if (a == 0) | ||
439 | return; | ||
440 | |||
441 | r = R_VAL(&dc->mul.col) >> 3; | ||
442 | g = G_VAL(&dc->mul.col) >> 2; | ||
443 | b = B_VAL(&dc->mul.col) >> 3; | ||
444 | |||
445 | if (r > a) r = a; | ||
446 | if (g > (a << 1)) g = (a << 1); | ||
447 | if (b > a) b = a; | ||
448 | |||
449 | mul_rgb565 = (r << 11) || (g << 5) | b; | ||
450 | } | ||
451 | |||
452 | /* pre-calculated scale tables */ | ||
453 | offset_x = alloca(cr.w * sizeof(*offset_x)); | ||
454 | for (x = 0; x < cr.w; x++) | ||
455 | offset_x[x] = (((x + cr.x - dr.x) * sr.w) / dr.w) + sr.x; | ||
456 | |||
457 | offset_y = alloca(cr.h * sizeof(*offset_y)); | ||
458 | for (y = 0; y < cr.h; y++) | ||
459 | offset_y[y] = (((((y + cr.y - dr.y) * sr.h) / dr.h) + sr.y) | ||
460 | * src->stride); | ||
461 | |||
462 | dst_offset = cr.x + (cr.y * dst->stride); | ||
463 | |||
464 | |||
465 | if (mul_rgb565 == 0xffff) | ||
466 | _soft16_image_draw_scaled_no_mul | ||
467 | (src, dst, dc, dst_offset, cr.w, cr.h, offset_x, offset_y); | ||
468 | else | ||
469 | _soft16_image_draw_scaled_mul | ||
470 | (src, dst, dc, dst_offset, cr.w, cr.h, offset_x, offset_y, r, g, b, a); | ||
471 | } | ||