1 #include "evas_common.h"
2 #include "evas_private.h"
3 #include "evas_common_soft16.h"
13 #define NOT_IMPLEMENTED() \
14 fprintf(stderr, "NOT_IMPLEMENTED: %s() at %s:%d\n", \
15 __FUNCTION__, __FILE__, __LINE__)
18 eng_context_new(void *data)
20 return evas_common_draw_context_new();
24 eng_context_free(void *data, void *context)
26 evas_common_draw_context_free(context);
30 eng_context_clip_set(void *data, void *context, int x, int y, int w, int h)
32 evas_common_draw_context_set_clip(context, x, y, w, h);
36 eng_context_clip_clip(void *data, void *context, int x, int y, int w, int h)
38 evas_common_draw_context_clip_clip(context, x, y, w, h);
42 eng_context_clip_unset(void *data, void *context)
44 evas_common_draw_context_unset_clip(context);
48 eng_context_clip_get(void *data, void *context, int *x, int *y, int *w, int *h)
50 *x = ((RGBA_Draw_Context *)context)->clip.x;
51 *y = ((RGBA_Draw_Context *)context)->clip.y;
52 *w = ((RGBA_Draw_Context *)context)->clip.w;
53 *h = ((RGBA_Draw_Context *)context)->clip.h;
54 return ((RGBA_Draw_Context *)context)->clip.use;
58 eng_context_color_set(void *data, void *context, int r, int g, int b, int a)
60 evas_common_draw_context_set_color(context, r, g, b, a);
64 eng_context_color_get(void *data, void *context, int *r, int *g, int *b, int *a)
66 *r = (int)(R_VAL(&((RGBA_Draw_Context *)context)->col.col));
67 *g = (int)(G_VAL(&((RGBA_Draw_Context *)context)->col.col));
68 *b = (int)(B_VAL(&((RGBA_Draw_Context *)context)->col.col));
69 *a = (int)(A_VAL(&((RGBA_Draw_Context *)context)->col.col));
74 eng_context_multiplier_set(void *data, void *context, int r, int g, int b, int a)
76 evas_common_draw_context_set_multiplier(context, r, g, b, a);
80 eng_context_multiplier_unset(void *data, void *context)
82 evas_common_draw_context_unset_multiplier(context);
86 eng_context_multiplier_get(void *data, void *context, int *r, int *g, int *b, int *a)
88 *r = (int)(R_VAL(&((RGBA_Draw_Context *)context)->mul.col));
89 *g = (int)(G_VAL(&((RGBA_Draw_Context *)context)->mul.col));
90 *b = (int)(B_VAL(&((RGBA_Draw_Context *)context)->mul.col));
91 *a = (int)(A_VAL(&((RGBA_Draw_Context *)context)->mul.col));
92 return ((RGBA_Draw_Context *)context)->mul.use;
96 eng_context_cutout_add(void *data, void *context, int x, int y, int w, int h)
98 evas_common_draw_context_add_cutout(context, x, y, w, h);
102 eng_context_cutout_clear(void *data, void *context)
104 evas_common_draw_context_clear_cutouts(context);
108 eng_context_anti_alias_set(void *data, void *context, unsigned char aa)
110 evas_common_draw_context_set_anti_alias(context, aa);
114 eng_context_anti_alias_get(void *data, void *context)
116 return ((RGBA_Draw_Context *)context)->anti_alias;
120 eng_context_color_interpolation_set(void *data, void *context, int color_space)
122 evas_common_draw_context_set_color_interpolation(context, color_space);
126 eng_context_color_interpolation_get(void *data, void *context)
128 return ((RGBA_Draw_Context *)context)->interpolation.color_space;
132 eng_context_render_op_set(void *data, void *context, int op)
134 evas_common_draw_context_set_render_op(context, op);
138 eng_context_render_op_get(void *data, void *context)
140 return ((RGBA_Draw_Context *)context)->render_op;
146 eng_rectangle_draw(void *data, void *context, void *surface, int x, int y, int w, int h)
148 soft16_rectangle_draw(surface, context, x, y, w, h);
152 eng_line_draw(void *data, void *context, void *surface, int x1, int y1, int x2, int y2)
154 soft16_line_draw(surface, context, x1, y1, x2, y2);
158 eng_polygon_point_add(void *data, void *context, void *polygon, int x, int y)
160 return evas_common_polygon_point_add(polygon, x, y);
164 eng_polygon_points_clear(void *data, void *context, void *polygon)
166 return evas_common_polygon_points_clear(polygon);
170 eng_polygon_draw(void *data, void *context, void *surface, void *polygon)
172 soft16_polygon_draw(surface, context, polygon);
176 eng_gradient_new(void *data)
180 // return evas_common_gradient_new();
184 eng_gradient_free(void *data, void *gradient)
187 // evas_common_gradient_free(gradient);
191 eng_gradient_color_stop_add(void *data, void *gradient, int r, int g, int b, int a, int delta)
194 // evas_common_gradient_color_stop_add(gradient, r, g, b, a, delta);
198 eng_gradient_alpha_stop_add(void *data, void *gradient, int a, int delta)
201 // evas_common_gradient_alpha_stop_add(gradient, a, delta);
205 eng_gradient_color_data_set(void *data, void *gradient, void *map, int len, int has_alpha)
208 // evas_common_gradient_color_data_set(gradient, map, len, has_alpha);
212 eng_gradient_alpha_data_set(void *data, void *gradient, void *alpha_map, int len)
215 // evas_common_gradient_alpha_data_set(gradient, alpha_map, len);
219 eng_gradient_clear(void *data, void *gradient)
222 // evas_common_gradient_clear(gradient);
226 eng_gradient_fill_set(void *data, void *gradient, int x, int y, int w, int h)
229 // evas_common_gradient_fill_set(gradient, x, y, w, h);
233 eng_gradient_fill_angle_set(void *data, void *gradient, double angle)
236 // evas_common_gradient_fill_angle_set(gradient, angle);
240 eng_gradient_fill_spread_set(void *data, void *gradient, int spread)
243 // evas_common_gradient_fill_spread_set(gradient, spread);
247 eng_gradient_angle_set(void *data, void *gradient, double angle)
250 // evas_common_gradient_map_angle_set(gradient, angle);
254 eng_gradient_offset_set(void *data, void *gradient, float offset)
257 // evas_common_gradient_map_offset_set(gradient, offset);
261 eng_gradient_direction_set(void *data, void *gradient, int direction)
264 // evas_common_gradient_map_direction_set(gradient, direction);
268 eng_gradient_type_set(void *data, void *gradient, char *name, char *params)
271 // evas_common_gradient_type_set(gradient, name, params);
275 eng_gradient_is_opaque(void *data, void *context, void *gradient, int x, int y, int w, int h)
279 // RGBA_Draw_Context *dc = (RGBA_Draw_Context *)context;
280 // RGBA_Gradient *gr = (RGBA_Gradient *)gradient;
282 // if (!dc || !gr || !gr->type.geometer) return 0;
283 // return !(gr->type.geometer->has_alpha(gr, dc->render_op) |
284 // gr->type.geometer->has_mask(gr, dc->render_op));
288 eng_gradient_is_visible(void *data, void *context, void *gradient, int x, int y, int w, int h)
292 // RGBA_Draw_Context *dc = (RGBA_Draw_Context *)context;
294 // if (!dc || !gradient) return 0;
299 eng_gradient_render_pre(void *data, void *context, void *gradient)
301 // RGBA_Draw_Context *dc = (RGBA_Draw_Context *)context;
302 // RGBA_Gradient *gr = (RGBA_Gradient *)gradient;
305 // if (!dc || !gr || !gr->type.geometer) return;
306 // gr->type.geometer->geom_set(gr);
307 // len = gr->type.geometer->get_map_len(gr);
308 // evas_common_gradient_map(dc, gr, len);
313 eng_gradient_render_post(void *data, void *gradient)
319 eng_gradient_draw(void *data, void *context, void *surface, void *gradient, int x, int y, int w, int h)
321 // evas_common_gradient_draw(surface, context, x, y, w, h, gradient);
322 // evas_common_cpu_end_opt();
327 eng_image_alpha_get(void *data, void *image)
331 if (!image) return 0;
333 return im->cache_entry.flags.alpha;
337 eng_image_colorspace_get(void *data, void *image)
339 return EVAS_COLORSPACE_RGB565_A5P;
343 eng_image_alpha_set(void *data, void *image, int have_alpha)
345 if (!image) return NULL;
346 have_alpha = !!have_alpha;
347 image = soft16_image_alpha_set(image, have_alpha);
352 eng_image_border_set(void *data, void *image, int l, int r, int t, int b)
358 eng_image_border_get(void *data, void *image, int *l, int *r, int *t, int *b)
363 eng_image_comment_get(void *data, void *image, char *key)
369 eng_image_format_get(void *data, void *image)
376 eng_image_colorspace_set(void *data, void *image, int cspace)
382 eng_image_native_set(void *data, void *image, void *native)
388 eng_image_native_get(void *data, void *image)
395 eng_image_load(void *data, const char *file, const char *key, int *error, Evas_Image_Load_Opts *lo)
397 return evas_cache_image_request(evas_common_soft16_image_cache_get(), file, key, lo, error);
401 eng_image_new_from_data(void *data, int w, int h, DATA32 *image_data, int alpha, int cspace)
403 if ((image_data) && (cspace != EVAS_COLORSPACE_RGB565_A5P))
405 fprintf(stderr, "Unsupported colorspace %d in %s() (%s:%d)\n",
406 cspace, __FUNCTION__, __FILE__, __LINE__);
409 return evas_cache_image_data(evas_common_soft16_image_cache_get(), w, h, image_data, alpha, EVAS_COLORSPACE_RGB565_A5P);
413 eng_image_new_from_copied_data(void *data, int w, int h, DATA32 *image_data, int alpha, int cspace)
415 if ((image_data) && (cspace != EVAS_COLORSPACE_RGB565_A5P))
417 fprintf(stderr, "Unsupported colorspace %d in %s() (%s:%d)\n",
418 cspace, __FUNCTION__, __FILE__, __LINE__);
421 return evas_cache_image_copied_data(evas_common_soft16_image_cache_get(), w, h, image_data, alpha, EVAS_COLORSPACE_RGB565_A5P);
425 eng_image_free(void *data, void *image)
427 evas_cache_image_drop((Image_Entry *) image);
431 eng_image_size_get(void *data, void *image, int *w, int *h)
439 if (w) *w = im->cache_entry.w;
440 if (h) *h = im->cache_entry.h;
444 eng_image_size_set(void *data, void *image, int w, int h)
446 if (!image) return NULL;
447 if ((w <= 0) || (h <= 0))
449 evas_cache_image_drop((Image_Entry *) image);
452 return evas_cache_image_size_set((Image_Entry *) image, w, h);
456 eng_image_stride_get(void *data, void *image, int *stride)
460 if (stride) *stride = 0;
463 if (stride) *stride = im->stride;
467 eng_image_dirty_region(void *data, void *image, int x, int y, int w, int h)
469 /* FIXME: is this required? */
475 eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data)
486 evas_cache_image_load_data(&im->cache_entry);
489 im = (Soft16_Image *) evas_cache_image_alone(&im->cache_entry);
491 if (image_data) *image_data = (DATA32 *) im->pixels;
497 eng_image_data_put(void *data, void *image, DATA32 *image_data)
499 Soft16_Image *old_im, *new_im;
501 if (!image) return NULL;
504 if ((DATA16 *)image_data == old_im->pixels) return old_im;
506 new_im = (Soft16_Image *) evas_cache_image_copied_data(evas_common_soft16_image_cache_get(), old_im->cache_entry.w, old_im->cache_entry.h, image_data, old_im->cache_entry.flags.alpha, EVAS_COLORSPACE_RGB565_A5P);
507 evas_cache_image_drop(&old_im->cache_entry);
514 eng_image_draw(void *data, 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)
518 im = (Soft16_Image *) image;
520 evas_cache_image_load_data(&im->cache_entry);
521 soft16_image_draw(im, surface, context,
522 src_x, src_y, src_w, src_h,
523 dst_x, dst_y, dst_w, dst_h,
528 eng_image_cache_flush(void *data)
530 evas_cache_image_flush(evas_common_soft16_image_cache_get());
534 eng_image_cache_set(void *data, int bytes)
536 evas_cache_image_set(evas_common_soft16_image_cache_get(), bytes);
540 eng_image_cache_get(void *data)
542 return evas_cache_image_get(evas_common_soft16_image_cache_get());
546 eng_font_load(void *data, const char *name, int size)
548 return evas_common_font_load(name, size);
552 eng_font_memory_load(void *data, char *name, int size, const void *fdata, int fdata_size)
554 return evas_common_font_memory_load(name, size, fdata, fdata_size);
558 eng_font_add(void *data, void *font, const char *name, int size)
560 return evas_common_font_add(font, name, size);
564 eng_font_memory_add(void *data, void *font, char *name, int size, const void *fdata, int fdata_size)
566 return evas_common_font_memory_add(font, name, size, fdata, fdata_size);
570 eng_font_free(void *data, void *font)
572 evas_common_font_free(font);
576 eng_font_ascent_get(void *data, void *font)
578 return evas_common_font_ascent_get(font);
582 eng_font_descent_get(void *data, void *font)
584 return evas_common_font_descent_get(font);
588 eng_font_max_ascent_get(void *data, void *font)
590 return evas_common_font_max_ascent_get(font);
594 eng_font_max_descent_get(void *data, void *font)
596 return evas_common_font_max_descent_get(font);
600 eng_font_string_size_get(void *data, void *font, const char *text, int *w, int *h)
602 evas_common_font_query_size(font, text, w, h);
606 eng_font_inset_get(void *data, void *font, const char *text)
608 return evas_common_font_query_inset(font, text);
612 eng_font_h_advance_get(void *data, void *font, const char *text)
616 evas_common_font_query_advance(font, text, &h, &v);
621 eng_font_v_advance_get(void *data, void *font, const char *text)
625 evas_common_font_query_advance(font, text, &h, &v);
630 eng_font_char_coords_get(void *data, void *font, const char *text, int pos, int *cx, int *cy, int *cw, int *ch)
632 return evas_common_font_query_char_coords(font, text, pos, cx, cy, cw, ch);
636 eng_font_char_at_coords_get(void *data, void *font, const char *text, int x, int y, int *cx, int *cy, int *cw, int *ch)
638 return evas_common_font_query_text_at_pos(font, text, x, y, cx, cy, cw, ch);
642 eng_font_draw(void *data, void *context, void *surface, void *font, int x, int y, int w, int h, int ow, int oh, const char *text)
644 static RGBA_Image *im = NULL;
645 Soft16_Image *dst = surface;
648 im = (RGBA_Image *) evas_cache_image_empty(evas_common_image_cache_get());
649 evas_cache_image_surface_alloc(&im->cache_entry, dst->cache_entry.w, dst->cache_entry.h);
650 evas_common_draw_context_font_ext_set(context,
652 soft16_font_glyph_new,
653 soft16_font_glyph_free,
654 soft16_font_glyph_draw);
655 evas_common_font_draw(im, context, font, x, y, text);
656 evas_common_draw_context_font_ext_set(context,
664 eng_font_cache_flush(void *data)
666 evas_common_font_flush();
670 eng_font_cache_set(void *data, int bytes)
672 evas_common_font_cache_set(bytes);
676 eng_font_cache_get(void *data)
678 return evas_common_font_cache_get();
682 eng_font_hinting_set(void *data, void *font, int hinting)
684 evas_common_font_hinting_set(font, hinting);
688 eng_font_hinting_can_hint(void *data, int hinting)
690 return evas_common_hinting_available(hinting);
702 static Evas_Func func =
717 /* draw context virtual methods */
720 eng_context_clip_set,
721 eng_context_clip_clip,
722 eng_context_clip_unset,
723 eng_context_clip_get,
724 eng_context_color_set,
725 eng_context_color_get,
726 eng_context_multiplier_set,
727 eng_context_multiplier_unset,
728 eng_context_multiplier_get,
729 eng_context_cutout_add,
730 eng_context_cutout_clear,
731 eng_context_anti_alias_set,
732 eng_context_anti_alias_get,
733 eng_context_color_interpolation_set,
734 eng_context_color_interpolation_get,
735 eng_context_render_op_set,
736 eng_context_render_op_get,
737 /* rect draw funcs */
739 /* line draw funcs */
741 /* polygon draw funcs */
742 eng_polygon_point_add,
743 eng_polygon_points_clear,
745 /* gradient draw funcs */
748 eng_gradient_color_stop_add,
749 eng_gradient_alpha_stop_add,
750 eng_gradient_color_data_set,
751 eng_gradient_alpha_data_set,
753 eng_gradient_fill_set,
754 eng_gradient_fill_angle_set,
755 eng_gradient_fill_spread_set,
756 eng_gradient_angle_set,
757 eng_gradient_offset_set,
758 eng_gradient_direction_set,
759 eng_gradient_type_set,
760 eng_gradient_is_opaque,
761 eng_gradient_is_visible,
762 eng_gradient_render_pre,
763 eng_gradient_render_post,
765 /* image draw funcs */
767 eng_image_new_from_data,
768 eng_image_new_from_copied_data,
772 eng_image_stride_get,
773 eng_image_dirty_region,
778 eng_image_border_set,
779 eng_image_border_get,
781 eng_image_comment_get,
782 eng_image_format_get,
783 eng_image_colorspace_set,
784 eng_image_colorspace_get,
785 eng_image_native_set,
786 eng_image_native_get,
787 /* image cache funcs */
788 eng_image_cache_flush,
791 /* font draw functions */
793 eng_font_memory_load,
798 eng_font_descent_get,
799 eng_font_max_ascent_get,
800 eng_font_max_descent_get,
801 eng_font_string_size_get,
803 eng_font_h_advance_get,
804 eng_font_v_advance_get,
805 eng_font_char_coords_get,
806 eng_font_char_at_coords_get,
808 /* font cache functions */
809 eng_font_cache_flush,
812 /* font hinting functions */
813 eng_font_hinting_set,
814 eng_font_hinting_can_hint
815 /* FUTURE software generic calls go here */
821 ** MODULE ACCESSIBLE API API
827 module_open(Evas_Module *em)
830 em->functions = (void *)(&func);
839 EAPI Evas_Module_Api evas_modapi =
841 EVAS_MODULE_API_VERSION,
842 EVAS_MODULE_TYPE_ENGINE,