Mercurial > MadButterfly
comparison src/paint.c @ 602:ac2e6468a22a openvg
Replace mbe_image_surface_create_from_png() with mbe_pattern_create_image()
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Fri, 02 Jul 2010 13:42:22 +0800 |
parents | e813ac222f48 |
children | 7b4e80ab671a |
comparison
equal
deleted
inserted
replaced
601:8863d23cea4b | 602:ac2e6468a22a |
---|---|
244 * This type of paints fill/stroke shapes with an image. | 244 * This type of paints fill/stroke shapes with an image. |
245 */ | 245 */ |
246 typedef struct _paint_image { | 246 typedef struct _paint_image { |
247 paint_t paint; | 247 paint_t paint; |
248 mb_img_data_t *img; | 248 mb_img_data_t *img; |
249 mbe_surface_t *surf; | |
250 mbe_pattern_t *ptn; | 249 mbe_pattern_t *ptn; |
251 } paint_image_t; | 250 } paint_image_t; |
252 | 251 |
253 static | 252 static |
254 void paint_image_prepare(paint_t *paint, mbe_t *cr) { | 253 void paint_image_prepare(paint_t *paint, mbe_t *cr) { |
262 static | 261 static |
263 void paint_image_free(redraw_man_t *rdman, paint_t *paint) { | 262 void paint_image_free(redraw_man_t *rdman, paint_t *paint) { |
264 paint_image_t *paint_img = (paint_image_t *)paint; | 263 paint_image_t *paint_img = (paint_image_t *)paint; |
265 mb_img_data_t *img_data; | 264 mb_img_data_t *img_data; |
266 | 265 |
267 mbe_surface_destroy(paint_img->surf); | |
268 img_data = paint_img->img; | 266 img_data = paint_img->img; |
269 MB_IMG_DATA_FREE(img_data); | 267 MB_IMG_DATA_FREE(img_data); |
270 paint_destroy(&paint_img->paint); | 268 paint_destroy(&paint_img->paint); |
271 free(paint); | 269 free(paint); |
272 } | 270 } |
287 return NULL; | 285 return NULL; |
288 | 286 |
289 paint_init(&paint->paint, MBP_IMAGE, | 287 paint_init(&paint->paint, MBP_IMAGE, |
290 paint_image_prepare, paint_image_free); | 288 paint_image_prepare, paint_image_free); |
291 paint->img = img; | 289 paint->img = img; |
292 paint->surf = mbe_image_surface_create_for_data(img->content, | 290 |
293 img->fmt, | 291 paint->ptn = mbe_pattern_create_image(img); |
294 img->w, | |
295 img->h, | |
296 img->stride); | |
297 if(paint->surf == NULL) { | |
298 paint_destroy(&paint->paint); | |
299 free(paint); | |
300 return NULL; | |
301 } | |
302 | |
303 paint->ptn = mbe_pattern_create_for_surface(paint->surf); | |
304 if(paint->ptn == NULL) { | 292 if(paint->ptn == NULL) { |
305 paint_destroy(&paint->paint); | 293 paint_destroy(&paint->paint); |
306 mbe_surface_destroy(paint->surf); | |
307 free(paint); | 294 free(paint); |
308 return NULL; | 295 return NULL; |
309 } | 296 } |
310 | 297 |
311 return (paint_t *)paint; | 298 return (paint_t *)paint; |