summaryrefslogtreecommitdiff
path: root/src/lib/evas/common/evas_blend_main.c
blob: 6e08382286bab262bf435de665f0d3c2c23f2e9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
#include "evas_common_private.h"
#include "evas_blend_private.h"

#ifdef BUILD_MMX
#include "evas_mmx.h"
#endif

const DATA32 ALPHA_255 = 255;
const DATA32 ALPHA_256 = 256;

static void
_composite_span_nothing(DATA32 *s EINA_UNUSED, DATA8 *m EINA_UNUSED, DATA32 c EINA_UNUSED, DATA32 *d EINA_UNUSED, int l EINA_UNUSED)
{
}

static void
_composite_pt_nothing(DATA32 s EINA_UNUSED, DATA8 m EINA_UNUSED, DATA32 c EINA_UNUSED, DATA32 *d EINA_UNUSED)
{
}

static RGBA_Gfx_Compositor  *
evas_gfx_compositor_get(unsigned char op)
{
   RGBA_Gfx_Compositor  *comp;

   switch (op)
      {
	case _EVAS_RENDER_BLEND:
	   comp = evas_common_gfx_compositor_blend_get();
	   break;
	case _EVAS_RENDER_BLEND_REL:
	   comp = evas_common_gfx_compositor_blend_rel_get();
	   break;
	case _EVAS_RENDER_COPY:
	   comp = evas_common_gfx_compositor_copy_get();
	   break;
	case _EVAS_RENDER_COPY_REL:
	   comp = evas_common_gfx_compositor_copy_rel_get();
	   break;
/*
	case _EVAS_RENDER_ADD:
	   comp = evas_common_gfx_compositor_add_get();
	   break;
	case _EVAS_RENDER_ADD_REL:
	   comp = evas_common_gfx_compositor_add_rel_get();
	   break;
	case _EVAS_RENDER_SUB:
	   comp = evas_common_gfx_compositor_sub_get();
	   break;
	case _EVAS_RENDER_SUB_REL:
	   comp = evas_common_gfx_compositor_sub_rel_get();
	   break;
*/
	case _EVAS_RENDER_MASK:
	   comp = evas_common_gfx_compositor_mask_get();
	   break;
	case _EVAS_RENDER_MUL:
	   comp = evas_common_gfx_compositor_mul_get();
	   break;
	default:
	   comp = evas_common_gfx_compositor_blend_get();
	   break;
      }
   return comp;
}

EAPI void
evas_common_blend_init(void)
{
   static int gfx_initialised = 0;
   static int mmx = 0;
   static int sse = 0;
   static int sse2 = 0;
   RGBA_Gfx_Compositor  *comp;

   if (gfx_initialised) return;
   gfx_initialised = 1;

   evas_common_cpu_can_do(&mmx, &sse, &sse2);

   comp = evas_common_gfx_compositor_copy_get();
   if (comp) comp->init();
   comp = evas_common_gfx_compositor_copy_rel_get();
   if (comp) comp->init();

   comp = evas_common_gfx_compositor_blend_get();
   if (comp) comp->init();
   comp = evas_common_gfx_compositor_blend_rel_get();
   if (comp) comp->init();

/*
   comp = evas_common_gfx_compositor_add_get();
   if (comp) comp->init();
   comp = evas_common_gfx_compositor_add_rel_get();
   if (comp) comp->init();
   comp = evas_common_gfx_compositor_sub_get();
   if (comp) comp->init();
   comp = evas_common_gfx_compositor_sub_rel_get();
   if (comp) comp->init();
*/
   comp = evas_common_gfx_compositor_mask_get();
   if (comp) comp->init();

   comp = evas_common_gfx_compositor_mul_get();
   if (comp) comp->init();
}

void
evas_common_blend_shutdown(void)
{
   RGBA_Gfx_Compositor  *comp;

   comp = evas_common_gfx_compositor_copy_get();
   if (comp) comp->shutdown();
   comp = evas_common_gfx_compositor_copy_rel_get();
   if (comp) comp->shutdown();

   comp = evas_common_gfx_compositor_blend_get();
   if (comp) comp->shutdown();
   comp = evas_common_gfx_compositor_blend_rel_get();
   if (comp) comp->shutdown();

/*
   comp = evas_common_gfx_compositor_add_get();
   if (comp) comp->shutdown();
   comp = evas_common_gfx_compositor_add_rel_get();
   if (comp) comp->shutdown();
   comp = evas_common_gfx_compositor_sub_get();
   if (comp) comp->shutdown();
   comp = evas_common_gfx_compositor_sub_rel_get();
   if (comp) comp->shutdown();
*/
   comp = evas_common_gfx_compositor_mask_get();
   if (comp) comp->shutdown();

   comp = evas_common_gfx_compositor_mul_get();
   if (comp) comp->shutdown();
}


RGBA_Gfx_Func
evas_common_gfx_func_composite_pixel_span_get(RGBA_Image *src, RGBA_Image *dst, int pixels, int op)
{
   RGBA_Gfx_Compositor  *comp;
   RGBA_Gfx_Func        func = NULL;

   if (src && (!src->cache_entry.flags.alpha))
     {
	if (op == _EVAS_RENDER_BLEND)
	   op = _EVAS_RENDER_COPY;
	if (op == _EVAS_RENDER_BLEND_REL)
	   op = _EVAS_RENDER_COPY_REL;
     }
   comp = evas_gfx_compositor_get(op);
   if (comp)
	func = comp->composite_pixel_span_get(src, dst, pixels);
   if (func)
	return func;
   return _composite_span_nothing;
}

