Mercurial > MadButterfly
comparison src/redraw_man.c @ 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 | e89512d6fa0a |
children | 995ee8fd5f1a |
comparison
equal
deleted
inserted
replaced
145:609ed47a58f2 | 146:e96a584487af |
---|---|
194 coord->num_members--; | 194 coord->num_members--; |
195 } | 195 } |
196 | 196 |
197 int redraw_man_init(redraw_man_t *rdman, cairo_t *cr, cairo_t *backend) { | 197 int redraw_man_init(redraw_man_t *rdman, cairo_t *cr, cairo_t *backend) { |
198 extern void redraw_man_destroy(redraw_man_t *rdman); | 198 extern void redraw_man_destroy(redraw_man_t *rdman); |
199 extern int paint_color_size; | |
199 | 200 |
200 memset(rdman, 0, sizeof(redraw_man_t)); | 201 memset(rdman, 0, sizeof(redraw_man_t)); |
201 | 202 |
202 rdman->geo_pool = elmpool_new(sizeof(geo_t), 128); | 203 rdman->geo_pool = elmpool_new(sizeof(geo_t), 128); |
203 if(rdman->geo_pool == NULL) | 204 if(rdman->geo_pool == NULL) |
228 if(rdman->subject_pool == NULL) { | 229 if(rdman->subject_pool == NULL) { |
229 elmpool_free(rdman->geo_pool); | 230 elmpool_free(rdman->geo_pool); |
230 elmpool_free(rdman->coord_pool); | 231 elmpool_free(rdman->coord_pool); |
231 elmpool_free(rdman->shnode_pool); | 232 elmpool_free(rdman->shnode_pool); |
232 elmpool_free(rdman->observer_pool); | 233 elmpool_free(rdman->observer_pool); |
234 return ERR; | |
235 } | |
236 | |
237 rdman->paint_color_pool = elmpool_new(paint_color_size, 64); | |
238 if(rdman->subject_pool == NULL) { | |
239 elmpool_free(rdman->geo_pool); | |
240 elmpool_free(rdman->coord_pool); | |
241 elmpool_free(rdman->shnode_pool); | |
242 elmpool_free(rdman->observer_pool); | |
243 elmpool_free(rdman->subject_pool); | |
233 return ERR; | 244 return ERR; |
234 } | 245 } |
235 | 246 |
236 rdman->ob_factory.subject_alloc = ob_subject_alloc; | 247 rdman->ob_factory.subject_alloc = ob_subject_alloc; |
237 rdman->ob_factory.subject_free = ob_subject_free; | 248 rdman->ob_factory.subject_free = ob_subject_free; |
270 elmpool_free(rdman->coord_pool); | 281 elmpool_free(rdman->coord_pool); |
271 elmpool_free(rdman->geo_pool); | 282 elmpool_free(rdman->geo_pool); |
272 elmpool_free(rdman->shnode_pool); | 283 elmpool_free(rdman->shnode_pool); |
273 elmpool_free(rdman->observer_pool); | 284 elmpool_free(rdman->observer_pool); |
274 elmpool_free(rdman->subject_pool); | 285 elmpool_free(rdman->subject_pool); |
286 elmpool_free(rdman->paint_color_pool); | |
275 if(rdman->dirty_coords) | 287 if(rdman->dirty_coords) |
276 free(rdman->dirty_coords); | 288 free(rdman->dirty_coords); |
277 if(rdman->dirty_geos) | 289 if(rdman->dirty_geos) |
278 free(rdman->dirty_geos); | 290 free(rdman->dirty_geos); |
279 if(rdman->gen_geos) | 291 if(rdman->gen_geos) |
551 } | 563 } |
552 coord->canvas = coord->parent->canvas; | 564 coord->canvas = coord->parent->canvas; |
553 } | 565 } |
554 } | 566 } |
555 | 567 |
568 /*! \todo Use a static variable to hold positions array for clean_coord()? */ | |
556 static int clean_coord(redraw_man_t *rdman, coord_t *coord) { | 569 static int clean_coord(redraw_man_t *rdman, coord_t *coord) { |
557 geo_t *geo; | 570 geo_t *geo; |
558 co_aix (*poses)[2]; | 571 co_aix (*poses)[2]; |
559 int cnt, pos_cnt; | 572 int cnt, pos_cnt; |
560 | 573 |