Evas: Add UNUSED to evas_engine function 'eng_image_load_error_get'
[framework/uifw/evas.git] / src / modules / engines / software_generic / evas_engine.c
1 #include "evas_common.h" /* Also includes international specific stuff */
2 #include "evas_private.h"
3
4 /*
5  *****
6  **
7  ** ENGINE ROUTINES
8  **
9  *****
10  */
11 static int cpunum = 0;
12 static int _evas_soft_gen_log_dom = -1;
13
14 static void
15 eng_output_dump(void *data __UNUSED__)
16 {
17    evas_common_image_image_all_unload();
18    evas_common_font_font_all_unload();
19 }
20
21 static void *
22 eng_context_new(void *data __UNUSED__)
23 {
24    return evas_common_draw_context_new();
25 }
26
27 static void
28 eng_context_free(void *data __UNUSED__, void *context)
29 {
30    evas_common_draw_context_free(context);
31 }
32
33 static void
34 eng_context_clip_set(void *data __UNUSED__, void *context, int x, int y, int w, int h)
35 {
36    evas_common_draw_context_set_clip(context, x, y, w, h);
37 }
38
39 static void
40 eng_context_clip_clip(void *data __UNUSED__, void *context, int x, int y, int w, int h)
41 {
42    evas_common_draw_context_clip_clip(context, x, y, w, h);
43 }
44
45 static void
46 eng_context_clip_unset(void *data __UNUSED__, void *context)
47 {
48    evas_common_draw_context_unset_clip(context);
49 }
50
51 static int
52 eng_context_clip_get(void *data __UNUSED__, void *context, int *x, int *y, int *w, int *h)
53 {
54    *x = ((RGBA_Draw_Context *)context)->clip.x;
55    *y = ((RGBA_Draw_Context *)context)->clip.y;
56    *w = ((RGBA_Draw_Context *)context)->clip.w;
57    *h = ((RGBA_Draw_Context *)context)->clip.h;
58    return ((RGBA_Draw_Context *)context)->clip.use;
59 }
60
61 static void
62 eng_context_color_set(void *data __UNUSED__, void *context, int r, int g, int b, int a)
63 {
64    evas_common_draw_context_set_color(context, r, g, b, a);
65 }
66
67 static int
68 eng_context_color_get(void *data __UNUSED__, void *context, int *r, int *g, int *b, int *a)
69 {
70    *r = (int)(R_VAL(&((RGBA_Draw_Context *)context)->col.col));
71    *g = (int)(G_VAL(&((RGBA_Draw_Context *)context)->col.col));
72    *b = (int)(B_VAL(&((RGBA_Draw_Context *)context)->col.col));
73    *a = (int)(A_VAL(&((RGBA_Draw_Context *)context)->col.col));
74    return 1;
75 }
76
77 static void
78 eng_context_multiplier_set(void *data __UNUSED__, void *context, int r, int g, int b, int a)
79 {
80    evas_common_draw_context_set_multiplier(context, r, g, b, a);
81 }
82
83 static void
84 eng_context_multiplier_unset(void *data __UNUSED__, void *context)
85 {
86    evas_common_draw_context_unset_multiplier(context);
87 }
88
89 static int
90 eng_context_multiplier_get(void *data __UNUSED__, void *context, int *r, int *g, int *b, int *a)
91 {
92    *r = (int)(R_VAL(&((RGBA_Draw_Context *)context)->mul.col));
93    *g = (int)(G_VAL(&((RGBA_Draw_Context *)context)->mul.col));
94    *b = (int)(B_VAL(&((RGBA_Draw_Context *)context)->mul.col));
95    *a = (int)(A_VAL(&((RGBA_Draw_Context *)context)->mul.col));
96    return ((RGBA_Draw_Context *)context)->mul.use;
97 }
98
99 static void
100 eng_context_mask_set(void *data __UNUSED__, void *context, void *mask, int x, int y, int w, int h)
101 {
102    evas_common_draw_context_set_mask(context, mask, x, y, w, h);
103 }
104
105 static void
106 eng_context_mask_unset(void *data __UNUSED__, void *context)
107 {
108    evas_common_draw_context_unset_mask(context);
109 }
110 /*
111 static void *
112 eng_context_mask_get(void *data __UNUSED__, void *context)
113 {
114    return ((RGBA_Draw_Context *)context)->mask.mask;
115 }
116 */
117
118 static void
119 eng_context_cutout_add(void *data __UNUSED__, void *context, int x, int y, int w, int h)
120 {
121    evas_common_draw_context_add_cutout(context, x, y, w, h);
122 }
123
124 static void
125 eng_context_cutout_clear(void *data __UNUSED__, void *context)
126 {
127    evas_common_draw_context_clear_cutouts(context);
128 }
129
130 static void
131 eng_context_anti_alias_set(void *data __UNUSED__, void *context, unsigned char aa)
132 {
133    evas_common_draw_context_set_anti_alias(context, aa);
134 }
135
136 static unsigned char
137 eng_context_anti_alias_get(void *data __UNUSED__, void *context)
138 {
139    return ((RGBA_Draw_Context *)context)->anti_alias;
140 }
141
142 static void
143 eng_context_color_interpolation_set(void *data __UNUSED__, void *context, int color_space)
144 {
145    evas_common_draw_context_set_color_interpolation(context, color_space);
146 }
147
148 static int
149 eng_context_color_interpolation_get(void *data __UNUSED__, void *context)
150 {
151    return ((RGBA_Draw_Context *)context)->interpolation.color_space;
152 }
153
154 static void
155 eng_context_render_op_set(void *data __UNUSED__, void *context, int op)
156 {
157    evas_common_draw_context_set_render_op(context, op);
158 }
159
160 static int
161 eng_context_render_op_get(void *data __UNUSED__, void *context)
162 {
163    return ((RGBA_Draw_Context *)context)->render_op;
164 }
165
166
167
168 static void
169 eng_rectangle_draw(void *data __UNUSED__, void *context, void *surface, int x, int y, int w, int h)
170 {
171 #ifdef BUILD_PIPE_RENDER
172    if ((cpunum > 1)
173 #ifdef EVAS_FRAME_QUEUING
174         && evas_common_frameq_enabled()
175 #endif
176         )
177      evas_common_pipe_rectangle_draw(surface, context, x, y, w, h);
178    else
179 #endif
180      {
181         evas_common_rectangle_draw(surface, context, x, y, w, h);
182         evas_common_cpu_end_opt();
183      }
184 }
185
186 static void
187 eng_line_draw(void *data __UNUSED__, void *context, void *surface, int x1, int y1, int x2, int y2)
188 {
189 #ifdef BUILD_PIPE_RENDER
190    if ((cpunum > 1)
191  #ifdef EVAS_FRAME_QUEUING
192         && evas_common_frameq_enabled()
193 #endif
194         )
195     evas_common_pipe_line_draw(surface, context, x1, y1, x2, y2);
196    else
197 #endif   
198      {
199         evas_common_line_draw(surface, context, x1, y1, x2, y2);
200         evas_common_cpu_end_opt();
201      }
202 }
203
204 static void *
205 eng_polygon_point_add(void *data __UNUSED__, void *context __UNUSED__, void *polygon, int x, int y)
206 {
207    return evas_common_polygon_point_add(polygon, x, y);
208 }
209
210 static void *
211 eng_polygon_points_clear(void *data __UNUSED__, void *context __UNUSED__, void *polygon)
212 {
213    return evas_common_polygon_points_clear(polygon);
214 }
215
216 static void
217 eng_polygon_draw(void *data __UNUSED__, void *context, void *surface, void *polygon, int x, int y)
218 {
219 #ifdef BUILD_PIPE_RENDER
220    if ((cpunum > 1)
221 #ifdef EVAS_FRAME_QUEUING
222         && evas_common_frameq_enabled()
223 #endif
224         )
225      evas_common_pipe_poly_draw(surface, context, polygon, x, y);
226    else
227 #endif
228      {
229         evas_common_polygon_draw(surface, context, polygon, x, y);
230         evas_common_cpu_end_opt();
231      }
232 }
233
234 static int
235 eng_image_alpha_get(void *data __UNUSED__, void *image)
236 {
237    Image_Entry *im;
238
239    if (!image) return 1;
240    im = image;
241    switch (im->space)
242      {
243       case EVAS_COLORSPACE_ARGB8888:
244         if (im->flags.alpha) return 1;
245       default:
246         break;
247      }
248    return 0;
249 }
250
251 static int
252 eng_image_colorspace_get(void *data __UNUSED__, void *image)
253 {
254    Image_Entry *im;
255
256    if (!image) return EVAS_COLORSPACE_ARGB8888;
257    im = image;
258    return im->space;
259 }
260
261 static void
262 eng_image_mask_create(void *data __UNUSED__, void *image)
263 {
264    RGBA_Image *im;
265    int sz;
266    uint8_t *dst,*end;
267    uint32_t *src;
268
269    if (!image) return;
270    im = image;
271    if (im->mask.mask && !im->mask.dirty) return;
272
273    if (im->mask.mask) free(im->mask.mask);
274    sz = im->cache_entry.w * im->cache_entry.h;
275    im->mask.mask = malloc(sz);
276    dst = im->mask.mask;
277    if (!im->image.data)
278       evas_cache_image_load_data(&im->cache_entry);
279    src = im->image.data;
280    if (!src) return;
281    for (end = dst + sz ; dst < end ; dst ++, src ++)
282       *dst = *src >> 24;
283    im->mask.dirty = 0;
284 }
285
286
287 static void *
288 eng_image_alpha_set(void *data __UNUSED__, void *image, int has_alpha)
289 {
290    RGBA_Image *im;
291
292    if (!image) return NULL;
293    im = image;
294    if (im->cache_entry.space != EVAS_COLORSPACE_ARGB8888)
295      {
296         im->cache_entry.flags.alpha = 0;
297         return im;
298      }
299    im = (RGBA_Image *) evas_cache_image_alone(&im->cache_entry);
300    evas_common_image_colorspace_dirty(im);
301
302    im->cache_entry.flags.alpha = has_alpha ? 1 : 0;
303    return im;
304 }
305
306 static void *
307 eng_image_border_set(void *data __UNUSED__, void *image, int l __UNUSED__, int r __UNUSED__, int t __UNUSED__, int b __UNUSED__)
308 {
309    RGBA_Image *im;
310
311    im = image;
312    return im;
313 }
314
315 static void
316 eng_image_border_get(void *data __UNUSED__, void *image, int *l __UNUSED__, int *r __UNUSED__, int *t __UNUSED__, int *b __UNUSED__)
317 {
318    RGBA_Image *im;
319
320    im = image;
321 }
322
323 static char *
324 eng_image_comment_get(void *data __UNUSED__, void *image, char *key __UNUSED__)
325 {
326    RGBA_Image *im;
327
328    if (!image) return NULL;
329    im = image;
330    return im->info.comment;
331 }
332
333 static char *
334 eng_image_format_get(void *data __UNUSED__, void *image __UNUSED__)
335 {
336    return NULL;
337 }
338
339 static void
340 eng_image_colorspace_set(void *data __UNUSED__, void *image, int cspace)
341 {
342    Image_Entry *im;
343
344    if (!image) return;
345    im = image;
346    evas_cache_image_colorspace(im, cspace);
347 }
348
349 static void *
350 eng_image_native_set(void *data __UNUSED__, void *image, void *native __UNUSED__)
351 {
352    return image;
353 }
354
355 static void *
356 eng_image_native_get(void *data __UNUSED__, void *image __UNUSED__)
357 {
358    return NULL;
359 }
360
361 static void *
362 eng_image_load(void *data __UNUSED__, const char *file, const char *key, int *error, Evas_Image_Load_Opts *lo)
363 {
364    *error = EVAS_LOAD_ERROR_NONE;
365    return evas_common_load_image_from_file(file, key, lo, error);
366 }
367
368 static void *
369 eng_image_new_from_data(void *data __UNUSED__, int w, int h, DATA32 *image_data, int alpha, int cspace)
370 {
371    return evas_cache_image_data(evas_common_image_cache_get(), w, h, image_data, alpha, cspace);
372 }
373
374 static void *
375 eng_image_new_from_copied_data(void *data __UNUSED__, int w, int h, DATA32 *image_data, int alpha, int cspace)
376 {
377    return evas_cache_image_copied_data(evas_common_image_cache_get(), w, h, image_data, alpha, cspace);
378 }
379
380 static void
381 eng_image_free(void *data __UNUSED__, void *image)
382 {
383    evas_cache_image_drop(image);
384 }
385
386 static void
387 eng_image_size_get(void *data __UNUSED__, void *image, int *w, int *h)
388 {
389    Image_Entry *im;
390
391    im = image;
392    if (w) *w = im->w;
393    if (h) *h = im->h;
394 }
395
396 static void *
397 eng_image_size_set(void *data __UNUSED__, void *image, int w, int h)
398 {
399    Image_Entry *im;
400
401    im = image;
402    return evas_cache_image_size_set(image, w, h);
403 }
404
405 static void *
406 eng_image_dirty_region(void *data __UNUSED__, void *image, int x, int y, int w, int h)
407 {
408    Image_Entry *im = image;
409
410    if (!image) return NULL;
411    return evas_cache_image_dirty(im, x, y, w, h);
412 }
413
414 static void *
415 eng_image_data_get(void *data __UNUSED__, void *image, int to_write, DATA32 **image_data, int *err)
416 {
417    RGBA_Image *im;
418    int error;
419
420    if (!image)
421      {
422         *image_data = NULL;
423         return NULL;
424      }
425    im = image;
426    error = evas_cache_image_load_data(&im->cache_entry);
427    switch (im->cache_entry.space)
428      {
429       case EVAS_COLORSPACE_ARGB8888:
430         if (to_write)
431           im = (RGBA_Image *)evas_cache_image_alone(&im->cache_entry);
432         *image_data = im->image.data;
433         break;
434       case EVAS_COLORSPACE_YCBCR422P601_PL:
435       case EVAS_COLORSPACE_YCBCR422P709_PL:
436         *image_data = im->cs.data;
437         break;
438       default:
439         abort();
440         break;
441      }
442    if (err) *err = error;
443    return im;
444 }
445
446 static void *
447 eng_image_data_put(void *data, void *image, DATA32 *image_data)
448 {
449    RGBA_Image *im, *im2;
450
451    if (!image) return NULL;
452    im = image;
453    switch (im->cache_entry.space)
454      {
455       case EVAS_COLORSPACE_ARGB8888:
456         if (image_data != im->image.data)
457           {
458              int w, h;
459
460              w = im->cache_entry.w;
461              h = im->cache_entry.h;
462              im2 = eng_image_new_from_data(data, w, h, image_data,
463                                            eng_image_alpha_get(data, image),
464                                            eng_image_colorspace_get(data, image));
465              evas_cache_image_drop(&im->cache_entry);
466              im = im2;
467           }
468         break;
469       case EVAS_COLORSPACE_YCBCR422P601_PL:
470       case EVAS_COLORSPACE_YCBCR422P709_PL:
471         if (image_data != im->cs.data)
472           {
473              if (im->cs.data)
474                {
475                   if (!im->cs.no_free) free(im->cs.data);
476                }
477              im->cs.data = image_data;
478              evas_common_image_colorspace_dirty(im);
479           }
480         break;
481       default:
482         abort();
483         break;
484      }
485    return im;
486 }
487
488 static void
489 eng_image_data_preload_request(void *data __UNUSED__, void *image, const void *target)
490 {
491    RGBA_Image *im = image;
492
493    if (!im) return ;
494    evas_cache_image_preload_data(&im->cache_entry, target);
495 }
496
497 static void
498 eng_image_data_preload_cancel(void *data __UNUSED__, void *image, const void *target)
499 {
500    RGBA_Image *im = image;
501
502    if (!im) return ;
503    evas_cache_image_preload_cancel(&im->cache_entry, target);
504 }
505
506 static void
507 eng_image_draw(void *data __UNUSED__, void *context, void *surface, void *image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h, int smooth)
508 {
509    RGBA_Image *im;
510
511    if (!image) return;
512    im = image;
513 #ifdef BUILD_PIPE_RENDER
514    if ((cpunum > 1)
515 #ifdef EVAS_FRAME_QUEUING
516         && evas_common_frameq_enabled()
517 #endif
518         )
519      {
520         evas_common_rgba_image_scalecache_prepare((Image_Entry *)(im), 
521                                                   surface, context, smooth,
522                                                   src_x, src_y, src_w, src_h,
523                                                   dst_x, dst_y, dst_w, dst_h);
524         
525         evas_common_pipe_image_draw(im, surface, context, smooth,
526                                     src_x, src_y, src_w, src_h,
527                                     dst_x, dst_y, dst_w, dst_h);
528      }
529    else
530 #endif
531      {
532 //        if (im->cache_entry.space == EVAS_COLORSPACE_ARGB8888)
533 //          evas_cache_image_load_data(&im->cache_entry);
534 //        evas_common_image_colorspace_normalize(im);
535         evas_common_rgba_image_scalecache_prepare(&im->cache_entry, surface, context, smooth,
536                                                   src_x, src_y, src_w, src_h,
537                                                   dst_x, dst_y, dst_w, dst_h);
538         evas_common_rgba_image_scalecache_do(&im->cache_entry, surface, context, smooth,
539                                              src_x, src_y, src_w, src_h,
540                                              dst_x, dst_y, dst_w, dst_h);
541 /*        
542         if (smooth)
543           evas_common_scale_rgba_in_to_out_clip_smooth(im, surface, context,
544                                                        src_x, src_y, src_w, src_h,
545                                                        dst_x, dst_y, dst_w, dst_h);
546         else
547           evas_common_scale_rgba_in_to_out_clip_sample(im, surface, context,
548                                                        src_x, src_y, src_w, src_h,
549                                                        dst_x, dst_y, dst_w, dst_h);
550  */
551         evas_common_cpu_end_opt();
552      }
553 }
554
555 static void
556 eng_image_map_draw(void *data __UNUSED__, void *context, void *surface, void *image, int npoints, RGBA_Map_Point *p, int smooth, int level)
557 {
558    RGBA_Image *im;
559
560    if (!image) return;
561    if (npoints < 3) return;
562    im = image;
563
564    if ((p[0].x == p[3].x) &&
565        (p[1].x == p[2].x) &&
566        (p[0].y == p[1].y) &&
567        (p[3].y == p[2].y) &&
568        (p[0].x <= p[1].x) &&
569        (p[0].y <= p[2].y) &&
570        (p[0].u == 0) &&
571        (p[0].v == 0) &&
572        (p[1].u == (int)(im->cache_entry.w << FP)) &&
573        (p[1].v == 0) &&
574        (p[2].u == (int)(im->cache_entry.w << FP)) &&
575        (p[2].v == (int)(im->cache_entry.h << FP)) &&
576        (p[3].u == 0) &&
577        (p[3].v == (int)(im->cache_entry.h << FP)) &&
578        (p[0].col == 0xffffffff) &&
579        (p[1].col == 0xffffffff) &&
580        (p[2].col == 0xffffffff) &&
581        (p[3].col == 0xffffffff))
582      {
583         int dx, dy, dw, dh;
584
585         dx = p[0].x >> FP;
586         dy = p[0].y >> FP;
587         dw = (p[2].x >> FP) - dx;
588         dh = (p[2].y >> FP) - dy;
589         eng_image_draw
590           (data, context, surface, image,
591            0, 0, im->cache_entry.w, im->cache_entry.h,
592            dx, dy, dw, dh, smooth);
593      }
594    else
595      {
596 #ifdef BUILD_PIPE_RENDER
597         if ((cpunum > 1)
598 # ifdef EVAS_FRAME_QUEUING
599        && evas_common_frameq_enabled()
600 # endif
601         )
602           evas_common_pipe_map_draw(im, surface, context, npoints, p, smooth, level);
603         else
604 #endif
605           evas_common_map_rgba(im, surface, context, npoints, p, smooth, level);
606      }
607    evas_common_cpu_end_opt();
608
609    if (npoints > 4)
610      {
611         eng_image_map_draw(data, context, surface, image, npoints - 2, p + 2,
612                            smooth, level);
613      }
614 }
615
616 static void *
617 eng_image_map_surface_new(void *data __UNUSED__, int w, int h, int alpha)
618 {
619    void *surface;
620    DATA32 *pixels;
621    surface = evas_cache_image_copied_data(evas_common_image_cache_get(), 
622                                           w, h, NULL, alpha, 
623                                           EVAS_COLORSPACE_ARGB8888);
624    pixels = evas_cache_image_pixels(surface);
625    return surface;
626 }
627
628 static void
629 eng_image_map_surface_free(void *data __UNUSED__, void *surface)
630 {
631    evas_cache_image_drop(surface);
632 }
633
634 static void
635 eng_image_scale_hint_set(void *data __UNUSED__, void *image, int hint)
636 {
637    Image_Entry *im;
638
639    if (!image) return;
640    im = image;
641    im->scale_hint = hint;
642 }
643
644 static int
645 eng_image_scale_hint_get(void *data __UNUSED__, void *image)
646 {
647    Image_Entry *im;
648
649    if (!image) return EVAS_IMAGE_SCALE_HINT_NONE;
650    im = image;
651    return im->scale_hint;
652 }
653
654 static void
655 eng_image_cache_flush(void *data __UNUSED__)
656 {
657    int tmp_size;
658
659    tmp_size = evas_common_image_get_cache();
660    evas_common_image_set_cache(0);
661    evas_common_rgba_image_scalecache_flush();
662    evas_common_image_set_cache(tmp_size);
663 }
664
665 static void
666 eng_image_cache_set(void *data __UNUSED__, int bytes)
667 {
668    evas_common_image_set_cache(bytes);
669    evas_common_rgba_image_scalecache_size_set(bytes);
670 }
671
672 static int
673 eng_image_cache_get(void *data __UNUSED__)
674 {
675    return evas_common_image_get_cache();
676 }
677
678 static void *
679 eng_font_load(void *data __UNUSED__, const char *name, int size,
680       Font_Rend_Flags wanted_rend)
681 {
682    return evas_common_font_load(name, size, wanted_rend);
683 }
684
685 static void *
686 eng_font_memory_load(void *data __UNUSED__, char *name, int size, const void *fdata, int fdata_size, Font_Rend_Flags wanted_rend)
687 {
688    return evas_common_font_memory_load(name, size, fdata, fdata_size,
689          wanted_rend);
690 }
691
692 static void *
693 eng_font_add(void *data __UNUSED__, void *font, const char *name, int size, Font_Rend_Flags wanted_rend)
694 {
695    return evas_common_font_add(font, name, size, wanted_rend);
696 }
697
698 static void *
699 eng_font_memory_add(void *data __UNUSED__, void *font, char *name, int size, const void *fdata, int fdata_size, Font_Rend_Flags wanted_rend)
700 {
701    return evas_common_font_memory_add(font, name, size, fdata, fdata_size,
702          wanted_rend);
703 }
704
705 static void
706 eng_font_free(void *data __UNUSED__, void *font)
707 {
708    evas_common_font_free(font);
709 }
710
711 static int
712 eng_font_ascent_get(void *data __UNUSED__, void *font)
713 {
714    return evas_common_font_ascent_get(font);
715 }
716
717 static int
718 eng_font_descent_get(void *data __UNUSED__, void *font)
719 {
720    return evas_common_font_descent_get(font);
721 }
722
723 static int
724 eng_font_max_ascent_get(void *data __UNUSED__, void *font)
725 {
726    return evas_common_font_max_ascent_get(font);
727 }
728
729 static int
730 eng_font_max_descent_get(void *data __UNUSED__, void *font)
731 {
732    return evas_common_font_max_descent_get(font);
733 }
734
735 static void
736 eng_font_string_size_get(void *data __UNUSED__, void *font, const Evas_Text_Props *text_props, int *w, int *h)
737 {
738    evas_common_font_query_size(font, text_props, w, h);
739 }
740
741 static int
742 eng_font_inset_get(void *data __UNUSED__, void *font, const Evas_Text_Props *text_props)
743 {
744    return evas_common_font_query_inset(font, text_props);
745 }
746
747 static int
748 eng_font_right_inset_get(void *data __UNUSED__, void *font, const Evas_Text_Props *text_props)
749 {
750    return evas_common_font_query_right_inset(font, text_props);
751 }
752
753 static int
754 eng_font_h_advance_get(void *data __UNUSED__, void *font, const Evas_Text_Props *text_props)
755 {
756    int h, v;
757
758    evas_common_font_query_advance(font, text_props, &h, &v);
759    return h;
760 }
761
762 static int
763 eng_font_v_advance_get(void *data __UNUSED__, void *font, const Evas_Text_Props *text_props)
764 {
765    int h, v;
766
767    evas_common_font_query_advance(font, text_props, &h, &v);
768    return v;
769 }
770
771 static int
772 eng_font_pen_coords_get(void *data __UNUSED__, void *font, const Evas_Text_Props *text_props, int pos, int *cpen_x, int *cy, int *cadv, int *ch)
773 {
774    return evas_common_font_query_pen_coords(font, text_props, pos, cpen_x, cy, cadv, ch);
775 }
776
777 static Eina_Bool
778 eng_font_text_props_info_create(void *data __UNUSED__, void *font, const Eina_Unicode *text, Evas_Text_Props *text_props, const Evas_BiDi_Paragraph_Props *par_props, size_t par_pos, size_t len)
779 {
780    return evas_common_text_props_content_create(font, text, text_props,
781          par_props, par_pos, len);
782 }
783
784 static int
785 eng_font_char_coords_get(void *data __UNUSED__, void *font, const Evas_Text_Props *text_props, int pos, int *cx, int *cy, int *cw, int *ch)
786 {
787    return evas_common_font_query_char_coords(font, text_props, pos, cx, cy, cw, ch);
788 }
789
790 static int
791 eng_font_char_at_coords_get(void *data __UNUSED__, void *font, const Evas_Text_Props *text_props, int x, int y, int *cx, int *cy, int *cw, int *ch)
792 {
793    return evas_common_font_query_char_at_coords(font, text_props, x, y, cx, cy, cw, ch);
794 }
795
796 static int
797 eng_font_last_up_to_pos(void *data __UNUSED__, void *font, const Evas_Text_Props *text_props, int x, int y)
798 {
799    return evas_common_font_query_last_up_to_pos(font, text_props, x, y);
800 }
801
802 static void
803 eng_font_draw(void *data __UNUSED__, void *context, void *surface, void *font, int x, int y, int w __UNUSED__, int h __UNUSED__, int ow __UNUSED__, int oh __UNUSED__, const Evas_Text_Props *text_props)
804 {
805 #ifdef BUILD_PIPE_RENDER
806    if ((cpunum > 1)
807 #ifdef EVAS_FRAME_QUEUING
808         && evas_common_frameq_enabled()
809 #endif
810         )
811      evas_common_pipe_text_draw(surface, context, font, x, y, text_props);
812    else
813 #endif   
814      {
815         evas_common_font_draw(surface, context, font, x, y, text_props);
816         evas_common_cpu_end_opt();
817      }
818 }
819
820 static void
821 eng_font_cache_flush(void *data __UNUSED__)
822 {
823    int tmp_size;
824
825    tmp_size = evas_common_font_cache_get();
826    evas_common_font_cache_set(0);
827    evas_common_font_flush();
828    evas_common_font_cache_set(tmp_size);
829 }
830
831 static void
832 eng_font_cache_set(void *data __UNUSED__, int bytes)
833 {
834    evas_common_font_cache_set(bytes);
835 }
836
837 static int
838 eng_font_cache_get(void *data __UNUSED__)
839 {
840    return evas_common_font_cache_get();
841 }
842
843 static void
844 eng_font_hinting_set(void *data __UNUSED__, void *font, int hinting)
845 {
846    evas_common_font_hinting_set(font, hinting);
847 }
848
849 static int
850 eng_font_hinting_can_hint(void *data __UNUSED__, int hinting)
851 {
852    return evas_common_hinting_available(hinting);
853 }
854
855 static Eina_Bool
856 eng_canvas_alpha_get(void *data __UNUSED__, void *info __UNUSED__)
857 {
858    return EINA_TRUE;
859 }
860
861
862 /* Filter API */
863 static void
864 eng_image_draw_filtered(void *data __UNUSED__, void *context __UNUSED__,
865                         void *surface, void *image, Evas_Filter_Info *filter)
866 {
867    Evas_Software_Filter_Fn fn;
868    RGBA_Image *im = image;
869
870    fn = evas_filter_software_get(filter);
871    if (!fn) return;
872    if (im->cache_entry.cache) evas_cache_image_load_data(&im->cache_entry);
873    fn(filter, image, surface);
874    return;
875 }
876
877 static Filtered_Image *
878 eng_image_filtered_get(void *image, uint8_t *key, size_t keylen)
879 {
880    RGBA_Image *im = image;
881    Filtered_Image *fi;
882    Eina_List *l;
883
884    for (l = im->filtered ; l ; l = l->next)
885      {
886          fi = l->data;
887          if (fi->keylen != keylen) continue;
888          if (memcmp(key, fi->key, keylen) != 0) continue;
889          fi->ref ++;
890          return fi;
891      }
892
893    return NULL;
894 }
895
896 static Filtered_Image *
897 eng_image_filtered_save(void *image, void *fimage, uint8_t *key, size_t keylen)
898 {
899    RGBA_Image *im = image;
900    Filtered_Image *fi;
901    Eina_List *l;
902
903    for (l = im->filtered ; l ; l = l->next)
904      {
905         fi = l->data;
906         if (fi->keylen != keylen) continue;
907         if (memcmp(key, fi->key, keylen) == 0) continue;
908         evas_cache_image_drop((void *)fi->image);
909         fi->image = fimage;
910         return fi;
911      }
912
913    fi = calloc(1,sizeof(Filtered_Image));
914    if (!fi) return NULL;
915
916    fi->keylen = keylen;
917    fi->key = malloc(keylen);
918    memcpy(fi->key, key, keylen);
919    fi->image = fimage;
920    fi->ref = 1;
921
922    im->filtered = eina_list_prepend(im->filtered, fi);
923
924    return fi;
925 }
926
927 static void
928 eng_image_filtered_free(void *image, Filtered_Image *fi)
929 {
930    RGBA_Image *im = image;
931
932    fi->ref --;
933    if (fi->ref) return;
934
935    free(fi->key);
936    evas_cache_image_drop(&fi->image->cache_entry);
937    fi->image = NULL;
938
939    im->filtered = eina_list_remove(im->filtered, fi);
940 }
941
942 static int
943 eng_image_load_error_get(void *data __UNUSED__, void *image)
944 {
945    RGBA_Image *im;
946    
947    if (!image) return EVAS_LOAD_ERROR_NONE;
948    im = image;
949    return im->cache_entry.load_error;
950 }
951
952 /*
953  *****
954  **
955  ** ENGINE API
956  **
957  *****
958  */
959
960 static Evas_Func func =
961 {
962    NULL,
963      NULL,
964      NULL,
965      NULL,
966      NULL,
967      NULL,
968      NULL,
969      NULL,
970      NULL,
971      NULL,
972      NULL,
973      NULL,
974      NULL,
975      eng_output_dump,
976      /* draw context virtual methods */
977      eng_context_new,
978      eng_canvas_alpha_get,
979      eng_context_free,
980      eng_context_clip_set,
981      eng_context_clip_clip,
982      eng_context_clip_unset,
983      eng_context_clip_get,
984      eng_context_mask_set,
985      eng_context_mask_unset,
986      eng_context_color_set,
987      eng_context_color_get,
988      eng_context_multiplier_set,
989      eng_context_multiplier_unset,
990      eng_context_multiplier_get,
991      eng_context_cutout_add,
992      eng_context_cutout_clear,
993      eng_context_anti_alias_set,
994      eng_context_anti_alias_get,
995      eng_context_color_interpolation_set,
996      eng_context_color_interpolation_get,
997      eng_context_render_op_set,
998      eng_context_render_op_get,
999      /* rect draw funcs */
1000      eng_rectangle_draw,
1001      /* line draw funcs */
1002      eng_line_draw,
1003      /* polygon draw funcs */
1004      eng_polygon_point_add,
1005      eng_polygon_points_clear,
1006      eng_polygon_draw,
1007      /* image draw funcs */
1008      eng_image_load,
1009      eng_image_new_from_data,
1010      eng_image_new_from_copied_data,
1011      eng_image_free,
1012      eng_image_size_get,
1013      eng_image_size_set,
1014      NULL,
1015      eng_image_dirty_region,
1016      eng_image_data_get,
1017      eng_image_data_put,
1018      eng_image_data_preload_request,
1019      eng_image_data_preload_cancel,
1020      eng_image_alpha_set,
1021      eng_image_alpha_get,
1022      eng_image_border_set,
1023      eng_image_border_get,
1024      eng_image_draw,
1025      eng_image_comment_get,
1026      eng_image_format_get,
1027      eng_image_colorspace_set,
1028      eng_image_colorspace_get,
1029      eng_image_mask_create,
1030      eng_image_native_set,
1031      eng_image_native_get,
1032      /* image cache funcs */
1033      eng_image_cache_flush,
1034      eng_image_cache_set,
1035      eng_image_cache_get,
1036      /* font draw functions */
1037      eng_font_load,
1038      eng_font_memory_load,
1039      eng_font_add,
1040      eng_font_memory_add,
1041      eng_font_free,
1042      eng_font_ascent_get,
1043      eng_font_descent_get,
1044      eng_font_max_ascent_get,
1045      eng_font_max_descent_get,
1046      eng_font_string_size_get,
1047      eng_font_inset_get,
1048      eng_font_h_advance_get,
1049      eng_font_v_advance_get,
1050      eng_font_char_coords_get,
1051      eng_font_char_at_coords_get,
1052      eng_font_draw,
1053      /* font cache functions */
1054      eng_font_cache_flush,
1055      eng_font_cache_set,
1056      eng_font_cache_get,
1057      /* font hinting functions */
1058      eng_font_hinting_set,
1059      eng_font_hinting_can_hint,
1060      eng_image_scale_hint_set,
1061      eng_image_scale_hint_get,
1062      /* more font draw functions */
1063      eng_font_last_up_to_pos,
1064      eng_image_map_draw,
1065      eng_image_map_surface_new,
1066      eng_image_map_surface_free,
1067      NULL, // eng_image_content_hint_set - software doesn't use it
1068      NULL, // eng_image_content_hint_get - software doesn't use it
1069      eng_font_pen_coords_get,
1070      eng_font_text_props_info_create,
1071      eng_font_right_inset_get,
1072      eng_image_draw_filtered,
1073      eng_image_filtered_get,
1074      eng_image_filtered_save,
1075      eng_image_filtered_free,
1076      NULL, // FIXME: need software mesa for gl rendering <- gl_surface_create
1077      NULL, // FIXME: need software mesa for gl rendering <- gl_surface_destroy
1078      NULL, // FIXME: need software mesa for gl rendering <- gl_context_create
1079      NULL, // FIXME: need software mesa for gl rendering <- gl_context_destroy
1080      NULL, // FIXME: need software mesa for gl rendering <- gl_make_current
1081      NULL, // FIXME: need software mesa for gl rendering <- gl_proc_address_get
1082      NULL, // FIXME: need software mesa for gl rendering <- gl_native_surface_get
1083      NULL, // FIXME: need software mesa for gl rendering <- gl_api_get
1084      eng_image_load_error_get
1085    /* FUTURE software generic calls go here */
1086 };
1087
1088 /*
1089  *****
1090  **
1091  ** MODULE ACCESSIBLE API API
1092  **
1093  *****
1094  */
1095
1096 static int
1097 module_open(Evas_Module *em)
1098 {
1099    if (!em) return 0;
1100    _evas_soft_gen_log_dom = eina_log_domain_register
1101      ("evas-software_generic", EVAS_DEFAULT_LOG_COLOR);
1102    if(_evas_soft_gen_log_dom<0)
1103      {
1104         EINA_LOG_ERR("Can not create a module log domain.");
1105         return 0;
1106      }
1107    em->functions = (void *)(&func);
1108    cpunum = eina_cpu_count();
1109    return 1;
1110 }
1111
1112 static void
1113 module_close(Evas_Module *em __UNUSED__)
1114 {
1115   eina_log_domain_unregister(_evas_soft_gen_log_dom);
1116 }
1117
1118 static Evas_Module_Api evas_modapi =
1119 {
1120    EVAS_MODULE_API_VERSION,
1121    "software_generic",
1122    "none",
1123    {
1124      module_open,
1125      module_close
1126    }
1127 };
1128
1129 EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_ENGINE, engine, software_generic);
1130
1131 #ifndef EVAS_STATIC_BUILD_SOFTWARE_GENERIC
1132 EVAS_EINA_MODULE_DEFINE(engine, software_generic);
1133 #endif