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