# HG changeset patch # User Thinker K.F. Li # Date 1258032778 -28800 # Node ID ba64f928542b5ae47d06ca947db88044da6eea45 # Parent 4254eaa699d0f9f00e5882466f7c74522521abdd Remove mbe_matrix_t type. The struct mbe_matrix_t is defined in a layout accoriding definition of Cairo. It is not feasible for all graphic engine. Now, we start supporting of other graphic engine; Skia, so use type of (co_aix[6]) defined and used by MadButterfly intead of mbe_matrix_t. And, bridges of graphic engines are responsible for translate matrics into the matrix type of the graphic enigne. diff -r 4254eaa699d0 -r ba64f928542b include/mb_config.h.in --- a/include/mb_config.h.in Thu Nov 12 21:32:52 2009 +0800 +++ b/include/mb_config.h.in Thu Nov 12 21:32:58 2009 +0800 @@ -7,4 +7,10 @@ /* Enable Skia Graphic Engine */ #undef SKIA_GRAPH_ENGINE +/* Enable sh_text */ +#undef SH_TEXT + +/* Enable sh_stext */ +#undef SH_STEXT + #endif /* __MB_CONFIG_H_ */ diff -r 4254eaa699d0 -r ba64f928542b include/mb_graph_engine_cairo.h --- a/include/mb_graph_engine_cairo.h Thu Nov 12 21:32:52 2009 +0800 +++ b/include/mb_graph_engine_cairo.h Thu Nov 12 21:32:58 2009 +0800 @@ -27,7 +27,6 @@ #define mbe_xlib_surface_create cairo_xlib_surface_create #define mbe_scaled_font_destroy cairo_scaled_font_destroy #define mbe_font_face_reference cairo_font_face_reference -#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_surface_destroy cairo_surface_destroy @@ -65,16 +64,33 @@ typedef cairo_font_face_t mbe_font_face_t; typedef cairo_surface_t mbe_surface_t; typedef cairo_pattern_t mbe_pattern_t; -typedef cairo_matrix_t mbe_matrix_t; typedef cairo_t mbe_t; typedef float co_aix; +#define MB_MATRIX_2_CAIRO(cmtx, mtx) { \ + (cmtx).xx = (mtx)[0]; \ + (cmtx).xy = (mtx)[1]; \ + (cmtx).x0 = (mtx)[2]; \ + (cmtx).yx = (mtx)[3]; \ + (cmtx).yy = (mtx)[4]; \ + (cmtx).y0 = (mtx)[5]; \ +} + + extern mbe_font_face_t * mbe_query_font_face(const char *family, int slant, int weight); extern void mbe_free_font_face(mbe_font_face_t *face); +static void mbe_pattern_set_matrix(mbe_pattern_t *ptn, + const co_aix matrix[6]) { + cairo_matrix_t cmtx; + + MB_MATRIX_2_CAIRO(cmtx, matrix); + cairo_pattern_set_matrix(ptn, &cmtx); +} + static void mbe_clear(mbe_t *canvas) { cairo_operator_t old_op; @@ -94,16 +110,19 @@ } static mbe_scaled_font_t * -mbe_scaled_font_create(mbe_font_face_t *face, mbe_matrix_t *fnt_mtx, - mbe_matrix_t *ctm) { +mbe_scaled_font_create(mbe_font_face_t *face, co_aix fnt_mtx[6], + co_aix ctm[6]) { cairo_font_options_t *options; mbe_scaled_font_t *scaled; + cairo_matrix_t cfnt_mtx, cctm; options = cairo_font_options_create(); if(options == NULL) return NULL; - scaled = cairo_scaled_font_create(face, fnt_mtx, ctm, options); + MB_MATRIX_2_CAIRO(cfnt_mtx, fnt_mtx); + MB_MATRIX_2_CAIRO(cctm, ctm); + scaled = cairo_scaled_font_create(face, &cfnt_mtx, &cctm, options); cairo_font_options_destroy(options); diff -r 4254eaa699d0 -r ba64f928542b include/mb_graph_engine_skia.h --- a/include/mb_graph_engine_skia.h Thu Nov 12 21:32:52 2009 +0800 +++ b/include/mb_graph_engine_skia.h Thu Nov 12 21:32:58 2009 +0800 @@ -32,11 +32,6 @@ typedef struct _mbe_font_face_t mbe_font_face_t; typedef struct _mbe_surface_t mbe_surface_t; typedef struct _mbe_pattern_t mbe_pattern_t; -typedef struct { - co_aix xx; co_aix yx; - co_aix xy; co_aix yy; - co_aix x0; co_aix y0; -} mbe_matrix_t; typedef struct _mbe_t mbe_t; extern void mbe_pattern_add_color_stop_rgba(mbe_pattern_t *ptn, @@ -63,10 +58,10 @@ extern void mbe_set_source_surface(mbe_t *canvas, mbe_surface_t *surface, co_aix x, co_aix y); extern mbe_scaled_font_t * -mbe_scaled_font_create(mbe_font_face_t *face, mbe_matrix_t *fnt_mtx, - mbe_matrix_t *ctm); +mbe_scaled_font_create(mbe_font_face_t *face, co_aix fnt_mtx[6], + co_aix ctm[6]); extern void mbe_pattern_set_matrix(mbe_pattern_t *ptn, - const mbe_matrix_t *matrix); + const co_aix matrix[6]); extern void mbe_font_face_destroy(mbe_font_face_t *face); extern void mbe_paint_with_alpha(mbe_t *canvas, co_aix alpha); extern void mbe_surface_destroy(mbe_surface_t *surface); @@ -116,7 +111,7 @@ extern mb_img_fmt_t mbe_image_surface_get_format(mbe_surface_t *surface); extern mbe_surface_t * mbe_image_surface_create(mb_img_fmt_t fmt, int width, int height); -extern void mbe_transform(mbe_t *mbe, mbe_matrix_t *matrix); +extern void mbe_transform(mbe_t *mbe, co_aix matrix[6]); extern void mbe_arc(mbe_t *mbe, co_aix x, co_aix y, co_aix radius, co_aix angle_start, co_aix angle_stop); /* @} */ diff -r 4254eaa699d0 -r ba64f928542b include/mb_shapes.h --- a/include/mb_shapes.h Thu Nov 12 21:32:52 2009 +0800 +++ b/include/mb_shapes.h Thu Nov 12 21:32:58 2009 +0800 @@ -7,6 +7,12 @@ #ifndef __SHAPES_H_ #define __SHAPES_H_ +#include "mb_config.h" + +#ifdef SH_TEXT +#include +#endif + #include "mb_graph_engine.h" #include "mb_types.h" #include "mb_redraw_man.h" diff -r 4254eaa699d0 -r ba64f928542b src/graph_engine_skia.cpp --- a/src/graph_engine_skia.cpp Thu Nov 12 21:32:52 2009 +0800 +++ b/src/graph_engine_skia.cpp Thu Nov 12 21:32:58 2009 +0800 @@ -13,8 +13,8 @@ struct _mbe_scaled_font_t { struct _mb_font_face_t *face; - mbe_matrix_t fnt_mtx; - mbe_matrix_t ctm; + co_aix fnt_mtx[6]; + co_aix ctm[6]; } struct _mbe_font_face_t {}; struct _mbe_t { @@ -39,7 +39,7 @@ mbe_pattern_t *mbe_pattern_create_linear(co_aix x0, co_aix y0, co_aix x1, co_aix y1) {} void mbe_pattern_set_matrix(mbe_pattern_t *ptn, - const mbe_matrix_t *matrix) {} + const co_aix matrix[6]) {} void mbe_pattern_destroy(mbe_pattern_t *canvas) {} int mbe_image_surface_get_stride(mbe_surface_t *surface) {} @@ -60,8 +60,8 @@ void mbe_scaled_font_destroy(mbe_scaled_font_t *scaled) {} mbe_font_face_t *mbe_font_face_reference(mbe_font_face_t *face) {} mbe_scaled_font_t * -mbe_scaled_font_create(mbe_font_face_t *face, mbe_matrix_t *fnt_mtx, - mbe_matrix_t *ctm) {} +mbe_scaled_font_create(mbe_font_face_t *face, co_aix fnt_mtx[6], + co_aix ctm[6]) {} mbe_scaled_font_t *mbe_get_scaled_font(mbe_t *canvas) {} void mbe_scaled_font_text_extents(mbe_scaled_font_t *scaled, const char *txt, @@ -128,7 +128,7 @@ void mbe_clear(mbe_t *canvas) {} void mbe_copy_source(mbe_t *canvas) {} -void mbe_transform(mbe_t *mbe, mbe_matrix_t *matrix) {} +void mbe_transform(mbe_t *mbe, co_aix matrix[6]) {} void mbe_arc(mbe_t *mbe, co_aix x, co_aix y, co_aix radius, co_aix angle_start, co_aix angle_stop) {} diff -r 4254eaa699d0 -r ba64f928542b src/paint.c --- a/src/paint.c Thu Nov 12 21:32:52 2009 +0800 +++ b/src/paint.c Thu Nov 12 21:32:58 2009 +0800 @@ -328,15 +328,8 @@ */ void paint_image_set_matrix(paint_t *paint, co_aix matrix[6]) { paint_image_t *img_paint = (paint_image_t *)paint; - mbe_matrix_t cmatrix; - cmatrix.xx = matrix[0]; - cmatrix.xy = matrix[1]; - cmatrix.x0 = matrix[2]; - cmatrix.yx = matrix[3]; - cmatrix.yy = matrix[4]; - cmatrix.y0 = matrix[5]; - mbe_pattern_set_matrix(img_paint->ptn, &cmatrix); + mbe_pattern_set_matrix(img_paint->ptn, matrix); } void paint_image_get_size(paint_t *paint, int *w, int *h) { diff -r 4254eaa699d0 -r ba64f928542b src/redraw_man.c --- a/src/redraw_man.c Thu Nov 12 21:32:52 2009 +0800 +++ b/src/redraw_man.c Thu Nov 12 21:32:58 2009 +0800 @@ -1913,7 +1913,6 @@ 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]; @@ -1923,18 +1922,11 @@ compute_cached_2_pdev_matrix(coord, canvas2pdev_matrix); compute_reverse(canvas2pdev_matrix, reverse); - cr_matrix.xx = reverse[0]; - cr_matrix.xy = reverse[1]; - cr_matrix.x0 = reverse[2]; - cr_matrix.yx = reverse[3]; - cr_matrix.yy = reverse[4]; - cr_matrix.y0 = reverse[5]; - canvas = _coord_get_canvas(coord); pcanvas = _coord_get_canvas(coord->parent); surface = mbe_get_target(canvas); pattern = mbe_pattern_create_for_surface(surface); - mbe_pattern_set_matrix(pattern, &cr_matrix); + mbe_pattern_set_matrix(pattern, reverse); mbe_set_source(pcanvas, pattern); mbe_paint_with_alpha(pcanvas, coord->opacity); } diff -r 4254eaa699d0 -r ba64f928542b src/shape_image.c --- a/src/shape_image.c Thu Nov 12 21:32:52 2009 +0800 +++ b/src/shape_image.c Thu Nov 12 21:32:58 2009 +0800 @@ -104,7 +104,6 @@ co_aix img_matrix[6]; co_aix x_factor, y_factor; int img_w, img_h; - mbe_matrix_t cmatrix; int i; poses = img->poses; @@ -158,7 +157,6 @@ void sh_image_draw(shape_t *shape, mbe_t *cr) { sh_image_t *img = (sh_image_t *)shape; mbe_pattern_t *saved_source; - mbe_matrix_t matrix, saved_matrix; co_aix *aggr; mbe_move_to(cr, img->poses[0][0], img->poses[0][1]); diff -r 4254eaa699d0 -r ba64f928542b src/shape_stext.c --- a/src/shape_stext.c Thu Nov 12 21:32:52 2009 +0800 +++ b/src/shape_stext.c Thu Nov 12 21:32:58 2009 +0800 @@ -149,23 +149,13 @@ mb_scaled_font_t *make_scaled_font_face_matrix(mb_font_face_t *face, co_aix *matrix) { mbe_scaled_font_t *scaled_font; - mbe_matrix_t font_matrix; - static mbe_matrix_t id = { - 1, 0, - 0, 1, - 0, 0 - }; + static co_aix id[6] = { 1, 0, 0, + 0, 1, 0 }; ASSERT(matrix != NULL); - font_matrix.xx = *matrix++; - font_matrix.xy = *matrix++; - font_matrix.x0 = *matrix++; - font_matrix.yx = *matrix++; - font_matrix.yy = *matrix++; - font_matrix.y0 = *matrix; scaled_font = mbe_scaled_font_create((mbe_font_face_t *)face, - &font_matrix, &id); + matrix, &id); return (mb_scaled_font_t *)scaled_font; } diff -r 4254eaa699d0 -r ba64f928542b src/shape_text.c --- a/src/shape_text.c Thu Nov 12 21:32:52 2009 +0800 +++ b/src/shape_text.c Thu Nov 12 21:32:58 2009 +0800 @@ -204,8 +204,6 @@ } static int get_extents(sh_text_t *text, PangoRectangle *extents) { - mbe_matrix_t fmatrix; - mbe_matrix_t ctm; mbe_scaled_font_t *new_scaled; pango_layout_get_extents(text->layout, NULL, extents);