comparison src/paint.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 1ca417f741f1
children 995ee8fd5f1a
comparison
equal deleted inserted replaced
145:609ed47a58f2 146:e96a584487af
11 paint_t paint; 11 paint_t paint;
12 co_comp_t r, g, b, a; 12 co_comp_t r, g, b, a;
13 redraw_man_t *rdman; 13 redraw_man_t *rdman;
14 } paint_color_t; 14 } paint_color_t;
15 15
16 int paint_color_size = sizeof(paint_color_t);
17
16 18
17 static void paint_color_prepare(paint_t *paint, cairo_t *cr) { 19 static void paint_color_prepare(paint_t *paint, cairo_t *cr) {
18 paint_color_t *color = (paint_color_t *)paint; 20 paint_color_t *color = (paint_color_t *)paint;
19 21
20 cairo_set_source_rgba(cr, color->r, color->g, color->b, color->a); 22 cairo_set_source_rgba(cr, color->r, color->g, color->b, color->a);
30 paint_t *paint_color_new(redraw_man_t *rdman, 32 paint_t *paint_color_new(redraw_man_t *rdman,
31 co_comp_t r, co_comp_t g, 33 co_comp_t r, co_comp_t g,
32 co_comp_t b, co_comp_t a) { 34 co_comp_t b, co_comp_t a) {
33 paint_color_t *color; 35 paint_color_t *color;
34 36
35 color = (paint_color_t *)malloc(sizeof(paint_color_t)); 37 color = (paint_color_t *)elmpool_elm_alloc(rdman->paint_color_pool);
36 if(color == NULL) 38 if(color == NULL)
37 return NULL; 39 return NULL;
38 color->rdman = rdman; 40 color->rdman = rdman;
39 color->r = r; 41 color->r = r;
40 color->g = g; 42 color->g = g;