svn update: 58227 (latest:58227)
[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 static void
118 eng_context_cutout_add(void *data __UNUSED__, void *context, int x, int y, int w, int h)
119 {
120    evas_common_draw_context_add_cutout(context, x, y, w, h);
121 }
122
123 static void
124 eng_context_cutout_clear(void *data __UNUSED__, void *context)
125 {
126    evas_common_draw_context_clear_cutouts(context);
127 }
128
129 static void
130 eng_context_anti_alias_set(void *data __UNUSED__, void *context, unsigned char aa)
131 {
132    evas_common_draw_context_set_anti_alias(context, aa);
133 }
134
135 static unsigned char
136 eng_context_anti_alias_get(void *data __UNUSED__, void *context)
137 {
138    return ((RGBA_Draw_Context *)context)->anti_alias;
139 }
140
141 static void
142 eng_context_color_interpolation_set(void *data __UNUSED__, void *context, int color_space)
143 {
144    evas_common_draw_context_set_color_interpolation(context, color_space);
145 }
146
147 static int
148 eng_context_color_interpolation_get(void *data __UNUSED__, void *context)
149 {
150    return ((RGBA_Draw_Context *)context)->interpolation.color_space;
151 }
152
153 static void
154 eng_context_render_op_set(void *data __UNUSED__, void *context, int op)
155 {
156    evas_common_draw_context_set_render_op(context, op);
157 }
158
159 static int
160 eng_context_render_op_get(void *data __UNUSED__, void *context)
161 {
162    return ((RGBA_Draw_Context *)context)->render_op;
163 }
164
165
166
167 static void
168 eng_rectangle_draw(void *data __UNUSED__, void *context, void *surface, int x, int y, int w, int h)
169 {
170 #ifdef BUILD_PIPE_RENDER
171    if ((cpunum > 1)
172 #ifdef EVAS_FRAME_QUEUING
173         && evas_common_frameq_enabled()
174 #endif
175         )
176      evas_common_pipe_rectangle_draw(surface, context, x, y, w, h);
177    else
178 #endif
179      {
180         evas_common_rectangle_draw(surface, context, x, y, w, h);
181         evas_common_cpu_end_opt();
182      }
183 }
184
185 static void
186 eng_line_draw(void *data __UNUSED__, void *context, void *surface, int x1, int y1, int x2, int y2)
187 {
188 #ifdef BUILD_PIPE_RENDER
189    if ((cpunum > 1)
190  #ifdef EVAS_FRAME_QUEUING
191         && evas_common_frameq_enabled()
192 #endif
193         )
194     evas_common_pipe_line_draw(surface, context, x1, y1, x2, y2);
195    else
196 #endif   
197      {
198         evas_common_line_draw(surface, context, x1, y1, x2, y2);
199         evas_common_cpu_end_opt();
200      }
201 }
202
203 static void *
204 eng_polygon_point_add(void *data __UNUSED__, void *context __UNUSED__, void *polygon, int x, int y)
205 {
206    return evas_common_polygon_point_add(polygon, x, y);
207 }
208
209 static void *
210 eng_polygon_points_clear(void *data __UNUSED__, void *context __UNUSED__, void *polygon)
211 {
212    return evas_common_polygon_points_clear(polygon);
213 }
214
215 static void
216 eng_polygon_draw(void *data __UNUSED__, void *context, void *surface, void *polygon, int x, int y)
217 {
218 #ifdef BUILD_PIPE_RENDER
219    if ((cpunum > 1)
220 #ifdef EVAS_FRAME_QUEUING
221         && evas_common_frameq_enabled()
222 #endif
223         )
224      evas_common_pipe_poly_draw(surface, context, polygon, x, y);
225    else
226 #endif
227      {
228         evas_common_polygon_draw(surface, context, polygon, x, y);
229         evas_common_cpu_end_opt();
230      }
231 }
232
233 static int
234 eng_image_alpha_get(void *data __UNUSED__, void *image)
235 {
236    Image_Entry *im;
237
238    if (!image) return 1;
239    im = image;
240    switch (im->space)
241      {
242       case EVAS_COLORSPACE_ARGB8888:
243         if (im->flags.alpha) return 1;
244       default:
245         break;
246      }
247    return 0;
248 }
249
250 static int
251 eng_image_colorspace_get(void *data __UNUSED__, void *image)
252 {
253    Image_Entry *im;
254
255    if (!image) return EVAS_COLORSPACE_ARGB8888;
256    im = image;
257    return im->space;
258 }
259
260 static void
261 eng_image_mask_create(void *data __UNUSED__, void *image)
262 {
263    RGBA_Image *im;
264    int sz;
265    uint8_t *dst,*end;
266    uint32_t *src;
267
268    if (!image) return;
269    im = image;
270    if (im->mask.mask && !im->mask.dirty) return;
271
272    if (im->mask.mask) free(im->mask.mask);
273    sz = im->cache_entry.w * im->cache_entry.h;
274    im->mask.mask = malloc(sz);
275    dst = im->mask.mask;
276    if (!im->image.data)
277       evas_cache_image_load_data(&im->cache_entry);
278    src = im->image.data;
279    for (end = dst + sz ; dst < end ; dst ++, src ++)
280       *dst = *src >> 24;
281    im->mask.dirty = 0;
282 }
283
284
285 static void *
286 eng_image_alpha_set(void *data __UNUSED__, void *image, int has_alpha)
287 {
288    RGBA_Image *im;
289
290    if (!image) return NULL;
291    im = image;
292    if (im->cache_entry.space != EVAS_COLORSPACE_ARGB8888)
293      {
294         im->cache_entry.flags.alpha = 0;
295         return im;
296      }
297    im = (RGBA_Image *) evas_cache_image_alone(&im->cache_entry);
298    evas_common_image_colorspace_dirty(im);
299
300    im->cache_entry.flags.alpha = has_alpha ? 1 : 0;
301    return im;
302 }
303
304 static void *
305 eng_image_border_set(void *data __UNUSED__, void *image, int l __UNUSED__, int r __UNUSED__, int t __UNUSED__, int b __UNUSED__)
306 {
307    RGBA_Image *im;
308
309    im = image;
310    return im;
311 }
312
313 static void
314 eng_image_border_get(void *data __UNUSED__, void *image, int *l __UNUSED__, int *r __UNUSED__, int *t __UNUSED__, int *b __UNUSED__)
315 {
316    RGBA_Image *im;
317
318    im = image;
319 }
320
321 static char *
322 eng_image_comment_get(void *data __UNUSED__, void *image, char *key __UNUSED__)
323 {
324    RGBA_Image *im;
325
326    if (!image) return NULL;
327    im = image;
328    return im->info.comment;
329 }
330
331 static char *
332 eng_image_format_get(void *data __UNUSED__, void *image __UNUSED__)
333 {
334    return NULL;
335 }
336
337 static void
338 eng_image_colorspace_set(void *data __UNUSED__, void *image, int cspace)
339 {
340    Image_Entry *im;
341
342    if (!image) return;
343    im = image;
344    evas_cache_image_colorspace(im, cspace);
345 }
346
347 static void *
348 eng_image_native_set(void *data __UNUSED__, void *image, void *native __UNUSED__)
349 {
350    return image;
351 }
352
353 static void *
354 eng_image_native_get(void *data __UNUSED__, void *image __UNUSED__)
355 {
356    return NULL;
357 }
358
359 static void *
360 eng_image_load(void *data __UNUSED__, const char *file, const char *key, int *error, Evas_Image_Load_Opts *lo)
361 {
362    *error = EVAS_LOAD_ERROR_NONE;
363    return evas_common_load_image_from_file(file, key, lo, error);
364 }
365
366 static void *
367 eng_image_new_from_data(void *data __UNUSED__, int w, int h, DATA32 *image_data, int alpha, int cspace)
368 {
369    return evas_cache_image_data(evas_common_image_cache_get(), w, h, image_data, alpha, cspace);
370 }
371
372 static void *
373 eng_image_new_from_copied_data(void *data __UNUSED__, int w, int h, DATA32 *image_data, int alpha, int cspace)
374 {
375    return evas_cache_image_copied_data(evas_common_image_cache_get(), w, h, image_data, alpha, cspace);
376 }
377
378 static void
379 eng_image_free(void *data __UNUSED__, void *image)
380 {
381    evas_cache_image_drop(image);
382 }
383
384 static void
385 eng_image_size_get(void *data __UNUSED__, void *image, int *w, int *h)
386 {
387    Image_Entry *im;
388
389    im = image;
390    if (w) *w = im->w;
391    if (h) *h = im->h;
392 }
393
394 static void *
395 eng_image_size_set(void *data __UNUSED__, void *image, int w, int h)
396 {
397    Image_Entry *im;
398
399    im = image;
400    return evas_cache_image_size_set(image, w, h);
401 }
402
403 static void *
404 eng_image_dirty_region(void *data __UNUSED__, void *image, int x, int y, int w, int h)
405 {
406    Image_Entry *im = image;
407
408    if (!image) return NULL;
409    return evas_cache_image_dirty(im, x, y, w, h);
410 }
411
412 static void *
413 eng_image_data_get(void *data __UNUSED__, void *image, int to_write, DATA32 **image_data)
414 {
415    RGBA_Image *im;
416
417    if (!image)
418      {
419         *image_data = NULL;
420         return NULL;
421      }
422    im = image;
423    evas_cache_image_load_data(&im->cache_entry);
424    switch (im->cache_entry.space)
425      {
426       case EVAS_COLORSPACE_ARGB8888:
427         if (to_write)
428           im = (RGBA_Image *) evas_cache_image_alone(&im->cache_entry);
429         *image_data = im->image.data;
430         break;
431       case EVAS_COLORSPACE_YCBCR422P601_PL:
432       case EVAS_COLORSPACE_YCBCR422P709_PL:
433         *image_data = im->cs.data;
434         break;
435       default:
436         abort();
437         break;
438      }
439    return im;
440 }
441
442 static void *
443 eng_image_data_put(void *data, void *image, DATA32 *image_data)
444 {
445    RGBA_Image *im, *im2;
446
447    if (!image) return NULL;
448    im = image;
449    switch (im->cache_entry.space)
450      {
451       case EVAS_COLORSPACE_ARGB8888:
452         if (image_data != im->image.data)
453           {
454              int w, h;
455
456              w = im->cache_entry.w;
457              h = im->cache_entry.h;
458              im2 = eng_image_new_from_data(data, w, h, image_data,
459                                            eng_image_alpha_get(data, image),
460                                            eng_image_colorspace_get(data, image));
461              evas_cache_image_drop(&im->cache_entry);
462              im = im2;
463           }
464         break;
465       case EVAS_COLORSPACE_YCBCR422P601_PL:
466       case EVAS_COLORSPACE_YCBCR422P709_PL:
467         if (image_data != im->cs.data)
468           {
469              if (im->cs.data)
470                {
471                   if (!im->cs.no_free) free(im->cs.data);
472                }
473              im->cs.data = image_data;
474           }
475         break;
476       default:
477         abort();
478         break;
479      }
480    return im;
481 }
482
483 static void
484 eng_image_data_preload_request(void *data __UNUSED__, void *image, const void *target)
485 {
486    RGBA_Image *im = image;
487
488    if (!im) return ;
489    evas_cache_image_preload_data(&im->cache_entry, target);
490 }
491
492 static void
493 eng_image_data_preload_cancel(void *data __UNUSED__, void *image, const void *target)
494 {
495    RGBA_Image *im = image;
496
497    if (!im) return ;
498    evas_cache_image_preload_cancel(&im->cache_entry, target);
499 }
500
501 static void
502 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)
503 {
504    RGBA_Image *im;
505
506    if (!image) return;
507    im = image;
508 #ifdef BUILD_PIPE_RENDER
509    if ((cpunum > 1)
510 #ifdef EVAS_FRAME_QUEUING
511         && evas_common_frameq_enabled()
512 #endif
513         )
514      {
515         evas_common_rgba_image_scalecache_prepare((Image_Entry *)(im),
516                                                   surface, context, smooth,
517                                                   src_x, src_y, src_w, src_h,
518                                                   dst_x, dst_y, dst_w, dst_h);
519
520         evas_common_pipe_image_draw(im, surface, context, smooth,
521                                     src_x, src_y, src_w, src_h,
522                                     dst_x, dst_y, dst_w, dst_h);
523      }
524    else
525 #endif
526      {
527 //        if (im->cache_entry.space == EVAS_COLORSPACE_ARGB8888)
528 //          evas_cache_image_load_data(&im->cache_entry);
529 //        evas_common_image_colorspace_normalize(im);
530         evas_common_rgba_image_scalecache_prepare(&im->cache_entry, surface, context, smooth,
531                                                   src_x, src_y, src_w, src_h,
532                                                   dst_x, dst_y, dst_w, dst_h);
533         evas_common_rgba_image_scalecache_do(&im->cache_entry, surface, context, smooth,
534                                              src_x, src_y, src_w, src_h,
535                                              dst_x, dst_y, dst_w, dst_h);
536 /*
537         if (smooth)
538           evas_common_scale_rgba_in_to_out_clip_smooth(im, surface, context,
539                                                        src_x, src_y, src_w, src_h,
540                                                        dst_x, dst_y, dst_w, dst_h);
541         else
542           evas_common_scale_rgba_in_to_out_clip_sample(im, surface, context,
543                                                        src_x, src_y, src_w, src_h,
544                                                        dst_x, dst_y, dst_w, dst_h);
545  */
546         evas_common_cpu_end_opt();
547      }
548 }
549
550 static void
551 eng_image_map_draw(void *data __UNUSED__, void *context, void *surface, void *image, int npoints, RGBA_Map_Point *p, int smooth, int level)
552 {
553    RGBA_Image *im;
554
555    if (!image) return;
556    if (npoints < 3) return;
557    im = image;
558
559    if ((p[0].x == p[3].x) &&
560        (p[1].x == p[2].x) &&
561        (p[0].y == p[1].y) &&
562        (p[3].y == p[2].y) &&
563        (p[0].x <= p[1].x) &&
564        (p[0].y <= p[2].y) &&
565        (p[0].u == 0) &&
566        (p[0].v == 0) &&
567        (p[1].u == (int)(im->cache_entry.w << FP)) &&
568        (p[1].v == 0) &&
569        (p[2].u == (int)(im->cache_entry.w << FP)) &&
570        (p[2].v == (int)(im->cache_entry.h << FP)) &&
571        (p[3].u == 0) &&
572        (p[3].v == (int)(im->cache_entry.h << FP)) &&
573        (p[0].col == 0xffffffff) &&
574        (p[1].col == 0xffffffff) &&
575        (p[2].col == 0xffffffff) &&
576        (p[3].col == 0xffffffff))
577      {
578         int dx, dy, dw, dh;
579
580         dx = p[0].x >> FP;
581         dy = p[0].y >> FP;
582         dw = (p[2].x >> FP) - dx;
583         dh = (p[2].y >> FP) - dy;
584         eng_image_draw
585           (data, context, surface, image,
586            0, 0, im->cache_entry.w, im->cache_entry.h,
587            dx, dy, dw, dh, smooth);
588      }
589    else
590      {
591 #ifdef BUILD_PIPE_RENDER
592         if ((cpunum > 1)
593 # ifdef EVAS_FRAME_QUEUING
594        && evas_common_frameq_enabled()
595 # endif
596         )
597           evas_common_pipe_map_draw(im, surface, context, npoints, p, smooth, level);
598         else
599 #endif
600           evas_common_map_rgba(im, surface, context, npoints, p, smooth, level);
601      }
602    evas_common_cpu_end_opt();
603
604    if (npoints > 4)
605      {
606         eng_image_map_draw(data, context, surface, image, npoints - 2, p + 2,
607                            smooth, level);
608      }
609 }
610
611 static void *
612 eng_image_map_surface_new(void *data __UNUSED__, int w, int h, int alpha)
613 {
614    void *surface;
615    DATA32 *pixels;
616    surface = evas_cache_image_copied_data(evas_common_image_cache_get(), 
617                                           w, h, NULL, alpha, 
618                                           EVAS_COLORSPACE_ARGB8888);
619    pixels = evas_cache_image_pixels(surface);
620    return surface;
621 }
622
623 static void
624 eng_image_map_surface_free(void *data __UNUSED__, void *surface)
625 {
626    evas_cache_image_drop(surface);
627 }
628
629 static void
630 eng_image_scale_hint_set(void *data __UNUSED__, void *image, int hint)
631 {
632    Image_Entry *im;
633
634    if (!image) return;
635    im = image;
636    im->scale_hint = hint;
637 }
638
639 static int
640 eng_image_scale_hint_get(void *data __UNUSED__, void *image)
641 {
642    Image_Entry *im;
643
644    if (!image) return EVAS_IMAGE_SCALE_HINT_NONE;
645    im = image;
646    return im->scale_hint;
647 }
648
649 static void
650 eng_image_cache_flush(void *data __UNUSED__)
651 {
652    int tmp_size;
653
654    tmp_size = evas_common_image_get_cache();
655    evas_common_image_set_cache(0);
656    evas_common_rgba_image_scalecache_flush();
657    evas_common_image_set_cache(tmp_size);
658 }
659
660 static void
661 eng_image_cache_set(void *data __UNUSED__, int bytes)
662 {
663    evas_common_image_set_cache(bytes);
664    evas_common_rgba_image_scalecache_size_set(bytes);
665 }
666
667 static int
668 eng_image_cache_get(void *data __UNUSED__)
669 {
670    return evas_common_image_get_cache();
671 }
672
673 static void *
674 eng_font_load(void *data __UNUSED__, const char *name, int size)
675 {
676    return evas_common_font_load(name, size);
677 }
678
679 static void *
680 eng_font_memory_load(void *data __UNUSED__, char *name, int size, const void *fdata, int fdata_size)
681 {
682    return evas_common_font_memory_load(name, size, fdata, fdata_size);
683 }
684
685 static void *
686 eng_font_add(void *data __UNUSED__, void *font, const char *name, int size)
687 {
688    return evas_common_font_add(font, name, size);
689 }
690
691 static void *
692 eng_font_memory_add(void *data __UNUSED__, void *font, char *name, int size, const void *fdata, int fdata_size)
693 {
694    return evas_common_font_memory_add(font, name, size, fdata, fdata_size);
695 }
696
697 static void
698 eng_font_free(void *data __UNUSED__, void *font)
699 {
700    evas_common_font_free(font);
701 }
702
703 static int
704 eng_font_ascent_get(void *data __UNUSED__, void *font)
705 {
706    return evas_common_font_ascent_get(font);
707 }
708
709 static int
710 eng_font_descent_get(void *data __UNUSED__, void *font)
711 {
712    return evas_common_font_descent_get(font);
713 }
714
715 static int
716 eng_font_max_ascent_get(void *data __UNUSED__, void *font)
717 {
718    return evas_common_font_max_ascent_get(font);
719 }
720
721 static int
722 eng_font_max_descent_get(void *data __UNUSED__, void *font)
723 {
724    return evas_common_font_max_descent_get(font);
725 }
726
727 static void
728 eng_font_string_size_get(void *data __UNUSED__, void *font, const Eina_Unicode *text, const Evas_Text_Props *text_props, int *w, int *h)
729 {
730    evas_common_font_query_size(font, text, text_props, w, h);
731 }
732
733 static int
734 eng_font_inset_get(void *data __UNUSED__, void *font, const Evas_Text_Props *text_props)
735 {
736    return evas_common_font_query_inset(font, text_props);
737 }
738
739 static int
740 eng_font_right_inset_get(void *data __UNUSED__, void *font, const Evas_Text_Props *text_props)
741 {
742    return evas_common_font_query_right_inset(font, text_props);
743 }
744
745 static int
746 eng_font_h_advance_get(void *data __UNUSED__, void *font, const Eina_Unicode *text, const Evas_Text_Props *text_props)
747 {
748    int h, v;
749
750    evas_common_font_query_advance(font, text, text_props, &h, &v);
751    return h;
752 }
753
754 static int
755 eng_font_v_advance_get(void *data __UNUSED__, void *font, const Eina_Unicode *text, const Evas_Text_Props *text_props)
756 {
757    int h, v;
758
759    evas_common_font_query_advance(font, text, text_props, &h, &v);
760    return v;
761 }
762
763 static int
764 eng_font_pen_coords_get(void *data __UNUSED__, void *font, const Eina_Unicode *text, const Evas_Text_Props *text_props, int pos, int *cpen_x, int *cy, int *cadv, int *ch)
765 {
766    return evas_common_font_query_pen_coords(font, text, text_props, pos, cpen_x, cy, cadv, ch);
767 }
768
769 static Eina_Bool
770 eng_font_text_props_info_create(void *data __UNUSED__, void *font, Eina_Unicode *text, Evas_Text_Props *text_props, const Evas_BiDi_Paragraph_Props *par_props, size_t pos, size_t len)
771 {
772    (void) font;
773    (void) text;
774    (void) text_props;
775    (void) par_props;
776    (void) pos;
777    (void) len;
778 #if !defined(OT_SUPPORT) && defined(BIDI_SUPPORT)
779    evas_bidi_shape_string(text, par_props, pos, len);
780 #endif
781    return evas_common_text_props_content_create(font, text, text_props, len);
782 }
783
784 static int
785 eng_font_char_coords_get(void *data __UNUSED__, void *font, const Eina_Unicode *text, 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, 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 Eina_Unicode *text, 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, 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 Eina_Unicode *text, const Evas_Text_Props *text_props, int x, int y)
798 {
799    return evas_common_font_query_last_up_to_pos(font, text, 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 Eina_Unicode *text, 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, text_props);
812    else
813 #endif   
814      {
815         evas_common_font_draw(surface, context, font, x, y, text, 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  *****
863  **
864  ** ENGINE API
865  **
866  *****
867  */
868
869 static Evas_Func func =
870 {
871    NULL,
872      NULL,
873      NULL,
874      NULL,
875      NULL,
876      NULL,
877      NULL,
878      NULL,
879      NULL,
880      NULL,
881      NULL,
882      NULL,
883      NULL,
884      eng_output_dump,
885      /* draw context virtual methods */
886      eng_context_new,
887      eng_canvas_alpha_get,
888      eng_context_free,
889      eng_context_clip_set,
890      eng_context_clip_clip,
891      eng_context_clip_unset,
892      eng_context_clip_get,
893      eng_context_mask_set,
894      eng_context_mask_unset,
895      eng_context_color_set,
896      eng_context_color_get,
897      eng_context_multiplier_set,
898      eng_context_multiplier_unset,
899      eng_context_multiplier_get,
900      eng_context_cutout_add,
901      eng_context_cutout_clear,
902      eng_context_anti_alias_set,
903      eng_context_anti_alias_get,
904      eng_context_color_interpolation_set,
905      eng_context_color_interpolation_get,
906      eng_context_render_op_set,
907      eng_context_render_op_get,
908      /* rect draw funcs */
909      eng_rectangle_draw,
910      /* line draw funcs */
911      eng_line_draw,
912      /* polygon draw funcs */
913      eng_polygon_point_add,
914      eng_polygon_points_clear,
915      eng_polygon_draw,
916      /* image draw funcs */
917      eng_image_load,
918      eng_image_new_from_data,
919      eng_image_new_from_copied_data,
920      eng_image_free,
921      eng_image_size_get,
922      eng_image_size_set,
923      NULL,
924      eng_image_dirty_region,
925      eng_image_data_get,
926      eng_image_data_put,
927      eng_image_data_preload_request,
928      eng_image_data_preload_cancel,
929      eng_image_alpha_set,
930      eng_image_alpha_get,
931      eng_image_border_set,
932      eng_image_border_get,
933      eng_image_draw,
934      eng_image_comment_get,
935      eng_image_format_get,
936      eng_image_colorspace_set,
937      eng_image_colorspace_get,
938      eng_image_mask_create,
939      eng_image_native_set,
940      eng_image_native_get,
941      /* image cache funcs */
942      eng_image_cache_flush,
943      eng_image_cache_set,
944      eng_image_cache_get,
945      /* font draw functions */
946      eng_font_load,
947      eng_font_memory_load,
948      eng_font_add,
949      eng_font_memory_add,
950      eng_font_free,
951      eng_font_ascent_get,
952      eng_font_descent_get,
953      eng_font_max_ascent_get,
954      eng_font_max_descent_get,
955      eng_font_string_size_get,
956      eng_font_inset_get,
957      eng_font_h_advance_get,
958      eng_font_v_advance_get,
959      eng_font_char_coords_get,
960      eng_font_char_at_coords_get,
961      eng_font_draw,
962      /* font cache functions */
963      eng_font_cache_flush,
964      eng_font_cache_set,
965      eng_font_cache_get,
966      /* font hinting functions */
967      eng_font_hinting_set,
968      eng_font_hinting_can_hint,
969      eng_image_scale_hint_set,
970      eng_image_scale_hint_get,
971      /* more font draw functions */
972      eng_font_last_up_to_pos,
973      /* FUTURE software generic calls go here (done) */
974      eng_image_map_draw,
975      eng_image_map_surface_new,
976      eng_image_map_surface_free,
977      NULL, // eng_image_content_hint_set - software doesn't use it
978      NULL, // eng_image_content_hint_get - software doesn't use it
979      eng_font_pen_coords_get,
980      eng_font_text_props_info_create,
981      eng_font_right_inset_get
982      /* FUTURE software generic calls go here */
983 };
984
985 /*
986  *****
987  **
988  ** MODULE ACCESSIBLE API API
989  **
990  *****
991  */
992
993 static int
994 module_open(Evas_Module *em)
995 {
996    if (!em) return 0;
997    _evas_soft_gen_log_dom = eina_log_domain_register
998      ("evas-software_generic", EVAS_DEFAULT_LOG_COLOR);
999    if(_evas_soft_gen_log_dom<0)
1000      {
1001         EINA_LOG_ERR("Can not create a module log domain.");
1002         return 0;
1003      }
1004    em->functions = (void *)(&func);
1005    cpunum = eina_cpu_count();
1006    return 1;
1007 }
1008
1009 static void
1010 module_close(Evas_Module *em __UNUSED__)
1011 {
1012   eina_log_domain_unregister(_evas_soft_gen_log_dom);
1013 }
1014
1015 static Evas_Module_Api evas_modapi =
1016 {
1017    EVAS_MODULE_API_VERSION,
1018    "software_generic",
1019    "none",
1020    {
1021      module_open,
1022      module_close
1023    }
1024 };
1025
1026 EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_ENGINE, engine, software_generic);
1027
1028 #ifndef EVAS_STATIC_BUILD_SOFTWARE_GENERIC
1029 EVAS_EINA_MODULE_DEFINE(engine, software_generic);
1030 #endif