Enlightenment CVS committal Author : raster Project : e17 Module : libs/evas
Dir : e17/libs/evas/src/modules/engines/software_xcb Modified Files: Makefile.am evas_engine.c Added Files: Evas_Engine_Software_Xcb.h Log Message: software engines all now totally inherit from software_generic and xrender_x11 now partially inherits. =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/evas/src/modules/engines/software_xcb/Makefile.am,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- Makefile.am 17 Jan 2006 03:47:39 -0000 1.4 +++ Makefile.am 2 Mar 2006 09:16:46 -0000 1.5 @@ -1,23 +1,15 @@ -## Process this file with automake to produce Makefile.in - AUTOMAKE_OPTIONS = 1.4 foreign -# A list of all the files in the current directory which can be regenerated MAINTAINERCLEANFILES = Makefile.in -INCLUDES = -I. \ - -I$(top_srcdir)/src/lib \ - -I$(top_srcdir)/src/lib/include \ - -I$(top_srcdir)/src/modules/engines \ - @FREETYPE_CFLAGS@ @xcb_cflags@ +INCLUDES = -I. -I$(top_srcdir)/src/lib -I$(top_srcdir)/src/lib/include -I$(top_srcdir)/src/modules/engines @FREETYPE_CFLAGS@ @xcb_cflags@ if BUILD_ENGINE_SOFTWARE_XCB -pkgdir = $(libdir)/evas/modules/engines/software_xcb/$(MODULE_ARCH) - -pkg_LTLIBRARIES = module.la +pkgdir = $(libdir)/evas/modules/engines/software_xcb/$(MODULE_ARCH) -module_la_SOURCES = \ +pkg_LTLIBRARIES = module.la +module_la_SOURCES = \ evas_engine.h \ evas_engine.c \ evas_outbuf.c \ @@ -25,11 +17,11 @@ evas_xcb_color.c \ evas_xcb_main.c -module_la_LIBADD = @xcb_libs@ $(top_builddir)/src/lib/libevas.la -module_la_LDFLAGS = -module -avoid-version -L$(top_builddir)/src/lib -L$(top_builddir)/src/lib/.libs +module_la_LIBADD = @xcb_libs@ $(top_builddir)/src/lib/libevas.la +module_la_LDFLAGS = -module -avoid-version -L$(top_builddir)/src/lib -L$(top_builddir)/src/lib/.libs +module_la_DEPENDENCIES = $(top_builddir)/config.h -module_la_DEPENDENCIES = \ -$(top_builddir)/config.h +include_HEADERS = Evas_Engine_Software_Xcb.h endif @@ -39,4 +31,5 @@ evas_outbuf.c \ evas_xcb_buffer.c \ evas_xcb_color.c \ -evas_xcb_main.c +evas_xcb_main.c \ +Evas_Engine_Software_Xcb.h \ No newline at end of file =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/evas/src/modules/engines/software_xcb/evas_engine.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- evas_engine.c 28 Feb 2006 04:07:48 -0000 1.3 +++ evas_engine.c 2 Mar 2006 09:16:46 -0000 1.4 @@ -4,10 +4,37 @@ #include "evas_engine_api_software_xcb.h" #include "Evas_Engine_Software_Xcb.h" +/* function tables - filled in later (func and parent func) */ +static Evas_Func func, pfunc; + +/* engine struct data */ +typedef struct _Render_Engine Render_Engine; + +struct _Render_Engine +{ + Tilebuf *tb; + Outbuf *ob; + Tilebuf_Rect *rects; + Evas_Object_List *cur_rect; + int end : 1; +}; + +/* prototypes we will use here */ +static void *_output_setup(int w, int h, int rot, XCBConnection *conn, XCBDRAWABLE draw, XCBVISUALTYPE *vis, XCBCOLORMAP cmap, int depth, int debug, int grayscale, int max_colors, XCBDRAWABLE mask, int shape_dither); +static XCBVISUALTYPE *_best_visual_get(XCBConnection *conn, int screen); +static XCBCOLORMAP _best_colormap_get(XCBConnection *conn, int screen); +static int _best_depth_get(XCBConnection *conn, int screen); +static Evas_Performance *_output_perf_new(Evas *e, XCBConnection *conn, XCBVISUALTYPE *vis, XCBCOLORMAP cmap, XCBDRAWABLE draw, int depth); +static Evas_Performance *_output_perf_test(Evas *e, XCBConnection *conn, XCBVISUALTYPE *vis, XCBCOLORMAP cmap, XCBDRAWABLE draw, int depth); +static char *_output_perf_data(Evas_Performance *perf); +static char *_output_perf_key(Evas_Performance *perf); +static void _output_perf_free(Evas_Performance *perf); +static void _output_perf_build(Evas_Performance *perf, const char *data); +static void _output_perf_device_store(Evas_Performance *perf); + static void *eng_info(Evas *e); static void eng_info_free(Evas *e, void *info); static void eng_setup(Evas *e, void *info); -static void *eng_output_setup(int w, int h, int rot, XCBConnection *conn, XCBDRAWABLE draw, XCBVISUALTYPE *vis, XCBCOLORMAP cmap, int depth, int debug, int grayscale, int max_colors, XCBDRAWABLE mask, int shape_dither); static void eng_output_free(void *data); static void eng_output_resize(void *data, int w, int h); static void eng_output_tile_size_set(void *data, int w, int h); @@ -17,196 +44,185 @@ static void *eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, int *cx, int *cy, int *cw, int *ch); static void eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h); static void eng_output_flush(void *data); -static void *eng_context_new(void *data); -static void eng_context_free(void *data, void *context); -static void eng_context_clip_set(void *data, void *context, int x, int y, int w, int h); -static void eng_context_clip_clip(void *data, void *context, int x, int y, int w, int h); -static void eng_context_clip_unset(void *data, void *context); -static int eng_context_clip_get(void *data, void *context, int *x, int *y, int *w, int *h); -static void eng_context_color_set(void *data, void *context, int r, int g, int b, int a); -static int eng_context_color_get(void *data, void *context, int *r, int *g, int *b, int *a); -static void eng_context_multiplier_set(void *data, void *context, int r, int g, int b, int a); -static void eng_context_multiplier_unset(void *data, void *context); -static int eng_context_multiplier_get(void *data, void *context, int *r, int *g, int *b, int *a); -static void eng_context_cutout_add(void *data, void *context, int x, int y, int w, int h); -static void eng_context_cutout_clear(void *data, void *context); -static void eng_context_anti_alias_set(void *data, void *context, unsigned char aa); -static unsigned char eng_context_anti_alias_get(void *data, void *context); -static void eng_context_color_interpolation_set(void *data, void *context, int color_space); -static int eng_context_color_interpolation_get(void *data, void *context); -static void eng_rectangle_draw(void *data, void *context, void *surface, int x, int y, int w, int h); -static void eng_line_draw(void *data, void *context, void *surface, int x1, int y1, int x2, int y2); -static void *eng_polygon_point_add(void *data, void *context, void *polygon, int x, int y); -static void *eng_polygon_points_clear(void *data, void *context, void *polygon); -static void eng_polygon_draw(void *data, void *context, void *surface, void *polygon); -static void *eng_gradient_color_add(void *data, void *context, void *gradient, int r, int g, int b, int a, int distance); -static void *eng_gradient_colors_clear(void *data, void *context, void *gradient); -static void eng_gradient_free(void *data, void *gradient); -static void eng_gradient_fill_set(void *data, void *gradient, int x, int y, int w, int h); -static void eng_gradient_type_set(void *data, void *gradient, char *name); -static void eng_gradient_type_params_set(void *data, void *gradient, char *params); -static void *eng_gradient_geometry_init(void *data, void *gradient, int spread); -static int eng_gradient_alpha_get(void *data, void *gradient, int spread); -static void eng_gradient_map(void *data, void *context, void *gradient, int spread); -static void eng_gradient_draw(void *data, void *context, void *surface, void *gradient, int x, int y, int w, int h, double angle, int spread); -static void *eng_image_load(void *data, char *file, char *key, int *error); -static void *eng_image_new_from_data(void *data, int w, int h, DATA32 *image_data); -static void *eng_image_new_from_copied_data(void *data, int w, int h, DATA32 *image_data); -static void eng_image_free(void *data, void *image); -static void eng_image_size_get(void *data, void *image, int *w, int *h); -static void *eng_image_size_set(void *data, void *image, int w, int h); -static void *eng_image_dirty_region(void *data, void *image, int x, int y, int w, int h); -static void *eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data); -static void *eng_image_data_put(void *data, void *image, DATA32 *image_data); -static void *eng_image_alpha_set(void *data, void *image, int has_alpha); -static int eng_image_alpha_get(void *data, void *image); -static void 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); -static char *eng_image_comment_get(void *data, void *image, char *key); -static char *eng_image_format_get(void *data, void *image); -static void eng_image_cache_flush(void *data); -static void eng_image_cache_set(void *data, int bytes); -static int eng_image_cache_get(void *data); -static void *eng_font_load(void *data, char *name, int size); -static void *eng_font_memory_load(void *data, char *name, int size, const void *fdata, int fdata_size); -static void *eng_font_add(void *data, void *font, char *name, int size); -static void *eng_font_memory_add(void *data, void *font, char *name, int size, const void *fdata, int fdata_size); -static void eng_font_free(void *data, void *font); -static int eng_font_ascent_get(void *data, void *font); -static int eng_font_descent_get(void *data, void *font); -static int eng_font_max_ascent_get(void *data, void *font); -static int eng_font_max_descent_get(void *data, void *font); -static void eng_font_string_size_get(void *data, void *font, char *text, int *w, int *h); -static int eng_font_inset_get(void *data, void *font, char *text); -static int eng_font_h_advance_get(void *data, void *font, char *text); -static int eng_font_v_advance_get(void *data, void *font, char *text); -static int eng_font_char_coords_get(void *data, void *font, char *text, int pos, int *cx, int *cy, int *cw, int *ch); -static int eng_font_char_at_coords_get(void *data, void *font, char *text, int x, int y, int *cx, int *cy, int *cw, int *ch); -static void eng_font_draw(void *data, void *context, void *surface, void *font, int x, int y, int w, int h, int ow, int oh, char *text); -static void eng_font_cache_flush(void *data); -static void eng_font_cache_set(void *data, int bytes); -static int eng_font_cache_get(void *data); - -static void eng_font_hinting_set(void *data, void *font, int hinting); -static int eng_font_hinting_can_hint(void *data, int hinting); - -static XCBVISUALTYPE *eng_best_visual_get(XCBConnection *conn, int screen); -static XCBCOLORMAP eng_best_colormap_get(XCBConnection *conn, int screen); -static int eng_best_depth_get(XCBConnection *conn, int screen); -static Evas_Performance *eng_output_perf_new(Evas *e, XCBConnection *conn, XCBVISUALTYPE *vis, XCBCOLORMAP cmap, XCBDRAWABLE draw, int depth); -static Evas_Performance *eng_output_perf_test(Evas *e, XCBConnection *conn, XCBVISUALTYPE *vis, XCBCOLORMAP cmap, XCBDRAWABLE draw, int depth); -static char *eng_output_perf_data(Evas_Performance *perf); -static char *eng_output_perf_key(Evas_Performance *perf); -static void eng_output_perf_free(Evas_Performance *perf); -static void eng_output_perf_build(Evas_Performance *perf, const char *data); -static void eng_output_perf_device_store(Evas_Performance *perf); -typedef struct _Render_Engine Render_Engine; +static void * +_output_setup(int w, + int h, + int rot, + XCBConnection *conn, + XCBDRAWABLE draw, + XCBVISUALTYPE *vis, + XCBCOLORMAP cmap, + int depth, + int debug, + int grayscale, + int max_colors, + XCBDRAWABLE mask, + int shape_dither) +{ + Render_Engine *re; + Outbuf_Perf *perf; -struct _Render_Engine + re = calloc(1, sizeof(Render_Engine)); + /* if we haven't initialized - init (automatic abort if already done) */ + evas_common_cpu_init(); + + evas_common_blend_init(); + evas_common_image_init(); + evas_common_convert_init(); + evas_common_scale_init(); + evas_common_rectangle_init(); + evas_common_gradient_init(); + evas_common_polygon_init(); + evas_common_line_init(); + evas_common_font_init(); + evas_common_draw_init(); + evas_common_tilebuf_init(); + + evas_software_xcb_x_init(); + evas_software_xcb_x_color_init(); + evas_software_xcb_outbuf_init(); + + /* get any stored performance metrics from device (xserver) */ + perf = evas_software_xcb_outbuf_perf_restore_x(conn, draw, vis, cmap, depth); + re->ob = evas_software_xcb_outbuf_setup_x(w, h, rot, + OUTBUF_DEPTH_INHERIT, + conn, + draw, + vis, + cmap, + depth, + perf, + grayscale, + max_colors, + mask, shape_dither); + if (!re->ob) + { + evas_software_xcb_outbuf_perf_free(perf); + free(re); + return NULL; + } + evas_software_xcb_outbuf_debug_set(re->ob, debug); + re->tb = evas_common_tilebuf_new(w, h); + if (!re->tb) + { + evas_software_xcb_outbuf_free(re->ob); + free(re); + return NULL; + } + /* in preliminary tests 16x16 gave highest framerates */ + evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE); + return re; +} + +static XCBSCREEN * +_screen_get(XCBConnection *conn, int screen) { - Tilebuf *tb; - Outbuf *ob; - Tilebuf_Rect *rects; - Evas_Object_List *cur_rect; - int end : 1; -}; + XCBSCREENIter i; + int cur; -static Evas_Func eng_func = + if (!conn) return NULL; + + i = XCBConnSetupSuccessRepRootsIter(XCBGetSetup(conn)); + if (screen > i.rem - 1) return NULL; /* screen must be between 0 and i.rem - 1 */ + for (cur = 0; cur <= screen; XCBSCREENNext(&i), ++cur); + + return i.data; +} + +static XCBVISUALTYPE * +_best_visual_get(XCBConnection *conn, int screen) { - eng_info, - eng_info_free, - eng_setup, - eng_output_free, - eng_output_resize, - eng_output_tile_size_set, - eng_output_redraws_rect_add, - eng_output_redraws_rect_del, - eng_output_redraws_clear, - eng_output_redraws_next_update_get, - eng_output_redraws_next_update_push, - eng_output_flush, - /* draw context virtual methods */ - eng_context_new, - eng_context_free, - eng_context_clip_set, - eng_context_clip_clip, - eng_context_clip_unset, - eng_context_clip_get, - eng_context_color_set, - eng_context_color_get, - eng_context_multiplier_set, - eng_context_multiplier_unset, - eng_context_multiplier_get, - eng_context_cutout_add, - eng_context_cutout_clear, - eng_context_anti_alias_set, - eng_context_anti_alias_get, - eng_context_color_interpolation_set, - eng_context_color_interpolation_get, - /* rectangle draw funcs */ - eng_rectangle_draw, - /* line draw funcs */ - eng_line_draw, - /* polygon draw funcs */ - eng_polygon_point_add, - eng_polygon_points_clear, - eng_polygon_draw, - /* gradient draw funcs */ - eng_gradient_color_add, - eng_gradient_colors_clear, - eng_gradient_free, - eng_gradient_fill_set, - eng_gradient_type_set, - eng_gradient_type_params_set, - eng_gradient_geometry_init, - eng_gradient_alpha_get, - eng_gradient_map, - eng_gradient_draw, - /* image draw funcs */ - eng_image_load, - eng_image_new_from_data, - eng_image_new_from_copied_data, - eng_image_free, - eng_image_size_get, - eng_image_size_set, - eng_image_dirty_region, - eng_image_data_get, - eng_image_data_put, - eng_image_alpha_set, - eng_image_alpha_get, - eng_image_draw, - eng_image_comment_get, - eng_image_format_get, - /* image cache funcs */ - eng_image_cache_flush, - eng_image_cache_set, - eng_image_cache_get, - /* font draw functions */ - eng_font_load, - eng_font_memory_load, - eng_font_add, - eng_font_memory_add, - eng_font_free, - eng_font_ascent_get, - eng_font_descent_get, - eng_font_max_ascent_get, - eng_font_max_descent_get, - eng_font_string_size_get, - eng_font_inset_get, - eng_font_h_advance_get, - eng_font_v_advance_get, - eng_font_char_coords_get, - eng_font_char_at_coords_get, - eng_font_draw, - /* font cache functions */ - eng_font_cache_flush, - eng_font_cache_set, - eng_font_cache_get, - - eng_font_hinting_set, - eng_font_hinting_can_hint -}; + XCBSCREEN *scr; + XCBDEPTH *d; + XCBVISUALTYPEIter iter; + int cur; + + if (!conn) return NULL; + scr = _screen_get(conn, screen); + if (!scr) return NULL; + d = XCBSCREENAllowedDepthsIter(scr).data; + if (!d) return NULL; + + iter = XCBDEPTHVisualsIter(d); + for (cur = 0 ; cur < iter.rem ; XCBVISUALTYPENext(&iter), ++cur) + if (scr->root_visual.id == iter.data->visual_id.id) + return iter.data; + + return NULL; +} + +static XCBCOLORMAP +_best_colormap_get(XCBConnection *conn, int screen) +{ + XCBSCREEN *scr; + XCBCOLORMAP c; + + c.xid = 0; + if (!conn) return c; + scr = _screen_get(conn, screen); + if (!scr) return c; + + return scr->default_colormap; +} + +static int +_best_depth_get(XCBConnection *conn, int screen) +{ + XCBSCREEN *scr; + + if (!conn) return 0; + scr = _screen_get(conn, screen); + if (!scr) return 0; + + return scr->root_depth; +} + +static Evas_Performance * +_output_perf_new(Evas *e, XCBConnection *conn, XCBVISUALTYPE *vis, XCBCOLORMAP cmap, XCBDRAWABLE draw, int depth) +{ + return evas_software_xcb_outbuf_perf_new_x(conn, draw, vis, cmap, depth); + e = NULL; +} + +static Evas_Performance * +_output_perf_test(Evas *e, XCBConnection *conn, XCBVISUALTYPE *vis, XCBCOLORMAP cmap, XCBDRAWABLE draw, int depth) +{ + return evas_software_xcb_outbuf_perf_x(conn, draw, vis, cmap, depth); + e = NULL; +} + +static char * +_output_perf_data(Evas_Performance *perf) +{ + return evas_software_xcb_outbuf_perf_serialize_x(perf); +} + +static char * +_output_perf_key(Evas_Performance *perf) +{ + return evas_software_xcb_outbuf_perf_serialize_info_x(perf); +} + +static void +_output_perf_free(Evas_Performance *perf) +{ + evas_software_xcb_outbuf_perf_free(perf); +} + +static void +_output_perf_build(Evas_Performance *perf, const char *data) +{ + evas_software_xcb_outbuf_perf_deserialize_x(perf, data); +} + +static void +_output_perf_device_store(Evas_Performance *perf) +{ + evas_software_xcb_outbuf_perf_store_x(perf); +} +/* engine api this module provides */ static void * eng_info(Evas *e) { @@ -250,19 +266,19 @@ info = (Evas_Engine_Info_Software_Xcb *)in; if (!e->engine.data.output) e->engine.data.output = - eng_output_setup(e->output.w, - e->output.h, - info->info.rotation, - info->info.conn, - info->info.drawable, - info->info.visual, - info->info.colormap, - info->info.depth, - info->info.debug, - info->info.alloc_grayscale, - info->info.alloc_colors_max, - info->info.mask, - info->info.shape_dither); + _output_setup(e->output.w, + e->output.h, + info->info.rotation, + info->info.conn, + info->info.drawable, + info->info.visual, + info->info.colormap, + info->info.depth, + info->info.debug, + info->info.alloc_grayscale, + info->info.alloc_colors_max, + info->info.mask, + info->info.shape_dither); if (!e->engine.data.output) return; if (!e->engine.data.context) e->engine.data.context = @@ -274,76 +290,6 @@ evas_software_xcb_outbuf_rotation_set(re->ob, info->info.rotation); } -static void * -eng_output_setup(int w, - int h, - int rot, - XCBConnection *conn, - XCBDRAWABLE draw, - XCBVISUALTYPE *vis, - XCBCOLORMAP cmap, - int depth, - int debug, - int grayscale, - int max_colors, - XCBDRAWABLE mask, - int shape_dither) -{ - Render_Engine *re; - Outbuf_Perf *perf; - - re = calloc(1, sizeof(Render_Engine)); - /* if we haven't initialized - init (automatic abort if already done) */ - evas_common_cpu_init(); - - evas_common_blend_init(); - evas_common_image_init(); - evas_common_convert_init(); - evas_common_scale_init(); - evas_common_rectangle_init(); - evas_common_gradient_init(); - evas_common_polygon_init(); - evas_common_line_init(); - evas_common_font_init(); - evas_common_draw_init(); - evas_common_tilebuf_init(); - - evas_software_xcb_x_init(); - evas_software_xcb_x_color_init(); - evas_software_xcb_outbuf_init(); - - /* get any stored performance metrics from device (xserver) */ - perf = evas_software_xcb_outbuf_perf_restore_x(conn, draw, vis, cmap, depth); - re->ob = evas_software_xcb_outbuf_setup_x(w, h, rot, - OUTBUF_DEPTH_INHERIT, - conn, - draw, - vis, - cmap, - depth, - perf, - grayscale, - max_colors, - mask, shape_dither); - if (!re->ob) - { - evas_software_xcb_outbuf_perf_free(perf); - free(re); - return NULL; - } - evas_software_xcb_outbuf_debug_set(re->ob, debug); - re->tb = evas_common_tilebuf_new(w, h); - if (!re->tb) - { - evas_software_xcb_outbuf_free(re->ob); - free(re); - return NULL; - } - /* in preliminary tests 16x16 gave highest framerates */ - evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE); - return re; -} - static void eng_output_free(void *data) { @@ -367,7 +313,7 @@ re = (Render_Engine *)data; evas_software_xcb_outbuf_reconfigure(re->ob, w, h, evas_software_xcb_outbuf_get_rot(re->ob), - OUTBUF_DEPTH_INHERIT); + OUTBUF_DEPTH_INHERIT); evas_common_tilebuf_free(re->tb); re->tb = evas_common_tilebuf_new(w, h); if (re->tb) @@ -467,968 +413,37 @@ evas_software_xcb_outbuf_flush(re->ob); } -static void * -eng_context_new(void *data) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - return evas_common_draw_context_new(); -} - -static void -eng_context_free(void *data, void *context) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - evas_common_draw_context_free(context); -} - -static void -eng_context_clip_set(void *data, void *context, int x, int y, int w, int h) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - evas_common_draw_context_set_clip(context, x, y, w, h); -} - -static void -eng_context_clip_clip(void *data, void *context, int x, int y, int w, int h) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - evas_common_draw_context_clip_clip(context, x, y, w, h); -} - -static void -eng_context_clip_unset(void *data, void *context) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - evas_common_draw_context_unset_clip(context); -} - -static int -eng_context_clip_get(void *data, void *context, int *x, int *y, int *w, int *h) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - *x = ((RGBA_Draw_Context *)context)->clip.x; - *y = ((RGBA_Draw_Context *)context)->clip.y; - *w = ((RGBA_Draw_Context *)context)->clip.w; - *h = ((RGBA_Draw_Context *)context)->clip.h; - return ((RGBA_Draw_Context *)context)->clip.use; -} - -static void -eng_context_color_set(void *data, void *context, int r, int g, int b, int a) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - evas_common_draw_context_set_color(context, r, g, b, a); -} - -static int -eng_context_color_get(void *data, void *context, int *r, int *g, int *b, int *a) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - *r = (int)(R_VAL(&((RGBA_Draw_Context *)context)->col.col)); - *g = (int)(G_VAL(&((RGBA_Draw_Context *)context)->col.col)); - *b = (int)(B_VAL(&((RGBA_Draw_Context *)context)->col.col)); - *a = (int)(A_VAL(&((RGBA_Draw_Context *)context)->col.col)); - return 1; -} - -static void -eng_context_multiplier_set(void *data, void *context, int r, int g, int b, int a) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - evas_common_draw_context_set_multiplier(context, r, g, b, a); -} - -static void -eng_context_multiplier_unset(void *data, void *context) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - evas_common_draw_context_unset_multiplier(context); -} - -static int -eng_context_multiplier_get(void *data, void *context, int *r, int *g, int *b, int *a) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - *r = (int)(R_VAL(&((RGBA_Draw_Context *)context)->mul.col)); - *g = (int)(G_VAL(&((RGBA_Draw_Context *)context)->mul.col)); - *b = (int)(B_VAL(&((RGBA_Draw_Context *)context)->mul.col)); - *a = (int)(A_VAL(&((RGBA_Draw_Context *)context)->mul.col)); - return ((RGBA_Draw_Context *)context)->mul.use; -} - -static void -eng_context_cutout_add(void *data, void *context, int x, int y, int w, int h) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - evas_common_draw_context_add_cutout(context, x, y, w, h); -} - -static void -eng_context_cutout_clear(void *data, void *context) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - evas_common_draw_context_clear_cutouts(context); -} - -static void -eng_context_anti_alias_set(void *data, void *context, unsigned char aa) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - evas_common_draw_context_set_anti_alias(context, aa); -} - -static unsigned char -eng_context_anti_alias_get(void *data, void *context) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - return ((RGBA_Draw_Context *)context)->anti_alias; -} - -static void -eng_context_color_interpolation_set(void *data, void *context, int color_space) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - evas_common_draw_context_set_color_interpolation(context, color_space); -} - -static int -eng_context_color_interpolation_get(void *data, void *context) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - return ((RGBA_Draw_Context *)context)->interpolation.color_space; -} - - - - - - -static void -eng_rectangle_draw(void *data, void *context, void *surface, int x, int y, int w, int h) -{ - Render_Engine *re; - - re = (Render_Engine *)data; -#ifdef IMGONLY - return; -#endif - evas_common_rectangle_draw(surface, context, x, y, w, h); - evas_common_cpu_end_opt(); -} - -static void -eng_line_draw(void *data, void *context, void *surface, int x1, int y1, int x2, int y2) -{ - Render_Engine *re; - - re = (Render_Engine *)data; -#ifdef IMGONLY - return; -#endif - evas_common_line_draw(surface, context, x1, y1, x2, y2); - evas_common_cpu_end_opt(); -} - -static void * -eng_polygon_point_add(void *data, void *context, void *polygon, int x, int y) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - return evas_common_polygon_point_add(polygon, x, y); - context = NULL; -} - -static void * -eng_polygon_points_clear(void *data, void *context, void *polygon) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - return evas_common_polygon_points_clear(polygon); - context = NULL; -} - -static void -eng_polygon_draw(void *data, void *context, void *surface, void *polygon) -{ - Render_Engine *re; - - re = (Render_Engine *)data; -#ifdef IMGONLY - return; -#endif - evas_common_polygon_draw(surface, context, polygon); - evas_common_cpu_end_opt(); -} - -static void * -eng_gradient_color_add(void *data, void *context, void *gradient, int r, int g, int b, int a, int distance) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - if (!gradient) - gradient = evas_common_gradient_new(); - evas_common_gradient_color_add(gradient, r, g, b, a, distance); - return gradient; - context = NULL; -} - -static void * -eng_gradient_colors_clear(void *data, void *context, void *gradient) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - evas_common_gradient_colors_clear(gradient); - return gradient; - context = NULL; -} - -static void -eng_gradient_free(void *data, void *gradient) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - evas_common_gradient_free(gradient); -} - -static void -eng_gradient_fill_set(void *data, void *gradient, int x, int y, int w, int h) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - evas_common_gradient_fill_set(gradient, x, y, w, h); -} - -static void -eng_gradient_type_set(void *data, void *gradient, char *name) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - evas_common_gradient_type_set(gradient, name); -} - -static void -eng_gradient_type_params_set(void *data, void *gradient, char *params) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - evas_common_gradient_type_params_set(gradient, params); -} - -static void * -eng_gradient_geometry_init(void *data, void *gradient, int spread) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - gradient = evas_common_gradient_geometry_init(gradient, spread); - return gradient; -} - -static int -eng_gradient_alpha_get(void *data, void *gradient, int spread) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - return evas_common_gradient_has_alpha(gradient, spread); -} - -static void -eng_gradient_map(void *data, void *context, void *gradient, int spread) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - evas_common_gradient_map(context, gradient, spread); - evas_common_cpu_end_opt(); -} - -static void -eng_gradient_draw(void *data, void *context, void *surface, void *gradient, int x, int y, int w, int h, double angle, int spread) -{ - Render_Engine *re; - - re = (Render_Engine *)data; -#ifdef IMGONLY - return; -#endif - evas_common_gradient_draw(surface, context, x, y, w, h, gradient, angle, spread); - evas_common_cpu_end_opt(); -} - -static void * -eng_image_load(void *data, char *file, char *key, int *error) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - *error = 0; - return evas_common_load_image_from_file(file, key); -} - -static void * -eng_image_new_from_data(void *data, int w, int h, DATA32 *image_data) -{ - Render_Engine *re; - RGBA_Image *im; - - re = (Render_Engine *)data; - im = evas_common_image_new(); - im->image = evas_common_image_surface_new(im); - if (!im->image) - { - evas_common_image_free(im); - return NULL; - } - im->image->w = w; - im->image->h = h; - im->image->data = image_data; - im->image->no_free = 1; - return im; -} - -static void * -eng_image_new_from_copied_data(void *data, int w, int h, DATA32 *image_data) -{ - Render_Engine *re; - RGBA_Image *im; - - re = (Render_Engine *)data; - im = evas_common_image_create(w, h); - if (!im) return NULL; - if (image_data) - memcpy(im->image->data, image_data, w * h * sizeof(DATA32)); - return im; -} - -static void -eng_image_free(void *data, void *image) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - evas_common_image_unref(image); -} - -static void -eng_image_size_get(void *data, void *image, int *w, int *h) -{ - Render_Engine *re; - RGBA_Image *im; - - re = (Render_Engine *)data; - im = image; - if (w) *w = im->image->w; - if (h) *h = im->image->h; -} - -static void * -eng_image_size_set(void *data, void *image, int w, int h) -{ - Render_Engine *re; - RGBA_Image *im, *im_old; - - re = (Render_Engine *)data; - im_old = image; - im = evas_common_image_create(w, h); - if (!im) return im_old; - if (im_old) - { - evas_common_load_image_data_from_file(im_old); - if (im_old->image->data) - { - evas_common_blit_rectangle(im_old, im, 0, 0, w, h, 0, 0); - evas_common_cpu_end_opt(); - } - evas_common_image_unref(im_old); - } - return im; -} - -static void * -eng_image_dirty_region(void *data, void *image, int x, int y, int w, int h) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - evas_common_image_dirty(image); - return image; - x = 0; - y = 0; - w = 0; - h = 0; -} - -static void * -eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data) -{ - Render_Engine *re; - RGBA_Image *im; - - re = (Render_Engine *)data; - im = image; - evas_common_load_image_data_from_file(im); - if (to_write) - { - if (im->references > 1) - { - RGBA_Image *im_new; - - im_new = evas_common_image_create(im->image->w, im->image->h); - if (!im_new) return im; - evas_common_blit_rectangle(im, im_new, 0, 0, im->image->w, im->image->h, 0, 0); - evas_common_cpu_end_opt(); - evas_common_image_unref(im); - im = im_new; - } - else - evas_common_image_dirty(im); - } - *image_data = im->image->data; - return im; -} - -static void * -eng_image_data_put(void *data, void *image, DATA32 *image_data) -{ - Render_Engine *re; - RGBA_Image *im; - - re = (Render_Engine *)data; - im = image; - if (image_data != im->image->data) - { - int w, h; - - w = im->image->w; - h = im->image->h; - evas_common_image_unref(im); - return eng_image_new_from_data(data, w, h, image_data); - } - /* hmmm - but if we wrote... why bother? */ -/* evas_common_image_dirty(im); */ - return im; -} - -static void * -eng_image_alpha_set(void *data, void *image, int has_alpha) -{ - Render_Engine *re; - RGBA_Image *im; - - re = (Render_Engine *)data; - im = image; - if (im->references > 1) - { - RGBA_Image *im_new; - - im_new = evas_common_image_create(im->image->w, im->image->h); - if (!im_new) return im; - evas_common_load_image_data_from_file(im); - evas_common_blit_rectangle(im, im_new, 0, 0, im->image->w, im->image->h, 0, 0); - evas_common_cpu_end_opt(); - evas_common_image_unref(im); - im = im_new; - } - else - evas_common_image_dirty(im); - if (has_alpha) - im->flags |= RGBA_IMAGE_HAS_ALPHA; - else - im->flags &= ~RGBA_IMAGE_HAS_ALPHA; - return im; -} - - -static int -eng_image_alpha_get(void *data, void *image) -{ - Render_Engine *re; - RGBA_Image *im; - - re = (Render_Engine *)data; - im = image; - if (im->flags & RGBA_IMAGE_HAS_ALPHA) return 1; - return 0; -} - -static void -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) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - evas_common_load_image_data_from_file(image); - if (smooth) - evas_common_scale_rgba_in_to_out_clip_smooth(image, surface, context, - src_x, src_y, src_w, src_h, - dst_x, dst_y, dst_w, dst_h); - else - evas_common_scale_rgba_in_to_out_clip_sample(image, surface, context, - src_x, src_y, src_w, src_h, - dst_x, dst_y, dst_w, dst_h); - evas_common_cpu_end_opt(); -} - -static char * -eng_image_comment_get(void *data, void *image, char *key) -{ - Render_Engine *re; - RGBA_Image *im; - - re = (Render_Engine *)data; - im = image; - return im->info.comment; - key = 0; -} - -static char * -eng_image_format_get(void *data, void *image) -{ - Render_Engine *re; - RGBA_Image *im; - - re = (Render_Engine *)data; - im = image; -// if (im->info.format == 1) return "png"; - return NULL; -} - -static void -eng_image_cache_flush(void *data) -{ - Render_Engine *re; - int tmp_size; - - re = (Render_Engine *)data; - tmp_size = evas_common_image_get_cache(); - evas_common_image_set_cache(0); - evas_common_image_set_cache(tmp_size); -} - -static void -eng_image_cache_set(void *data, int bytes) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - evas_common_image_set_cache(bytes); -} - -static int -eng_image_cache_get(void *data) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - return evas_common_image_get_cache(); -} - -static void * -eng_font_load(void *data, char *name, int size) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - return evas_common_font_load(name, size); -} - -static void * -eng_font_memory_load(void *data, char *name, int size, const void *fdata, int fdata_size) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - return evas_common_font_memory_load(name, size, fdata, fdata_size); -} - -static void * -eng_font_add(void *data, void *font, char *name, int size) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - return evas_common_font_add(font, name, size); -} - -static void * -eng_font_memory_add(void *data, void *font, char *name, int size, const void *fdata, int fdata_size) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - return evas_common_font_memory_add(font, name, size, fdata, fdata_size); -} - -static void -eng_font_free(void *data, void *font) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - evas_common_font_free(font); -} - -static int -eng_font_ascent_get(void *data, void *font) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - return evas_common_font_ascent_get(font); -} - -static int -eng_font_descent_get(void *data, void *font) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - return evas_common_font_descent_get(font); -} - -static int -eng_font_max_ascent_get(void *data, void *font) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - return evas_common_font_max_ascent_get(font); -} - -static int -eng_font_max_descent_get(void *data, void *font) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - return evas_common_font_max_descent_get(font); -} - -static void -eng_font_string_size_get(void *data, void *font, char *text, int *w, int *h) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - evas_common_font_query_size(font, text, w, h); -} - -static int -eng_font_inset_get(void *data, void *font, char *text) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - return evas_common_font_query_inset(font, text); -} - -static int -eng_font_h_advance_get(void *data, void *font, char *text) -{ - Render_Engine *re; - int h, v; - - re = (Render_Engine *)data; - evas_common_font_query_advance(font, text, &h, &v); - return h; -} - -static int -eng_font_v_advance_get(void *data, void *font, char *text) -{ - Render_Engine *re; - int h, v; - - re = (Render_Engine *)data; - evas_common_font_query_advance(font, text, &h, &v); - return v; -} - -static int -eng_font_char_coords_get(void *data, void *font, char *text, int pos, int *cx, int *cy, int *cw, int *ch) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - return evas_common_font_query_char_coords(font, text, pos, cx, cy, cw, ch); -} - -static int -eng_font_char_at_coords_get(void *data, void *font, char *text, int x, int y, int *cx, int *cy, int *cw, int *ch) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - return evas_common_font_query_text_at_pos(font, text, x, y, cx, cy, cw, ch); -} - -static void -eng_font_draw(void *data, void *context, void *surface, void *font, int x, int y, int w, int h, int ow, int oh, char *text) -{ - Render_Engine *re; - - re = (Render_Engine *)data; -#ifdef IMGONLY - return; -#endif - if ((w == ow) && (h == oh)) - evas_common_font_draw(surface, context, font, x, y, text); - else - { - /* create output surface size ow x oh and scale to w x h */ - RGBA_Draw_Context *dc, *dc_in; - - dc_in = context; - dc = evas_common_draw_context_new(); - if (dc) - { - RGBA_Image *im; - int inset; - - dc->col.col = dc_in->col.col; - inset = evas_common_font_query_inset( font, text); - im = evas_common_image_create(ow+inset, oh); - if (im) - { - int max_ascent; - int j; - - im->flags |= RGBA_IMAGE_HAS_ALPHA; - j = (ow+inset) * oh; - memset(im->image->data, 0, j * sizeof(DATA32)); - - max_ascent = evas_common_font_max_ascent_get(font); - - evas_common_font_draw(im, dc, font, 0, max_ascent, text); - evas_common_cpu_end_opt(); - evas_common_scale_rgba_in_to_out_clip_smooth(im, surface, context, - inset, 0, ow, oh, - x + ((inset * w) / ow), y - ((max_ascent * h) / oh), - w, h); - evas_common_image_free(im); - } - evas_common_draw_context_free(dc); - } - } - evas_common_cpu_end_opt(); -} - -static void -eng_font_cache_flush(void *data) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - evas_common_font_flush(); -} - -static void -eng_font_cache_set(void *data, int bytes) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - evas_common_font_cache_set(bytes); -} - -static int -eng_font_cache_get(void *data) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - return evas_common_font_cache_get(); -} - -static void -eng_font_hinting_set(void *data, void *font, int hinting) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - evas_common_font_hinting_set(font, hinting); -} - -static int -eng_font_hinting_can_hint(void *data, int hinting) -{ - Render_Engine *re; - - re = (Render_Engine *)data; - return evas_common_hinting_available(hinting); -} - - - - - - - - - -/* private engine functions the calling prog can use */ - -/* Convenient function for getting the best visual, colormap and depth */ -static XCBSCREEN * -eng_screen_get(XCBConnection *conn, int screen) -{ - XCBSCREENIter i; - int cur; - - if (!conn) return NULL; - - i = XCBConnSetupSuccessRepRootsIter(XCBGetSetup(conn)); - if (screen > i.rem - 1) return NULL; /* screen must be between 0 and i.rem - 1 */ - for (cur = 0; cur <= screen; XCBSCREENNext(&i), ++cur) {} - - return i.data; -} - -static XCBVISUALTYPE * -eng_best_visual_get(XCBConnection *conn, int screen) -{ - XCBSCREEN *scr; - XCBDEPTH *d; - XCBVISUALTYPEIter iter; - int cur; - - if (!conn) return NULL; - scr = eng_screen_get(conn, screen); - if (!scr) return NULL; - d = XCBSCREENAllowedDepthsIter(scr).data; - if (!d) return NULL; - - iter = XCBDEPTHVisualsIter(d); - for (cur = 0 ; cur < iter.rem ; XCBVISUALTYPENext(&iter), ++cur) - if (scr->root_visual.id == iter.data->visual_id.id) - return iter.data; - - return NULL; -} - -static XCBCOLORMAP -eng_best_colormap_get(XCBConnection *conn, int screen) -{ - XCBSCREEN *scr; - XCBCOLORMAP c; - - c.xid = 0; - if (!conn) return c; - scr = eng_screen_get(conn, screen); - if (!scr) return c; - - return scr->default_colormap; -} - -static int -eng_best_depth_get(XCBConnection *conn, int screen) -{ - XCBSCREEN *scr; - - if (!conn) return 0; - scr = eng_screen_get(conn, screen); - if (!scr) return 0; - - return scr->root_depth; -} - -static Evas_Performance * -eng_output_perf_new(Evas *e, XCBConnection *conn, XCBVISUALTYPE *vis, XCBCOLORMAP cmap, XCBDRAWABLE draw, int depth) -{ - return evas_software_xcb_outbuf_perf_new_x(conn, draw, vis, cmap, depth); - e = NULL; -} - -static Evas_Performance * -eng_output_perf_test(Evas *e, XCBConnection *conn, XCBVISUALTYPE *vis, XCBCOLORMAP cmap, XCBDRAWABLE draw, int depth) -{ - return evas_software_xcb_outbuf_perf_x(conn, draw, vis, cmap, depth); - e = NULL; -} - -static char * -eng_output_perf_data(Evas_Performance *perf) -{ - return evas_software_xcb_outbuf_perf_serialize_x(perf); -} - -static char * -eng_output_perf_key(Evas_Performance *perf) -{ - return evas_software_xcb_outbuf_perf_serialize_info_x(perf); -} - -static void -eng_output_perf_free(Evas_Performance *perf) -{ - evas_software_xcb_outbuf_perf_free(perf); -} - -static void -eng_output_perf_build(Evas_Performance *perf, const char *data) -{ - evas_software_xcb_outbuf_perf_deserialize_x(perf, data); -} - -static void -eng_output_perf_device_store(Evas_Performance *perf) -{ - evas_software_xcb_outbuf_perf_store_x(perf); -} - -int module_open(Evas_Module *em) +/* module advertising code */ +int +module_open(Evas_Module *em) { if (!em) return 0; - em->functions = (void *)(&eng_func); + /* get whatever engine module we inherit from */ + if (!_evas_module_engine_inherit(&pfunc, "software_generic")) return 0; + /* store it for later use */ + func = pfunc; + /* now to override methods */ +#define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_) + ORD(info); + ORD(info_free); + ORD(setup); + ORD(output_free); + ORD(output_resize); + ORD(output_tile_size_set); + ORD(output_redraws_rect_add); + ORD(output_redraws_rect_del); + ORD(output_redraws_clear); + ORD(output_redraws_next_update_get); + ORD(output_redraws_next_update_push); + ORD(output_flush); + /* now advertise out own api */ + em->functions = (void *)(&func); return 1; } -void module_close(void) +void +module_close(void) { - } Evas_Module_Api evas_modapi = ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs