Mercurial > MadButterfly
changeset 586:b42d69ab8857 openvg
Replace mbe_clip() with mbe_scissoring()
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Wed, 30 Jun 2010 13:28:53 +0800 |
parents | 6af1aa74e57c |
children | 1302b336add6 |
files | include/mb_basic_types.h include/mb_graph_engine_cairo.h include/mb_graph_engine_dummy.h include/mb_graph_engine_openvg.h include/mb_graph_engine_skia.h include/mb_types.h src/graph_engine_cairo.c src/graph_engine_skia.cpp src/redraw_man.c |
diffstat | 9 files changed, 52 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/include/mb_basic_types.h Wed Jun 30 09:52:22 2010 +0800 +++ b/include/mb_basic_types.h Wed Jun 30 13:28:53 2010 +0800 @@ -7,5 +7,9 @@ co_aix offset; co_comp_t r, g, b, a; } grad_stop_t; +typedef struct _area { + co_aix x, y; + co_aix w, h; +} area_t; #endif /* __MB_BASIC_TYPES_H_ */
--- a/include/mb_graph_engine_cairo.h Wed Jun 30 09:52:22 2010 +0800 +++ b/include/mb_graph_engine_cairo.h Wed Jun 30 13:28:53 2010 +0800 @@ -37,7 +37,7 @@ #define mbe_get_font_face cairo_get_font_face #define mbe_fill_preserve cairo_fill_preserve #define mbe_set_source cairo_set_source -#define mbe_reset_clip cairo_reset_clip +#define mbe_reset_scissoring cairo_reset_clip #define mbe_get_target cairo_get_target #define mbe_close_path cairo_close_path #define mbe_text_path cairo_text_path @@ -55,7 +55,6 @@ #define mbe_paint cairo_paint #define mbe_save cairo_save #define mbe_fill cairo_fill -#define mbe_clip cairo_clip typedef cairo_text_extents_t mbe_text_extents_t; typedef cairo_scaled_font_t mbe_scaled_font_t; @@ -87,6 +86,7 @@ co_aix x1, co_aix y1, grad_stop_t *stops, int stop_cnt); +extern void mbe_scissoring(mbe_t *canvas, int n_areas, area_t **areas); static void mbe_pattern_set_matrix(mbe_pattern_t *ptn,
--- a/include/mb_graph_engine_dummy.h Wed Jun 30 09:52:22 2010 +0800 +++ b/include/mb_graph_engine_dummy.h Wed Jun 30 13:28:53 2010 +0800 @@ -54,7 +54,7 @@ #define mbe_fill_preserve(canvas) #define mbe_copy_source(src_canvas, dst_canvas) #define mbe_set_source(canvas, pattern) -#define mbe_reset_clip(canvas) +#define mbe_reset_scissoring(canvas) #define mbe_get_target(canvas) ((mbe_surface_t *)NULL) #define mbe_close_path(canvas) #define mbe_text_path(canvas, utf8) @@ -74,7 +74,11 @@ #define mbe_paint(canvas) #define mbe_save(canvas) #define mbe_fill(canvas) -#define mbe_clip(canvas) +/*! \brief Make scissoring rectangles. + * + * It would reset all previous pathes. + */ +#define mbe_scissoring(canvas, n_areas, areas) #define mbe_arc(canvas, x, y, radius, angle_start, angle_stop) typedef struct _mbe_text_extents_t mbe_text_extents_t;
--- a/include/mb_graph_engine_openvg.h Wed Jun 30 09:52:22 2010 +0800 +++ b/include/mb_graph_engine_openvg.h Wed Jun 30 13:28:53 2010 +0800 @@ -50,7 +50,7 @@ #define mbe_copy_source(src_canvas, dst_canvas) #define mbe_set_source(canvas, pattern) \ do { (canvas)->src = (pattern); } while(0) -#define mbe_reset_clip(canvas) +#define mbe_reset_scissoring(canvas) #define mbe_get_target(canvas) ((mbe_surface_t *)(canvas)->tgt) #define mbe_close_path(canvas) #define mbe_text_path(canvas, utf8) @@ -68,7 +68,7 @@ #define mbe_paint(canvas) #define mbe_save(canvas) #define mbe_fill(canvas) -#define mbe_clip(canvas) +#define mbe_scissoring(canvas, n_areas, areas) #define mbe_arc(canvas, x, y, radius, angle_start, angle_stop) typedef struct _mbe_text_extents_t mbe_text_extents_t;
--- a/include/mb_graph_engine_skia.h Wed Jun 30 09:52:22 2010 +0800 +++ b/include/mb_graph_engine_skia.h Wed Jun 30 13:28:53 2010 +0800 @@ -85,7 +85,7 @@ extern mbe_font_face_t *mbe_get_font_face(mbe_t *canvas); extern void mbe_fill_preserve(mbe_t *canvas); extern void mbe_set_source(mbe_t *canvas, mbe_pattern_t *source); -extern void mbe_reset_clip(mbe_t *canvas); +extern void mbe_reset_scissoring(mbe_t *canvas); extern mbe_surface_t *mbe_get_target(mbe_t *canvas); extern void mbe_close_path(mbe_t *canvas); extern void mbe_text_path(mbe_t *canvas, const char *txt); @@ -106,7 +106,7 @@ extern void mbe_paint(mbe_t *canvas); extern void mbe_save(mbe_t *canvas); extern void mbe_fill(mbe_t *canvas); -extern void mbe_clip(mbe_t *canvas); +extern void mbe_scissoring(mbe_t *canvas, int n_areas, area_t **areas); extern mbe_font_face_t * mbe_query_font_face(const char *family, int slant, int weight);
--- a/include/mb_types.h Wed Jun 30 09:52:22 2010 +0800 +++ b/include/mb_types.h Wed Jun 30 13:28:53 2010 +0800 @@ -8,7 +8,6 @@ typedef struct _shape shape_t; typedef struct _geo geo_t; -typedef struct _area area_t; typedef struct _shnode shnode_t; typedef struct _paint paint_t; typedef struct _mb_obj mb_obj_t; @@ -99,11 +98,6 @@ shnode_t *next; }; -struct _area { - co_aix x, y; - co_aix w, h; -}; - /*! \brief Geometry data of a shape or a group of shape. */ struct _geo {
--- a/src/graph_engine_cairo.c Wed Jun 30 09:52:22 2010 +0800 +++ b/src/graph_engine_cairo.c Wed Jun 30 13:28:53 2010 +0800 @@ -152,3 +152,18 @@ return ptn; } + +void +mbe_scissoring(mbe_t *canvas, int n_areas, area_t **areas) { + area_t *area; + int i; + + cairo_new_path(canvas); + + for(i = 0; i < n_areas; i++) { + area = areas[i]; + cairo_rectangle(canvas, area->x, area->y, area->w, area->h); + } + + cairo_clip(canvas); +}
--- a/src/graph_engine_skia.cpp Wed Jun 30 09:52:22 2010 +0800 +++ b/src/graph_engine_skia.cpp Wed Jun 30 13:28:53 2010 +0800 @@ -556,7 +556,7 @@ canvas->states->ptn = source; } -void mbe_reset_clip(mbe_t *canvas) { +void mbe_reset_scissoring(mbe_t *canvas) { SkRegion clip; _canvas_device_region(canvas->canvas, &clip); @@ -780,13 +780,23 @@ canvas->subpath->rewind(); } -void mbe_clip(mbe_t *canvas) { - if(!canvas->subpath->isEmpty()) - _update_path(canvas); +void mbe_scissoring(mbe_t *canvas, int n_areas, area_t **areas) { + int i; + area_t *area; + SkPath *path; + + mbe_new_path(canvas); - canvas->canvas->clipPath(*canvas->path, SkRegion::kIntersect_Op); - canvas->path->rewind(); - canvas->subpath->rewind(); + path = canvas->path; + for(i = 0; i < n_areas; i++) { + area = areas[i]; + path->addRect(CO_AIX_2_SKSCALAR(area->x), CO_AIX_2_SKSCALAR(area->y), + CO_AIX_2_SKSCALAR(area->x + area->width), + CO_AIX_2_SKSCALAR(area->y + area->height)); + } + + canvas->canvas->clipPath(*path, SkRegion::kIntersect_Op); + path->rewind(); } mbe_font_face_t * mbe_query_font_face(const char *family,
--- a/src/redraw_man.c Wed Jun 30 09:52:22 2010 +0800 +++ b/src/redraw_man.c Wed Jun 30 13:28:53 2010 +0800 @@ -2141,23 +2141,11 @@ mbe_clear(canvas); } -static void make_clip(mbe_t *cr, int n_dirty_areas, - area_t **dirty_areas) { - int i; - area_t *area; - - mbe_new_path(cr); - for(i = 0; i < n_dirty_areas; i++) { - area = dirty_areas[i]; - if(area->w < 0.1 || area->h < 0.1) - continue; - mbe_rectangle(cr, area->x, area->y, area->w, area->h); - } - mbe_clip(cr); -} +#define make_clip(canvas, n_dirty_areas, dirty_areas) \ + mbe_scissoring(canvas, n_dirty_areas, dirty_areas) static void reset_clip(canvas_t *cr) { - mbe_reset_clip(cr); + mbe_reset_scissoring(cr); } static void copy_cr_2_backend(redraw_man_t *rdman, int n_dirty_areas, @@ -2168,9 +2156,7 @@ mbe_copy_source(rdman->cr, rdman->backend); } #else /* UNITTEST */ -static void make_clip(mbe_t *cr, int n_dirty_areas, - area_t **dirty_areas) { -} +#define make_clip(canvas, n_dirty_areas, dirty_areas) static void clear_canvas(canvas_t *canvas) { }