summaryrefslogtreecommitdiff
path: root/src/lib/evas/common/evas_convert_rgb_32.c
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2012-11-04 11:51:42 +0000
committerVincent Torri <vincent.torri@gmail.com>2012-11-04 11:51:42 +0000
commitc15e9c6575c3b5f39ded167dda5259de3de96151 (patch)
tree5115d7ae3620af24c2bc094cd062575af7adeda9 /src/lib/evas/common/evas_convert_rgb_32.c
parenta5ac6a987caec5a7f7596a25d0a065b9cc94c50c (diff)
merge: and now Evas
I've tested make -j 3 install and it works nicely I've tested expedite with software and opengl xlib, and it works. Not tested other engines, so please report any problems (engines or other) on the ML. TODO: examples and tests, I'll add them later ISSUE: Eina_Unicode size check. It indirectly depends on eina_config.h, which is created at the end of the configure script. So its size is always 0. I don't know how that size is used, so I can't do a lot, for now. SVN revision: 78895
Diffstat (limited to 'src/lib/evas/common/evas_convert_rgb_32.c')
-rw-r--r--src/lib/evas/common/evas_convert_rgb_32.c555
1 files changed, 555 insertions, 0 deletions
diff --git a/src/lib/evas/common/evas_convert_rgb_32.c b/src/lib/evas/common/evas_convert_rgb_32.c
new file mode 100644
index 0000000000..b7652269c0
--- /dev/null
+++ b/src/lib/evas/common/evas_convert_rgb_32.c
@@ -0,0 +1,555 @@
1#include "evas_common.h"
2#include "evas_convert_rgb_32.h"
3
4void
5evas_common_convert_rgba_to_32bpp_rgb_8888 (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x EINA_UNUSED, int dith_y EINA_UNUSED, DATA8 *pal EINA_UNUSED)
6{
7 DATA32 *src_ptr;
8 DATA32 *dst_ptr;
9 int y;
10 Gfx_Func_Copy func;
11
12 dst_ptr = (DATA32 *)dst;
13 src_ptr = src;
14
15 func = evas_common_draw_func_copy_get(w, 0);
16
17 for (y = 0; y < h; y++)
18 {
19 func(src_ptr, dst_ptr, w);
20 src_ptr += w + src_jump;
21 dst_ptr += w + dst_jump;
22 }
23 return;
24}
25
26void
27evas_common_convert_rgba_to_32bpp_rgb_8888_rot_180 (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x EINA_UNUSED, int dith_y EINA_UNUSED, DATA8 *pal EINA_UNUSED)
28{
29 DATA32 *src_ptr;
30 DATA32 *dst_ptr;
31 int x, y;
32
33 dst_ptr = (DATA32 *)dst;
34
35 CONVERT_LOOP_START_ROT_180();
36
37 *dst_ptr = *src_ptr;
38
39 CONVERT_LOOP_END_ROT_180();
40 return;
41}
42
43#ifdef TILE_ROTATE
44#define FAST_SIMPLE_ROTATE(suffix, pix_type) \
45 static void \
46 blt_rotated_90_trivial_##suffix(pix_type *dst, \
47 int dst_stride, \
48 const pix_type *src, \
49 int src_stride, \
50 int w, \
51 int h) \
52 { \
53 int x, y; \
54 for (y = 0; y < h; y++) \
55 { \
56 const pix_type *s = src + (h - y - 1); \
57 pix_type *d = dst + (dst_stride * y); \
58 for (x = 0; x < w; x++) \
59 { \
60 *d++ = *s; \
61 s += src_stride; \
62 } \
63 } \
64 } \
65 static void \
66 blt_rotated_270_trivial_##suffix(pix_type *dst, \
67 int dst_stride, \
68 const pix_type *src, \
69 int src_stride, \
70 int w, \
71 int h) \
72 { \
73 int x, y; \
74 for (y = 0; y < h; y++) \
75 { \
76 const pix_type *s = src + (src_stride * (w - 1)) + y; \
77 pix_type *d = dst + (dst_stride * y); \
78 for (x = 0; x < w; x++) \
79 { \
80 *d++ = *s; \
81 s -= src_stride; \
82 } \
83 } \
84 } \
85 static void \
86 blt_rotated_90_##suffix(pix_type *dst, \
87 int dst_stride, \
88 const pix_type *src, \
89 int src_stride, \
90 int w, \
91 int h) \
92 { \
93 int x, leading_pixels = 0, trailing_pixels = 0; \
94 const int TILE_SIZE = TILE_CACHE_LINE_SIZE / sizeof(pix_type); \
95 if ((uintptr_t)dst & (TILE_CACHE_LINE_SIZE - 1)) \
96 { \
97 leading_pixels = TILE_SIZE - \
98 (((uintptr_t)dst & (TILE_CACHE_LINE_SIZE - 1)) / sizeof(pix_type)); \
99 if (leading_pixels > w) \
100 leading_pixels = w; \
101 blt_rotated_90_trivial_##suffix(dst, \
102 dst_stride, \
103 src, \
104 src_stride, \
105 leading_pixels, \
106 h); \
107 dst += leading_pixels; \
108 src += leading_pixels * src_stride; \
109 w -= leading_pixels; \
110 } \
111 if ((uintptr_t)(dst + w) & (TILE_CACHE_LINE_SIZE - 1)) \
112 { \
113 trailing_pixels = (((uintptr_t)(dst + w) & \
114 (TILE_CACHE_LINE_SIZE - 1)) / sizeof(pix_type)); \
115 if (trailing_pixels > w) \
116 trailing_pixels = w; \
117 w -= trailing_pixels; \
118 } \
119 for (x = 0; x < w; x += TILE_SIZE) \
120 { \
121 blt_rotated_90_trivial_##suffix(dst + x, \
122 dst_stride, \
123 src + (src_stride * x), \
124 src_stride, \
125 TILE_SIZE, \
126 h); \
127 } \
128 if (trailing_pixels) \
129 blt_rotated_90_trivial_##suffix(dst + w, \
130 dst_stride, \
131 src + (w * src_stride), \
132 src_stride, \
133 trailing_pixels, \
134 h); \
135 } \
136 static void \
137 blt_rotated_270_##suffix(pix_type *dst, \
138 int dst_stride, \
139 const pix_type *src, \
140 int src_stride, \
141 int w, \
142 int h) \
143 { \
144 int x, leading_pixels = 0, trailing_pixels = 0; \
145 const int TILE_SIZE = TILE_CACHE_LINE_SIZE / sizeof(pix_type); \
146 if ((uintptr_t)dst & (TILE_CACHE_LINE_SIZE - 1)) \
147 { \
148 leading_pixels = TILE_SIZE - \
149 (((uintptr_t)dst & (TILE_CACHE_LINE_SIZE - 1)) / sizeof(pix_type)); \
150 if (leading_pixels > w) \
151 leading_pixels = w; \
152 blt_rotated_270_trivial_##suffix(dst, \
153 dst_stride, \
154 src + (src_stride * (w - leading_pixels)), \
155 src_stride, \
156 leading_pixels, \
157 h); \
158 dst += leading_pixels; \
159 w -= leading_pixels; \
160 } \
161 if ((uintptr_t)(dst + w) & (TILE_CACHE_LINE_SIZE - 1)) \
162 { \
163 trailing_pixels = (((uintptr_t)(dst + w) & \
164 (TILE_CACHE_LINE_SIZE - 1)) / sizeof(pix_type)); \
165 if (trailing_pixels > w) \
166 trailing_pixels = w; \
167 w -= trailing_pixels; \
168 src += trailing_pixels * src_stride; \
169 } \
170 for (x = 0; x < w; x += TILE_SIZE) \
171 { \
172 blt_rotated_270_trivial_##suffix(dst + x, \
173 dst_stride, \
174 src + (src_stride * (w - x - TILE_SIZE)), \
175 src_stride, \
176 TILE_SIZE, \
177 h); \
178 } \
179 if (trailing_pixels) \
180 blt_rotated_270_trivial_##suffix(dst + w, \
181 dst_stride, \
182 src - (trailing_pixels * src_stride), \
183 src_stride, \
184 trailing_pixels, \
185 h); \
186 }
187
188FAST_SIMPLE_ROTATE(8888, DATA32)
189#endif
190
191void
192evas_common_convert_rgba_to_32bpp_rgb_8888_rot_270 (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x EINA_UNUSED, int dith_y EINA_UNUSED, DATA8 *pal EINA_UNUSED)
193{
194#ifdef TILE_ROTATE
195 blt_rotated_270_8888((DATA8 *)dst, dst_jump+w, (const DATA8 *)src, src_jump+h, w, h) ;
196#else
197 DATA32 *src_ptr;
198 DATA32 *dst_ptr;
199 int x, y;
200
201 dst_ptr = (DATA32 *)dst;
202
203 CONVERT_LOOP_START_ROT_270();
204
205 *dst_ptr = *src_ptr;
206
207 CONVERT_LOOP_END_ROT_270();
208#endif
209 return;
210}
211
212void
213evas_common_convert_rgba_to_32bpp_rgb_8888_rot_90 (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x EINA_UNUSED, int dith_y EINA_UNUSED, DATA8 *pal EINA_UNUSED)
214{
215# ifndef BUILD_NEON
216# ifdef TILE_ROTATE
217 blt_rotated_90_8888((DATA8 *)dst, dst_jump+w, (const DATA8 *)src, src_jump+h, w, h) ;
218# else
219 DATA32 *src_ptr;
220 DATA32 *dst_ptr;
221 int x, y;
222
223 dst_ptr = (DATA32 *)dst;
224 CONVERT_LOOP_START_ROT_90();
225
226 *dst_ptr = *src_ptr;
227
228 CONVERT_LOOP_END_ROT_90();
229# endif
230
231# else
232
233# ifdef TILE_ROTATE
234 blt_rotated_90_8888((DATA8 *)dst, dst_jump+w, (const DATA8 *)src, src_jump+h, w, h) ;
235# else
236 if ((w & 1) || (h & 1))
237 {
238 /* Rarely (if ever) if ever: so slow path is fine */
239 DATA32 *src_ptr;
240 DATA32 *dst_ptr;
241 int x, y;
242
243 dst_ptr = (DATA32 *)dst;
244 CONVERT_LOOP_START_ROT_90();
245
246 *dst_ptr = *src_ptr;
247
248 CONVERT_LOOP_END_ROT_90();
249 }
250 else
251 {
252# define AP "convert_rgba32_rot_90_"
253 asm volatile (
254 ".fpu neon \n\t"
255 " mov %[s1], %[src] \n\t"
256 " add %[s1], %[s1], %[h],lsl #2 \n\t"
257 " sub %[s1], #8 \n\t"
258
259 " mov %[s2], %[src] \n\t"
260 " add %[s2], %[s2], %[h], lsl #3 \n\t"
261 " add %[s2], %[s2], %[sjmp], lsr #1 \n\t"
262 " sub %[s2], #8 \n\t"
263
264 " mov %[d1], %[dst] \n\t"
265
266 " add %[d2], %[d1], %[djmp] \n\t"
267 " add %[d2], %[d2], %[w], lsl #2 \n\t"
268
269 " mov %[sadv], %[h], lsl #3 \n\t"
270 " add %[sadv], %[sadv], %[sjmp], lsl #1\n\t"
271
272 " mov %[y], #0 \n\t"
273 " mov %[x], #0 \n\t"
274 AP"loop: \n\t"
275 " vld1.u32 d0, [%[s1]] \n\t"
276 " vld1.u32 d1, [%[s2]] \n\t"
277 " add %[x], #2 \n\t"
278 " add %[s1], %[sadv] \n\t"
279 " add %[s2], %[sadv] \n\t"
280 " vtrn.u32 d0, d1 \n\t"
281 " cmp %[x], %[w] \n\t"
282 " vst1.u32 d1, [%[d1]]! \n\t"
283 " vst1.u32 d0, [%[d2]]! \n\t"
284 " blt "AP"loop \n\t"
285
286 " mov %[x], #0 \n\t"
287 " add %[d1], %[djmp] \n\t"
288 " add %[d1], %[d1], %[w], lsl #2 \n\t"
289 " add %[d2], %[djmp] \n\t"
290 " add %[d2], %[d2], %[w], lsl #2 \n\t"
291
292 " mov %[s1], %[src] \n\t"
293 " add %[s1], %[s1], %[h], lsl #2 \n\t"
294 " sub %[s1], %[s1], %[y], lsl #2 \n\t"
295 " sub %[s1], #16 \n\t"
296
297 " add %[s2], %[s1], %[h], lsl #2 \n\t"
298 " add %[s2], %[s2], %[sjmp], lsl #2 \n\t"
299
300 " add %[y], #2 \n\t"
301
302 " cmp %[y], %[h] \n\t"
303 " blt "AP"loop \n\t"
304
305 : // Out
306 : [s1] "r" (1),
307 [s2] "r" (11),
308 [d1] "r" (2),
309 [d2] "r" (12),
310 [src] "r" (src),
311 [dst] "r" (dst),
312 [x] "r" (3),
313 [y] "r" (4),
314 [w] "r" (w),
315 [h] "r" (h),
316 [sadv] "r" (5),
317 [sjmp] "r" (src_jump * 4),
318 [djmp] "r" (dst_jump * 4 * 2)
319 : "d0", "d1", "memory", "cc"// Clober
320
321
322 );
323 }
324# undef AP
325# endif
326# endif
327 return;
328}
329
330void
331evas_common_convert_rgba_to_32bpp_rgbx_8888 (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x EINA_UNUSED, int dith_y EINA_UNUSED, DATA8 *pal EINA_UNUSED)
332{
333 DATA32 *src_ptr;
334 DATA32 *dst_ptr;
335 int x, y;
336
337 dst_ptr = (DATA32 *)dst;
338
339 CONVERT_LOOP_START_ROT_0();
340
341// *dst_ptr = (R_VAL(src_ptr) << 24) | (G_VAL(src_ptr) << 16) | (B_VAL(src_ptr) << 8);
342 *dst_ptr = (*src_ptr << 8);
343
344 CONVERT_LOOP_END_ROT_0();
345 return;
346}
347
348void
349evas_common_convert_rgba_to_32bpp_rgbx_8888_rot_180 (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x EINA_UNUSED, int dith_y EINA_UNUSED, DATA8 *pal EINA_UNUSED)
350{
351 DATA32 *src_ptr;
352 DATA32 *dst_ptr;
353 int x, y;
354
355 dst_ptr = (DATA32 *)dst;
356
357 CONVERT_LOOP_START_ROT_180();
358
359// *dst_ptr = (R_VAL(src_ptr) << 24) | (G_VAL(src_ptr) << 16) | (B_VAL(src_ptr) << 8);
360 *dst_ptr = (*src_ptr << 8);
361
362 CONVERT_LOOP_END_ROT_180();
363 return;
364}
365
366void
367evas_common_convert_rgba_to_32bpp_rgbx_8888_rot_270 (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x EINA_UNUSED, int dith_y EINA_UNUSED, DATA8 *pal EINA_UNUSED)
368{
369 DATA32 *src_ptr;
370 DATA32 *dst_ptr;
371 int x, y;
372
373 dst_ptr = (DATA32 *)dst;
374
375 CONVERT_LOOP_START_ROT_270();
376
377// *dst_ptr = (R_VAL(src_ptr) << 24) | (G_VAL(src_ptr) << 16) | (B_VAL(src_ptr) << 8);
378 *dst_ptr = (*src_ptr << 8);
379
380 CONVERT_LOOP_END_ROT_270();
381 return;
382}
383
384void
385evas_common_convert_rgba_to_32bpp_rgbx_8888_rot_90 (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x EINA_UNUSED, int dith_y EINA_UNUSED, DATA8 *pal EINA_UNUSED)
386{
387 DATA32 *src_ptr;
388 DATA32 *dst_ptr;
389 int x, y;
390
391 dst_ptr = (DATA32 *)dst;
392
393 CONVERT_LOOP_START_ROT_90();
394
395// *dst_ptr = (R_VAL(src_ptr) << 24) | (G_VAL(src_ptr) << 16) | (B_VAL(src_ptr) << 8);
396 *dst_ptr = (*src_ptr << 8);
397
398 CONVERT_LOOP_END_ROT_90();
399 return;
400}
401
402void
403evas_common_convert_rgba_to_32bpp_bgr_8888 (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x EINA_UNUSED, int dith_y EINA_UNUSED, DATA8 *pal EINA_UNUSED)
404{
405 DATA32 *src_ptr;
406 DATA32 *dst_ptr;
407 int x, y;
408
409 dst_ptr = (DATA32 *)dst;
410
411 CONVERT_LOOP_START_ROT_0();
412
413 *dst_ptr = (B_VAL(src_ptr) << 16) | (G_VAL(src_ptr) << 8) | (R_VAL(src_ptr));
414
415 CONVERT_LOOP_END_ROT_0();
416 return;
417}
418
419void
420evas_common_convert_rgba_to_32bpp_bgr_8888_rot_180 (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x EINA_UNUSED, int dith_y EINA_UNUSED, DATA8 *pal EINA_UNUSED)
421{
422 DATA32 *src_ptr;
423 DATA32 *dst_ptr;
424 int x, y;
425
426 dst_ptr = (DATA32 *)dst;
427
428 CONVERT_LOOP_START_ROT_180();
429
430 *dst_ptr = (B_VAL(src_ptr) << 16) | (G_VAL(src_ptr) << 8) | (R_VAL(src_ptr));
431
432 CONVERT_LOOP_END_ROT_180();
433 return;
434}
435
436void
437evas_common_convert_rgba_to_32bpp_bgr_8888_rot_270 (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x EINA_UNUSED, int dith_y EINA_UNUSED, DATA8 *pal EINA_UNUSED)
438{
439 DATA32 *src_ptr;
440 DATA32 *dst_ptr;
441 int x, y;
442
443 dst_ptr = (DATA32 *)dst;
444
445 CONVERT_LOOP_START_ROT_270();
446
447 *dst_ptr = (B_VAL(src_ptr) << 16) | (G_VAL(src_ptr) << 8) | (R_VAL(src_ptr));
448
449 CONVERT_LOOP_END_ROT_270();
450 return;
451}
452
453void
454evas_common_convert_rgba_to_32bpp_bgr_8888_rot_90 (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x EINA_UNUSED, int dith_y EINA_UNUSED, DATA8 *pal EINA_UNUSED)
455{
456 DATA32 *src_ptr;
457 DATA32 *dst_ptr;
458 int x, y;
459
460 dst_ptr = (DATA32 *)dst;
461
462 CONVERT_LOOP_START_ROT_90();
463
464 *dst_ptr = (B_VAL(src_ptr) << 16) | (G_VAL(src_ptr) << 8) | (R_VAL(src_ptr));
465
466 CONVERT_LOOP_END_ROT_90();
467 return;
468}
469
470void
471evas_common_convert_rgba_to_32bpp_bgrx_8888 (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x EINA_UNUSED, int dith_y EINA_UNUSED, DATA8 *pal EINA_UNUSED)
472{
473 DATA32 *src_ptr;
474 DATA32 *dst_ptr;
475 int x, y;
476
477 dst_ptr = (DATA32 *)dst;
478
479 CONVERT_LOOP_START_ROT_0();
480
481 *dst_ptr = (B_VAL(src_ptr) << 24) | (G_VAL(src_ptr) << 16) | (R_VAL(src_ptr) << 8);
482
483 CONVERT_LOOP_END_ROT_0();
484 return;
485}
486
487void
488evas_common_convert_rgba_to_32bpp_bgrx_8888_rot_180 (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x EINA_UNUSED, int dith_y EINA_UNUSED, DATA8 *pal EINA_UNUSED)
489{
490 DATA32 *src_ptr;
491 DATA32 *dst_ptr;
492 int x, y;
493
494 dst_ptr = (DATA32 *)dst;
495
496 CONVERT_LOOP_START_ROT_180();
497
498 *dst_ptr = (B_VAL(src_ptr) << 24) | (G_VAL(src_ptr) << 16) | (R_VAL(src_ptr) << 8);
499
500 CONVERT_LOOP_END_ROT_180();
501 return;
502}
503
504void
505evas_common_convert_rgba_to_32bpp_bgrx_8888_rot_270 (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x EINA_UNUSED, int dith_y EINA_UNUSED, DATA8 *pal EINA_UNUSED)
506{
507 DATA32 *src_ptr;
508 DATA32 *dst_ptr;
509 int x, y;
510
511 dst_ptr = (DATA32 *)dst;
512
513 CONVERT_LOOP_START_ROT_270();
514
515 *dst_ptr = (B_VAL(src_ptr) << 24) | (G_VAL(src_ptr) << 16) | (R_VAL(src_ptr) << 8);
516
517 CONVERT_LOOP_END_ROT_270();
518 return;
519}
520
521void
522evas_common_convert_rgba_to_32bpp_bgrx_8888_rot_90 (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x EINA_UNUSED, int dith_y EINA_UNUSED, DATA8 *pal EINA_UNUSED)
523{
524 DATA32 *src_ptr;
525 DATA32 *dst_ptr;
526 int x, y;
527
528 dst_ptr = (DATA32 *)dst;
529
530 CONVERT_LOOP_START_ROT_90();
531
532 *dst_ptr = (B_VAL(src_ptr) << 24) | (G_VAL(src_ptr) << 16) | (R_VAL(src_ptr) << 8);
533
534 CONVERT_LOOP_END_ROT_90();
535 return;
536}
537
538void
539evas_common_convert_rgba_to_32bpp_rgb_666(DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x EINA_UNUSED, int dith_y EINA_UNUSED, DATA8 *pal EINA_UNUSED)
540{
541 DATA32 *src_ptr;
542 DATA32 *dst_ptr;
543 int x, y;
544
545 dst_ptr = (DATA32 *)dst;
546
547 CONVERT_LOOP_START_ROT_0();
548
549 *dst_ptr =
550 (((R_VAL(src_ptr) << 12) | (B_VAL(src_ptr) >> 2)) & 0x03f03f) |
551 ((G_VAL(src_ptr) << 4) & 0x000fc0);
552
553 CONVERT_LOOP_END_ROT_0();
554 return;
555}