Evas font-engine: Fixed *props_info_create to accept a const string.
[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    for (end = dst + sz ; dst < end ; dst ++, src ++)
281       *dst = *src >> 24;
282    im->mask.dirty = 0;
283 }
284
285
286 static void *
287 eng_image_alpha_set(void *data __UNUSED__, void *image, int has_alpha)
288 {
289    RGBA_Image *im;
290
291    if (!image) return NULL;
292    im = image;
293    if (im->cache_entry.space != EVAS_COLORSPACE_ARGB8888)
294      {
295         im->cache_entry.flags.alpha = 0;
296         return im;
297      }
298    im = (RGBA_Image *) evas_cache_image_alone(&im->cache_entry);
299    evas_common_image_colorspace_dirty(im);
300
301    im->cache_entry.flags.alpha = has_alpha ? 1 : 0;
302    return im;
303 }
304
305 static void *
306 eng_image_border_set(void *data __UNUSED__, void *image, int l __UNUSED__, int r __UNUSED__, int t __UNUSED__, int b __UNUSED__)
307 {
308    RGBA_Image *im;
309
310    im = image;
311    return im;
312 }
313
314 static void
315 eng_image_border_get(void *data __UNUSED__, void *image, int *l __UNUSED__, int *r __UNUSED__, int *t __UNUSED__, int *b __UNUSED__)
316 {
317    RGBA_Image *im;
318
319    im = image;
320 }
321
322 static char *
323 eng_image_comment_get(void *data __UNUSED__, void *image, char *key __UNUSED__)
324 {
325    RGBA_Image *im;
326
327    if (!image) return NULL;
328    im = image;
329    return im->info.comment;
330 }
331
332 static char *
333 eng_image_format_get(void *data __UNUSED__, void *image __UNUSED__)
334 {
335    return NULL;
336 }
337
338 static void
339 eng_image_colorspace_set(void *data __UNUSED__, void *image, int cspace)
340 {
341    Image_Entry *im;
342
343    if (!image) return;
344    im = image;
345    evas_cache_image_colorspace(im, cspace);
346 }
347
348 static void *
349 eng_image_native_set(void *data __UNUSED__, void *image, void *native __UNUSED__)
350 {
351    return image;
352 }
353
354 static void *
355 eng_image_native_get(void *data __UNUSED__, void *image __UNUSED__)
356 {
357    return NULL;
358 }
359
360 static void *
361 eng_image_load(void *data __UNUSED__, const char *file, const char *key, int *error, Evas_Image_Load_Opts *lo)
362 {
363    *error = EVAS_LOAD_ERROR_NONE;
364    return evas_common_load_image_from_file(file, key, lo, error);
365 }
366
367 static void *
368 eng_image_new_from_data(void *data __UNUSED__, int w, int h, DATA32 *image_data, int alpha, int cspace)
369 {
370    return evas_cache_image_data(evas_common_image_cache_get(), w, h, image_data, alpha, cspace);
371 }
372
373 static void *
374 eng_image_new_from_copied_data(void *data __UNUSED__, int w, int h, DATA32 *image_data, int alpha, int cspace)
375 {
376    return evas_cache_image_copied_data(evas_common_image_cache_get(), w, h, image_data, alpha, cspace);
377 }
378
379 static void
380 eng_image_free(void *data __UNUSED__, void *image)
381 {
382    evas_cache_image_drop(image);
383 }
384
385 static void
386 eng_image_size_get(void *data __UNUSED__, void *image, int *w, int *h)
387 {
388    Image_Entry *im;
389
390    im = image;
391    if (w) *w = im->w;
392    if (h) *h = im->h;
393 }
394
395 static void *
396 eng_image_size_set(void *data __UNUSED__, void *image, int w, int h)
397 {
398    Image_Entry *im;
399
400    im = image;
401    return evas_cache_image_size_set(image, w, h);
402 }
403
404 static void *
405 eng_image_dirty_region(void *data __UNUSED__, void *image, int x, int y, int w, int h)
406 {
407    Image_Entry *im = image;
408
409    if (!image) return NULL;
410    return evas_cache_image_dirty(im, x, y, w, h);
411 }
412
413 static void *
414 eng_image_data_get(void *data __UNUSED__, void *image, int to_write, DATA32 **image_data)
415 {
416    RGBA_Image *im;
417
418    if (!image)
419      {
420         *image_data = NULL;
421         return NULL;
422      }
423    im = image;
424    evas_cache_image_load_data(&im->cache_entry);
425    switch (im->cache_entry.space)
426      {
427       case EVAS_COLORSPACE_ARGB8888:
428         if (to_write)
429           im = (RGBA_Image *) evas_cache_image_alone(&im->cache_entry);
430         *image_data = im->image.data;
431         break;
432       case EVAS_COLORSPACE_YCBCR422P601_PL:
433       case EVAS_COLORSPACE_YCBCR422P709_PL:
434         *image_data = im->cs.data;
435         break;
436       default:
437         abort();
438         break;
439      }
440    return im;
441 }
442
443 static void *
444 eng_image_data_put(void *data, void *image, DATA32 *image_data)
445 {
446    RGBA_Image *im, *im2;
447
448    if (!image) return NULL;
449    im = image;
450    switch (im->cache_entry.space)
451      {
452       case EVAS_COLORSPACE_ARGB8888:
453         if (image_data != im->image.data)
454           {
455              int w, h;
456
457              w = im->cache_entry.w;
458              h = im->cache_entry.h;
459              im2 = eng_image_new_from_data(data, w, h, image_data,
460                                            eng_image_alpha_get(data, image),
461                                            eng_image_colorspace_get(data, image));
462              evas_cache_image_drop(&im->cache_entry);
463              im = im2;
464           }
465         break;
466       case EVAS_COLORSPACE_YCBCR422P601_PL:
467       case EVAS_COLORSPACE_YCBCR422P709_PL:
468         if (image_data != im->cs.data)
469           {
470              if (im->cs.data)
471                {
472                   if (!im->cs.no_free) free(im->cs.data);
473                }
474              im->cs.data = image_data;
475              evas_common_image_colorspace_dirty(im);
476           }
477         break;
478       default:
479         abort();
480         break;
481      }
482    return im;
483 }
484
485 static void
486 eng_image_data_preload_request(void *data __UNUSED__, void *image, const void *target)
487 {
488    RGBA_Image *im = image;
489
490    if (!im) return ;
491    evas_cache_image_preload_data(&im->cache_entry, target);
492 }
493
494 static void
495 eng_image_data_preload_cancel(void *data __UNUSED__, void *image, const void *target)
496 {
497    RGBA_Image *im = image;
498
499    if (!im) return ;
500    evas_cache_image_preload_cancel(&im->cache_entry, target);
501 }
502
503 static void
504 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)
505 {
506    RGBA_Image *im;
507
508    if (!image) return;
509    im = image;
510 #ifdef BUILD_PIPE_RENDER
511    if ((cpunum > 1)
512 #ifdef EVAS_FRAME_QUEUING
513         && evas_common_frameq_enabled()
514 #endif
515         )
516      {
517         evas_common_rgba_image_scalecache_prepare((Image_Entry *)(im), 
518                                                   surface, context, smooth,
519                                                   src_x, src_y, src_w, src_h,
520                                                   dst_x, dst_y, dst_w, dst_h);
521         
522         evas_common_pipe_image_draw(im, surface, context, smooth,
523                                     src_x, src_y, src_w, src_h,
524                                     dst_x, dst_y, dst_w, dst_h);
525      }
526    else
527 #endif
528      {
529 //        if (im->cache_entry.space == EVAS_COLORSPACE_ARGB8888)
530 //          evas_cache_image_load_data(&im->cache_entry);
531 //        evas_common_image_colorspace_normalize(im);
532         evas_common_rgba_image_scalecache_prepare(&im->cache_entry, surface, context, smooth,
533                                                   src_x, src_y, src_w, src_h,
534                                                   dst_x, dst_y, dst_w, dst_h);
535         evas_common_rgba_image_scalecache_do(&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 /*        
539         if (smooth)
540           evas_common_scale_rgba_in_to_out_clip_smooth(im, surface, context,
541                                                        src_x, src_y, src_w, src_h,
542                                                        dst_x, dst_y, dst_w, dst_h);
543         else
544           evas_common_scale_rgba_in_to_out_clip_sample(im, surface, context,
545                                                        src_x, src_y, src_w, src_h,
546                                                        dst_x, dst_y, dst_w, dst_h);
547  */
548         evas_common_cpu_end_opt();
549      }
550 }
551
552 static void
553 eng_image_map_draw(void *data __UNUSED__, void *context, void *surface, void *image, int npoints, RGBA_Map_Point *p, int smooth, int level)
554 {
555    RGBA_Image *im;
556
557    if (!image) return;
558    if (npoints < 3) return;
559    im = image;
560
561    if ((p[0].x == p[3].x) &&
562        (p[1].x == p[2].x) &&
563        (p[0].y == p[1].y) &&
564        (p[3].y == p[2].y) &&
565        (p[0].x <= p[1].x) &&
566        (p[0].y <= p[2].y) &&
567        (p[0].u == 0) &&
568        (p[0].v == 0) &&
569        (p[1].u == (int)(im->cache_entry.w << FP)) &&
570        (p[1].v == 0) &&
571        (p[2].u == (int)(im->cache_entry.w << FP)) &&
572        (p[2].v == (int)(im->cache_entry.h << FP)) &&
573        (p[3].u == 0) &&
574        (p[3].v == (int)(im->cache_entry.h << FP)) &&
575        (p[0].col == 0xffffffff) &&
576        (p[1].col == 0xffffffff) &&
577        (p[2].col == 0xffffffff) &&
578        (p[3].col == 0xffffffff))
579      {
580         int dx, dy, dw, dh;
581
582         dx = p[0].x >> FP;
583         dy = p[0].y >> FP;
584         dw = (p[2].x >> FP) - dx;
585         dh = (p[2].y >> FP) - dy;
586         eng_image_draw
587           (data, context, surface, image,
588            0, 0, im->cache_entry.w, im->cache_entry.h,
589            dx, dy, dw, dh, smooth);
590      }
591    else
592      {
593 #ifdef BUILD_PIPE_RENDER
594         if ((cpunum > 1)
595 # ifdef EVAS_FRAME_QUEUING
596        && evas_common_frameq_enabled()
597 # endif
598         )
599           evas_common_pipe_map_draw(im, surface, context, npoints, p, smooth, level);
600         else
601 #endif
602           evas_common_map_rgba(im, surface, context, npoints, p, smooth, level);
603      }
604    evas_common_cpu_end_opt();
605
606    if (npoints > 4)
607      {
608         eng_image_map_draw(data, context, surface, image, npoints - 2, p + 2,
609                            smooth, level);
610      }
611 }
612
613 static void *
614 eng_image_map_surface_new(void *data __UNUSED__, int w, int h, int alpha)
615 {
616    void *surface;
617    DATA32 *pixels;
618    surface = evas_cache_image_copied_data(evas_common_image_cache_get(), 
619                                           w, h, NULL, alpha, 
620                                           EVAS_COLORSPACE_ARGB8888);
621    pixels = evas_cache_image_pixels(surface);
622    return surface;
623 }
624
625 static void
626 eng_image_map_surface_free(void *data __UNUSED__, void *surface)
627 {
628    evas_cache_image_drop(surface);
629 }
630
631 static void
632 eng_image_scale_hint_set(void *data __UNUSED__, void *image, int hint)
633 {
634    Image_Entry *im;
635
636    if (!image) return;
637    im = image;
638    im->scale_hint = hint;
639 }
640
641 static int
642 eng_image_scale_hint_get(void *data __UNUSED__, void *image)
643 {
644    Image_Entry *im;
645
646    if (!image) return EVAS_IMAGE_SCALE_HINT_NONE;
647    im = image;
648    return im->scale_hint;
649 }
650
651 static void
652 eng_image_cache_flush(void *data __UNUSED__)
653 {
654    int tmp_size;
655
656    tmp_size = evas_common_image_get_cache();
657    evas_common_image_set_cache(0);
658    evas_common_rgba_image_scalecache_flush();
659    evas_common_image_set_cache(tmp_size);
660 }
661
662 static void
663 eng_image_cache_set(void *data __UNUSED__, int bytes)
664 {
665    evas_common_image_set_cache(bytes);
666    evas_common_rgba_image_scalecache_size_set(bytes);
667 }
668
669 static int
670 eng_image_cache_get(void *data __UNUSED__)
671 {
672    return evas_common_image_get_cache();
673 }
674
675 static void *
676 eng_font_load(void *data __UNUSED__, const char *name, int size,
677       Font_Rend_Flags wanted_rend)
678 {
679    return evas_common_font_load(name, size, wanted_rend);
680 }
681
682 static void *
683 eng_font_memory_load(void *data __UNUSED__, char *name, int size, const void *fdata, int fdata_size, Font_Rend_Flags wanted_rend)
684 {
685    return evas_common_font_memory_load(name, size, fdata, fdata_size,
686          wanted_rend);
687 }
688
689 static void *
690 eng_font_add(void *data __UNUSED__, void *font, const char *name, int size, Font_Rend_Flags wanted_rend)
691 {
692    return evas_common_font_add(font, name, size, wanted_rend);
693 }
694
695 static void *
696 eng_font_memory_add(void *data __UNUSED__, void *font, char *name, int size, const void *fdata, int fdata_size, Font_Rend_Flags wanted_rend)
697 {
698    return evas_common_font_memory_add(font, name, size, fdata, fdata_size,
699          wanted_rend);
700 }
701
702 static void
703 eng_font_free(void *data __UNUSED__, void *font)
704 {
705    evas_common_font_free(font);
706 }
707
708 static int
709 eng_font_ascent_get(void *data __UNUSED__, void *font)
710 {
711    return evas_common_font_ascent_get(font);
712 }
713
714 static int
715 eng_font_descent_get(void *data __UNUSED__, void *font)
716 {
717    return evas_common_font_descent_get(font);
718 }
719
720 static int
721 eng_font_max_ascent_get(void *data __UNUSED__, void *font)
722 {
723    return evas_common_font_max_ascent_get(font);
724 }
725
726 static int
727 eng_font_max_descent_get(void *data __UNUSED__, void *font)
728 {
729    return evas_common_font_max_descent_get(font);
730 }
731
732 static void
733 eng_font_string_size_get(void *data __UNUSED__, void *font, const Evas_Text_Props *text_props, int *w, int *h)
734 {
735    evas_common_font_query_size(font, text_props, w, h);
736 }
737
738 static int
739 eng_font_inset_get(void *data __UNUSED__, void *font, const Evas_Text_Props *text_props)
740 {
741    return evas_common_font_query_inset(font, text_props);
742 }
743
744 static int
745 eng_font_right_inset_get(void *data __UNUSED__, void *font, const Evas_Text_Props *text_props)
746 {
747    return evas_common_font_query_right_inset(font, text_props);
748 }
749
750 static int
751 eng_font_h_advance_get(void *data __UNUSED__, void *font, const Evas_Text_Props *text_props)
752 {
753    int h, v;
754
755    evas_common_font_query_advance(font, text_props, &h, &v);
756    return h;
757 }
758
759 static int
760 eng_font_v_advance_get(void *data __UNUSED__, void *font, const Evas_Text_Props *text_props)
761 {
762    int h, v;
763
764    evas_common_font_query_advance(font, text_props, &h, &v);
765    return v;
766 }
767
768 static int
769 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)
770 {
771    return evas_common_font_query_pen_coords(font, text_props, pos, cpen_x, cy, cadv, ch);
772 }
773
774 static Eina_Bool
775 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 pos, size_t len)
776 {
777    Eina_Bool ret;
778    (void) par_props;
779    (void) pos;
780 #if !defined(OT_SUPPORT) && defined(BIDI_SUPPORT)
781    Eina_Unicode *tmp = eina_unicode_strndup(text, len);
782    text = tmp;
783    evas_bidi_shape_string(text, par_props, pos, len);
784 #endif
785    ret = evas_common_text_props_content_create(font, text, text_props, len);
786
787 #if !defined(OT_SUPPORT) && defined(BIDI_SUPPORT)
788    free(tmp);
789 #endif
790    return ret;
791 }
792
793 static int
794 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)
795 {
796    return evas_common_font_query_char_coords(font, text_props, pos, cx, cy, cw, ch);
797 }
798
799 static int
800 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)
801 {
802    return evas_common_font_query_char_at_coords(font, text_props, x, y, cx, cy, cw, ch);
803 }
804
805 static int
806 eng_font_last_up_to_pos(void *data __UNUSED__, void *font, const Evas_Text_Props *text_props, int x, int y)
807 {
808    return evas_common_font_query_last_up_to_pos(font, text_props, x, y);
809 }
810
811 static void
812 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)
813 {
814 #ifdef BUILD_PIPE_RENDER
815    if ((cpunum > 1)
816 #ifdef EVAS_FRAME_QUEUING
817         && evas_common_frameq_enabled()
818 #endif
819         )
820      evas_common_pipe_text_draw(surface, context, font, x, y, text, text_props);
821    else
822 #endif   
823      {
824         evas_common_font_draw(surface, context, font, x, y, text, text_props);
825         evas_common_cpu_end_opt();
826      }
827 }
828
829 static void
830 eng_font_cache_flush(void *data __UNUSED__)
831 {
832    int tmp_size;
833
834    tmp_size = evas_common_font_cache_get();
835    evas_common_font_cache_set(0);
836    evas_common_font_flush();
837    evas_common_font_cache_set(tmp_size);
838 }
839
840 static void
841 eng_font_cache_set(void *data __UNUSED__, int bytes)
842 {
843    evas_common_font_cache_set(bytes);
844 }
845
846 static int
847 eng_font_cache_get(void *data __UNUSED__)
848 {
849    return evas_common_font_cache_get();
850 }
851
852 static void
853 eng_font_hinting_set(void *data __UNUSED__, void *font, int hinting)
854 {
855    evas_common_font_hinting_set(font, hinting);
856 }
857
858 static int
859 eng_font_hinting_can_hint(void *data __UNUSED__, int hinting)
860 {
861    return evas_common_hinting_available(hinting);
862 }
863
864 static Eina_Bool
865 eng_canvas_alpha_get(void *data __UNUSED__, void *info __UNUSED__)
866 {
867    return EINA_TRUE;
868 }
869
870 /*
871  *****
872  **
873  ** ENGINE API
874  **
875  *****
876  */
877
878 static Evas_Func func =
879 {
880    NULL,
881      NULL,
882      NULL,
883      NULL,
884      NULL,
885      NULL,
886      NULL,
887      NULL,
888      NULL,
889      NULL,
890      NULL,
891      NULL,
892      NULL,
893      eng_output_dump,
894      /* draw context virtual methods */
895      eng_context_new,
896      eng_canvas_alpha_get,
897      eng_context_free,
898      eng_context_clip_set,
899      eng_context_clip_clip,
900      eng_context_clip_unset,
901      eng_context_clip_get,
902      eng_context_mask_set,
903      eng_context_mask_unset,
904      eng_context_color_set,
905      eng_context_color_get,
906      eng_context_multiplier_set,
907      eng_context_multiplier_unset,
908      eng_context_multiplier_get,
909      eng_context_cutout_add,
910      eng_context_cutout_clear,
911      eng_context_anti_alias_set,
912      eng_context_anti_alias_get,
913      eng_context_color_interpolation_set,
914      eng_context_color_interpolation_get,
915      eng_context_render_op_set,
916      eng_context_render_op_get,
917      /* rect draw funcs */
918      eng_rectangle_draw,
919      /* line draw funcs */
920      eng_line_draw,
921      /* polygon draw funcs */
922      eng_polygon_point_add,
923      eng_polygon_points_clear,
924      eng_polygon_draw,
925      /* image draw funcs */
926      eng_image_load,
927      eng_image_new_from_data,
928      eng_image_new_from_copied_data,
929      eng_image_free,
930      eng_image_size_get,
931      eng_image_size_set,
932      NULL,
933      eng_image_dirty_region,
934      eng_image_data_get,
935      eng_image_data_put,
936      eng_image_data_preload_request,
937      eng_image_data_preload_cancel,
938      eng_image_alpha_set,
939      eng_image_alpha_get,
940      eng_image_border_set,
941      eng_image_border_get,
942      eng_image_draw,
943      eng_image_comment_get,
944      eng_image_format_get,
945      eng_image_colorspace_set,
946      eng_image_colorspace_get,
947      eng_image_mask_create,
948      eng_image_native_set,
949      eng_image_native_get,
950      /* image cache funcs */
951      eng_image_cache_flush,
952      eng_image_cache_set,
953      eng_image_cache_get,
954      /* font draw functions */
955      eng_font_load,
956      eng_font_memory_load,
957      eng_font_add,
958      eng_font_memory_add,
959      eng_font_free,
960      eng_font_ascent_get,
961      eng_font_descent_get,
962      eng_font_max_ascent_get,
963      eng_font_max_descent_get,
964      eng_font_string_size_get,
965      eng_font_inset_get,
966      eng_font_h_advance_get,
967      eng_font_v_advance_get,
968      eng_font_char_coords_get,
969      eng_font_char_at_coords_get,
970      eng_font_draw,
971      /* font cache functions */
972      eng_font_cache_flush,
973      eng_font_cache_set,
974      eng_font_cache_get,
975      /* font hinting functions */
976      eng_font_hinting_set,
977      eng_font_hinting_can_hint,
978      eng_image_scale_hint_set,
979      eng_image_scale_hint_get,
980      /* more font draw functions */
981      eng_font_last_up_to_pos,
982      eng_image_map_draw,
983      eng_image_map_surface_new,
984      eng_image_map_surface_free,
985      NULL, // eng_image_content_hint_set - software doesn't use it
986      NULL, // eng_image_content_hint_get - software doesn't use it
987      eng_font_pen_coords_get,
988      eng_font_text_props_info_create,
989      eng_font_right_inset_get,
990      NULL, // FIXME: need software mesa for gl rendering <- gl_surface_create
991      NULL, // FIXME: need software mesa for gl rendering <- gl_surface_destroy
992      NULL, // FIXME: need software mesa for gl rendering <- gl_context_create
993      NULL, // FIXME: need software mesa for gl rendering <- gl_context_destroy
994      NULL, // FIXME: need software mesa for gl rendering <- gl_make_current
995      NULL, // FIXME: need software mesa for gl rendering <- gl_proc_address_get
996      NULL  // FIXME: need software mesa for gl rendering <- gl_native_surface_get
997     /* FUTURE software generic calls go here */
998 };
999
1000 /*
1001  *****
1002  **
1003  ** MODULE ACCESSIBLE API API
1004  **
1005  *****
1006  */
1007
1008 static int
1009 module_open(Evas_Module *em)
1010 {
1011    if (!em) return 0;
1012    _evas_soft_gen_log_dom = eina_log_domain_register
1013      ("evas-software_generic", EVAS_DEFAULT_LOG_COLOR);
1014    if(_evas_soft_gen_log_dom<0)
1015      {
1016         EINA_LOG_ERR("Can not create a module log domain.");
1017         return 0;
1018      }
1019    em->functions = (void *)(&func);
1020    cpunum = eina_cpu_count();
1021    return 1;
1022 }
1023
1024 static void
1025 module_close(Evas_Module *em __UNUSED__)
1026 {
1027   eina_log_domain_unregister(_evas_soft_gen_log_dom);
1028 }
1029
1030 static Evas_Module_Api evas_modapi =
1031 {
1032    EVAS_MODULE_API_VERSION,
1033    "software_generic",
1034    "none",
1035    {
1036      module_open,
1037      module_close
1038    }
1039 };
1040
1041 EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_ENGINE, engine, software_generic);
1042
1043 #ifndef EVAS_STATIC_BUILD_SOFTWARE_GENERIC
1044 EVAS_EINA_MODULE_DEFINE(engine, software_generic);
1045 #endif