Mercurial > MadButterfly
diff src/shape_image.c @ 346:b391722bf20e
sh_image_t::img_data is managed by paint_image_t.
- sh_image_t should not try to free it.
- call sh_text_P_generate_layout() in sh_text_transform()
- remove calling from other functions.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Sun, 08 Mar 2009 14:44:41 +0800 |
parents | bb6e964da1c8 |
children | 04d22dc38bc0 |
line wrap: on
line diff
--- a/src/shape_image.c Sun Mar 08 11:47:14 2009 +0800 +++ b/src/shape_image.c Sun Mar 08 14:44:41 2009 +0800 @@ -65,6 +65,32 @@ static void sh_image_free(shape_t *shape); +int _sh_image_set_img_data(shape_t *shape, mb_img_data_t *img_data, + co_aix x, co_aix y, co_aix w, co_aix h) { + sh_image_t *img = (sh_image_t *)shape; + paint_t *paint; + + ASSERT(img_data != NULL); + ASSERT(shape->obj.obj_type == MBO_IMAGE); + + paint = rdman_paint_image_new(img->rdman, img_data); + if(paint == NULL) + return ERR; + + if(img->paint) + rdman_paint_free(img->rdman, img->paint); + + img->img_data = img_data; + img->x = x; + img->y = y; + img->w = w; + img->h = h; + img->paint = paint; + rdman_paint_fill(img->rdman, paint, (shape_t *)img); + + return OK; +} + /*! \brief Creae a new image shape. * * \param img_data is image data whose owner-ship is transfered. @@ -85,7 +111,7 @@ img->rdman = rdman; img->shape.free = sh_image_free; - r = sh_image_set_img_data((shape_t *)img, img_data, x, y, w, h); + r = _sh_image_set_img_data((shape_t *)img, img_data, x, y, w, h); if(r != OK) { mb_obj_destroy((shape_t *)img); free(img); @@ -100,7 +126,6 @@ rdman_paint_free(img->rdman, img->paint); mb_obj_destroy(shape); - MB_IMG_DATA_FREE(img->img_data); free(img); } @@ -184,30 +209,10 @@ int sh_image_set_img_data(shape_t *shape, mb_img_data_t *img_data, co_aix x, co_aix y, co_aix w, co_aix h) { - sh_image_t *img = (sh_image_t *)shape; - paint_t *paint; - - ASSERT(img_data != NULL); - ASSERT(shape->obj.obj_type == MBO_IMAGE); + int r; - paint = rdman_paint_image_new(img->rdman, img_data); - if(paint == NULL) - return ERR; - - if(img->paint) { - rdman_paint_free(img->rdman, img->paint); - MB_IMG_DATA_FREE(img->img_data); - } - - img->img_data = img_data; - img->x = x; - img->y = y; - img->w = w; - img->h = h; - img->paint = paint; - rdman_paint_fill(img->rdman, paint, (shape_t *)img); - - return OK; + r = _sh_image_set_img_data(shape, img_data, x, y, w, h); + return r; } mb_img_data_t *sh_image_get_img_data(shape_t *shape) {