comparison src/paint.c @ 873:881efcd8a18f abs_n_rel_center

Merge from default branch
author Thinker K.F. Li <thinker@codemud.net>
date Fri, 24 Sep 2010 16:06:42 +0800
parents f41ac71266bc
children a17c4e231e54
comparison
equal deleted inserted replaced
862:3ce9daa9558b 873:881efcd8a18f
79 int flags; 79 int flags;
80 mbe_pattern_t *ptn; 80 mbe_pattern_t *ptn;
81 } paint_linear_t; 81 } paint_linear_t;
82 82
83 #define LIF_DIRTY 0x1 83 #define LIF_DIRTY 0x1
84
85 int _paint_linear_size = sizeof(paint_linear_t);
84 86
85 static void paint_linear_prepare(paint_t *paint, mbe_t *cr) { 87 static void paint_linear_prepare(paint_t *paint, mbe_t *cr) {
86 paint_linear_t *linear = (paint_linear_t *)paint; 88 paint_linear_t *linear = (paint_linear_t *)paint;
87 mbe_pattern_t *ptn; 89 mbe_pattern_t *ptn;
88 90
105 paint_linear_t *linear = (paint_linear_t *)paint; 107 paint_linear_t *linear = (paint_linear_t *)paint;
106 108
107 if(linear->ptn) 109 if(linear->ptn)
108 mbe_pattern_destroy(linear->ptn); 110 mbe_pattern_destroy(linear->ptn);
109 paint_destroy(paint); 111 paint_destroy(paint);
110 free(paint); 112 elmpool_elm_free(rdman->paint_linear_pool, linear);
111 } 113 }
112 114
113 paint_t *rdman_paint_linear_new(redraw_man_t *rdman, 115 paint_t *rdman_paint_linear_new(redraw_man_t *rdman,
114 co_aix x1, co_aix y1, 116 co_aix x1, co_aix y1,
115 co_aix x2, co_aix y2) { 117 co_aix x2, co_aix y2) {
116 paint_linear_t *linear; 118 paint_linear_t *linear;
117 119
118 linear = (paint_linear_t *)malloc(sizeof(paint_linear_t)); 120 linear = (paint_linear_t *)elmpool_elm_alloc(rdman->paint_linear_pool);
119 if(linear == NULL) 121 if(linear == NULL)
120 return NULL; 122 return NULL;
121 123
122 paint_init(&linear->paint, MBP_LINEAR, 124 paint_init(&linear->paint, MBP_LINEAR,
123 paint_linear_prepare, paint_linear_free); 125 paint_linear_prepare, paint_linear_free);
167 int flags; 169 int flags;
168 mbe_pattern_t *ptn; 170 mbe_pattern_t *ptn;
169 } paint_radial_t; 171 } paint_radial_t;
170 172
171 #define RDF_DIRTY 0x1 173 #define RDF_DIRTY 0x1
174
175 int _paint_radial_size = sizeof(paint_radial_t);
172 176
173 static void paint_radial_prepare(paint_t *paint, mbe_t *cr) { 177 static void paint_radial_prepare(paint_t *paint, mbe_t *cr) {
174 paint_radial_t *radial = (paint_radial_t *)paint; 178 paint_radial_t *radial = (paint_radial_t *)paint;
175 mbe_pattern_t *ptn; 179 mbe_pattern_t *ptn;
176 180
191 paint_radial_t *radial = (paint_radial_t *)paint; 195 paint_radial_t *radial = (paint_radial_t *)paint;
192 196
193 if(radial->ptn) 197 if(radial->ptn)
194 mbe_pattern_destroy(radial->ptn); 198 mbe_pattern_destroy(radial->ptn);
195 paint_destroy(paint); 199 paint_destroy(paint);
196 free(paint); 200 elmpool_elm_free(rdman->paint_radial_pool, radial);
197 } 201 }
198 202
199 paint_t *rdman_paint_radial_new(redraw_man_t *rdman, 203 paint_t *rdman_paint_radial_new(redraw_man_t *rdman,
200 co_aix cx, co_aix cy, co_aix r) { 204 co_aix cx, co_aix cy, co_aix r) {
201 paint_radial_t *radial; 205 paint_radial_t *radial;
202 206
203 radial = O_ALLOC(paint_radial_t); 207 radial = elmpool_elm_alloc(rdman->paint_radial_pool);
204 if(radial == NULL) 208 if(radial == NULL)
205 return NULL; 209 return NULL;
206 210
207 paint_init(&radial->paint, MBP_RADIAL, 211 paint_init(&radial->paint, MBP_RADIAL,
208 paint_radial_prepare, paint_radial_free); 212 paint_radial_prepare, paint_radial_free);
247 mb_img_data_t *img; 251 mb_img_data_t *img;
248 mbe_surface_t *surf; 252 mbe_surface_t *surf;
249 mbe_pattern_t *ptn; 253 mbe_pattern_t *ptn;
250 } paint_image_t; 254 } paint_image_t;
251 255
256 int _paint_image_size = sizeof(paint_image_t);
257
252 static 258 static
253 void paint_image_prepare(paint_t *paint, mbe_t *cr) { 259 void paint_image_prepare(paint_t *paint, mbe_t *cr) {
254 paint_image_t *paint_img = (paint_image_t *)paint; 260 paint_image_t *paint_img = (paint_image_t *)paint;
255 mb_img_data_t *img_data; 261 mb_img_data_t *img_data;
256 262
265 271
266 mbe_surface_destroy(paint_img->surf); 272 mbe_surface_destroy(paint_img->surf);
267 img_data = paint_img->img; 273 img_data = paint_img->img;
268 MB_IMG_DATA_FREE(img_data); 274 MB_IMG_DATA_FREE(img_data);
269 paint_destroy(&paint_img->paint); 275 paint_destroy(&paint_img->paint);
270 free(paint); 276 elmpool_elm_free(rdman->paint_image_pool, paint_img);
271 } 277 }
272 278
273 /*! \brief Create an image painter. 279 /*! \brief Create an image painter.
274 * 280 *
275 * Create a painter that fill/stroke shapes with an image. 281 * Create a painter that fill/stroke shapes with an image.
279 */ 285 */
280 paint_t *rdman_paint_image_new(redraw_man_t *rdman, 286 paint_t *rdman_paint_image_new(redraw_man_t *rdman,
281 mb_img_data_t *img) { 287 mb_img_data_t *img) {
282 paint_image_t *paint; 288 paint_image_t *paint;
283 289
284 paint = O_ALLOC(paint_image_t); 290 paint = elmpool_elm_alloc(rdman->paint_image_pool);
285 if(paint == NULL) 291 if(paint == NULL)
286 return NULL; 292 return NULL;
287 293
288 paint_init(&paint->paint, MBP_IMAGE, 294 paint_init(&paint->paint, MBP_IMAGE,
289 paint_image_prepare, paint_image_free); 295 paint_image_prepare, paint_image_free);
293 img->w, 299 img->w,
294 img->h, 300 img->h,
295 img->stride); 301 img->stride);
296 if(paint->surf == NULL) { 302 if(paint->surf == NULL) {
297 paint_destroy(&paint->paint); 303 paint_destroy(&paint->paint);
298 free(paint); 304 elmpool_elm_free(rdman->paint_image_pool, paint);
299 return NULL; 305 return NULL;
300 } 306 }
301 307
302 paint->ptn = mbe_pattern_create_for_surface(paint->surf); 308 paint->ptn = mbe_pattern_create_for_surface(paint->surf);
303 if(paint->ptn == NULL) { 309 if(paint->ptn == NULL) {
304 paint_destroy(&paint->paint); 310 paint_destroy(&paint->paint);
305 mbe_surface_destroy(paint->surf); 311 mbe_surface_destroy(paint->surf);
306 free(paint); 312 elmpool_elm_free(rdman->paint_image_pool, paint);
307 return NULL; 313 return NULL;
308 } 314 }
309 315
310 return (paint_t *)paint; 316 return (paint_t *)paint;
311 } 317 }