Mercurial > MadButterfly
changeset 448:16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
mb_graph_engine is a layer to separate MadButterfly from Cairo.
It is only a set of macro mapping to cairo implementation, now.
But, it provides a oppotunities to replace cairo with other engines;
likes skia.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Tue, 04 Aug 2009 23:35:41 +0800 |
parents | 38aae921243f |
children | c525edac917e |
files | include/mb_graph_engine.h include/mb_paint.h include/mb_redraw_man.h include/mb_shapes.h include/mb_types.h src/X_main.c src/X_supp.c src/event.c src/img_ldr.c src/paint.c src/redraw_man.c src/shape_image.c src/shape_path.c src/shape_rect.c src/shape_stext.c src/shape_text.c src/sprite.c |
diffstat | 17 files changed, 455 insertions(+), 368 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/mb_graph_engine.h Tue Aug 04 23:35:41 2009 +0800 @@ -0,0 +1,87 @@ +#ifndef __MBE_H_ +#define __MBE_H_ + +#include <cairo.h> + +#define mbe_ft_font_face_create_for_pattern cairo_ft_font_face_create_for_pattern +#define mbe_image_surface_create_from_png cairo_image_surface_create_from_png +#define mbe_image_surface_create_for_data cairo_image_surface_create_for_data +#define mbe_pattern_add_color_stop_rgba cairo_pattern_add_color_stop_rgba +#define mbe_pattern_create_for_surface cairo_pattern_create_for_surface +#define mbe_scaled_font_text_extents cairo_scaled_font_text_extents +#define mbe_image_surface_get_stride cairo_image_surface_get_stride +#define mbe_image_surface_get_height cairo_image_surface_get_height +#define mbe_image_surface_get_format cairo_image_surface_get_format +#define mbe_image_surface_get_width cairo_image_surface_get_width +#define mbe_image_surface_get_data cairo_image_surface_get_data +#define mbe_scaled_font_reference cairo_scaled_font_reference +#define mbe_pattern_create_radial cairo_pattern_create_radial +#define mbe_pattern_create_linear cairo_pattern_create_linear +#define mbe_image_surface_create cairo_image_surface_create +#define mbe_xlib_surface_create cairo_xlib_surface_create +#define mbe_scaled_font_destroy cairo_scaled_font_destroy +#define mbe_font_options_create cairo_font_options_create +#define mbe_font_face_reference cairo_font_face_reference +#define mbe_set_source_surface cairo_set_source_surface +#define mbe_scaled_font_status cairo_scaled_font_status +#define mbe_scaled_font_create cairo_scaled_font_create +#define mbe_pattern_set_matrix cairo_pattern_set_matrix +#define mbe_font_face_destroy cairo_font_face_destroy +#define mbe_paint_with_alpha cairo_paint_with_alpha +#define mbe_font_face_status cairo_font_face_status +#define mbe_surface_destroy cairo_surface_destroy +#define mbe_set_source_rgba cairo_set_source_rgba +#define mbe_set_scaled_font cairo_set_scaled_font +#define mbe_pattern_destroy cairo_pattern_destroy +#define mbe_get_scaled_font cairo_get_scaled_font +#define mbe_text_extents_t cairo_text_extents_t +#define mbe_set_source_rgb cairo_set_source_rgb +#define mbe_set_line_width cairo_set_line_width +#define mbe_font_options_t cairo_font_options_t +#define mbe_scaled_font_t cairo_scaled_font_t +#define mbe_get_font_face cairo_get_font_face +#define mbe_fill_preserve cairo_fill_preserve +#define mbe_set_operator cairo_set_operator +#define mbe_get_operator cairo_get_operator +#define mbe_arc_negative cairo_arc_negative +#define mbe_font_face_t cairo_font_face_t +#define mbe_set_source cairo_set_source +#define mbe_reset_clip cairo_reset_clip +#define mbe_operator_t cairo_operator_t +#define mbe_get_target cairo_get_target +#define mbe_close_path cairo_close_path +#define mbe_translate cairo_translate +#define mbe_text_path cairo_text_path +#define mbe_surface_t cairo_surface_t +#define mbe_show_text cairo_show_text +#define mbe_rectangle cairo_rectangle +#define mbe_pattern_t cairo_pattern_t +#define mbe_in_stroke cairo_in_stroke +#define mbe_status_t cairo_status_t +#define mbe_new_path cairo_new_path +#define mbe_matrix_t cairo_matrix_t +#define mbe_format_t cairo_format_t +#define mbe_curve_to cairo_curve_to +#define mbe_restore cairo_restore +#define mbe_move_to cairo_move_to +#define mbe_line_to cairo_line_to +#define mbe_in_fill cairo_in_fill +#define mbe_destroy cairo_destroy +#define mbe_curve_t cairo_curve_t +#define mbe_stroke cairo_stroke +#define mbe_show_t cairo_show_t +#define mbe_rotate cairo_rotate +#define mbe_move_t cairo_move_t +#define mbe_line_t cairo_line_t +#define mbe_create cairo_create +#define mbe_scale cairo_scale +#define mbe_paint cairo_paint +#define mbe_get_t cairo_get_t +#define mbe_for_t cairo_for_t +#define mbe_save cairo_save +#define mbe_fill cairo_fill +#define mbe_clip cairo_clip +#define mbe_arc cairo_arc +#define mbe_t cairo_t + +#endif /* __MBE_H_ */
--- a/include/mb_paint.h Sun Aug 02 11:00:37 2009 +0800 +++ b/include/mb_paint.h Tue Aug 04 23:35:41 2009 +0800 @@ -1,7 +1,7 @@ #ifndef __PAINT_H_ #define __PAINT_H_ -#include <cairo.h> +#include "mb_graph_engine.h" #include "mb_types.h" #include "mb_redraw_man.h" #include "mb_img_ldr.h"
--- a/include/mb_redraw_man.h Sun Aug 02 11:00:37 2009 +0800 +++ b/include/mb_redraw_man.h Tue Aug 04 23:35:41 2009 +0800 @@ -1,7 +1,7 @@ #ifndef __REDRAW_MAN_H_ #define __REDRAW_MAN_H_ -#include <cairo.h> +#include "mb_graph_engine.h" #include "mb_tools.h" #include "mb_types.h" #include "mb_observer.h" @@ -65,8 +65,8 @@ free_objs_t free_objs; - cairo_t *cr; - cairo_t *backend; + mbe_t *cr; + mbe_t *backend; ob_factory_t ob_factory; @@ -89,8 +89,8 @@ */ }; -extern int redraw_man_init(redraw_man_t *rdman, cairo_t *cr, - cairo_t *backend); +extern int redraw_man_init(redraw_man_t *rdman, mbe_t *cr, + mbe_t *backend); extern void redraw_man_destroy(redraw_man_t *rdman); extern int rdman_find_overlaid_shapes(redraw_man_t *rdman, geo_t *geo,
--- a/include/mb_shapes.h Sun Aug 02 11:00:37 2009 +0800 +++ b/include/mb_shapes.h Tue Aug 04 23:35:41 2009 +0800 @@ -7,7 +7,7 @@ #ifndef __SHAPES_H_ #define __SHAPES_H_ -#include <cairo.h> +#include "mb_graph_engine.h" #include "mb_types.h" #include "mb_redraw_man.h" #include "mb_img_ldr.h" @@ -63,7 +63,7 @@ extern shape_t *rdman_shape_path_new(redraw_man_t *rdman, char *data); extern shape_t *rdman_shape_path_new_from_binary(redraw_man_t *rdman, char *commands, co_aix *arg,int arg_cnt,int *fix_arg,int fix_arg_cnt); extern void sh_path_transform(shape_t *shape); -extern void sh_path_draw(shape_t *shape, cairo_t *cr); +extern void sh_path_draw(shape_t *shape, mbe_t *cr); /* @} */ /*! \defgroup shape_text Shape of Text @@ -72,7 +72,7 @@ extern shape_t *rdman_shape_text_new(redraw_man_t *rdman, const char *txt, co_aix x, co_aix y, co_aix font_size, - cairo_font_face_t *face,PangoAttrList *attrs); + mbe_font_face_t *face,PangoAttrList *attrs); /*! \brief Change the content of the text element. * In the SVG, the content of a text tag can be composed of several tspan inside it. The Madbutterfly parser will collect all content of a * text segement as a single string. The attribute of these characters are saved in a seperate data structure. In the program level, we will @@ -85,7 +85,7 @@ extern void sh_text_set_text(shape_t *shape, const char *txt); extern void sh_text_transform(shape_t *shape); -extern void sh_text_draw(shape_t *shape, cairo_t *cr); +extern void sh_text_draw(shape_t *shape, mbe_t *cr); /* @} */ /*! \defgroup mb_text_t Shape of Text @@ -125,7 +125,7 @@ int nseg; mb_text_segment_t *segs; int flag; - cairo_surface_t *surface; + mbe_surface_t *surface; } mb_text_t; /*! \brief Change the style of the text. @@ -236,7 +236,7 @@ co_aix w, co_aix h, co_aix rx, co_aix ry); extern void sh_rect_transform(shape_t *shape); -extern void sh_rect_draw(shape_t *shape, cairo_t *cr); +extern void sh_rect_draw(shape_t *shape, mbe_t *cr); extern void sh_rect_set(shape_t *shape, co_aix x, co_aix y, co_aix w, co_aix h, co_aix rx, co_aix ry); /* @} */ @@ -248,7 +248,7 @@ co_aix x, co_aix y, co_aix w, co_aix h); extern void sh_image_transform(shape_t *shape); -extern void sh_image_draw(shape_t *shape, cairo_t *cr); +extern void sh_image_draw(shape_t *shape, mbe_t *cr); extern void sh_image_set_geometry(shape_t *shape, co_aix x, co_aix y, co_aix w, co_aix h); /* @} */ @@ -262,8 +262,8 @@ */ /*! \brief Font face of MadButterfly. * - * It actully a cairo_font_face_t, now. But, it can be change for latter. - * So, programmer should not depend on cairo_font_face_t. + * It actully a mbe_font_face_t, now. But, it can be change for latter. + * So, programmer should not depend on mbe_font_face_t. */ typedef struct _mb_font_face mb_font_face_t; @@ -297,7 +297,7 @@ const char *txt, co_aix x, co_aix y); extern void sh_stext_transform(shape_t *shape); -extern void sh_stext_draw(shape_t *shape, cairo_t *cr); +extern void sh_stext_draw(shape_t *shape, mbe_t *cr); extern int sh_stext_set_text(shape_t *shape, const char *txt); extern int sh_stext_set_style(shape_t *shape, const mb_style_blk_t *blks,
--- a/include/mb_types.h Sun Aug 02 11:00:37 2009 +0800 +++ b/include/mb_types.h Tue Aug 04 23:35:41 2009 +0800 @@ -1,7 +1,7 @@ #ifndef __MB_TYPES_H_ #define __MB_TYPES_H_ -#include <cairo.h> +#include "mb_graph_engine.h" #include "mb_tools.h" #include "mb_observer.h" #include "mb_prop.h" @@ -14,8 +14,8 @@ typedef struct _paint paint_t; typedef struct _mb_obj mb_obj_t; typedef struct _mb_sprite mb_sprite_t; -/*! \todo Replace cairo_t with canvas_t. */ -typedef cairo_t canvas_t; +/*! \todo Replace mbe_t with canvas_t. */ +typedef mbe_t canvas_t; struct _redraw_man; @@ -81,7 +81,7 @@ struct _paint { int pnt_type; int flags; - void (*prepare)(paint_t *paint, cairo_t *cr); + void (*prepare)(paint_t *paint, mbe_t *cr); void (*free)(struct _redraw_man *rdman, paint_t *paint); STAILQ(shnode_t) members; paint_t *pnt_next; /*!< \brief Collect all paints of a rdman. */
--- a/src/X_main.c Sun Aug 02 11:00:37 2009 +0800 +++ b/src/X_main.c Tue Aug 04 23:35:41 2009 +0800 @@ -4,7 +4,7 @@ #include <sys/select.h> #include <X11/Xlib.h> #include <X11/Xutil.h> -#include <cairo.h> +#include "mb_graph_engine.h" #include <cairo-xlib.h> #include <pango/pangocairo.h> @@ -120,9 +120,9 @@ } } -void draw_path(cairo_t *cr, int w, int h) { - cairo_t *tmpcr; - cairo_surface_t *tmpsuf; +void draw_path(mbe_t *cr, int w, int h) { + mbe_t *tmpcr; + mbe_surface_t *tmpsuf; redraw_man_t rdman; shape_t *path1, *path2, *rect; coord_t *coord1, *coord2, *coord3; @@ -132,7 +132,7 @@ paint_t *stroke, *text_stroke; shape_t *text; grad_stop_t fill3_stops[3]; - cairo_font_face_t *face; + mbe_font_face_t *face; struct timeval tv; mb_tman_t *tman; mb_timeval_t mbtv, start, playing; @@ -141,10 +141,10 @@ mb_action_t *act; PangoAttrList *attrs = pango_attr_list_new(); - tmpsuf = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h); - tmpcr = cairo_create(tmpsuf); + tmpsuf = mbe_image_surface_create(CAIRO_FORMAT_ARGB32, w, h); + tmpcr = mbe_create(tmpsuf); - cairo_set_source_surface(cr, tmpsuf, 0, 0); + mbe_set_source_surface(cr, tmpsuf, 0, 0); redraw_man_init(&rdman, tmpcr, cr); coord1 = rdman_coord_new(&rdman, rdman.root_coord); coord2 = rdman_coord_new(&rdman, rdman.root_coord); @@ -155,7 +155,7 @@ stroke = rdman_paint_color_new(&rdman, 0.4, 0.4, 0.4, 1); text_stroke = rdman_paint_color_new(&rdman, 0.5, 0.5, 0.5, 1); - face = cairo_get_font_face(tmpcr); + face = mbe_get_font_face(tmpcr); text = rdman_shape_text_new(&rdman, "hello \xe6\xbc\xa2\xe5\xad\x97", 10, h / 4, 36.0, face, attrs); text_fill = rdman_paint_radial_new(&rdman, 100, h / 4, 70); @@ -255,18 +255,18 @@ rdman_shape_free(&rdman, rect); rdman_shape_free(&rdman, text); redraw_man_destroy(&rdman); - cairo_destroy(tmpcr); - cairo_surface_destroy(tmpsuf); + mbe_destroy(tmpcr); + mbe_surface_destroy(tmpsuf); } -void drawing(cairo_surface_t *surface, int w, int h) { - cairo_t *cr; +void drawing(mbe_surface_t *surface, int w, int h) { + mbe_t *cr; - cr = cairo_create(surface); - cairo_set_source_rgb(cr, 0, 0, 0); - cairo_paint(cr); + cr = mbe_create(surface); + mbe_set_source_rgb(cr, 0, 0, 0); + mbe_paint(cr); draw_path(cr, w, h); - cairo_destroy(cr); + mbe_destroy(cr); } int @@ -276,7 +276,7 @@ int screen; XSetWindowAttributes wattr; int depth; - cairo_surface_t *surface; + mbe_surface_t *surface; int w, h; int x, y; int r; @@ -300,9 +300,9 @@ CWOverrideRedirect, &wattr); r = XMapWindow(display, win); - surface = cairo_xlib_surface_create(display, win, visual, w, h); + surface = mbe_xlib_surface_create(display, win, visual, w, h); if(surface == NULL) - printf("cairo_xlib_surface_create\n"); + printf("mbe_xlib_surface_create\n"); drawing(surface, w, h);
--- a/src/X_supp.c Sun Aug 02 11:00:37 2009 +0800 +++ b/src/X_supp.c Tue Aug 04 23:35:41 2009 +0800 @@ -3,7 +3,7 @@ #include <string.h> #include <X11/Xlib.h> #include <X11/Xutil.h> -#include <cairo.h> +#include "mb_graph_engine.h" #include <cairo-xlib.h> #include "mb_redraw_man.h" #include "mb_timer.h" @@ -31,8 +31,8 @@ Display *display; Window win; Visual *visual; - cairo_surface_t *surface, *backend_surface; - cairo_t *cr, *backend_cr; + mbe_surface_t *surface, *backend_surface; + mbe_t *cr, *backend_cr; redraw_man_t *rdman; mb_tman_t *tman; mb_img_ldr_t *img_ldr; @@ -441,18 +441,18 @@ &xmb_rt->visual, &xmb_rt->win); xmb_rt->surface = - cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h); + mbe_image_surface_create(CAIRO_FORMAT_ARGB32, w, h); xmb_rt->backend_surface = - cairo_xlib_surface_create(xmb_rt->display, + mbe_xlib_surface_create(xmb_rt->display, xmb_rt->win, xmb_rt->visual, w, h); - xmb_rt->cr = cairo_create(xmb_rt->surface); - xmb_rt->backend_cr = cairo_create(xmb_rt->backend_surface); + xmb_rt->cr = mbe_create(xmb_rt->surface); + xmb_rt->backend_cr = mbe_create(xmb_rt->backend_surface); - cairo_set_source_surface(xmb_rt->backend_cr, xmb_rt->surface, 0, 0); + mbe_set_source_surface(xmb_rt->backend_cr, xmb_rt->surface, 0, 0); xmb_rt->rdman = (redraw_man_t *)malloc(sizeof(redraw_man_t)); redraw_man_init(xmb_rt->rdman, xmb_rt->cr, xmb_rt->backend_cr); @@ -491,14 +491,14 @@ MB_IMG_LDR_FREE(xmb_rt->img_ldr); if(xmb_rt->cr) - cairo_destroy(xmb_rt->cr); + mbe_destroy(xmb_rt->cr); if(xmb_rt->backend_cr) - cairo_destroy(xmb_rt->backend_cr); + mbe_destroy(xmb_rt->backend_cr); if(xmb_rt->surface) - cairo_surface_destroy(xmb_rt->surface); + mbe_surface_destroy(xmb_rt->surface); if(xmb_rt->backend_surface) - cairo_surface_destroy(xmb_rt->backend_surface); + mbe_surface_destroy(xmb_rt->backend_surface); if(xmb_rt->display) XCloseDisplay(xmb_rt->display);
--- a/src/event.c Sun Aug 02 11:00:37 2009 +0800 +++ b/src/event.c Tue Aug 04 23:35:41 2009 +0800 @@ -4,7 +4,7 @@ #include <stdio.h> #include <stdlib.h> #ifndef UNITTEST -#include <cairo.h> +#include "mb_graph_engine.h" #include "mb_types.h" #include "mb_redraw_man.h" #include "mb_shapes.h" @@ -28,29 +28,29 @@ typedef float co_aix; typedef struct shape shape_t; -typedef struct cairo_surface cairo_surface_t; +typedef struct cairo_surface mbe_surface_t; typedef struct coord coord_t; -typedef struct cairo cairo_t; +typedef struct cairo mbe_t; struct cairo { STAILQ(shape_t) drawed; STAILQ(shape_t) clip_pathes; - cairo_surface_t *tgt; + mbe_surface_t *tgt; }; struct cairo_surface { - cairo_t *cr; + mbe_t *cr; int w, h; unsigned char *data; }; -#define cairo_new_path(cr) do { STAILQ_CLEAN((cr)->drawed); } while(0) -#define cairo_get_target(cr) (cr)->tgt +#define mbe_new_path(cr) do { STAILQ_CLEAN((cr)->drawed); } while(0) +#define mbe_get_target(cr) (cr)->tgt static -cairo_t *cairo_create(cairo_surface_t *target) { - cairo_t *cr; +mbe_t *mbe_create(mbe_surface_t *target) { + mbe_t *cr; - cr = (cairo_t *)malloc(sizeof(cairo_t)); + cr = (mbe_t *)malloc(sizeof(mbe_t)); STAILQ_INIT(cr->drawed); STAILQ_INIT(cr->clip_pathes); cr->tgt = target; @@ -58,23 +58,23 @@ return cr; } -#define cairo_destroy(cr) do { free(cr); } while(0) -#define cairo_clip(cr) \ +#define mbe_destroy(cr) do { free(cr); } while(0) +#define mbe_clip(cr) \ do { \ memcpy(&(cr)->clip_pathes, \ &(cr)->drawed, \ sizeof((cr)->drawed)); \ STAILQ_CLEAN((cr)->drawed); \ } while(0) -#define cairo_fill(cr) +#define mbe_fill(cr) -#define cairo_image_surface_get_width(surface) (surface)->w -#define cairo_image_surface_get_height(surface) (surface)->h +#define mbe_image_surface_get_width(surface) (surface)->w +#define mbe_image_surface_get_height(surface) (surface)->h static -cairo_surface_t *cairo_image_surface_create(int format, int w, int h) { - cairo_surface_t *surf; +mbe_surface_t *mbe_image_surface_create(int format, int w, int h) { + mbe_surface_t *surf; - surf = (cairo_surface_t *)malloc(sizeof(cairo_surface_t)); + surf = (mbe_surface_t *)malloc(sizeof(mbe_surface_t)); surf->w = w; surf->h = h; surf->data = (unsigned char *)malloc(h); @@ -82,9 +82,9 @@ return surf; } -#define cairo_surface_destroy(surface) \ +#define mbe_surface_destroy(surface) \ do { free((surface)->data); free(surface); } while(0) -#define cairo_image_surface_get_stride(surface) 1 +#define mbe_image_surface_get_stride(surface) 1 #define CAIRO_FORMAT_A1 1 @@ -300,7 +300,7 @@ } static -void shape_draw(shape_t *sh, cairo_t *cr) { +void shape_draw(shape_t *sh, mbe_t *cr) { STAILQ_INS_TAIL(cr->drawed, shape_t, drawed_next, sh); } @@ -328,7 +328,7 @@ struct redraw_man { - cairo_t *cr; + mbe_t *cr; coord_t *root_coord; int shape_gl_sz; shape_t *shape_gl[32]; @@ -366,7 +366,7 @@ static coord_t *rdman_coord_new_noparent(redraw_man_t *rdman); static -redraw_man_t *redraw_man_new(cairo_t *cr, cairo_t *backend) { +redraw_man_t *redraw_man_new(mbe_t *cr, mbe_t *backend) { redraw_man_t *rdman; rdman = O_ALLOC(redraw_man_t); @@ -380,7 +380,7 @@ } while(0) static -int cairo_in_fill(cairo_t *cr, int x, int y) { +int mbe_in_fill(mbe_t *cr, int x, int y) { shape_t *shape; int i; @@ -395,7 +395,7 @@ return 0; } -#define cairo_in_stroke cairo_in_fill +#define mbe_in_stroke mbe_in_fill static void rdman_coord_init_noparent(redraw_man_t *rdman, coord_t *co) { @@ -474,8 +474,8 @@ } static -void *cairo_image_surface_get_data(cairo_surface_t *surf) { - cairo_t *cr; +void *mbe_image_surface_get_data(mbe_surface_t *surf) { + mbe_t *cr; shape_t *shape1, *shape2; co_aix x1, y1, x2, y2; int i, j; @@ -533,7 +533,7 @@ * * \note This function should be merged with what is in redraw_man.c. */ -static void draw_shape_path(shape_t *shape, cairo_t *cr) { +static void draw_shape_path(shape_t *shape, mbe_t *cr) { switch(MBO_TYPE(shape)) { case MBO_PATH: sh_path_draw(shape, cr); @@ -563,16 +563,16 @@ * _shape_pos_is_in() insteaded. */ static int _shape_pos_is_in_cairo(shape_t *shape, co_aix x, co_aix y, - int *in_stroke, cairo_t *cr) { + int *in_stroke, mbe_t *cr) { draw_shape_path(shape, cr); if(shape->fill) { - if(cairo_in_fill(cr, x, y)) { + if(mbe_in_fill(cr, x, y)) { *in_stroke = 0; return TRUE; } } if(shape->stroke) { - if(cairo_in_stroke(cr, x, y)) { + if(mbe_in_stroke(cr, x, y)) { *in_stroke = 1; return TRUE; } @@ -584,7 +584,7 @@ */ static int _shape_pos_is_in(shape_t *shape, co_aix x, co_aix y, - int *in_stroke, cairo_t *cr) { + int *in_stroke, mbe_t *cr) { int r; r = sh_pos_is_in(shape, x, y); @@ -592,7 +592,7 @@ return FALSE; r = _shape_pos_is_in_cairo(shape, x, y, in_stroke, cr); - cairo_new_path(cr); + mbe_new_path(cr); if(!r) return FALSE; @@ -604,7 +604,7 @@ static shape_t *_find_shape_in_pos(redraw_man_t *rdman, co_aix x, co_aix y, int *in_stroke) { shape_t *shape; - cairo_t *cr; + mbe_t *cr; int i, r; cr = rdman_get_cr(rdman); @@ -667,57 +667,57 @@ } static -cairo_t * _prepare_cairo_for_testing(redraw_man_t *rdman) { - cairo_surface_t *surface, *rdman_surface; - cairo_t *cr; +mbe_t * _prepare_mbe_for_testing(redraw_man_t *rdman) { + mbe_surface_t *surface, *rdman_surface; + mbe_t *cr; int w, h; - rdman_surface = cairo_get_target(rdman_get_cr(rdman)); - w = cairo_image_surface_get_width(rdman_surface); - h = cairo_image_surface_get_height(rdman_surface); + rdman_surface = mbe_get_target(rdman_get_cr(rdman)); + w = mbe_image_surface_get_width(rdman_surface); + h = mbe_image_surface_get_height(rdman_surface); - surface = cairo_image_surface_create(CAIRO_FORMAT_A1, w, h); + surface = mbe_image_surface_create(CAIRO_FORMAT_A1, w, h); if(surface == NULL) return NULL; - cr = cairo_create(surface); + cr = mbe_create(surface); if(cr == NULL) - cairo_surface_destroy(surface); + mbe_surface_destroy(surface); return cr; } static -void _release_cairo_for_testing(cairo_t *cr) { - cairo_destroy(cr); +void _release_mbe_for_testing(mbe_t *cr) { + mbe_destroy(cr); } static -void _draw_to_mask(shape_t *shape, cairo_t *cr) { +void _draw_to_mask(shape_t *shape, mbe_t *cr) { if(sh_get_flags(shape, GEF_OV_DRAW)) return; draw_shape_path(shape, cr); - cairo_clip(cr); + mbe_clip(cr); sh_set_flags(shape, GEF_OV_DRAW); } static -int _fill_and_check(shape_t *shape, cairo_t *cr) { +int _fill_and_check(shape_t *shape, mbe_t *cr) { int h, stride; - cairo_surface_t *surface; + mbe_surface_t *surface; unsigned char *data; int i, sz; draw_shape_path(shape, cr); - cairo_fill(cr); + mbe_fill(cr); - surface = cairo_get_target(cr); - data = cairo_image_surface_get_data(surface); + surface = mbe_get_target(cr); + data = mbe_image_surface_get_data(surface); - h = cairo_image_surface_get_height(surface); - stride = cairo_image_surface_get_stride(surface); + h = mbe_image_surface_get_height(surface); + stride = mbe_image_surface_get_stride(surface); sz = stride * h; for(i = 0; i < sz; i++) { @@ -738,7 +738,7 @@ */ static int _is_obj_objs_overlay(mb_obj_t *obj, mb_obj_t *others_root, - cairo_t *cr) { + mbe_t *cr) { area_t *area, *candi_area; coord_t *coord, *candi_coord, *root; shape_t *shape, *candi_shape; @@ -829,13 +829,13 @@ */ int mb_objs_are_overlay(redraw_man_t *rdman, mb_obj_t *obj1, mb_obj_t *obj2) { - cairo_t *cr; + mbe_t *cr; area_t *area; shape_t *shape; coord_t *coord, *root; int r; - cr = _prepare_cairo_for_testing(rdman); + cr = _prepare_mbe_for_testing(rdman); if(IS_MBO_SHAPES(obj1)) { shape = (shape_t *)obj1; @@ -862,7 +862,7 @@ out: _clear_ov_draw(obj2); /* marked by _is_obj_objs_overlay() */ - _release_cairo_for_testing(cr); + _release_mbe_for_testing(cr); return r; } @@ -873,12 +873,12 @@ static redraw_man_t *_fake_rdman(void) { redraw_man_t *rdman; - cairo_t *cr, *backend; - cairo_surface_t *surf; + mbe_t *cr, *backend; + mbe_surface_t *surf; - surf = cairo_image_surface_create(CAIRO_FORMAT_A1, 100, 100); - cr = cairo_create(surf); - backend = cairo_create(surf); + surf = mbe_image_surface_create(CAIRO_FORMAT_A1, 100, 100); + cr = mbe_create(surf); + backend = mbe_create(surf); rdman = redraw_man_new(cr, backend); return rdman; @@ -886,8 +886,8 @@ static void _free_fake_rdman(redraw_man_t *rdman) { - cairo_surface_destroy(rdman->cr->tgt); - cairo_destroy(rdman->cr); + mbe_surface_destroy(rdman->cr->tgt); + mbe_destroy(rdman->cr); free(rdman); } @@ -938,8 +938,8 @@ redraw_man_t *rdman; coord_t *root, *coord1, *coord2; shape_t *shape1, *shape2, *shape3; - cairo_t *cr; - cairo_surface_t *surf; + mbe_t *cr; + mbe_surface_t *surf; int r; rdman = _fake_rdman(); @@ -962,102 +962,102 @@ shape_add_point(shape2, 5, 5); shape_add_point(shape3, 4, 3); - surf = cairo_image_surface_create(CAIRO_FORMAT_A1, 100, 100); - cr = cairo_create(surf); + surf = mbe_image_surface_create(CAIRO_FORMAT_A1, 100, 100); + cr = mbe_create(surf); r = _is_obj_objs_overlay((mb_obj_t *)coord1, (mb_obj_t *)coord2, cr); CU_ASSERT(!r); - cairo_destroy(cr); - cairo_surface_destroy(surf); + mbe_destroy(cr); + mbe_surface_destroy(surf); sh_clear_flags(coord2, GEF_OV_DRAW); - surf = cairo_image_surface_create(CAIRO_FORMAT_A1, 100, 100); - cr = cairo_create(surf); + surf = mbe_image_surface_create(CAIRO_FORMAT_A1, 100, 100); + cr = mbe_create(surf); r = _is_obj_objs_overlay((mb_obj_t *)shape1, (mb_obj_t *)coord2, cr); CU_ASSERT(!r); - cairo_destroy(cr); - cairo_surface_destroy(surf); + mbe_destroy(cr); + mbe_surface_destroy(surf); sh_clear_flags(coord2, GEF_OV_DRAW); - surf = cairo_image_surface_create(CAIRO_FORMAT_A1, 100, 100); - cr = cairo_create(surf); + surf = mbe_image_surface_create(CAIRO_FORMAT_A1, 100, 100); + cr = mbe_create(surf); r = _is_obj_objs_overlay((mb_obj_t *)coord1, (mb_obj_t *)shape2, cr); CU_ASSERT(!r); - cairo_destroy(cr); - cairo_surface_destroy(surf); + mbe_destroy(cr); + mbe_surface_destroy(surf); sh_clear_flags(shape2, GEF_OV_DRAW); - surf = cairo_image_surface_create(CAIRO_FORMAT_A1, 100, 100); - cr = cairo_create(surf); + surf = mbe_image_surface_create(CAIRO_FORMAT_A1, 100, 100); + cr = mbe_create(surf); r = _is_obj_objs_overlay((mb_obj_t *)shape1, (mb_obj_t *)shape2, cr); CU_ASSERT(!r); - cairo_destroy(cr); - cairo_surface_destroy(surf); + mbe_destroy(cr); + mbe_surface_destroy(surf); sh_clear_flags(shape2, GEF_OV_DRAW); - surf = cairo_image_surface_create(CAIRO_FORMAT_A1, 100, 100); - cr = cairo_create(surf); + surf = mbe_image_surface_create(CAIRO_FORMAT_A1, 100, 100); + cr = mbe_create(surf); r = _is_obj_objs_overlay((mb_obj_t *)shape1, (mb_obj_t *)shape3, cr); CU_ASSERT(!r); - cairo_destroy(cr); - cairo_surface_destroy(surf); + mbe_destroy(cr); + mbe_surface_destroy(surf); sh_clear_flags(shape3, GEF_OV_DRAW); - surf = cairo_image_surface_create(CAIRO_FORMAT_A1, 100, 100); - cr = cairo_create(surf); + surf = mbe_image_surface_create(CAIRO_FORMAT_A1, 100, 100); + cr = mbe_create(surf); r = _is_obj_objs_overlay((mb_obj_t *)coord1, (mb_obj_t *)shape3, cr); CU_ASSERT(!r); - cairo_destroy(cr); - cairo_surface_destroy(surf); + mbe_destroy(cr); + mbe_surface_destroy(surf); sh_clear_flags(shape3, GEF_OV_DRAW); shape_add_point(shape1, 5, 5); - surf = cairo_image_surface_create(CAIRO_FORMAT_A1, 100, 100); - cr = cairo_create(surf); + surf = mbe_image_surface_create(CAIRO_FORMAT_A1, 100, 100); + cr = mbe_create(surf); r = _is_obj_objs_overlay((mb_obj_t *)coord1, (mb_obj_t *)coord2, cr); CU_ASSERT(r); - cairo_destroy(cr); - cairo_surface_destroy(surf); + mbe_destroy(cr); + mbe_surface_destroy(surf); sh_clear_flags(coord2, GEF_OV_DRAW); - surf = cairo_image_surface_create(CAIRO_FORMAT_A1, 100, 100); - cr = cairo_create(surf); + surf = mbe_image_surface_create(CAIRO_FORMAT_A1, 100, 100); + cr = mbe_create(surf); r = _is_obj_objs_overlay((mb_obj_t *)shape1, (mb_obj_t *)coord2, cr); CU_ASSERT(r); - cairo_destroy(cr); - cairo_surface_destroy(surf); + mbe_destroy(cr); + mbe_surface_destroy(surf); sh_clear_flags(coord2, GEF_OV_DRAW); - surf = cairo_image_surface_create(CAIRO_FORMAT_A1, 100, 100); - cr = cairo_create(surf); + surf = mbe_image_surface_create(CAIRO_FORMAT_A1, 100, 100); + cr = mbe_create(surf); r = _is_obj_objs_overlay((mb_obj_t *)coord1, (mb_obj_t *)shape2, cr); CU_ASSERT(r); - cairo_destroy(cr); - cairo_surface_destroy(surf); + mbe_destroy(cr); + mbe_surface_destroy(surf); sh_clear_flags(shape2, GEF_OV_DRAW); - surf = cairo_image_surface_create(CAIRO_FORMAT_A1, 100, 100); - cr = cairo_create(surf); + surf = mbe_image_surface_create(CAIRO_FORMAT_A1, 100, 100); + cr = mbe_create(surf); r = _is_obj_objs_overlay((mb_obj_t *)shape1, (mb_obj_t *)shape2, cr); CU_ASSERT(r); - cairo_destroy(cr); - cairo_surface_destroy(surf); + mbe_destroy(cr); + mbe_surface_destroy(surf); sh_clear_flags(shape2, GEF_OV_DRAW); - surf = cairo_image_surface_create(CAIRO_FORMAT_A1, 100, 100); - cr = cairo_create(surf); + surf = mbe_image_surface_create(CAIRO_FORMAT_A1, 100, 100); + cr = mbe_create(surf); r = _is_obj_objs_overlay((mb_obj_t *)shape1, (mb_obj_t *)shape3, cr); CU_ASSERT(!r); - cairo_destroy(cr); - cairo_surface_destroy(surf); + mbe_destroy(cr); + mbe_surface_destroy(surf); sh_clear_flags(shape3, GEF_OV_DRAW); - surf = cairo_image_surface_create(CAIRO_FORMAT_A1, 100, 100); - cr = cairo_create(surf); + surf = mbe_image_surface_create(CAIRO_FORMAT_A1, 100, 100); + cr = mbe_create(surf); r = _is_obj_objs_overlay((mb_obj_t *)coord1, (mb_obj_t *)shape3, cr); CU_ASSERT(r); - cairo_destroy(cr); - cairo_surface_destroy(surf); + mbe_destroy(cr); + mbe_surface_destroy(surf); sh_clear_flags(shape3, GEF_OV_DRAW); rdman_shape_free(rdman, shape1);
--- a/src/img_ldr.c Sun Aug 02 11:00:37 2009 +0800 +++ b/src/img_ldr.c Tue Aug 04 23:35:41 2009 +0800 @@ -1,6 +1,6 @@ #include <stdio.h> #include <string.h> -#include <cairo.h> +#include "mb_graph_engine.h" #include "mb_tools.h" #include "mb_paint.h" #include "mb_img_ldr.h" @@ -16,7 +16,7 @@ struct _simple_mb_img_data { mb_img_data_t img; - cairo_surface_t *surf; + mbe_surface_t *surf; }; typedef struct _simple_mb_img_data simple_mb_img_data_t; @@ -26,9 +26,9 @@ mb_img_data_t *simple_mb_img_ldr_load(mb_img_ldr_t *ldr, const char *img_id) { simple_mb_img_ldr_t *sldr = (simple_mb_img_ldr_t *)ldr; simple_mb_img_data_t *img; - cairo_surface_t *surf; + mbe_surface_t *surf; char *fname; - cairo_format_t fmt; + mbe_format_t fmt; int sz; sz = strlen(sldr->repo); @@ -37,20 +37,20 @@ strcpy(fname, sldr->repo); strcat(fname, img_id); - surf = cairo_image_surface_create_from_png(fname); + surf = mbe_image_surface_create_from_png(fname); if(surf == NULL) return NULL; img = O_ALLOC(simple_mb_img_data_t); if(img == NULL) { - cairo_surface_destroy(surf); + mbe_surface_destroy(surf); return NULL; } - img->img.content = cairo_image_surface_get_data(surf); - img->img.w = cairo_image_surface_get_width(surf); - img->img.h = cairo_image_surface_get_height(surf); - img->img.stride = cairo_image_surface_get_stride(surf); - fmt = cairo_image_surface_get_format(surf); + img->img.content = mbe_image_surface_get_data(surf); + img->img.w = mbe_image_surface_get_width(surf); + img->img.h = mbe_image_surface_get_height(surf); + img->img.stride = mbe_image_surface_get_stride(surf); + fmt = mbe_image_surface_get_format(surf); switch(fmt) { case CAIRO_FORMAT_ARGB32: img->img.fmt = MB_IFMT_ARGB32; @@ -69,7 +69,7 @@ break; default: - cairo_surface_destroy(surf); + mbe_surface_destroy(surf); free(img); return NULL; } @@ -82,7 +82,7 @@ static void simple_mb_img_ldr_img_free(mb_img_data_t *img) { simple_mb_img_data_t *simg = (simple_mb_img_data_t *)img; - cairo_surface_destroy((cairo_surface_t *)simg->surf); + mbe_surface_destroy((mbe_surface_t *)simg->surf); free(img); }
--- a/src/paint.c Sun Aug 02 11:00:37 2009 +0800 +++ b/src/paint.c Tue Aug 04 23:35:41 2009 +0800 @@ -1,6 +1,6 @@ #include <stdio.h> #include <stdlib.h> -#include <cairo.h> +#include "mb_graph_engine.h" #include "mb_paint.h" #define ASSERT(x) @@ -15,10 +15,10 @@ int _paint_color_size = sizeof(paint_color_t); -static void paint_color_prepare(paint_t *paint, cairo_t *cr) { +static void paint_color_prepare(paint_t *paint, mbe_t *cr) { paint_color_t *color = (paint_color_t *)paint; - cairo_set_source_rgba(cr, color->r, color->g, color->b, color->a); + mbe_set_source_rgba(cr, color->r, color->g, color->b, color->a); } static void paint_color_free(redraw_man_t *rdman, paint_t *paint) { @@ -75,41 +75,41 @@ int n_stops; grad_stop_t *stops; int flags; - cairo_pattern_t *ptn; + mbe_pattern_t *ptn; } paint_linear_t; #define LIF_DIRTY 0x1 -static void paint_linear_prepare(paint_t *paint, cairo_t *cr) { +static void paint_linear_prepare(paint_t *paint, mbe_t *cr) { paint_linear_t *linear = (paint_linear_t *)paint; - cairo_pattern_t *ptn; + mbe_pattern_t *ptn; grad_stop_t *stop; int i; ptn = linear->ptn; if(linear->flags & LIF_DIRTY) { if(ptn) - cairo_pattern_destroy(ptn); + mbe_pattern_destroy(ptn); linear->flags &= ~LIF_DIRTY; - ptn = cairo_pattern_create_linear(linear->x1, linear->y1, + ptn = mbe_pattern_create_linear(linear->x1, linear->y1, linear->x2, linear->y2); for(i = 0; i < linear->n_stops; i++) { stop = &linear->stops[i]; - cairo_pattern_add_color_stop_rgba(ptn, stop->offset, + mbe_pattern_add_color_stop_rgba(ptn, stop->offset, stop->r, stop->g, stop->b, stop->a); } linear->ptn = ptn; } - cairo_set_source(cr, ptn); + mbe_set_source(cr, ptn); } static void paint_linear_free(redraw_man_t *rdman, paint_t *paint) { paint_linear_t *linear = (paint_linear_t *)paint; if(linear->ptn) - cairo_pattern_destroy(linear->ptn); + mbe_pattern_destroy(linear->ptn); paint_destroy(paint); free(paint); } @@ -169,39 +169,39 @@ int n_stops; grad_stop_t *stops; int flags; - cairo_pattern_t *ptn; + mbe_pattern_t *ptn; } paint_radial_t; #define RDF_DIRTY 0x1 -static void paint_radial_prepare(paint_t *paint, cairo_t *cr) { +static void paint_radial_prepare(paint_t *paint, mbe_t *cr) { paint_radial_t *radial = (paint_radial_t *)paint; - cairo_pattern_t *ptn; + mbe_pattern_t *ptn; grad_stop_t *stop; int i; if(radial->flags & RDF_DIRTY) { - ptn = cairo_pattern_create_radial(radial->cx, radial->cy, 0, + ptn = mbe_pattern_create_radial(radial->cx, radial->cy, 0, radial->cx, radial->cy, radial->r); ASSERT(ptn != NULL); stop = radial->stops; for(i = 0; i < radial->n_stops; i++, stop++) { - cairo_pattern_add_color_stop_rgba(ptn, stop->offset, + mbe_pattern_add_color_stop_rgba(ptn, stop->offset, stop->r, stop->g, stop->b, stop->a); } - cairo_pattern_destroy(radial->ptn); + mbe_pattern_destroy(radial->ptn); radial->ptn = ptn; } - cairo_set_source(cr, radial->ptn); + mbe_set_source(cr, radial->ptn); } static void paint_radial_free(redraw_man_t *rdman, paint_t *paint) { paint_radial_t *radial = (paint_radial_t *)paint; if(radial->ptn) - cairo_pattern_destroy(radial->ptn); + mbe_pattern_destroy(radial->ptn); paint_destroy(paint); free(paint); } @@ -255,17 +255,17 @@ typedef struct _paint_image { paint_t paint; mb_img_data_t *img; - cairo_surface_t *surf; - cairo_pattern_t *ptn; + mbe_surface_t *surf; + mbe_pattern_t *ptn; } paint_image_t; static -void paint_image_prepare(paint_t *paint, cairo_t *cr) { +void paint_image_prepare(paint_t *paint, mbe_t *cr) { paint_image_t *paint_img = (paint_image_t *)paint; mb_img_data_t *img_data; img_data = paint_img->img; - cairo_set_source(cr, paint_img->ptn); + mbe_set_source(cr, paint_img->ptn); } static @@ -273,7 +273,7 @@ paint_image_t *paint_img = (paint_image_t *)paint; mb_img_data_t *img_data; - cairo_surface_destroy(paint_img->surf); + mbe_surface_destroy(paint_img->surf); img_data = paint_img->img; MB_IMG_DATA_FREE(img_data); paint_destroy(&paint_img->paint); @@ -316,7 +316,7 @@ paint_init(&paint->paint, MBP_IMAGE, paint_image_prepare, paint_image_free); paint->img = img; - paint->surf = cairo_image_surface_create_for_data(img->content, + paint->surf = mbe_image_surface_create_for_data(img->content, fmt, img->w, img->h, @@ -327,10 +327,10 @@ return NULL; } - paint->ptn = cairo_pattern_create_for_surface(paint->surf); + paint->ptn = mbe_pattern_create_for_surface(paint->surf); if(paint->ptn == NULL) { paint_destroy(&paint->paint); - cairo_surface_destroy(paint->surf); + mbe_surface_destroy(paint->surf); free(paint); return NULL; } @@ -346,7 +346,7 @@ */ void paint_image_set_matrix(paint_t *paint, co_aix matrix[6]) { paint_image_t *img_paint = (paint_image_t *)paint; - cairo_matrix_t cmatrix; + mbe_matrix_t cmatrix; cmatrix.xx = matrix[0]; cmatrix.xy = matrix[1]; @@ -354,7 +354,7 @@ cmatrix.yx = matrix[3]; cmatrix.yy = matrix[4]; cmatrix.y0 = matrix[5]; - cairo_pattern_set_matrix(img_paint->ptn, &cmatrix); + mbe_pattern_set_matrix(img_paint->ptn, &cmatrix); } void paint_image_get_size(paint_t *paint, int *w, int *h) {
--- a/src/redraw_man.c Sun Aug 02 11:00:37 2009 +0800 +++ b/src/redraw_man.c Tue Aug 04 23:35:41 2009 +0800 @@ -2,7 +2,7 @@ #include <stdlib.h> #include <string.h> #include <math.h> -#include <cairo.h> +#include "mb_graph_engine.h" #include "mb_types.h" #include "mb_shapes.h" #include "mb_tools.h" @@ -330,7 +330,7 @@ typedef struct _sh_dummy sh_dummy_t; extern void sh_dummy_transform(shape_t *shape); -extern void sh_dummy_fill(shape_t *, cairo_t *); +extern void sh_dummy_fill(shape_t *, mbe_t *); #endif /* UNITTEST */ static subject_t *ob_subject_alloc(ob_factory_t *factory); @@ -507,14 +507,14 @@ -static cairo_t *canvas_new(int w, int h) { +static mbe_t *canvas_new(int w, int h) { #ifndef UNITTEST - cairo_surface_t *surface; - cairo_t *cr; + mbe_surface_t *surface; + mbe_t *cr; - surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, + surface = mbe_image_surface_create(CAIRO_FORMAT_ARGB32, w, h); - cr = cairo_create(surface); + cr = mbe_create(surface); return cr; #else @@ -522,19 +522,19 @@ #endif } -static void canvas_free(cairo_t *canvas) { +static void canvas_free(mbe_t *canvas) { #ifndef UNITTEST - cairo_destroy(canvas); + mbe_destroy(canvas); #endif } -static void canvas_get_size(cairo_t *canvas, int *w, int *h) { +static void canvas_get_size(mbe_t *canvas, int *w, int *h) { #ifndef UNITTEST - cairo_surface_t *surface; + mbe_surface_t *surface; - surface = cairo_get_target(canvas); - *w = cairo_image_surface_get_width(surface); - *h = cairo_image_surface_get_height(surface); + surface = mbe_get_target(canvas); + *w = mbe_image_surface_get_width(surface); + *h = mbe_image_surface_get_height(surface); #else *w = 0; *h = 0; @@ -576,7 +576,7 @@ static coord_canvas_info_t *coord_canvas_info_new(redraw_man_t *rdman, coord_t *coord, - cairo_t *canvas) { + mbe_t *canvas) { coord_canvas_info_t *info; info = (coord_canvas_info_t *)elmpool_elm_alloc(rdman->coord_canvas_pool); @@ -599,7 +599,7 @@ static void mouse_event_root_dummy(event_t *evt, void *arg) { } -int redraw_man_init(redraw_man_t *rdman, cairo_t *cr, cairo_t *backend) { +int redraw_man_init(redraw_man_t *rdman, mbe_t *cr, mbe_t *backend) { extern void redraw_man_destroy(redraw_man_t *rdman); extern int _paint_color_size; observer_t *addrm_ob; @@ -1353,7 +1353,7 @@ co_aix x, y; int w, h; int c_w, c_h; - cairo_t *canvas; + mbe_t *canvas; co_aix *aggr; co_aix poses[2][2]; @@ -1782,23 +1782,23 @@ */ #ifndef UNITTEST -static void set_shape_stroke_param(shape_t *shape, cairo_t *cr) { - cairo_set_line_width(cr, shape->stroke_width); +static void set_shape_stroke_param(shape_t *shape, mbe_t *cr) { + mbe_set_line_width(cr, shape->stroke_width); } static void fill_path_preserve(redraw_man_t *rdman) { - cairo_fill_preserve(rdman->cr); + mbe_fill_preserve(rdman->cr); } static void fill_path(redraw_man_t *rdman) { - cairo_fill(rdman->cr); + mbe_fill(rdman->cr); } static void stroke_path(redraw_man_t *rdman) { - cairo_stroke(rdman->cr); + mbe_stroke(rdman->cr); } #else -static void set_shape_stroke_param(shape_t *shape, cairo_t *cr) { +static void set_shape_stroke_param(shape_t *shape, mbe_t *cr) { } static void fill_path_preserve(redraw_man_t *rdman) { @@ -1811,7 +1811,7 @@ } #endif -static void draw_shape(redraw_man_t *rdman, cairo_t *cr, shape_t *shape) { +static void draw_shape(redraw_man_t *rdman, mbe_t *cr, shape_t *shape) { paint_t *fill, *stroke; /*! \todo Move operator of shapes into singleton structures that define @@ -1865,45 +1865,45 @@ #ifndef UNITTEST static void clear_canvas(canvas_t *canvas) { - cairo_operator_t old_op; + mbe_operator_t old_op; - old_op = cairo_get_operator(canvas); - cairo_set_operator(canvas, CAIRO_OPERATOR_CLEAR); - cairo_paint(canvas); - cairo_set_operator(canvas, old_op); + old_op = mbe_get_operator(canvas); + mbe_set_operator(canvas, CAIRO_OPERATOR_CLEAR); + mbe_paint(canvas); + mbe_set_operator(canvas, old_op); } -static void make_clip(cairo_t *cr, int n_dirty_areas, +static void make_clip(mbe_t *cr, int n_dirty_areas, area_t **dirty_areas) { int i; area_t *area; - cairo_new_path(cr); + mbe_new_path(cr); for(i = 0; i < n_dirty_areas; i++) { area = dirty_areas[i]; - cairo_rectangle(cr, area->x, area->y, area->w, area->h); + mbe_rectangle(cr, area->x, area->y, area->w, area->h); } - cairo_clip(cr); + mbe_clip(cr); } static void reset_clip(canvas_t *cr) { - cairo_reset_clip(cr); + mbe_reset_clip(cr); } static void copy_cr_2_backend(redraw_man_t *rdman, int n_dirty_areas, area_t **dirty_areas) { - cairo_operator_t saved_op; + mbe_operator_t saved_op; if(n_dirty_areas) make_clip(rdman->backend, n_dirty_areas, dirty_areas); - saved_op = cairo_get_operator(rdman->backend); - cairo_set_operator(rdman->backend, CAIRO_OPERATOR_SOURCE); - cairo_paint(rdman->backend); - cairo_set_operator(rdman->backend, saved_op); + saved_op = mbe_get_operator(rdman->backend); + mbe_set_operator(rdman->backend, CAIRO_OPERATOR_SOURCE); + mbe_paint(rdman->backend); + mbe_set_operator(rdman->backend, saved_op); } #else /* UNITTEST */ -static void make_clip(cairo_t *cr, int n_dirty_areas, +static void make_clip(mbe_t *cr, int n_dirty_areas, area_t **dirty_areas) { } @@ -1920,10 +1920,10 @@ static void update_cached_canvas_2_parent(redraw_man_t *rdman, coord_t *coord) { - cairo_t *pcanvas, *canvas; - cairo_surface_t *surface; - cairo_pattern_t *pattern; - cairo_matrix_t cr_matrix; + mbe_t *pcanvas, *canvas; + mbe_surface_t *surface; + mbe_pattern_t *pattern; + mbe_matrix_t cr_matrix; co_aix reverse[6]; co_aix canvas2pdev_matrix[6]; @@ -1942,11 +1942,11 @@ canvas = _coord_get_canvas(coord); pcanvas = _coord_get_canvas(coord->parent); - surface = cairo_get_target(canvas); - pattern = cairo_pattern_create_for_surface(surface); - cairo_pattern_set_matrix(pattern, &cr_matrix); - cairo_set_source(pcanvas, pattern); - cairo_paint_with_alpha(pcanvas, coord->opacity); + surface = mbe_get_target(canvas); + pattern = mbe_pattern_create_for_surface(surface); + mbe_pattern_set_matrix(pattern, &cr_matrix); + mbe_set_source(pcanvas, pattern); + mbe_paint_with_alpha(pcanvas, coord->opacity); } static int draw_coord_shapes_in_dirty_areas(redraw_man_t *rdman, @@ -1955,7 +1955,7 @@ int r; area_t **areas; int n_areas; - cairo_t *canvas; + mbe_t *canvas; geo_t *member; coord_t *child; int mem_idx; @@ -2003,7 +2003,7 @@ coord_t *coord) { area_t **areas, *area; int n_areas; - cairo_t *canvas; + mbe_t *canvas; int i; int r; @@ -2129,15 +2129,15 @@ int rdman_redraw_all(redraw_man_t *rdman) { area_t area; #ifndef UNITTEST - cairo_surface_t *surface; + mbe_surface_t *surface; #endif int r; area.x = area.y = 0; #ifndef UNITTEST - surface = cairo_get_target(rdman->cr); - area.w = cairo_image_surface_get_width(surface); - area.h = cairo_image_surface_get_height(surface); + surface = mbe_get_target(rdman->cr); + area.w = mbe_image_surface_get_width(surface); + area.h = mbe_image_surface_get_height(surface); #else area.w = 1024; area.h = 1024; @@ -2377,14 +2377,14 @@ dummy->trans_cnt++; } -void sh_dummy_fill(shape_t *shape, cairo_t *cr) { +void sh_dummy_fill(shape_t *shape, mbe_t *cr) { sh_dummy_t *dummy; dummy = (sh_dummy_t *)shape; dummy->draw_cnt++; } -static void dummy_paint_prepare(paint_t *paint, cairo_t *cr) { +static void dummy_paint_prepare(paint_t *paint, mbe_t *cr) { } static void dummy_paint_free(redraw_man_t *rdman, paint_t *paint) {
--- a/src/shape_image.c Sun Aug 02 11:00:37 2009 +0800 +++ b/src/shape_image.c Tue Aug 04 23:35:41 2009 +0800 @@ -1,6 +1,6 @@ #include <stdio.h> #include <string.h> -#include <cairo.h> +#include "mb_graph_engine.h" #include "mb_types.h" #include "mb_shapes.h" #include "mb_img_ldr.h" @@ -70,7 +70,7 @@ shape_t *rdman_shape_image_new(redraw_man_t *rdman, co_aix x, co_aix y, co_aix w, co_aix h) { sh_image_t *img; - cairo_format_t fmt; + mbe_format_t fmt; int r; img = O_ALLOC(sh_image_t); @@ -104,7 +104,7 @@ co_aix img_matrix[6]; co_aix x_factor, y_factor; int img_w, img_h; - cairo_matrix_t cmatrix; + mbe_matrix_t cmatrix; int i; poses = img->poses; @@ -155,17 +155,17 @@ * * \note Image is not rescaled for size of the shape. */ -void sh_image_draw(shape_t *shape, cairo_t *cr) { +void sh_image_draw(shape_t *shape, mbe_t *cr) { sh_image_t *img = (sh_image_t *)shape; - cairo_pattern_t *saved_source; - cairo_matrix_t matrix, saved_matrix; + mbe_pattern_t *saved_source; + mbe_matrix_t matrix, saved_matrix; co_aix *aggr; - cairo_move_to(cr, img->poses[0][0], img->poses[0][1]); - cairo_line_to(cr, img->poses[1][0], img->poses[1][1]); - cairo_line_to(cr, img->poses[2][0], img->poses[2][1]); - cairo_line_to(cr, img->poses[3][0], img->poses[3][1]); - cairo_close_path(cr); + mbe_move_to(cr, img->poses[0][0], img->poses[0][1]); + mbe_line_to(cr, img->poses[1][0], img->poses[1][1]); + mbe_line_to(cr, img->poses[2][0], img->poses[2][1]); + mbe_line_to(cr, img->poses[3][0], img->poses[3][1]); + mbe_close_path(cr); } /*! \brief Change geometry of an image.
--- a/src/shape_path.c Sun Aug 02 11:00:37 2009 +0800 +++ b/src/shape_path.c Tue Aug 04 23:35:41 2009 +0800 @@ -2,7 +2,7 @@ #include <stdlib.h> #include <ctype.h> #include <string.h> -#include <cairo.h> +#include "mb_graph_engine.h" #include "mb_types.h" #include "mb_redraw_man.h" @@ -235,7 +235,7 @@ /*! \brief Make path for arcs in a path. */ -void sh_path_arc_path(cairo_t *cr, const co_aix **args_p, +void sh_path_arc_path(mbe_t *cr, const co_aix **args_p, const int **fix_args_p) { co_aix cx, cy, x0, y0, x, y, xx, xy; co_aix dx, dy, dx0, dy0, dxx, dxy; @@ -295,15 +295,15 @@ /* Make a path for arc */ rotate = acos(dxx / rx); - cairo_save(cr); - cairo_translate(cr, cx, cy); - cairo_rotate(cr, rotate); - cairo_scale(cr, 1.0, xyratio); + mbe_save(cr); + mbe_translate(cr, cx, cy); + mbe_rotate(cr, rotate); + mbe_scale(cr, 1.0, xyratio); if(sweep) - cairo_arc(cr, 0, 0, rx, angle0, angle); + mbe_arc(cr, 0, 0, rx, angle0, angle); else - cairo_arc_negative(cr, 0, 0, rx, angle0, angle); - cairo_restore(cr); + mbe_arc_negative(cr, 0, 0, rx, angle0, angle); + mbe_restore(cr); *args_p = args; *fix_args_p = fix_args; @@ -795,7 +795,7 @@ } } -static void sh_path_path(shape_t *shape, cairo_t *cr) { +static void sh_path_path(shape_t *shape, mbe_t *cr) { sh_path_t *path; int cmd_len; char *cmds, cmd; @@ -821,12 +821,12 @@ case 'M': x = *args++; y = *args++; - cairo_move_to(cr, x, y); + mbe_move_to(cr, x, y); break; case 'L': x = *args++; y = *args++; - cairo_line_to(cr, x, y); + mbe_line_to(cr, x, y); break; case 'C': x1 = *args++; @@ -835,7 +835,7 @@ y2 = *args++; x = *args++; y = *args++; - cairo_curve_to(cr, x1, y1, x2, y2, x, y); + mbe_curve_to(cr, x1, y1, x2, y2, x, y); break; case 'S': x1 = x + x - x2; @@ -844,7 +844,7 @@ y2 = *args++; x = *args++; y = *args++; - cairo_curve_to(cr, x1, y1, x2, y2, x, y); + mbe_curve_to(cr, x1, y1, x2, y2, x, y); break; case 'Q': x1 = *args++; @@ -853,7 +853,7 @@ y2 = y1; x = *args++; y = *args++; - cairo_curve_to(cr, x1, y1, x2, y2, x, y); + mbe_curve_to(cr, x1, y1, x2, y2, x, y); break; case 'T': x1 = x + x - x2; @@ -862,13 +862,13 @@ y2 = y1; x = *args++; y = *args++; - cairo_curve_to(cr, x1, y1, x2, y2, x, y); + mbe_curve_to(cr, x1, y1, x2, y2, x, y); break; case 'A': sh_path_arc_path(cr, &args, &fix_args); break; case 'Z': - cairo_close_path(cr); + mbe_close_path(cr); break; case '\x0': i = cmd_len; /* padding! Skip remain ones. */ @@ -877,7 +877,7 @@ } } -void sh_path_draw(shape_t *shape, cairo_t *cr) { +void sh_path_draw(shape_t *shape, mbe_t *cr) { sh_path_path(shape, cr); }
--- a/src/shape_rect.c Sun Aug 02 11:00:37 2009 +0800 +++ b/src/shape_rect.c Tue Aug 04 23:35:41 2009 +0800 @@ -129,24 +129,24 @@ } } -void sh_rect_draw(shape_t *shape, cairo_t *cr) { +void sh_rect_draw(shape_t *shape, mbe_t *cr) { sh_rect_t *rect = (sh_rect_t *)shape; int i; co_aix (*poses)[2]; poses = rect->poses; if(rect->rx != 0 && rect->ry != 0) { - cairo_move_to(cr, poses[11][0], poses[11][1]); + mbe_move_to(cr, poses[11][0], poses[11][1]); for(i = 0; i < 12; i += 3) { - cairo_line_to(cr, poses[i][0], poses[i][1]); - cairo_curve_to(cr, + mbe_line_to(cr, poses[i][0], poses[i][1]); + mbe_curve_to(cr, poses[i + 1][0], poses[i + 1][1], poses[i + 1][0], poses[i + 1][1], poses[i + 2][0], poses[i + 2][1]); } } else { - cairo_move_to(cr, poses[3][0], poses[3][1]); + mbe_move_to(cr, poses[3][0], poses[3][1]); for(i = 0; i < 4; i++) - cairo_line_to(cr, poses[i][0], poses[i][1]); + mbe_line_to(cr, poses[i][0], poses[i][1]); } }
--- a/src/shape_stext.c Sun Aug 02 11:00:37 2009 +0800 +++ b/src/shape_stext.c Tue Aug 04 23:35:41 2009 +0800 @@ -1,5 +1,5 @@ #include <stdio.h> -#include <cairo.h> +#include "mb_graph_engine.h" #include <cairo-ft.h> #include <fontconfig/fontconfig.h> #include "mb_shapes.h" @@ -12,7 +12,7 @@ r x param {} UT_FAKE(void, sh_stext_transform, (shape_t *shape)); -UT_FAKE(void, sh_stext_draw, (shape_t *shape, cairo_t *cr)); +UT_FAKE(void, sh_stext_draw, (shape_t *shape, mbe_t *cr)); typedef struct _ut_area { co_aix x, y; @@ -44,27 +44,27 @@ #define sh_stext_set_text ut_sh_stext_set_text #define sh_stext_set_style ut_sh_stext_set_style -#undef cairo_get_scaled_font -#define cairo_get_scaled_font(cr) ((cairo_scaled_font_t *)NULL) -#undef cairo_set_scaled_font -#define cairo_set_scaled_font(cr, scaled) ((cairo_scaled_font_t *)NULL) -#undef cairo_scaled_font_reference -#define cairo_scaled_font_reference(x) +#undef mbe_get_scaled_font +#define mbe_get_scaled_font(cr) ((mbe_scaled_font_t *)NULL) +#undef mbe_set_scaled_font +#define mbe_set_scaled_font(cr, scaled) ((mbe_scaled_font_t *)NULL) +#undef mbe_scaled_font_reference +#define mbe_scaled_font_reference(x) #define MAX_MOVE 32 NO_DOX(static co_aix move_xys[MAX_MOVE][2]); NO_DOX(static int move_cnt = 0); -#undef cairo_move_to -#define cairo_move_to(cr, x, y) \ +#undef mbe_move_to +#define mbe_move_to(cr, x, y) \ do { \ move_xys[move_cnt][0] = x; \ move_xys[move_cnt++][1] = y; \ } while(0) -#undef cairo_show_text -#define cairo_show_text(cr, txt) -#undef cairo_scaled_font_destroy -#define cairo_scaled_font_destroy(scaled) \ - if(scaled != NULL) cairo_scaled_font_destroy(scaled) -#define cairo_text_path(cr, buf) +#undef mbe_show_text +#define mbe_show_text(cr, txt) +#undef mbe_scaled_font_destroy +#define mbe_scaled_font_destroy(scaled) +#undef mbe_text_path +#define mbe_text_path(cr, buf) #endif /* UNITTEST */ @@ -93,7 +93,7 @@ */ /*! \brief Stakeholder of scaled font. * - * It is actually a cairo_scaled_font_t, now. But, it should not be + * It is actually a mbe_scaled_font_t, now. But, it should not be * noticed by out-siders. Only \ref fontconfig_freetype * should known it. */ @@ -101,7 +101,7 @@ /*! \brief Stakeholder of scaled font. * - * Although, mb_text_extents_t is defined as a cairo_scaled_font_t, but + * Although, mb_text_extents_t is defined as a mbe_scaled_font_t, but * programmers should assume it is opague. * * An extents is the span of showing a fragement of text on the output device. @@ -113,7 +113,7 @@ * output device, that can contain the text. The bearing is related to * the base line for an extents. */ -typedef cairo_text_extents_t mb_text_extents_t; +typedef mbe_text_extents_t mb_text_extents_t; #define MBE_GET_X_ADV(ext) ((ext)->x_advance) #define MBE_GET_Y_ADV(ext) ((ext)->y_advance) @@ -213,11 +213,11 @@ */ static mb_font_face_t *query_font_face(const char *family, int slant, int weight) { - cairo_font_face_t *cface; + mbe_font_face_t *cface; FcPattern *ptn; ptn = query_font_pattern(family, slant, weight); - cface = cairo_ft_font_face_create_for_pattern(ptn); + cface = mbe_ft_font_face_create_for_pattern(ptn); FcPatternDestroy(ptn); return (mb_font_face_t *)cface; @@ -227,7 +227,7 @@ void free_font_face(mb_font_face_t *face) { ASSERT(face == NULL); - cairo_font_face_destroy((cairo_font_face_t *)face); + mbe_font_face_destroy((mbe_font_face_t *)face); } /*! \brief This is scaled font for specified size and extent. @@ -241,19 +241,19 @@ static mb_scaled_font_t *make_scaled_font_face_matrix(mb_font_face_t *face, co_aix *matrix) { - cairo_scaled_font_t *scaled_font; - cairo_matrix_t font_matrix; - static cairo_matrix_t id = { + mbe_scaled_font_t *scaled_font; + mbe_matrix_t font_matrix; + static mbe_matrix_t id = { 1, 0, 0, 1, 0, 0 }; - static cairo_font_options_t *opt = NULL; + static mbe_font_options_t *opt = NULL; ASSERT(matrix != NULL); if(opt == NULL) { - opt = cairo_font_options_create(); + opt = mbe_font_options_create(); if(opt == NULL) return NULL; } @@ -264,7 +264,7 @@ font_matrix.yx = *matrix++; font_matrix.yy = *matrix++; font_matrix.y0 = *matrix; - scaled_font = cairo_scaled_font_create((cairo_font_face_t *)face, + scaled_font = mbe_scaled_font_create((mbe_font_face_t *)face, &font_matrix, &id, opt); @@ -273,22 +273,22 @@ static void scaled_font_free(mb_scaled_font_t *scaled_font) { - cairo_scaled_font_destroy((cairo_scaled_font_t *)scaled_font); + mbe_scaled_font_destroy((mbe_scaled_font_t *)scaled_font); } static void compute_text_extents(mb_scaled_font_t *scaled_font, const char *txt, mb_text_extents_t *extents) { - cairo_scaled_font_text_extents((cairo_scaled_font_t *)scaled_font, + mbe_scaled_font_text_extents((mbe_scaled_font_t *)scaled_font, txt, - (cairo_text_extents_t *)extents); + (mbe_text_extents_t *)extents); } static mb_text_extents_t *mb_text_extents_new(void) { - cairo_text_extents_t *extents; + mbe_text_extents_t *extents; - extents = (cairo_text_extents_t *)malloc(sizeof(cairo_text_extents_t)); + extents = (mbe_text_extents_t *)malloc(sizeof(mbe_text_extents_t)); return extents; } @@ -298,9 +298,9 @@ } static -void draw_text_scaled(cairo_t *cr, const char *txt, int tlen, +void draw_text_scaled(mbe_t *cr, const char *txt, int tlen, mb_scaled_font_t *scaled, co_aix x, co_aix y) { - cairo_scaled_font_t *saved_scaled; + mbe_scaled_font_t *saved_scaled; int total_tlen; const char *buf; @@ -310,15 +310,15 @@ else buf = txt; - saved_scaled = cairo_get_scaled_font(cr); - cairo_scaled_font_reference(saved_scaled); - cairo_set_scaled_font(cr, (cairo_scaled_font_t *)scaled); + saved_scaled = mbe_get_scaled_font(cr); + mbe_scaled_font_reference(saved_scaled); + mbe_set_scaled_font(cr, (mbe_scaled_font_t *)scaled); - cairo_move_to(cr, x, y); - cairo_text_path(cr, buf); + mbe_move_to(cr, x, y); + mbe_text_path(cr, buf); - cairo_set_scaled_font(cr, saved_scaled); - cairo_scaled_font_destroy(saved_scaled); + mbe_set_scaled_font(cr, saved_scaled); + mbe_scaled_font_destroy(saved_scaled); if(total_tlen > tlen) free((char *)buf); @@ -625,7 +625,7 @@ area->h = MBE_GET_HEIGHT(ext); } -void sh_stext_draw(shape_t *shape, cairo_t *cr) { +void sh_stext_draw(shape_t *shape, mbe_t *cr) { sh_stext_t *txt_o = (sh_stext_t *)shape; co_aix x, y; const char *txt; @@ -705,11 +705,11 @@ static void test_query_font_face(void) { mb_font_face_t *face; - cairo_status_t status; + mbe_status_t status; face = query_font_face("serif", MB_FONT_SLANT_ROMAN, 100); CU_ASSERT(face != NULL); - status = cairo_font_face_status((cairo_font_face_t *)face); + status = mbe_font_face_status((mbe_font_face_t *)face); CU_ASSERT(status == CAIRO_STATUS_SUCCESS); free_font_face(face); @@ -720,16 +720,16 @@ co_aix matrix[6] = {5, 0, 0, 0, 5, 0}; mb_font_face_t *face; mb_scaled_font_t *scaled; - cairo_status_t status; + mbe_status_t status; face = query_font_face("serif", MB_FONT_SLANT_ROMAN, 100); CU_ASSERT(face != NULL); - status = cairo_font_face_status((cairo_font_face_t *)face); + status = mbe_font_face_status((mbe_font_face_t *)face); CU_ASSERT(status == CAIRO_STATUS_SUCCESS); scaled = make_scaled_font_face_matrix(face, matrix); CU_ASSERT(scaled != NULL); - status = cairo_scaled_font_status((cairo_scaled_font_t *)scaled); + status = mbe_scaled_font_status((mbe_scaled_font_t *)scaled); CU_ASSERT(status == CAIRO_STATUS_SUCCESS); scaled_font_free(scaled);
--- a/src/shape_text.c Sun Aug 02 11:00:37 2009 +0800 +++ b/src/shape_text.c Tue Aug 04 23:35:41 2009 +0800 @@ -2,7 +2,7 @@ #include <stdlib.h> #include <string.h> #include <math.h> -#include <cairo.h> +#include "mb_graph_engine.h" #include <pango/pangocairo.h> #include "mb_types.h" #include "mb_shapes.h" @@ -18,8 +18,8 @@ co_aix d_x, d_y; /* device x and y */ co_aix font_size; co_aix d_font_size; - cairo_font_face_t *face; - cairo_scaled_font_t *scaled_font; + mbe_font_face_t *face; + mbe_scaled_font_t *scaled_font; int flags; PangoLayout *layout; int align; @@ -32,14 +32,14 @@ sh_text_t *text = (sh_text_t *)shape; if(text->scaled_font) - cairo_scaled_font_destroy(text->scaled_font); - cairo_font_face_destroy(text->face); + mbe_scaled_font_destroy(text->scaled_font); + mbe_font_face_destroy(text->face); } -static void sh_text_P_generate_layout(sh_text_t *text,cairo_t *cr); +static void sh_text_P_generate_layout(sh_text_t *text,mbe_t *cr); shape_t *rdman_shape_text_new(redraw_man_t *rdman, const char *txt, co_aix x, co_aix y, - co_aix font_size, cairo_font_face_t *face,PangoAttrList *attrs) { + co_aix font_size, mbe_font_face_t *face,PangoAttrList *attrs) { sh_text_t *text; text = (sh_text_t *)malloc(sizeof(sh_text_t)); @@ -56,7 +56,7 @@ text->x = x; text->y = y; text->font_size = font_size; - cairo_font_face_reference(face); + mbe_font_face_reference(face); text->face = face; text->flags |= TXF_SCALE_DIRTY; @@ -193,10 +193,10 @@ } static int get_extents(sh_text_t *text, PangoRectangle *extents) { - cairo_matrix_t fmatrix; - cairo_matrix_t ctm; - cairo_scaled_font_t *new_scaled; - cairo_font_options_t *fopt; + mbe_matrix_t fmatrix; + mbe_matrix_t ctm; + mbe_scaled_font_t *new_scaled; + mbe_font_options_t *fopt; pango_layout_get_extents(text->layout, NULL, extents); pango_extents_to_pixels(extents,NULL); @@ -219,7 +219,7 @@ coord = sh_get_coord(shape); canvas = _coord_get_canvas(coord); - sh_text_P_generate_layout(text, (cairo_t *)canvas); + sh_text_P_generate_layout(text, (mbe_t *)canvas); x = text->x; y = text->y; @@ -244,7 +244,7 @@ /*! \todo Support ratation for shape_text. */ } -static void sh_text_P_generate_layout(sh_text_t *text,cairo_t *cr) +static void sh_text_P_generate_layout(sh_text_t *text,mbe_t *cr) { PangoAttribute *attr; PangoAttrList *attrlist; @@ -255,20 +255,20 @@ } text->layout = pango_cairo_create_layout(cr); desc = pango_font_description_from_string("Sans Bold"); - //cairo_set_source_rgb (cr, 0, 0, 0); + //mbe_set_source_rgb (cr, 0, 0, 0); pango_layout_set_font_description (text->layout, desc); pango_layout_set_text(text->layout,text->data,strlen(text->data)); pango_layout_set_attributes(text->layout, text->attrs); pango_cairo_update_layout(cr,text->layout); printf("text=%s\n",text->data); } -static void draw_text(sh_text_t *text, cairo_t *cr) { - cairo_move_to(cr, text->d_x, text->d_y); +static void draw_text(sh_text_t *text, mbe_t *cr) { + mbe_move_to(cr, text->d_x, text->d_y); pango_cairo_layout_path(cr,text->layout); } -void sh_text_draw(shape_t *shape, cairo_t *cr) { +void sh_text_draw(shape_t *shape, mbe_t *cr) { draw_text((sh_text_t *)shape, cr); }