Mercurial > MadButterfly
comparison src/paint.c @ 868:f41ac71266bc
Remove rdman pointer from structure of paints.
Since a pointer of rdman is passed when calling free function of
paint, this pointer can be removed.
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Thu, 23 Sep 2010 10:51:25 +0800 |
parents | 4f8d53be9488 |
children | a17c4e231e54 |
comparison
equal
deleted
inserted
replaced
867:4f8d53be9488 | 868:f41ac71266bc |
---|---|
76 co_aix x2, y2; | 76 co_aix x2, y2; |
77 int n_stops; | 77 int n_stops; |
78 grad_stop_t *stops; | 78 grad_stop_t *stops; |
79 int flags; | 79 int flags; |
80 mbe_pattern_t *ptn; | 80 mbe_pattern_t *ptn; |
81 | |
82 redraw_man_t *rdman; /*!< \brief Used by paint_linear_free(). */ | |
83 } paint_linear_t; | 81 } paint_linear_t; |
84 | 82 |
85 #define LIF_DIRTY 0x1 | 83 #define LIF_DIRTY 0x1 |
86 | 84 |
87 int _paint_linear_size = sizeof(paint_linear_t); | 85 int _paint_linear_size = sizeof(paint_linear_t); |
109 paint_linear_t *linear = (paint_linear_t *)paint; | 107 paint_linear_t *linear = (paint_linear_t *)paint; |
110 | 108 |
111 if(linear->ptn) | 109 if(linear->ptn) |
112 mbe_pattern_destroy(linear->ptn); | 110 mbe_pattern_destroy(linear->ptn); |
113 paint_destroy(paint); | 111 paint_destroy(paint); |
114 elmpool_elm_free(linear->rdman->paint_linear_pool, linear); | 112 elmpool_elm_free(rdman->paint_linear_pool, linear); |
115 } | 113 } |
116 | 114 |
117 paint_t *rdman_paint_linear_new(redraw_man_t *rdman, | 115 paint_t *rdman_paint_linear_new(redraw_man_t *rdman, |
118 co_aix x1, co_aix y1, | 116 co_aix x1, co_aix y1, |
119 co_aix x2, co_aix y2) { | 117 co_aix x2, co_aix y2) { |
132 linear->y2 = y2; | 130 linear->y2 = y2; |
133 linear->n_stops = 0; | 131 linear->n_stops = 0; |
134 linear->stops = NULL; | 132 linear->stops = NULL; |
135 linear->flags = LIF_DIRTY; | 133 linear->flags = LIF_DIRTY; |
136 linear->ptn = NULL; | 134 linear->ptn = NULL; |
137 linear->rdman = rdman; | |
138 | 135 |
139 return (paint_t *)linear; | 136 return (paint_t *)linear; |
140 } | 137 } |
141 | 138 |
142 /*! \brief Setup color stop for a linear radient paint. | 139 /*! \brief Setup color stop for a linear radient paint. |
169 co_aix r; | 166 co_aix r; |
170 int n_stops; | 167 int n_stops; |
171 grad_stop_t *stops; | 168 grad_stop_t *stops; |
172 int flags; | 169 int flags; |
173 mbe_pattern_t *ptn; | 170 mbe_pattern_t *ptn; |
174 | |
175 redraw_man_t *rdman; /*!< \brief Used by paint_radial_free() */ | |
176 } paint_radial_t; | 171 } paint_radial_t; |
177 | 172 |
178 #define RDF_DIRTY 0x1 | 173 #define RDF_DIRTY 0x1 |
179 | 174 |
180 int _paint_radial_size = sizeof(paint_radial_t); | 175 int _paint_radial_size = sizeof(paint_radial_t); |
200 paint_radial_t *radial = (paint_radial_t *)paint; | 195 paint_radial_t *radial = (paint_radial_t *)paint; |
201 | 196 |
202 if(radial->ptn) | 197 if(radial->ptn) |
203 mbe_pattern_destroy(radial->ptn); | 198 mbe_pattern_destroy(radial->ptn); |
204 paint_destroy(paint); | 199 paint_destroy(paint); |
205 elmpool_elm_free(radial->rdman->paint_radial_pool, radial); | 200 elmpool_elm_free(rdman->paint_radial_pool, radial); |
206 } | 201 } |
207 | 202 |
208 paint_t *rdman_paint_radial_new(redraw_man_t *rdman, | 203 paint_t *rdman_paint_radial_new(redraw_man_t *rdman, |
209 co_aix cx, co_aix cy, co_aix r) { | 204 co_aix cx, co_aix cy, co_aix r) { |
210 paint_radial_t *radial; | 205 paint_radial_t *radial; |
220 radial->r = r; | 215 radial->r = r; |
221 radial->n_stops = 0; | 216 radial->n_stops = 0; |
222 radial->stops = NULL; | 217 radial->stops = NULL; |
223 radial->flags = RDF_DIRTY; | 218 radial->flags = RDF_DIRTY; |
224 radial->ptn = NULL; | 219 radial->ptn = NULL; |
225 radial->rdman = rdman; | |
226 | 220 |
227 return (paint_t *)radial; | 221 return (paint_t *)radial; |
228 } | 222 } |
229 | 223 |
230 /*! \brief Setup color stop for a radial radient paint. | 224 /*! \brief Setup color stop for a radial radient paint. |
255 typedef struct _paint_image { | 249 typedef struct _paint_image { |
256 paint_t paint; | 250 paint_t paint; |
257 mb_img_data_t *img; | 251 mb_img_data_t *img; |
258 mbe_surface_t *surf; | 252 mbe_surface_t *surf; |
259 mbe_pattern_t *ptn; | 253 mbe_pattern_t *ptn; |
260 | |
261 redraw_man_t *rdman; /*!< \brief Used by paint_image_free() */ | |
262 } paint_image_t; | 254 } paint_image_t; |
263 | 255 |
264 int _paint_image_size = sizeof(paint_image_t); | 256 int _paint_image_size = sizeof(paint_image_t); |
265 | 257 |
266 static | 258 static |
279 | 271 |
280 mbe_surface_destroy(paint_img->surf); | 272 mbe_surface_destroy(paint_img->surf); |
281 img_data = paint_img->img; | 273 img_data = paint_img->img; |
282 MB_IMG_DATA_FREE(img_data); | 274 MB_IMG_DATA_FREE(img_data); |
283 paint_destroy(&paint_img->paint); | 275 paint_destroy(&paint_img->paint); |
284 elmpool_elm_free(paint_img->rdman->paint_image_pool, paint_img); | 276 elmpool_elm_free(rdman->paint_image_pool, paint_img); |
285 } | 277 } |
286 | 278 |
287 /*! \brief Create an image painter. | 279 /*! \brief Create an image painter. |
288 * | 280 * |
289 * Create a painter that fill/stroke shapes with an image. | 281 * Create a painter that fill/stroke shapes with an image. |
300 return NULL; | 292 return NULL; |
301 | 293 |
302 paint_init(&paint->paint, MBP_IMAGE, | 294 paint_init(&paint->paint, MBP_IMAGE, |
303 paint_image_prepare, paint_image_free); | 295 paint_image_prepare, paint_image_free); |
304 paint->img = img; | 296 paint->img = img; |
305 paint->rdman = rdman; | |
306 paint->surf = mbe_image_surface_create_for_data(img->content, | 297 paint->surf = mbe_image_surface_create_for_data(img->content, |
307 img->fmt, | 298 img->fmt, |
308 img->w, | 299 img->w, |
309 img->h, | 300 img->h, |
310 img->stride); | 301 img->stride); |