Mercurial > MadButterfly
diff src/paint.c @ 867:4f8d53be9488
Allocate linear, radial, image paints from elmpools
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Thu, 23 Sep 2010 10:43:56 +0800 |
parents | 586e50f82c1f |
children | f41ac71266bc |
line wrap: on
line diff
--- a/src/paint.c Thu Sep 23 10:14:05 2010 +0800 +++ b/src/paint.c Thu Sep 23 10:43:56 2010 +0800 @@ -78,10 +78,14 @@ grad_stop_t *stops; int flags; mbe_pattern_t *ptn; + + redraw_man_t *rdman; /*!< \brief Used by paint_linear_free(). */ } paint_linear_t; #define LIF_DIRTY 0x1 +int _paint_linear_size = sizeof(paint_linear_t); + static void paint_linear_prepare(paint_t *paint, mbe_t *cr) { paint_linear_t *linear = (paint_linear_t *)paint; mbe_pattern_t *ptn; @@ -107,7 +111,7 @@ if(linear->ptn) mbe_pattern_destroy(linear->ptn); paint_destroy(paint); - free(paint); + elmpool_elm_free(linear->rdman->paint_linear_pool, linear); } paint_t *rdman_paint_linear_new(redraw_man_t *rdman, @@ -115,7 +119,7 @@ co_aix x2, co_aix y2) { paint_linear_t *linear; - linear = (paint_linear_t *)malloc(sizeof(paint_linear_t)); + linear = (paint_linear_t *)elmpool_elm_alloc(rdman->paint_linear_pool); if(linear == NULL) return NULL; @@ -130,6 +134,7 @@ linear->stops = NULL; linear->flags = LIF_DIRTY; linear->ptn = NULL; + linear->rdman = rdman; return (paint_t *)linear; } @@ -166,10 +171,14 @@ grad_stop_t *stops; int flags; mbe_pattern_t *ptn; + + redraw_man_t *rdman; /*!< \brief Used by paint_radial_free() */ } paint_radial_t; #define RDF_DIRTY 0x1 +int _paint_radial_size = sizeof(paint_radial_t); + static void paint_radial_prepare(paint_t *paint, mbe_t *cr) { paint_radial_t *radial = (paint_radial_t *)paint; mbe_pattern_t *ptn; @@ -193,14 +202,14 @@ if(radial->ptn) mbe_pattern_destroy(radial->ptn); paint_destroy(paint); - free(paint); + elmpool_elm_free(radial->rdman->paint_radial_pool, radial); } paint_t *rdman_paint_radial_new(redraw_man_t *rdman, co_aix cx, co_aix cy, co_aix r) { paint_radial_t *radial; - radial = O_ALLOC(paint_radial_t); + radial = elmpool_elm_alloc(rdman->paint_radial_pool); if(radial == NULL) return NULL; @@ -213,6 +222,7 @@ radial->stops = NULL; radial->flags = RDF_DIRTY; radial->ptn = NULL; + radial->rdman = rdman; return (paint_t *)radial; } @@ -247,8 +257,12 @@ mb_img_data_t *img; mbe_surface_t *surf; mbe_pattern_t *ptn; + + redraw_man_t *rdman; /*!< \brief Used by paint_image_free() */ } paint_image_t; +int _paint_image_size = sizeof(paint_image_t); + static void paint_image_prepare(paint_t *paint, mbe_t *cr) { paint_image_t *paint_img = (paint_image_t *)paint; @@ -267,7 +281,7 @@ img_data = paint_img->img; MB_IMG_DATA_FREE(img_data); paint_destroy(&paint_img->paint); - free(paint); + elmpool_elm_free(paint_img->rdman->paint_image_pool, paint_img); } /*! \brief Create an image painter. @@ -281,13 +295,14 @@ mb_img_data_t *img) { paint_image_t *paint; - paint = O_ALLOC(paint_image_t); + paint = elmpool_elm_alloc(rdman->paint_image_pool); if(paint == NULL) return NULL; paint_init(&paint->paint, MBP_IMAGE, paint_image_prepare, paint_image_free); paint->img = img; + paint->rdman = rdman; paint->surf = mbe_image_surface_create_for_data(img->content, img->fmt, img->w, @@ -295,7 +310,7 @@ img->stride); if(paint->surf == NULL) { paint_destroy(&paint->paint); - free(paint); + elmpool_elm_free(rdman->paint_image_pool, paint); return NULL; } @@ -303,7 +318,7 @@ if(paint->ptn == NULL) { paint_destroy(&paint->paint); mbe_surface_destroy(paint->surf); - free(paint); + elmpool_elm_free(rdman->paint_image_pool, paint); return NULL; }