move around - flatter.
[profile/ivi/evas.git] / src / lib / engines / common / evas_op_blend_main_.c
1 #include "evas_common.h"
2
3 static RGBA_Gfx_Func     op_blend_span_funcs[SP_LAST][SM_LAST][SC_LAST][DP_LAST][CPU_LAST];
4 static RGBA_Gfx_Pt_Func  op_blend_pt_funcs[SP_LAST][SM_LAST][SC_LAST][DP_LAST][CPU_LAST];
5
6 static void op_blend_init(void);
7 static void op_blend_shutdown(void);
8
9 static RGBA_Gfx_Func op_blend_pixel_span_get(RGBA_Image *src, RGBA_Image *dst, int pixels);
10 static RGBA_Gfx_Func op_blend_color_span_get(DATA32 col, RGBA_Image *dst, int pixels);
11 static RGBA_Gfx_Func op_blend_pixel_color_span_get(RGBA_Image *src, DATA32 col, RGBA_Image *dst, int pixels);
12 static RGBA_Gfx_Func op_blend_mask_color_span_get(DATA32 col, RGBA_Image *dst, int pixels);
13 static RGBA_Gfx_Func op_blend_pixel_mask_span_get(RGBA_Image *src, RGBA_Image *dst, int pixels);
14
15 static RGBA_Gfx_Pt_Func op_blend_pixel_pt_get(Image_Entry_Flags src_flags, RGBA_Image *dst);
16 static RGBA_Gfx_Pt_Func op_blend_color_pt_get(DATA32 col, RGBA_Image *dst);
17 static RGBA_Gfx_Pt_Func op_blend_pixel_color_pt_get(Image_Entry_Flags src_flags, DATA32 col, RGBA_Image *dst);
18 static RGBA_Gfx_Pt_Func op_blend_mask_color_pt_get(DATA32 col, RGBA_Image *dst);
19 static RGBA_Gfx_Pt_Func op_blend_pixel_mask_pt_get(Image_Entry_Flags src_flags, RGBA_Image *dst);
20
21 static RGBA_Gfx_Compositor  _composite_blend = { "blend",
22  op_blend_init, op_blend_shutdown,
23  op_blend_pixel_span_get, op_blend_color_span_get,
24  op_blend_pixel_color_span_get, op_blend_mask_color_span_get,
25  op_blend_pixel_mask_span_get,
26  op_blend_pixel_pt_get, op_blend_color_pt_get,
27  op_blend_pixel_color_pt_get, op_blend_mask_color_pt_get,
28  op_blend_pixel_mask_pt_get
29  };
30
31 RGBA_Gfx_Compositor  *
32 evas_common_gfx_compositor_blend_get(void)
33 {
34    return &(_composite_blend);
35 }
36
37
38 static RGBA_Gfx_Func     op_blend_rel_span_funcs[SP_LAST][SM_LAST][SC_LAST][DP_LAST][CPU_LAST];
39 static RGBA_Gfx_Pt_Func  op_blend_rel_pt_funcs[SP_LAST][SM_LAST][SC_LAST][DP_LAST][CPU_LAST];
40
41 static void op_blend_rel_init(void);
42 static void op_blend_rel_shutdown(void);
43
44 static RGBA_Gfx_Func op_blend_rel_pixel_span_get(RGBA_Image *src, RGBA_Image *dst, int pixels);
45 static RGBA_Gfx_Func op_blend_rel_color_span_get(DATA32 col, RGBA_Image *dst, int pixels);
46 static RGBA_Gfx_Func op_blend_rel_pixel_color_span_get(RGBA_Image *src, DATA32 col, RGBA_Image *dst, int pixels);
47 static RGBA_Gfx_Func op_blend_rel_mask_color_span_get(DATA32 col, RGBA_Image *dst, int pixels);
48 static RGBA_Gfx_Func op_blend_rel_pixel_mask_span_get(RGBA_Image *src, RGBA_Image *dst, int pixels);
49
50 static RGBA_Gfx_Pt_Func op_blend_rel_pixel_pt_get(Image_Entry_Flags src_flags, RGBA_Image *dst);
51 static RGBA_Gfx_Pt_Func op_blend_rel_color_pt_get(DATA32 col, RGBA_Image *dst);
52 static RGBA_Gfx_Pt_Func op_blend_rel_pixel_color_pt_get(Image_Entry_Flags src_flags, DATA32 col, RGBA_Image *dst);
53 static RGBA_Gfx_Pt_Func op_blend_rel_mask_color_pt_get(DATA32 col, RGBA_Image *dst);
54 static RGBA_Gfx_Pt_Func op_blend_rel_pixel_mask_pt_get(Image_Entry_Flags src_flags, RGBA_Image *dst);
55
56 static RGBA_Gfx_Compositor  _composite_blend_rel = { "blend_rel",
57  op_blend_rel_init, op_blend_rel_shutdown,
58  op_blend_rel_pixel_span_get, op_blend_rel_color_span_get,
59  op_blend_rel_pixel_color_span_get, op_blend_rel_mask_color_span_get,
60  op_blend_rel_pixel_mask_span_get,
61  op_blend_rel_pixel_pt_get, op_blend_rel_color_pt_get,
62  op_blend_rel_pixel_color_pt_get, op_blend_rel_mask_color_pt_get,
63  op_blend_rel_pixel_mask_pt_get
64  };
65
66 RGBA_Gfx_Compositor  *
67 evas_common_gfx_compositor_blend_rel_get(void)
68 {
69    return &(_composite_blend_rel);
70 }
71
72
73 # include "./evas_op_blend/op_blend_pixel_.c"
74 # include "./evas_op_blend/op_blend_color_.c"
75 # include "./evas_op_blend/op_blend_pixel_color_.c"
76 # include "./evas_op_blend/op_blend_pixel_mask_.c"
77 # include "./evas_op_blend/op_blend_mask_color_.c"
78 //# include "./evas_op_blend/op_blend_pixel_mask_color_.c"
79
80 # include "./evas_op_blend/op_blend_pixel_i386.c"
81 # include "./evas_op_blend/op_blend_color_i386.c"
82 # include "./evas_op_blend/op_blend_pixel_color_i386.c"
83 # include "./evas_op_blend/op_blend_pixel_mask_i386.c"
84 # include "./evas_op_blend/op_blend_mask_color_i386.c"
85 //# include "./evas_op_blend/op_blend_pixel_mask_color_i386.c"
86
87 static void
88 op_blend_init(void)
89 {
90    memset(op_blend_span_funcs, 0, sizeof(op_blend_span_funcs));
91    memset(op_blend_pt_funcs, 0, sizeof(op_blend_pt_funcs));
92 #ifdef BUILD_MMX
93    init_blend_pixel_span_funcs_mmx();
94    init_blend_pixel_color_span_funcs_mmx();
95    init_blend_pixel_mask_span_funcs_mmx();
96    init_blend_color_span_funcs_mmx();
97    init_blend_mask_color_span_funcs_mmx();
98
99    init_blend_pixel_pt_funcs_mmx();
100    init_blend_pixel_color_pt_funcs_mmx();
101    init_blend_pixel_mask_pt_funcs_mmx();
102    init_blend_color_pt_funcs_mmx();
103    init_blend_mask_color_pt_funcs_mmx();
104 #endif
105 #ifdef BUILD_C
106    init_blend_pixel_span_funcs_c();
107    init_blend_pixel_color_span_funcs_c();
108    init_blend_pixel_mask_span_funcs_c();
109    init_blend_color_span_funcs_c();
110    init_blend_mask_color_span_funcs_c();
111
112    init_blend_pixel_pt_funcs_c();
113    init_blend_pixel_color_pt_funcs_c();
114    init_blend_pixel_mask_pt_funcs_c();
115    init_blend_color_pt_funcs_c();
116    init_blend_mask_color_pt_funcs_c();
117 #endif
118 }
119
120 static void
121 op_blend_shutdown(void)
122 {
123 }
124
125 static RGBA_Gfx_Func
126 blend_gfx_span_func_cpu(int s, int m, int c, int d)
127 {
128    RGBA_Gfx_Func func = NULL;
129    int cpu = CPU_N;
130 #ifdef BUILD_MMX
131    if (evas_common_cpu_has_feature(CPU_FEATURE_MMX))
132      {
133         cpu = CPU_MMX;
134         func = op_blend_span_funcs[s][m][c][d][cpu];
135         if (func) return func;
136      }
137 #endif
138 #ifdef BUILD_C
139    cpu = CPU_C;
140    func = op_blend_span_funcs[s][m][c][d][cpu];
141    if (func) return func;
142 #endif
143    return func;
144 }
145
146 static RGBA_Gfx_Func
147 op_blend_pixel_span_get(RGBA_Image *src, RGBA_Image *dst, int pixels)
148 {
149    int  s = SP_AN, m = SM_N, c = SC_N, d = DP_AN;
150
151    if (src && src->cache_entry.flags.alpha)
152      {
153         s = SP;
154         if (src->cache_entry.flags.alpha_sparse)
155             s = SP_AS;
156      }
157    if (dst && dst->cache_entry.flags.alpha)
158         d = DP;
159    return blend_gfx_span_func_cpu(s, m, c, d);
160 }
161
162 static RGBA_Gfx_Func
163 op_blend_color_span_get(DATA32 col, RGBA_Image *dst, int pixels)
164 {
165    int  s = SP_N, m = SM_N, c = SC_AN, d = DP_AN;
166
167    if ((col >> 24) < 255)
168         c = SC;
169    if (col == ((col >> 24) * 0x01010101))
170         c = SC_AA;
171    if (col == 0xffffffff)
172         c = SC_N;
173    if (dst && dst->cache_entry.flags.alpha)
174         d = DP;
175    return blend_gfx_span_func_cpu(s, m, c, d);
176 }
177
178 static RGBA_Gfx_Func
179 op_blend_pixel_color_span_get(RGBA_Image *src, DATA32 col, RGBA_Image *dst, int pixels)
180 {
181    int  s = SP_AN, m = SM_N, c = SC_AN, d = DP_AN;
182
183    if (src && src->cache_entry.flags.alpha)
184      {
185         s = SP;
186         if (src->cache_entry.flags.alpha_sparse)
187             s = SP_AS;
188      }
189    if ((col >> 24) < 255)
190         c = SC;
191    if (col == ((col >> 24) * 0x01010101))
192         c = SC_AA;
193    if (col == 0xffffffff)
194         c = SC_N;
195    if (dst && dst->cache_entry.flags.alpha)
196         d = DP;
197    return blend_gfx_span_func_cpu(s, m, c, d);
198 }
199
200 static RGBA_Gfx_Func
201 op_blend_mask_color_span_get(DATA32 col, RGBA_Image *dst, int pixels)
202 {
203    int  s = SP_N, m = SM_AS, c = SC_AN, d = DP_AN;
204
205    if ((col >> 24) < 255)
206         c = SC;
207    if (col == ((col >> 24) * 0x01010101))
208         c = SC_AA;
209    if (col == 0xffffffff)
210         c = SC_N;
211    if (dst && dst->cache_entry.flags.alpha)
212         d = DP;
213    return blend_gfx_span_func_cpu(s, m, c, d);
214 }
215
216 static RGBA_Gfx_Func
217 op_blend_pixel_mask_span_get(RGBA_Image *src, RGBA_Image *dst, int pixels)
218 {
219    int  s = SP_AN, m = SM_AS, c = SC_N, d = DP_AN;
220
221    if (src && src->cache_entry.flags.alpha)
222      {
223         s = SP;
224         if (src->cache_entry.flags.alpha_sparse)
225             s = SP_AS;
226      }
227    if (dst && dst->cache_entry.flags.alpha)
228         d = DP;
229    return blend_gfx_span_func_cpu(s, m, c, d);
230 }
231
232
233 static RGBA_Gfx_Pt_Func
234 blend_gfx_pt_func_cpu(int s, int m, int c, int d)
235 {
236    RGBA_Gfx_Pt_Func func = NULL;
237    int cpu = CPU_N;
238 #ifdef BUILD_MMX
239    if (evas_common_cpu_has_feature(CPU_FEATURE_MMX))
240      {
241         cpu = CPU_MMX;
242         func = op_blend_pt_funcs[s][m][c][d][cpu];
243         if (func) return func;
244      }
245 #endif
246 #ifdef BUILD_C
247    cpu = CPU_C;
248    func = op_blend_pt_funcs[s][m][c][d][cpu];
249    if (func) return func;
250 #endif
251    return func;
252 }
253
254 static RGBA_Gfx_Pt_Func
255 op_blend_pixel_pt_get(Image_Entry_Flags src_flags, RGBA_Image *dst)
256 {
257    int  s = SP_AN, m = SM_N, c = SC_N, d = DP_AN;
258
259    if (src_flags.alpha)
260         s = SP;
261    if (dst && dst->cache_entry.flags.alpha)
262         d = DP;
263    return blend_gfx_pt_func_cpu(s, m, c, d);
264 }
265
266 static RGBA_Gfx_Pt_Func
267 op_blend_color_pt_get(DATA32 col, RGBA_Image *dst)
268 {
269    int  s = SP_N, m = SM_N, c = SC_AN, d = DP_AN;
270
271    if ((col >> 24) < 255)
272         c = SC;
273    if (col == ((col >> 24) * 0x01010101))
274         c = SC_AA;
275    if (col == 0xffffffff)
276         c = SC_N;
277    if (dst && dst->cache_entry.flags.alpha)
278         d = DP;
279    return blend_gfx_pt_func_cpu(s, m, c, d);
280 }
281
282 static RGBA_Gfx_Pt_Func
283 op_blend_pixel_color_pt_get(Image_Entry_Flags src_flags, DATA32 col, RGBA_Image *dst)
284 {
285    int  s = SP_AN, m = SM_N, c = SC_AN, d = DP_AN;
286
287    if (src_flags.alpha)
288         s = SP;
289    if ((col >> 24) < 255)
290         c = SC;
291    if (col == ((col >> 24) * 0x01010101))
292         c = SC_AA;
293    if (col == 0xffffffff)
294         c = SC_N;
295    if (dst && dst->cache_entry.flags.alpha)
296         d = DP;
297    return blend_gfx_pt_func_cpu(s, m, c, d);
298 }
299
300 static RGBA_Gfx_Pt_Func
301 op_blend_mask_color_pt_get(DATA32 col, RGBA_Image *dst)
302 {
303    int  s = SP_N, m = SM_AS, c = SC_AN, d = DP_AN;
304
305    if ((col >> 24) < 255)
306         c = SC;
307    if (col == ((col >> 24) * 0x01010101))
308         c = SC_AA;
309    if (col == 0xffffffff)
310         c = SC_N;
311    if (dst && dst->cache_entry.flags.alpha)
312         d = DP;
313    return blend_gfx_pt_func_cpu(s, m, c, d);
314 }
315
316 static RGBA_Gfx_Pt_Func
317 op_blend_pixel_mask_pt_get(Image_Entry_Flags src_flags, RGBA_Image *dst)
318 {
319    int  s = SP_AN, m = SM_AS, c = SC_N, d = DP_AN;
320
321    if (src_flags.alpha)
322         s = SP;
323    if (dst && dst->cache_entry.flags.alpha)
324         d = DP;
325    return blend_gfx_pt_func_cpu(s, m, c, d);
326 }
327
328
329 static void
330 op_blend_rel_init(void)
331 {
332    memset(op_blend_rel_span_funcs, 0, sizeof(op_blend_rel_span_funcs));
333    memset(op_blend_rel_pt_funcs, 0, sizeof(op_blend_rel_pt_funcs));
334 #ifdef BUILD_MMX
335    init_blend_rel_pixel_span_funcs_mmx();
336    init_blend_rel_pixel_color_span_funcs_mmx();
337    init_blend_rel_pixel_mask_span_funcs_mmx();
338    init_blend_rel_color_span_funcs_mmx();
339    init_blend_rel_mask_color_span_funcs_mmx();
340
341    init_blend_rel_pixel_pt_funcs_mmx();
342    init_blend_rel_pixel_color_pt_funcs_mmx();
343    init_blend_rel_pixel_mask_pt_funcs_mmx();
344    init_blend_rel_color_pt_funcs_mmx();
345    init_blend_rel_mask_color_pt_funcs_mmx();
346 #endif
347 #ifdef BUILD_C
348    init_blend_rel_pixel_span_funcs_c();
349    init_blend_rel_pixel_color_span_funcs_c();
350    init_blend_rel_pixel_mask_span_funcs_c();
351    init_blend_rel_color_span_funcs_c();
352    init_blend_rel_mask_color_span_funcs_c();
353
354    init_blend_rel_pixel_pt_funcs_c();
355    init_blend_rel_pixel_color_pt_funcs_c();
356    init_blend_rel_pixel_mask_pt_funcs_c();
357    init_blend_rel_color_pt_funcs_c();
358    init_blend_rel_mask_color_pt_funcs_c();
359 #endif
360 }
361
362 static void
363 op_blend_rel_shutdown(void)
364 {
365 }
366
367 static RGBA_Gfx_Func
368 blend_rel_gfx_span_func_cpu(int s, int m, int c, int d)
369 {
370    RGBA_Gfx_Func func = NULL;
371    int cpu = CPU_N;
372 #ifdef BUILD_MMX
373    if (evas_common_cpu_has_feature(CPU_FEATURE_MMX))
374      {
375         cpu = CPU_MMX;
376         func = op_blend_rel_span_funcs[s][m][c][d][cpu];
377         if (func) return func;
378      }
379 #endif
380 #ifdef BUILD_C
381    cpu = CPU_C;
382    func = op_blend_rel_span_funcs[s][m][c][d][cpu];
383    if (func) return func;
384 #endif
385    return func;
386 }
387
388 static RGBA_Gfx_Func
389 op_blend_rel_pixel_span_get(RGBA_Image *src, RGBA_Image *dst, int pixels)
390 {
391    int  s = SP_AN, m = SM_N, c = SC_N, d = DP_AN;
392
393    if (src && src->cache_entry.flags.alpha)
394      {
395         s = SP;
396         if (src->cache_entry.flags.alpha_sparse)
397             s = SP_AS;
398      }
399    if (dst && dst->cache_entry.flags.alpha)
400         d = DP;
401    return blend_rel_gfx_span_func_cpu(s, m, c, d);
402 }
403
404 static RGBA_Gfx_Func
405 op_blend_rel_color_span_get(DATA32 col, RGBA_Image *dst, int pixels)
406 {
407    int  s = SP_N, m = SM_N, c = SC_AN, d = DP_AN;
408
409    if ((col >> 24) < 255)
410         c = SC;
411    if (col == ((col >> 24) * 0x01010101))
412         c = SC_AA;
413    if (col == 0xffffffff)
414         c = SC_N;
415    if (dst && dst->cache_entry.flags.alpha)
416         d = DP;
417    return blend_rel_gfx_span_func_cpu(s, m, c, d);
418 }
419
420 static RGBA_Gfx_Func
421 op_blend_rel_pixel_color_span_get(RGBA_Image *src, DATA32 col, RGBA_Image *dst, int pixels)
422 {
423    int  s = SP_AN, m = SM_N, c = SC_AN, d = DP_AN;
424
425    if (src && src->cache_entry.flags.alpha)
426         s = SP;
427    if ((col >> 24) < 255)
428         c = SC;
429    if (col == ((col >> 24) * 0x01010101))
430         c = SC_AA;
431    if (col == 0xffffffff)
432         c = SC_N;
433    if (dst && dst->cache_entry.flags.alpha)
434         d = DP;
435    return blend_rel_gfx_span_func_cpu(s, m, c, d);
436 }
437
438 static RGBA_Gfx_Func
439 op_blend_rel_mask_color_span_get(DATA32 col, RGBA_Image *dst, int pixels)
440 {
441    int  s = SP_N, m = SM_AS, c = SC_AN, d = DP_AN;
442
443    if ((col >> 24) < 255)
444         c = SC;
445    if (col == ((col >> 24) * 0x01010101))
446         c = SC_AA;
447    if (col == 0xffffffff)
448         c = SC_N;
449    if (dst && dst->cache_entry.flags.alpha)
450         d = DP;
451    return blend_rel_gfx_span_func_cpu(s, m, c, d);
452 }
453
454 static RGBA_Gfx_Func
455 op_blend_rel_pixel_mask_span_get(RGBA_Image *src, RGBA_Image *dst, int pixels)
456 {
457    int  s = SP_AN, m = SM_AS, c = SC_N, d = DP_AN;
458
459    if (src && src->cache_entry.flags.alpha)
460      {
461         s = SP;
462         if (src->cache_entry.flags.alpha_sparse)
463             s = SP_AS;
464      }
465    if (dst && dst->cache_entry.flags.alpha)
466         d = DP;
467    return blend_rel_gfx_span_func_cpu(s, m, c, d);
468 }
469
470 static RGBA_Gfx_Pt_Func
471 blend_rel_gfx_pt_func_cpu(int s, int m, int c, int d)
472 {
473    RGBA_Gfx_Pt_Func func = NULL;
474    int cpu = CPU_N;
475 #ifdef BUILD_MMX
476    if (evas_common_cpu_has_feature(CPU_FEATURE_MMX))
477      {
478         cpu = CPU_MMX;
479         func = op_blend_rel_pt_funcs[s][m][c][d][cpu];
480         if (func) return func;
481      }
482 #endif
483 #ifdef BUILD_C
484    cpu = CPU_C;
485    func = op_blend_rel_pt_funcs[s][m][c][d][cpu];
486    if (func) return func;
487 #endif
488    return func;
489 }
490
491 static RGBA_Gfx_Pt_Func
492 op_blend_rel_pixel_pt_get(Image_Entry_Flags src_flags, RGBA_Image *dst)
493 {
494    int  s = SP_AN, m = SM_N, c = SC_N, d = DP_AN;
495
496    if (src_flags.alpha)
497         s = SP;
498    if (dst && dst->cache_entry.flags.alpha)
499         d = DP;
500    return blend_rel_gfx_pt_func_cpu(s, m, c, d);
501 }
502
503 static RGBA_Gfx_Pt_Func
504 op_blend_rel_color_pt_get(DATA32 col, RGBA_Image *dst)
505 {
506    int  s = SP_N, m = SM_N, c = SC_AN, d = DP_AN;
507
508    if ((col >> 24) < 255)
509         c = SC;
510    if (col == ((col >> 24) * 0x01010101))
511         c = SC_AA;
512    if (col == 0xffffffff)
513         c = SC_N;
514    if (dst && dst->cache_entry.flags.alpha)
515         d = DP;
516    return blend_rel_gfx_pt_func_cpu(s, m, c, d);
517 }
518
519 static RGBA_Gfx_Pt_Func
520 op_blend_rel_pixel_color_pt_get(Image_Entry_Flags src_flags, DATA32 col, RGBA_Image *dst)
521 {
522    int  s = SP_AN, m = SM_N, c = SC_AN, d = DP_AN;
523
524    if (src_flags.alpha)
525         s = SP;
526    if ((col >> 24) < 255)
527         c = SC;
528    if (col == ((col >> 24) * 0x01010101))
529         c = SC_AA;
530    if (col == 0xffffffff)
531         c = SC_N;
532    if (dst && dst->cache_entry.flags.alpha)
533         d = DP;
534    return blend_rel_gfx_pt_func_cpu(s, m, c, d);
535 }
536
537 static RGBA_Gfx_Pt_Func
538 op_blend_rel_mask_color_pt_get(DATA32 col, RGBA_Image *dst)
539 {
540    int  s = SP_N, m = SM_AS, c = SC_AN, d = DP_AN;
541
542    if ((col >> 24) < 255)
543         c = SC;
544    if (col == ((col >> 24) * 0x01010101))
545         c = SC_AA;
546    if (col == 0xffffffff)
547         c = SC_N;
548    if (dst && dst->cache_entry.flags.alpha)
549         d = DP;
550    return blend_rel_gfx_pt_func_cpu(s, m, c, d);
551 }
552
553 static RGBA_Gfx_Pt_Func
554 op_blend_rel_pixel_mask_pt_get(Image_Entry_Flags src_flags, RGBA_Image *dst)
555 {
556    int  s = SP_AN, m = SM_AS, c = SC_N, d = DP_AN;
557
558    if (src_flags.alpha)
559         s = SP;
560    if (dst && dst->cache_entry.flags.alpha)
561         d = DP;
562    return blend_rel_gfx_pt_func_cpu(s, m, c, d);
563 }