move around - flatter.
[profile/ivi/evas.git] / src / lib / engines / common / evas_op_mul_main_.c
1 #include "evas_common.h"
2
3 static RGBA_Gfx_Func     op_mul_span_funcs[SP_LAST][SM_LAST][SC_LAST][DP_LAST][CPU_LAST];
4 static RGBA_Gfx_Pt_Func  op_mul_pt_funcs[SP_LAST][SM_LAST][SC_LAST][DP_LAST][CPU_LAST];
5
6 static void op_mul_init(void);
7 static void op_mul_shutdown(void);
8
9 static RGBA_Gfx_Func op_mul_pixel_span_get(RGBA_Image *src, RGBA_Image *dst, int pixels);
10 static RGBA_Gfx_Func op_mul_color_span_get(DATA32 col, RGBA_Image *dst, int pixels);
11 static RGBA_Gfx_Func op_mul_pixel_color_span_get(RGBA_Image *src, DATA32 col, RGBA_Image *dst, int pixels);
12 static RGBA_Gfx_Func op_mul_mask_color_span_get(DATA32 col, RGBA_Image *dst, int pixels);
13 static RGBA_Gfx_Func op_mul_pixel_mask_span_get(RGBA_Image *src, RGBA_Image *dst, int pixels);
14
15 static RGBA_Gfx_Pt_Func op_mul_pixel_pt_get(Image_Entry_Flags src_flags, RGBA_Image *dst);
16 static RGBA_Gfx_Pt_Func op_mul_color_pt_get(DATA32 col, RGBA_Image *dst);
17 static RGBA_Gfx_Pt_Func op_mul_pixel_color_pt_get(Image_Entry_Flags src_flags, DATA32 col, RGBA_Image *dst);
18 static RGBA_Gfx_Pt_Func op_mul_mask_color_pt_get(DATA32 col, RGBA_Image *dst);
19 static RGBA_Gfx_Pt_Func op_mul_pixel_mask_pt_get(Image_Entry_Flags src_flags, RGBA_Image *dst);
20
21 static RGBA_Gfx_Compositor  _composite_mul = { "mul",
22  op_mul_init, op_mul_shutdown,
23  op_mul_pixel_span_get, op_mul_color_span_get,
24  op_mul_pixel_color_span_get, op_mul_mask_color_span_get,
25  op_mul_pixel_mask_span_get,
26  op_mul_pixel_pt_get, op_mul_color_pt_get,
27  op_mul_pixel_color_pt_get, op_mul_mask_color_pt_get,
28  op_mul_pixel_mask_pt_get
29  };
30
31 RGBA_Gfx_Compositor  *
32 evas_common_gfx_compositor_mul_get(void)
33 {
34    return &(_composite_mul);
35 }
36
37
38 # include "./evas_op_mul/op_mul_pixel_.c"
39 # include "./evas_op_mul/op_mul_color_.c"
40 # include "./evas_op_mul/op_mul_pixel_color_.c"
41 # include "./evas_op_mul/op_mul_pixel_mask_.c"
42 # include "./evas_op_mul/op_mul_mask_color_.c"
43 //# include "./evas_op_mul/op_mul_pixel_mask_color_.c"
44
45 # include "./evas_op_mul/op_mul_pixel_i386.c"
46 # include "./evas_op_mul/op_mul_color_i386.c"
47 # include "./evas_op_mul/op_mul_pixel_color_i386.c"
48 # include "./evas_op_mul/op_mul_pixel_mask_i386.c"
49 # include "./evas_op_mul/op_mul_mask_color_i386.c"
50 // # include "./evas_op_mul/op_mul_pixel_mask_color_i386.c"
51
52 static void
53 op_mul_init(void)
54 {
55    memset(op_mul_span_funcs, 0, sizeof(op_mul_span_funcs));
56    memset(op_mul_pt_funcs, 0, sizeof(op_mul_pt_funcs));
57 #ifdef BUILD_MMX
58    init_mul_pixel_span_funcs_mmx();
59    init_mul_pixel_color_span_funcs_mmx();
60    init_mul_pixel_mask_span_funcs_mmx();
61    init_mul_color_span_funcs_mmx();
62    init_mul_mask_color_span_funcs_mmx();
63
64    init_mul_pixel_pt_funcs_mmx();
65    init_mul_pixel_color_pt_funcs_mmx();
66    init_mul_pixel_mask_pt_funcs_mmx();
67    init_mul_color_pt_funcs_mmx();
68    init_mul_mask_color_pt_funcs_mmx();
69 #endif
70 #ifdef BUILD_C
71    init_mul_pixel_span_funcs_c();
72    init_mul_pixel_color_span_funcs_c();
73    init_mul_pixel_mask_span_funcs_c();
74    init_mul_color_span_funcs_c();
75    init_mul_mask_color_span_funcs_c();
76
77    init_mul_pixel_pt_funcs_c();
78    init_mul_pixel_color_pt_funcs_c();
79    init_mul_pixel_mask_pt_funcs_c();
80    init_mul_color_pt_funcs_c();
81    init_mul_mask_color_pt_funcs_c();
82 #endif
83 }
84
85 static void
86 op_mul_shutdown(void)
87 {
88 }
89
90 static RGBA_Gfx_Func
91 mul_gfx_span_func_cpu(int s, int m, int c, int d)
92 {
93    RGBA_Gfx_Func func = NULL;
94    int cpu = CPU_N;
95 #ifdef BUILD_MMX
96    if (evas_common_cpu_has_feature(CPU_FEATURE_MMX))
97      {
98         cpu = CPU_MMX;
99         func = op_mul_span_funcs[s][m][c][d][cpu];
100         if (func) return func;
101      }
102 #endif
103 #ifdef BUILD_C
104    cpu = CPU_C;
105    func = op_mul_span_funcs[s][m][c][d][cpu];
106    if (func) return func;
107 #endif
108    return func;
109 }
110
111 static RGBA_Gfx_Func
112 op_mul_pixel_span_get(RGBA_Image *src, RGBA_Image *dst, int pixels)
113 {
114    int  s = SP_AN, m = SM_N, c = SC_N, d = DP_AN;
115
116    if (src && src->cache_entry.flags.alpha)
117      {
118         dst->cache_entry.flags.alpha = 1;
119         s = SP;
120      }
121    if (dst && dst->cache_entry.flags.alpha)
122         d = DP;
123    return mul_gfx_span_func_cpu(s, m, c, d);
124 }
125
126 static RGBA_Gfx_Func
127 op_mul_color_span_get(DATA32 col, RGBA_Image *dst, int pixels)
128 {
129    int  s = SP_N, m = SM_N, c = SC_AN, d = DP_AN;
130
131    if ((col >> 24) < 255)
132      {
133         if (dst)
134            dst->cache_entry.flags.alpha = 1;
135         c = SC;
136      }
137    if (col == (col | 0x00ffffff))
138         c = SC_AA;
139    if (col == 0xffffffff)
140         c = SC_N;
141    if (dst && dst->cache_entry.flags.alpha)
142         d = DP;
143    return mul_gfx_span_func_cpu(s, m, c, d);
144 }
145
146 static RGBA_Gfx_Func
147 op_mul_pixel_color_span_get(RGBA_Image *src, DATA32 col, RGBA_Image *dst, int pixels)
148 {
149    int  s = SP_AN, m = SM_N, c = SC_AN, d = DP_AN;
150
151    if (src && src->cache_entry.flags.alpha)
152      {
153         if (dst)
154            dst->cache_entry.flags.alpha = 1;
155         s = SP;
156      }
157    if ((col >> 24) < 255)
158      {
159         if (dst)
160            dst->cache_entry.flags.alpha = 1;
161         c = SC;
162      }
163    if (col == (col | 0x00ffffff))
164         c = SC_AA;
165    if (col == 0xffffffff)
166         c = SC_N;
167    if (dst && dst->cache_entry.flags.alpha)
168         d = DP;
169    return mul_gfx_span_func_cpu(s, m, c, d);
170 }
171
172 static RGBA_Gfx_Func
173 op_mul_mask_color_span_get(DATA32 col, RGBA_Image *dst, int pixels)
174 {
175    int  s = SP_N, m = SM_AS, c = SC_AN, d = DP;
176
177    if (dst)
178         dst->cache_entry.flags.alpha = 1;
179    if ((col >> 24) < 255)
180         c = SC;
181    if (col == (col | 0x00ffffff))
182         c = SC_AA;
183    if (col == 0xffffffff)
184         c = SC_N;
185    return mul_gfx_span_func_cpu(s, m, c, d);
186 }
187
188 static RGBA_Gfx_Func
189 op_mul_pixel_mask_span_get(RGBA_Image *src, RGBA_Image *dst, int pixels)
190 {
191    int  s = SP_AN, m = SM_AS, c = SC_N, d = DP;
192
193    if (dst)
194         dst->cache_entry.flags.alpha = 1;
195    if (src && src->cache_entry.flags.alpha)
196         s = SP;
197    return mul_gfx_span_func_cpu(s, m, c, d);
198 }
199
200 static RGBA_Gfx_Pt_Func
201 mul_gfx_pt_func_cpu(int s, int m, int c, int d)
202 {
203    RGBA_Gfx_Pt_Func func = NULL;
204    int cpu = CPU_N;
205 #ifdef BUILD_MMX
206    if (evas_common_cpu_has_feature(CPU_FEATURE_MMX))
207     {
208       cpu = CPU_MMX;
209       func = op_mul_pt_funcs[s][m][c][d][cpu];
210       if (func) return func;
211     }
212 #endif
213 #ifdef BUILD_C
214    cpu = CPU_C;
215    func = op_mul_pt_funcs[s][m][c][d][cpu];
216    if (func) return func;
217 #endif
218    return func;
219 }
220
221 static RGBA_Gfx_Pt_Func
222 op_mul_pixel_pt_get(Image_Entry_Flags src_flags, RGBA_Image *dst)
223 {
224    int  s = SP_AN, m = SM_N, c = SC_N, d = DP_AN;
225
226    if (src_flags.alpha)
227      {
228         dst->cache_entry.flags.alpha = 1;
229         s = SP;
230      }
231    if (dst && dst->cache_entry.flags.alpha)
232         d = DP;
233    return mul_gfx_pt_func_cpu(s, m, c, d);
234 }
235
236 static RGBA_Gfx_Pt_Func
237 op_mul_color_pt_get(DATA32 col, RGBA_Image *dst)
238 {
239    int  s = SP_N, m = SM_N, c = SC_AN, d = DP_AN;
240
241    if ((col >> 24) < 255)
242      {
243         if (dst)
244            dst->cache_entry.flags.alpha = 1;
245         c = SC;
246      }
247    if (col == (col | 0x00ffffff))
248         c = SC_AA;
249    if (col == 0xffffffff)
250         c = SC_N;
251    if (dst && dst->cache_entry.flags.alpha)
252         d = DP;
253    return mul_gfx_pt_func_cpu(s, m, c, d);
254 }
255
256 static RGBA_Gfx_Pt_Func
257 op_mul_pixel_color_pt_get(Image_Entry_Flags src_flags, DATA32 col, RGBA_Image *dst)
258 {
259    int  s = SP_AN, m = SM_N, c = SC_AN, d = DP_AN;
260
261    if (src_flags.alpha)
262      {
263         if (dst)
264            dst->cache_entry.flags.alpha = 1;
265         s = SP;
266      }
267    if ((col >> 24) < 255)
268      {
269         if (dst)
270            dst->cache_entry.flags.alpha = 1;
271         c = SC;
272      }
273    if (col == (col | 0x00ffffff))
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 mul_gfx_pt_func_cpu(s, m, c, d);
280 }
281
282 static RGBA_Gfx_Pt_Func
283 op_mul_mask_color_pt_get(DATA32 col, RGBA_Image *dst)
284 {
285    int  s = SP_N, m = SM_AS, c = SC_AN, d = DP;
286
287    if (dst)
288         dst->cache_entry.flags.alpha = 1;
289    if ((col >> 24) < 255)
290         c = SC;
291    if (col == (col | 0x00ffffff))
292         c = SC_AA;
293    if (col == 0xffffffff)
294         c = SC_N;
295    return mul_gfx_pt_func_cpu(s, m, c, d);
296 }
297
298 static RGBA_Gfx_Pt_Func
299 op_mul_pixel_mask_pt_get(Image_Entry_Flags src_flags, RGBA_Image *dst)
300 {
301    int  s = SP_AN, m = SM_AS, c = SC_N, d = DP;
302
303    if (dst)
304         dst->cache_entry.flags.alpha = 1;
305    if (src_flags.alpha)
306         s = SP;
307    return mul_gfx_pt_func_cpu(s, m, c, d);
308 }