Masking: Push a bit more arbitrary clipping
[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              evas_common_image_colorspace_dirty(im);
475           }
476         break;
477       default:
478         abort();
479         break;
480      }
481    return im;
482 }
483
484 static void
485 eng_image_data_preload_request(void *data __UNUSED__, void *image, const void *target)
486 {
487    RGBA_Image *im = image;
488
489    if (!im) return ;
490    evas_cache_image_preload_data(&im->cache_entry, target);
491 }
492
493 static void
494 eng_image_data_preload_cancel(void *data __UNUSED__, void *image, const void *target)
495 {
496    RGBA_Image *im = image;
497
498    if (!im) return ;
499    evas_cache_image_preload_cancel(&im->cache_entry, target);
500 }
501
502 static void
503 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)
504 {
505    RGBA_Image *im;
506
507    if (!image) return;
508    im = image;
509 #ifdef BUILD_PIPE_RENDER
510    if ((cpunum > 1)
511 #ifdef EVAS_FRAME_QUEUING
512         && evas_common_frameq_enabled()
513 #endif
514         )
515      {
516         evas_common_rgba_image_scalecache_prepare((Image_Entry *)(im), 
517                                                   surface, context, smooth,
518                                                   src_x, src_y, src_w, src_h,
519                                                   dst_x, dst_y, dst_w, dst_h);
520         
521         evas_common_pipe_image_draw(im, surface, context, smooth,
522                                     src_x, src_y, src_w, src_h,
523                                     dst_x, dst_y, dst_w, dst_h);
524      }
525    else
526 #endif
527      {
528 //        if (im->cache_entry.space == EVAS_COLORSPACE_ARGB8888)
529 //          evas_cache_image_load_data(&im->cache_entry);
530 //        evas_common_image_colorspace_normalize(im);
531         evas_common_rgba_image_scalecache_prepare(&im->cache_entry, surface, context, smooth,
532                                                   src_x, src_y, src_w, src_h,
533                                                   dst_x, dst_y, dst_w, dst_h);
534         evas_common_rgba_image_scalecache_do(&im->cache_entry, surface, context, smooth,
535                                              src_x, src_y, src_w, src_h,
536                                              dst_x, dst_y, dst_w, dst_h);
537 /*        
538         if (smooth)
539           evas_common_scale_rgba_in_to_out_clip_smooth(im, surface, context,
540                                                        src_x, src_y, src_w, src_h,
541                                                        dst_x, dst_y, dst_w, dst_h);
542         else
543           evas_common_scale_rgba_in_to_out_clip_sample(im, surface, context,
544                                                        src_x, src_y, src_w, src_h,
545                                                        dst_x, dst_y, dst_w, dst_h);
546  */
547         evas_common_cpu_end_opt();
548      }
549 }
550
551 static void
552 eng_image_map_draw(void *data __UNUSED__, void *context, void *surface, void *image, int npoints, RGBA_Map_Point *p, int smooth, int level)
553 {
554    RGBA_Image *im;
555
556    if (!image) return;
557    if (npoints < 3) return;
558    im = image;
559
560    if ((p[0].x == p[3].x) &&
561        (p[1].x == p[2].x) &&
562        (p[0].y == p[1].y) &&
563        (p[3].y == p[2].y) &&
564        (p[0].x <= p[1].x) &&
565        (p[0].y <= p[2].y) &&
566        (p[0].u == 0) &&
567        (p[0].v == 0) &&
568        (p[1].u == (int)(im->cache_entry.w << FP)) &&
569        (p[1].v == 0) &&
570        (p[2].u == (int)(im->cache_entry.w << FP)) &&
571        (p[2].v == (int)(im->cache_entry.h << FP)) &&
572        (p[3].u == 0) &&
573        (p[3].v == (int)(im->cache_entry.h << FP)) &&
574        (p[0].col == 0xffffffff) &&
575        (p[1].col == 0xffffffff) &&
576        (p[2].col == 0xffffffff) &&
577        (p[3].col == 0xffffffff))
578      {
579         int dx, dy, dw, dh;
580
581         dx = p[0].x >> FP;
582         dy = p[0].y >> FP;
583         dw = (p[2].x >> FP) - dx;
584         dh = (p[2].y >> FP) - dy;
585         eng_image_draw
586           (data, context, surface, image,
587            0, 0, im->cache_entry.w, im->cache_entry.h,
588            dx, dy, dw, dh, smooth);
589      }
590    else
591      {
592 #ifdef BUILD_PIPE_RENDER
593         if ((cpunum > 1)
594 # ifdef EVAS_FRAME_QUEUING
595        && evas_common_frameq_enabled()
596 # endif
597         )
598           evas_common_pipe_map_draw(im, surface, context, npoints, p, smooth, level);
599         else
600 #endif
601           evas_common_map_rgba(im, surface, context, npoints, p, smooth, level);
602      }
603    evas_common_cpu_end_opt();
604
605    if (npoints > 4)
606      {
607         eng_image_map_draw(data, context, surface, image, npoints - 2, p + 2,
608                            smooth, level);
609      }
610 }
611
612 static void *
613 eng_image_map_surface_new(void *data __UNUSED__, int w, int h, int alpha)
614 {
615    void *surface;
616    DATA32 *pixels;
617    surface = evas_cache_image_copied_data(evas_common_image_cache_get(), 
618                                           w, h, NULL, alpha, 
619                                           EVAS_COLORSPACE_ARGB8888);
620    pixels = evas_cache_image_pixels(surface);
621    return surface;
622 }
623
624 static void
625 eng_image_map_surface_free(void *data __UNUSED__, void *surface)
626 {
627    evas_cache_image_drop(surface);
628 }
629
630 static void
631 eng_image_scale_hint_set(void *data __UNUSED__, void *image, int hint)
632 {
633    Image_Entry *im;
634
635    if (!image) return;
636    im = image;
637    im->scale_hint = hint;
638 }
639
640 static int
641 eng_image_scale_hint_get(void *data __UNUSED__, void *image)
642 {
643    Image_Entry *im;
644
645    if (!image) return EVAS_IMAGE_SCALE_HINT_NONE;
646    im = image;
647    return im->scale_hint;
648 }
649
650 static void
651 eng_image_cache_flush(void *data __UNUSED__)
652 {
653    int tmp_size;
654
655    tmp_size = evas_common_image_get_cache();
656    evas_common_image_set_cache(0);
657    evas_common_rgba_image_scalecache_flush();
658    evas_common_image_set_cache(tmp_size);
659 }
660
661 static void
662 eng_image_cache_set(void *data __UNUSED__, int bytes)
663 {
664    evas_common_image_set_cache(bytes);
665    evas_common_rgba_image_scalecache_size_set(bytes);
666 }
667
668 static int
669 eng_image_cache_get(void *data __UNUSED__)
670 {
671    return evas_common_image_get_cache();
672 }
673
674 static void *
675 eng_font_load(void *data __UNUSED__, const char *name, int size)
676 {
677    return evas_common_font_load(name, size);
678 }
679
680 static void *
681 eng_font_memory_load(void *data __UNUSED__, char *name, int size, const void *fdata, int fdata_size)
682 {
683    return evas_common_font_memory_load(name, size, fdata, fdata_size);
684 }
685
686 static void *
687 eng_font_add(void *data __UNUSED__, void *font, const char *name, int size)
688 {
689    return evas_common_font_add(font, name, size);
690 }
691
692 static void *
693 eng_font_memory_add(void *data __UNUSED__, void *font, char *name, int size, const void *fdata, int fdata_size)
694 {
695    return evas_common_font_memory_add(font, name, size, fdata, fdata_size);
696 }
697
698 static void
699 eng_font_free(void *data __UNUSED__, void *font)
700 {
701    evas_common_font_free(font);
702 }
703
704 static int
705 eng_font_ascent_get(void *data __UNUSED__, void *font)
706 {
707    return evas_common_font_ascent_get(font);
708 }
709
710 static int
711 eng_font_descent_get(void *data __UNUSED__, void *font)
712 {
713    return evas_common_font_descent_get(font);
714 }
715
716 static int
717 eng_font_max_ascent_get(void *data __UNUSED__, void *font)
718 {
719    return evas_common_font_max_ascent_get(font);
720 }
721
722 static int
723 eng_font_max_descent_get(void *data __UNUSED__, void *font)
724 {
725    return evas_common_font_max_descent_get(font);
726 }
727
728 static void
729 eng_font_string_size_get(void *data __UNUSED__, void *font, const Eina_Unicode *text, const Evas_Text_Props *text_props, int *w, int *h)
730 {
731    evas_common_font_query_size(font, text, text_props, w, h);
732 }
733
734 static int
735 eng_font_inset_get(void *data __UNUSED__, void *font, const Evas_Text_Props *text_props)
736 {
737    return evas_common_font_query_inset(font, text_props);
738 }
739
740 static int
741 eng_font_right_inset_get(void *data __UNUSED__, void *font, const Evas_Text_Props *text_props)
742 {
743    return evas_common_font_query_right_inset(font, text_props);
744 }
745
746 static int
747 eng_font_h_advance_get(void *data __UNUSED__, void *font, const Eina_Unicode *text, const Evas_Text_Props *text_props)
748 {
749    int h, v;
750
751    evas_common_font_query_advance(font, text, text_props, &h, &v);
752    return h;
753 }
754
755 static int
756 eng_font_v_advance_get(void *data __UNUSED__, void *font, const Eina_Unicode *text, const Evas_Text_Props *text_props)
757 {
758    int h, v;
759
760    evas_common_font_query_advance(font, text, text_props, &h, &v);
761    return v;
762 }
763
764 static int
765 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)
766 {
767    return evas_common_font_query_pen_coords(font, text, text_props, pos, cpen_x, cy, cadv, ch);
768 }
769
770 static Eina_Bool
771 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)
772 {
773    (void) font;
774    (void) text;
775    (void) text_props;
776    (void) par_props;
777    (void) pos;
778    (void) len;
779 #if !defined(OT_SUPPORT) && defined(BIDI_SUPPORT)
780    evas_bidi_shape_string(text, par_props, pos, len);
781 #endif
782    return evas_common_text_props_content_create(font, text, text_props, len);
783 }
784
785 static int
786 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)
787 {
788    return evas_common_font_query_char_coords(font, text, text_props, pos, cx, cy, cw, ch);
789 }
790
791 static int
792 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)
793 {
794    return evas_common_font_query_char_at_coords(font, text, text_props, x, y, cx, cy, cw, ch);
795 }
796
797 static int
798 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)
799 {
800    return evas_common_font_query_last_up_to_pos(font, text, text_props, x, y);
801 }
802
803 static void
804 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)
805 {
806 #ifdef BUILD_PIPE_RENDER
807    if ((cpunum > 1)
808 #ifdef EVAS_FRAME_QUEUING
809         && evas_common_frameq_enabled()
810 #endif
811         )
812      evas_common_pipe_text_draw(surface, context, font, x, y, text, text_props);
813    else
814 #endif   
815      {
816         evas_common_font_draw(surface, context, font, x, y, text, text_props);
817         evas_common_cpu_end_opt();
818      }
819 }
820
821 static void
822 eng_font_cache_flush(void *data __UNUSED__)
823 {
824    int tmp_size;
825
826    tmp_size = evas_common_font_cache_get();
827    evas_common_font_cache_set(0);
828    evas_common_font_flush();
829    evas_common_font_cache_set(tmp_size);
830 }
831
832 static void
833 eng_font_cache_set(void *data __UNUSED__, int bytes)
834 {
835    evas_common_font_cache_set(bytes);
836 }
837
838 static int
839 eng_font_cache_get(void *data __UNUSED__)
840 {
841    return evas_common_font_cache_get();
842 }
843
844 static void
845 eng_font_hinting_set(void *data __UNUSED__, void *font, int hinting)
846 {
847    evas_common_font_hinting_set(font, hinting);
848 }
849
850 static int
851 eng_font_hinting_can_hint(void *data __UNUSED__, int hinting)
852 {
853    return evas_common_hinting_available(hinting);
854 }
855
856 static Eina_Bool
857 eng_canvas_alpha_get(void *data __UNUSED__, void *info __UNUSED__)
858 {
859    return EINA_TRUE;
860 }
861
862 /*
863  *****
864  **
865  ** ENGINE API
866  **
867  *****
868  */
869
870 static Evas_Func func =
871 {
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      NULL,
885      eng_output_dump,
886      /* draw context virtual methods */
887      eng_context_new,
888      eng_canvas_alpha_get,
889      eng_context_free,
890      eng_context_clip_set,
891      eng_context_clip_clip,
892      eng_context_clip_unset,
893      eng_context_clip_get,
894      eng_context_mask_set,
895      eng_context_mask_unset,
896      eng_context_color_set,
897      eng_context_color_get,
898      eng_context_multiplier_set,
899      eng_context_multiplier_unset,
900      eng_context_multiplier_get,
901      eng_context_cutout_add,
902      eng_context_cutout_clear,
903      eng_context_anti_alias_set,
904      eng_context_anti_alias_get,
905      eng_context_color_interpolation_set,
906      eng_context_color_interpolation_get,
907      eng_context_render_op_set,
908      eng_context_render_op_get,
909      /* rect draw funcs */
910      eng_rectangle_draw,
911      /* line draw funcs */
912      eng_line_draw,
913      /* polygon draw funcs */
914      eng_polygon_point_add,
915      eng_polygon_points_clear,
916      eng_polygon_draw,
917      /* image draw funcs */
918      eng_image_load,
919      eng_image_new_from_data,
920      eng_image_new_from_copied_data,
921      eng_image_free,
922      eng_image_size_get,
923      eng_image_size_set,
924      NULL,
925      eng_image_dirty_region,
926      eng_image_data_get,
927      eng_image_data_put,
928      eng_image_data_preload_request,
929      eng_image_data_preload_cancel,
930      eng_image_alpha_set,
931      eng_image_alpha_get,
932      eng_image_border_set,
933      eng_image_border_get,
934      eng_image_draw,
935      eng_image_comment_get,
936      eng_image_format_get,
937      eng_image_colorspace_set,
938      eng_image_colorspace_get,
939      eng_image_mask_create,
940      eng_image_native_set,
941      eng_image_native_get,
942      /* image cache funcs */
943      eng_image_cache_flush,
944      eng_image_cache_set,
945      eng_image_cache_get,
946      /* font draw functions */
947      eng_font_load,
948      eng_font_memory_load,
949      eng_font_add,
950      eng_font_memory_add,
951      eng_font_free,
952      eng_font_ascent_get,
953      eng_font_descent_get,
954      eng_font_max_ascent_get,
955      eng_font_max_descent_get,
956      eng_font_string_size_get,
957      eng_font_inset_get,
958      eng_font_h_advance_get,
959      eng_font_v_advance_get,
960      eng_font_char_coords_get,
961      eng_font_char_at_coords_get,
962      eng_font_draw,
963      /* font cache functions */
964      eng_font_cache_flush,
965      eng_font_cache_set,
966      eng_font_cache_get,
967      /* font hinting functions */
968      eng_font_hinting_set,
969      eng_font_hinting_can_hint,
970      eng_image_scale_hint_set,
971      eng_image_scale_hint_get,
972      /* more font draw functions */
973      eng_font_last_up_to_pos,
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      NULL, // FIXME: need software mesa for gl rendering <- gl_surface_create
983      NULL, // FIXME: need software mesa for gl rendering <- gl_surface_destroy
984      NULL, // FIXME: need software mesa for gl rendering <- gl_context_create
985      NULL, // FIXME: need software mesa for gl rendering <- gl_context_destroy
986      NULL, // FIXME: need software mesa for gl rendering <- gl_make_current
987      NULL, // FIXME: need software mesa for gl rendering <- gl_proc_address_get
988      NULL  // FIXME: need software mesa for gl rendering <- gl_native_surface_get
989     /* FUTURE software generic calls go here */
990 };
991
992 /*
993  *****
994  **
995  ** MODULE ACCESSIBLE API API
996  **
997  *****
998  */
999
1000 static int
1001 module_open(Evas_Module *em)
1002 {
1003    if (!em) return 0;
1004    _evas_soft_gen_log_dom = eina_log_domain_register
1005      ("evas-software_generic", EVAS_DEFAULT_LOG_COLOR);
1006    if(_evas_soft_gen_log_dom<0)
1007      {
1008         EINA_LOG_ERR("Can not create a module log domain.");
1009         return 0;
1010      }
1011    em->functions = (void *)(&func);
1012    cpunum = eina_cpu_count();
1013    return 1;
1014 }
1015
1016 static void
1017 module_close(Evas_Module *em __UNUSED__)
1018 {
1019   eina_log_domain_unregister(_evas_soft_gen_log_dom);
1020 }
1021
1022 static Evas_Module_Api evas_modapi =
1023 {
1024    EVAS_MODULE_API_VERSION,
1025    "software_generic",
1026    "none",
1027    {
1028      module_open,
1029      module_close
1030    }
1031 };
1032
1033 EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_ENGINE, engine, software_generic);
1034
1035 #ifndef EVAS_STATIC_BUILD_SOFTWARE_GENERIC
1036 EVAS_EINA_MODULE_DEFINE(engine, software_generic);
1037 #endif