Mercurial > MadButterfly
changeset 146:e96a584487af
Use elmpool to manage paint_color_t objects.
- Add a paint_color_pool member for redraw_man_t.
- Initialize and free when redraw_man_init() and redraw_man_destroy().
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Thu, 25 Sep 2008 09:53:05 +0800 |
parents | 609ed47a58f2 |
children | 995ee8fd5f1a |
files | src/paint.c src/redraw_man.c src/redraw_man.h src/shape_path.c |
diffstat | 4 files changed, 18 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/paint.c Thu Sep 25 02:13:50 2008 +0800 +++ b/src/paint.c Thu Sep 25 09:53:05 2008 +0800 @@ -13,6 +13,8 @@ redraw_man_t *rdman; } paint_color_t; +int paint_color_size = sizeof(paint_color_t); + static void paint_color_prepare(paint_t *paint, cairo_t *cr) { paint_color_t *color = (paint_color_t *)paint; @@ -32,7 +34,7 @@ co_comp_t b, co_comp_t a) { paint_color_t *color; - color = (paint_color_t *)malloc(sizeof(paint_color_t)); + color = (paint_color_t *)elmpool_elm_alloc(rdman->paint_color_pool); if(color == NULL) return NULL; color->rdman = rdman;
--- a/src/redraw_man.c Thu Sep 25 02:13:50 2008 +0800 +++ b/src/redraw_man.c Thu Sep 25 09:53:05 2008 +0800 @@ -196,6 +196,7 @@ int redraw_man_init(redraw_man_t *rdman, cairo_t *cr, cairo_t *backend) { extern void redraw_man_destroy(redraw_man_t *rdman); + extern int paint_color_size; memset(rdman, 0, sizeof(redraw_man_t)); @@ -233,6 +234,16 @@ return ERR; } + rdman->paint_color_pool = elmpool_new(paint_color_size, 64); + if(rdman->subject_pool == NULL) { + elmpool_free(rdman->geo_pool); + elmpool_free(rdman->coord_pool); + elmpool_free(rdman->shnode_pool); + elmpool_free(rdman->observer_pool); + elmpool_free(rdman->subject_pool); + return ERR; + } + rdman->ob_factory.subject_alloc = ob_subject_alloc; rdman->ob_factory.subject_free = ob_subject_free; rdman->ob_factory.observer_alloc = ob_observer_alloc; @@ -272,6 +283,7 @@ elmpool_free(rdman->shnode_pool); elmpool_free(rdman->observer_pool); elmpool_free(rdman->subject_pool); + elmpool_free(rdman->paint_color_pool); if(rdman->dirty_coords) free(rdman->dirty_coords); if(rdman->dirty_geos) @@ -553,6 +565,7 @@ } } +/*! \todo Use a static variable to hold positions array for clean_coord()? */ static int clean_coord(redraw_man_t *rdman, coord_t *coord) { geo_t *geo; co_aix (*poses)[2];
--- a/src/redraw_man.h Thu Sep 25 02:13:50 2008 +0800 +++ b/src/redraw_man.h Thu Sep 25 09:53:05 2008 +0800 @@ -31,6 +31,7 @@ elmpool_t *shnode_pool; elmpool_t *observer_pool; elmpool_t *subject_pool; + elmpool_t *paint_color_pool; int max_dirty_coords; int n_dirty_coords;
--- a/src/shape_path.c Thu Sep 25 02:13:50 2008 +0800 +++ b/src/shape_path.c Thu Sep 25 09:53:05 2008 +0800 @@ -678,6 +678,7 @@ cmd_cnt = (cmd_cnt + 3) & ~0x3; path = (sh_path_t *)malloc(sizeof(sh_path_t)); + /*! \todo Remove this memset()? */ memset(&path->shape, 0, sizeof(shape_t)); path->shape.sh_type = SHT_PATH; path->cmd_len = cmd_cnt;