1 #include "evas_common.h" /* Also includes international specific stuff */
2 #include "evas_private.h"
11 static int cpunum = 0;
12 static int _evas_soft_gen_log_dom = -1;
15 eng_output_dump(void *data __UNUSED__)
17 evas_common_image_image_all_unload();
18 evas_common_font_font_all_unload();
22 eng_context_new(void *data __UNUSED__)
24 return evas_common_draw_context_new();
28 eng_context_free(void *data __UNUSED__, void *context)
30 evas_common_draw_context_free(context);
34 eng_context_clip_set(void *data __UNUSED__, void *context, int x, int y, int w, int h)
36 evas_common_draw_context_set_clip(context, x, y, w, h);
40 eng_context_clip_clip(void *data __UNUSED__, void *context, int x, int y, int w, int h)
42 evas_common_draw_context_clip_clip(context, x, y, w, h);
46 eng_context_clip_unset(void *data __UNUSED__, void *context)
48 evas_common_draw_context_unset_clip(context);
52 eng_context_clip_get(void *data __UNUSED__, void *context, int *x, int *y, int *w, int *h)
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;
62 eng_context_color_set(void *data __UNUSED__, void *context, int r, int g, int b, int a)
64 evas_common_draw_context_set_color(context, r, g, b, a);
68 eng_context_color_get(void *data __UNUSED__, void *context, int *r, int *g, int *b, int *a)
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));
78 eng_context_multiplier_set(void *data __UNUSED__, void *context, int r, int g, int b, int a)
80 evas_common_draw_context_set_multiplier(context, r, g, b, a);
84 eng_context_multiplier_unset(void *data __UNUSED__, void *context)
86 evas_common_draw_context_unset_multiplier(context);
90 eng_context_multiplier_get(void *data __UNUSED__, void *context, int *r, int *g, int *b, int *a)
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;
100 eng_context_cutout_add(void *data __UNUSED__, void *context, int x, int y, int w, int h)
102 evas_common_draw_context_add_cutout(context, x, y, w, h);
106 eng_context_cutout_clear(void *data __UNUSED__, void *context)
108 evas_common_draw_context_clear_cutouts(context);
112 eng_context_anti_alias_set(void *data __UNUSED__, void *context, unsigned char aa)
114 evas_common_draw_context_set_anti_alias(context, aa);
118 eng_context_anti_alias_get(void *data __UNUSED__, void *context)
120 return ((RGBA_Draw_Context *)context)->anti_alias;
124 eng_context_color_interpolation_set(void *data __UNUSED__, void *context, int color_space)
126 evas_common_draw_context_set_color_interpolation(context, color_space);
130 eng_context_color_interpolation_get(void *data __UNUSED__, void *context)
132 return ((RGBA_Draw_Context *)context)->interpolation.color_space;
136 eng_context_render_op_set(void *data __UNUSED__, void *context, int op)
138 evas_common_draw_context_set_render_op(context, op);
142 eng_context_render_op_get(void *data __UNUSED__, void *context)
144 return ((RGBA_Draw_Context *)context)->render_op;
150 eng_rectangle_draw(void *data __UNUSED__, void *context, void *surface, int x, int y, int w, int h)
152 #ifdef BUILD_PIPE_RENDER
154 #ifdef EVAS_FRAME_QUEUING
155 && evas_common_frameq_enabled()
158 evas_common_pipe_rectangle_draw(surface, context, x, y, w, h);
162 evas_common_rectangle_draw(surface, context, x, y, w, h);
163 evas_common_cpu_end_opt();
168 eng_line_draw(void *data __UNUSED__, void *context, void *surface, int x1, int y1, int x2, int y2)
170 #ifdef BUILD_PIPE_RENDER
172 #ifdef EVAS_FRAME_QUEUING
173 && evas_common_frameq_enabled()
176 evas_common_pipe_line_draw(surface, context, x1, y1, x2, y2);
180 evas_common_line_draw(surface, context, x1, y1, x2, y2);
181 evas_common_cpu_end_opt();
186 eng_polygon_point_add(void *data __UNUSED__, void *context __UNUSED__, void *polygon, int x, int y)
188 return evas_common_polygon_point_add(polygon, x, y);
192 eng_polygon_points_clear(void *data __UNUSED__, void *context __UNUSED__, void *polygon)
194 return evas_common_polygon_points_clear(polygon);
198 eng_polygon_draw(void *data __UNUSED__, void *context, void *surface, void *polygon, int x, int y)
200 #ifdef BUILD_PIPE_RENDER
202 #ifdef EVAS_FRAME_QUEUING
203 && evas_common_frameq_enabled()
206 evas_common_pipe_poly_draw(surface, context, polygon, x, y);
210 evas_common_polygon_draw(surface, context, polygon, x, y);
211 evas_common_cpu_end_opt();
216 eng_image_alpha_get(void *data __UNUSED__, void *image)
220 if (!image) return 1;
224 case EVAS_COLORSPACE_ARGB8888:
225 if (im->flags.alpha) return 1;
233 eng_image_colorspace_get(void *data __UNUSED__, void *image)
237 if (!image) return EVAS_COLORSPACE_ARGB8888;
243 eng_image_alpha_set(void *data __UNUSED__, void *image, int has_alpha)
247 if (!image) return NULL;
249 if (im->cache_entry.space != EVAS_COLORSPACE_ARGB8888)
251 im->cache_entry.flags.alpha = 0;
254 im = (RGBA_Image *) evas_cache_image_alone(&im->cache_entry);
255 evas_common_image_colorspace_dirty(im);
257 im->cache_entry.flags.alpha = has_alpha ? 1 : 0;
262 eng_image_border_set(void *data __UNUSED__, void *image, int l __UNUSED__, int r __UNUSED__, int t __UNUSED__, int b __UNUSED__)
271 eng_image_border_get(void *data __UNUSED__, void *image, int *l __UNUSED__, int *r __UNUSED__, int *t __UNUSED__, int *b __UNUSED__)
279 eng_image_comment_get(void *data __UNUSED__, void *image, char *key __UNUSED__)
283 if (!image) return NULL;
285 return im->info.comment;
289 eng_image_format_get(void *data __UNUSED__, void *image __UNUSED__)
295 eng_image_colorspace_set(void *data __UNUSED__, void *image, int cspace)
301 evas_cache_image_colorspace(im, cspace);
305 eng_image_native_set(void *data __UNUSED__, void *image, void *native __UNUSED__)
311 eng_image_native_get(void *data __UNUSED__, void *image __UNUSED__)
317 eng_image_load(void *data __UNUSED__, const char *file, const char *key, int *error, Evas_Image_Load_Opts *lo)
319 *error = EVAS_LOAD_ERROR_NONE;
320 return evas_common_load_image_from_file(file, key, lo, error);
324 eng_image_new_from_data(void *data __UNUSED__, int w, int h, DATA32 *image_data, int alpha, int cspace)
326 return evas_cache_image_data(evas_common_image_cache_get(), w, h, image_data, alpha, cspace);
330 eng_image_new_from_copied_data(void *data __UNUSED__, int w, int h, DATA32 *image_data, int alpha, int cspace)
332 return evas_cache_image_copied_data(evas_common_image_cache_get(), w, h, image_data, alpha, cspace);
336 eng_image_free(void *data __UNUSED__, void *image)
338 evas_cache_image_drop(image);
342 eng_image_size_get(void *data __UNUSED__, void *image, int *w, int *h)
352 eng_image_size_set(void *data __UNUSED__, void *image, int w, int h)
357 return evas_cache_image_size_set(image, w, h);
361 eng_image_dirty_region(void *data __UNUSED__, void *image, int x, int y, int w, int h)
363 Image_Entry *im = image;
365 if (!image) return NULL;
366 return evas_cache_image_dirty(im, x, y, w, h);
370 eng_image_data_get(void *data __UNUSED__, void *image, int to_write, DATA32 **image_data)
380 evas_cache_image_load_data(&im->cache_entry);
381 switch (im->cache_entry.space)
383 case EVAS_COLORSPACE_ARGB8888:
385 im = (RGBA_Image *) evas_cache_image_alone(&im->cache_entry);
386 *image_data = im->image.data;
388 case EVAS_COLORSPACE_YCBCR422P601_PL:
389 case EVAS_COLORSPACE_YCBCR422P709_PL:
390 *image_data = im->cs.data;
400 eng_image_data_put(void *data, void *image, DATA32 *image_data)
402 RGBA_Image *im, *im2;
404 if (!image) return NULL;
406 switch (im->cache_entry.space)
408 case EVAS_COLORSPACE_ARGB8888:
409 if (image_data != im->image.data)
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);
422 case EVAS_COLORSPACE_YCBCR422P601_PL:
423 case EVAS_COLORSPACE_YCBCR422P709_PL:
424 if (image_data != im->cs.data)
428 if (!im->cs.no_free) free(im->cs.data);
430 im->cs.data = image_data;
431 evas_common_image_colorspace_dirty(im);
442 eng_image_data_preload_request(void *data __UNUSED__, void *image, const void *target)
444 RGBA_Image *im = image;
447 evas_cache_image_preload_data(&im->cache_entry, target);
451 eng_image_data_preload_cancel(void *data __UNUSED__, void *image, const void *target)
453 RGBA_Image *im = image;
456 evas_cache_image_preload_cancel(&im->cache_entry, target);
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)
466 #ifdef BUILD_PIPE_RENDER
468 #ifdef EVAS_FRAME_QUEUING
469 && evas_common_frameq_enabled()
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);
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);
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);
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);
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);
504 evas_common_cpu_end_opt();
509 eng_image_map4_draw(void *data __UNUSED__, void *context, void *surface, void *image, RGBA_Map_Point *p, int smooth, int level)
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) &&
523 (p[1].u == (int)(im->cache_entry.w << FP)) &&
525 (p[2].u == (int)(im->cache_entry.w << FP)) &&
526 (p[2].v == (int)(im->cache_entry.h << FP)) &&
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))
538 dw = (p[2].x >> FP) - dx;
539 dh = (p[2].y >> FP) - dy;
541 (data, context, surface, image,
542 0, 0, im->cache_entry.w, im->cache_entry.h,
543 dx, dy, dw, dh, smooth);
547 #ifdef BUILD_PIPE_RENDER
549 # ifdef EVAS_FRAME_QUEUING
550 && evas_common_frameq_enabled()
553 evas_common_pipe_map4_draw(im, surface, context, p, smooth, level);
556 evas_common_map4_rgba(im, surface, context, p, smooth, level);
558 evas_common_cpu_end_opt();
562 eng_image_map_surface_new(void *data __UNUSED__, int w, int h, int alpha)
566 surface = evas_cache_image_copied_data(evas_common_image_cache_get(),
568 EVAS_COLORSPACE_ARGB8888);
569 pixels = evas_cache_image_pixels(surface);
574 eng_image_map_surface_free(void *data __UNUSED__, void *surface)
576 evas_cache_image_drop(surface);
580 eng_image_scale_hint_set(void *data __UNUSED__, void *image, int hint)
586 im->scale_hint = hint;
590 eng_image_scale_hint_get(void *data __UNUSED__, void *image)
594 if (!image) return EVAS_IMAGE_SCALE_HINT_NONE;
596 return im->scale_hint;
600 eng_image_cache_flush(void *data __UNUSED__)
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);
611 eng_image_cache_set(void *data __UNUSED__, int bytes)
613 evas_common_image_set_cache(bytes);
614 evas_common_rgba_image_scalecache_size_set(bytes);
618 eng_image_cache_get(void *data __UNUSED__)
620 return evas_common_image_get_cache();
624 eng_font_load(void *data __UNUSED__, const char *name, int size)
626 return evas_common_font_load(name, size);
630 eng_font_memory_load(void *data __UNUSED__, char *name, int size, const void *fdata, int fdata_size)
632 return evas_common_font_memory_load(name, size, fdata, fdata_size);
636 eng_font_add(void *data __UNUSED__, void *font, const char *name, int size)
638 return evas_common_font_add(font, name, size);
642 eng_font_memory_add(void *data __UNUSED__, void *font, char *name, int size, const void *fdata, int fdata_size)
644 return evas_common_font_memory_add(font, name, size, fdata, fdata_size);
648 eng_font_free(void *data __UNUSED__, void *font)
650 evas_common_font_free(font);
654 eng_font_ascent_get(void *data __UNUSED__, void *font)
656 return evas_common_font_ascent_get(font);
660 eng_font_descent_get(void *data __UNUSED__, void *font)
662 return evas_common_font_descent_get(font);
666 eng_font_max_ascent_get(void *data __UNUSED__, void *font)
668 return evas_common_font_max_ascent_get(font);
672 eng_font_max_descent_get(void *data __UNUSED__, void *font)
674 return evas_common_font_max_descent_get(font);
678 eng_font_string_size_get(void *data __UNUSED__, void *font, const Eina_Unicode *text, const Evas_BiDi_Props *intl_props, int *w, int *h)
680 evas_common_font_query_size(font, text, intl_props, w, h);
684 eng_font_inset_get(void *data __UNUSED__, void *font, const Eina_Unicode *text)
686 return evas_common_font_query_inset(font, text);
690 eng_font_h_advance_get(void *data __UNUSED__, void *font, const Eina_Unicode *text, const Evas_BiDi_Props *intl_props)
694 evas_common_font_query_advance(font, text, intl_props, &h, &v);
699 eng_font_v_advance_get(void *data __UNUSED__, void *font, const Eina_Unicode *text, const Evas_BiDi_Props *intl_props)
703 evas_common_font_query_advance(font, text, intl_props, &h, &v);
708 eng_font_pen_coords_get(void *data __UNUSED__, void *font, const Eina_Unicode *text, const Evas_BiDi_Props *intl_props, int pos, int *cpen_x, int *cy, int *cadv, int *ch)
710 return evas_common_font_query_pen_coords(font, text, intl_props, pos, cpen_x, cy, cadv, ch);
714 eng_font_char_coords_get(void *data __UNUSED__, void *font, const Eina_Unicode *text, const Evas_BiDi_Props *intl_props, int pos, int *cx, int *cy, int *cw, int *ch)
716 return evas_common_font_query_char_coords(font, text, intl_props, pos, cx, cy, cw, ch);
720 eng_font_char_at_coords_get(void *data __UNUSED__, void *font, const Eina_Unicode *text, const Evas_BiDi_Props *intl_props, int x, int y, int *cx, int *cy, int *cw, int *ch)
722 return evas_common_font_query_char_at_coords(font, text, intl_props, x, y, cx, cy, cw, ch);
726 eng_font_last_up_to_pos(void *data __UNUSED__, void *font, const Eina_Unicode *text, const Evas_BiDi_Props *intl_props, int x, int y)
728 return evas_common_font_query_last_up_to_pos(font, text, intl_props, x, y);
732 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_BiDi_Props *intl_props)
734 #ifdef BUILD_PIPE_RENDER
736 #ifdef EVAS_FRAME_QUEUING
737 && evas_common_frameq_enabled()
740 evas_common_pipe_text_draw(surface, context, font, x, y, text, intl_props);
744 evas_common_font_draw(surface, context, font, x, y, text, intl_props);
745 evas_common_cpu_end_opt();
750 eng_font_cache_flush(void *data __UNUSED__)
752 evas_common_font_flush();
756 eng_font_cache_set(void *data __UNUSED__, int bytes)
758 evas_common_font_cache_set(bytes);
762 eng_font_cache_get(void *data __UNUSED__)
764 return evas_common_font_cache_get();
768 eng_font_hinting_set(void *data __UNUSED__, void *font, int hinting)
770 evas_common_font_hinting_set(font, hinting);
774 eng_font_hinting_can_hint(void *data __UNUSED__, int hinting)
776 return evas_common_hinting_available(hinting);
780 eng_canvas_alpha_get(void *data __UNUSED__, void *info __UNUSED__)
793 static Evas_Func func =
809 /* draw context virtual methods */
811 eng_canvas_alpha_get,
813 eng_context_clip_set,
814 eng_context_clip_clip,
815 eng_context_clip_unset,
816 eng_context_clip_get,
817 eng_context_color_set,
818 eng_context_color_get,
819 eng_context_multiplier_set,
820 eng_context_multiplier_unset,
821 eng_context_multiplier_get,
822 eng_context_cutout_add,
823 eng_context_cutout_clear,
824 eng_context_anti_alias_set,
825 eng_context_anti_alias_get,
826 eng_context_color_interpolation_set,
827 eng_context_color_interpolation_get,
828 eng_context_render_op_set,
829 eng_context_render_op_get,
830 /* rect draw funcs */
832 /* line draw funcs */
834 /* polygon draw funcs */
835 eng_polygon_point_add,
836 eng_polygon_points_clear,
838 /* image draw funcs */
840 eng_image_new_from_data,
841 eng_image_new_from_copied_data,
846 eng_image_dirty_region,
849 eng_image_data_preload_request,
850 eng_image_data_preload_cancel,
853 eng_image_border_set,
854 eng_image_border_get,
856 eng_image_comment_get,
857 eng_image_format_get,
858 eng_image_colorspace_set,
859 eng_image_colorspace_get,
860 eng_image_native_set,
861 eng_image_native_get,
862 /* image cache funcs */
863 eng_image_cache_flush,
866 /* font draw functions */
868 eng_font_memory_load,
873 eng_font_descent_get,
874 eng_font_max_ascent_get,
875 eng_font_max_descent_get,
876 eng_font_string_size_get,
878 eng_font_h_advance_get,
879 eng_font_v_advance_get,
880 eng_font_char_coords_get,
881 eng_font_char_at_coords_get,
883 /* font cache functions */
884 eng_font_cache_flush,
887 /* font hinting functions */
888 eng_font_hinting_set,
889 eng_font_hinting_can_hint,
890 eng_image_scale_hint_set,
891 eng_image_scale_hint_get,
892 /* more font draw functions */
893 eng_font_last_up_to_pos,
894 /* FUTURE software generic calls go here (done) */
896 eng_image_map_surface_new,
897 eng_image_map_surface_free,
898 NULL, // eng_image_content_hint_set - software doesn't use it
899 NULL, // eng_image_content_hint_get - software doesn't use it
900 eng_font_pen_coords_get
901 /* FUTURE software generic calls go here */
907 ** MODULE ACCESSIBLE API API
913 module_open(Evas_Module *em)
916 _evas_soft_gen_log_dom = eina_log_domain_register
917 ("evas-software_generic", EVAS_DEFAULT_LOG_COLOR);
918 if(_evas_soft_gen_log_dom<0)
920 EINA_LOG_ERR("Can not create a module log domain.");
923 em->functions = (void *)(&func);
924 cpunum = eina_cpu_count();
929 module_close(Evas_Module *em __UNUSED__)
931 eina_log_domain_unregister(_evas_soft_gen_log_dom);
934 static Evas_Module_Api evas_modapi =
936 EVAS_MODULE_API_VERSION,
945 EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_ENGINE, engine, software_generic);
947 #ifndef EVAS_STATIC_BUILD_SOFTWARE_GENERIC
948 EVAS_EINA_MODULE_DEFINE(engine, software_generic);