RGBA_Gfx_Func
evas_common_gfx_func_composite_color_span_get(DATA32 col, RGBA_Image *dst, int pixels, int op)
{
   RGBA_Gfx_Compositor  *comp;
   RGBA_Gfx_Func        func = NULL;

   if ((col & 0xff000000) == 0xff000000)
     {
	if (op == _EVAS_RENDER_BLEND)
	   op = _EVAS_RENDER_COPY;
	if (op == EVAS_RENDER_BLEND_REL)
	   op = _EVAS_RENDER_COPY_REL;
     }

   comp = evas_gfx_compositor_get(op);
   if (comp)
	func = comp->composite_color_span_get(col, dst, pixels);
   if (func)
	return func;
   return _composite_span_nothing;
}

RGBA_Gfx_Func
evas_common_gfx_func_composite_pixel_color_span_get(RGBA_Image *src, DATA32 col, RGBA_Image *dst, int pixels, int op)
{
   RGBA_Gfx_Compositor  *comp;
   RGBA_Gfx_Func        func = NULL;

   if ((src && (!src->cache_entry.flags.alpha)) && ((col & 0xff000000) == 0xff000000))
     {
	if (op == _EVAS_RENDER_BLEND)
	   op = _EVAS_RENDER_COPY;
	if (op == _EVAS_RENDER_BLEND_REL)
	   op = _EVAS_RENDER_COPY_REL;
     }

   comp = evas_gfx_compositor_get(op);
   if (comp)
	func = comp->composite_pixel_color_span_get(src, col, dst, pixels);
   if (func)
	return func;
   return _composite_span_nothing;
}

RGBA_Gfx_Func
evas_common_gfx_func_composite_mask_color_span_get(DATA32 col, RGBA_Image *dst, int pixels, int op)
{
   RGBA_Gfx_Compositor  *comp;
   RGBA_Gfx_Func        func = NULL;

   comp = evas_gfx_compositor_get(op);
   if (comp)
	func = comp->composite_mask_color_span_get(col, dst, pixels);
   if (func)
	return func;
   return _composite_span_nothing;
}

RGBA_Gfx_Func
evas_common_gfx_func_composite_pixel_mask_span_get(RGBA_Image *src, RGBA_Image *dst, int pixels, int op)
{
   RGBA_Gfx_Compositor  *comp;
   RGBA_Gfx_Func        func = NULL;

   comp = evas_gfx_compositor_get(op);
   if (comp)
	func = comp->composite_pixel_mask_span_get(src, dst, pixels);
   if (func)
	return func;
   return _composite_span_nothing;
}

RGBA_Gfx_Pt_Func
evas_common_gfx_func_composite_pixel_pt_get(Image_Entry_Flags src_flags, RGBA_Image *dst, int op)
{
   RGBA_Gfx_Compositor  *comp;
   RGBA_Gfx_Pt_Func     func = NULL;

   if (!src_flags.alpha)
     {
	if (op == _EVAS_RENDER_BLEND)
	   op = _EVAS_RENDER_COPY;
	if (op == _EVAS_RENDER_BLEND_REL)
	   op = _EVAS_RENDER_COPY_REL;
     }
   comp = evas_gfx_compositor_get(op);
   if (comp)
	func = comp->composite_pixel_pt_get(src_flags, dst);
   if (func)
	return func;
   return _composite_pt_nothing;
}

RGBA_Gfx_Pt_Func
evas_common_gfx_func_composite_color_pt_get(DATA32 col, RGBA_Image *dst, int op)
{
   RGBA_Gfx_Compositor  *comp;
   RGBA_Gfx_Pt_Func     func = NULL;

   if ((col & 0xff000000) == 0xff000000)
     {
	if (op == _EVAS_RENDER_BLEND)
	   op = _EVAS_RENDER_COPY;
	if (op == EVAS_RENDER_BLEND_REL)
	   op = _EVAS_RENDER_COPY_REL;
     }

   comp = evas_gfx_compositor_get(op);
   if (comp)
	func = comp->composite_color_pt_get(col, dst);
   if (func)
	return func;
   return _composite_pt_nothing;
}

RGBA_Gfx_Pt_Func
evas_common_gfx_func_composite_pixel_color_pt_get(Image_Entry_Flags src_flags, DATA32 col, RGBA_Image *dst, int op)
{
   RGBA_Gfx_Compositor  *comp;
   RGBA_Gfx_Pt_Func     func = NULL;

   if ((!src_flags.alpha) && ((col & 0xff000000) == 0xff000000))
     {
	if (op == _EVAS_RENDER_BLEND)
	   op = _EVAS_RENDER_COPY;
	if (op == _EVAS_RENDER_BLEND_REL)
	   op = _EVAS_RENDER_COPY_REL;
     }

   comp = evas_gfx_compositor_get(op);
   if (comp)
	func = comp->composite_pixel_color_pt_get(src_flags, col, dst);
   if (func)
	return func;
   return _composite_pt_nothing;
}

RGBA_Gfx_Pt_Func
evas_common_gfx_func_composite_mask_color_pt_get(DATA32 col, RGBA_Image *dst, int op)
{
   RGBA_Gfx_Compositor  *comp;
   RGBA_Gfx_Pt_Func     func = NULL;

   comp = evas_gfx_compositor_get(op);
   if (comp)
	func = comp->composite_mask_color_pt_get(col, dst);
   if (func)
	return func;
   return _composite_pt_nothing;
}

RGBA_Gfx_Pt_Func
evas_common_gfx_func_composite_pixel_mask_pt_get(Image_Entry_Flags src_flags, RGBA_Image *dst, int op)
{
   RGBA_Gfx_Compositor  *comp;
   RGBA_Gfx_Pt_Func     func = NULL;

   comp = evas_gfx_compositor_get(op);
   if (comp)
	func = comp->composite_pixel_mask_pt_get(src_flags, dst);
   if (func)
	return func;
   return _composite_pt_nothing;
}