Mercurial > MadButterfly
comparison src/paint.c @ 822:586e50f82c1f
Unify coding style tag for emacs and vim.
author | Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com> |
---|---|
date | Tue, 14 Sep 2010 01:08:39 +0800 |
parents | f43224bf3524 |
children | 4f8d53be9488 |
comparison
equal
deleted
inserted
replaced
821:bfdc82bbd6e4 | 822:586e50f82c1f |
---|---|
1 // -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- | |
2 // vim: sw=4:ts=8:sts=4 | |
1 #include <stdio.h> | 3 #include <stdio.h> |
2 #include <stdlib.h> | 4 #include <stdlib.h> |
3 #include "mb_graph_engine.h" | 5 #include "mb_graph_engine.h" |
4 #include "mb_paint.h" | 6 #include "mb_paint.h" |
5 | 7 |
141 grad_stop_t *paint_linear_stops(paint_t *paint, | 143 grad_stop_t *paint_linear_stops(paint_t *paint, |
142 int n_stops, | 144 int n_stops, |
143 grad_stop_t *stops) { | 145 grad_stop_t *stops) { |
144 paint_linear_t *linear = (paint_linear_t *)paint; | 146 paint_linear_t *linear = (paint_linear_t *)paint; |
145 grad_stop_t *old_stops; | 147 grad_stop_t *old_stops; |
146 | 148 |
147 old_stops = linear->stops; | 149 old_stops = linear->stops; |
148 linear->n_stops = n_stops; | 150 linear->n_stops = n_stops; |
149 linear->stops = stops; | 151 linear->stops = stops; |
150 linear->flags |= LIF_DIRTY; | 152 linear->flags |= LIF_DIRTY; |
151 | 153 |
224 grad_stop_t *paint_radial_stops(paint_t *paint, | 226 grad_stop_t *paint_radial_stops(paint_t *paint, |
225 int n_stops, | 227 int n_stops, |
226 grad_stop_t *stops) { | 228 grad_stop_t *stops) { |
227 paint_radial_t *radial = (paint_radial_t *)paint; | 229 paint_radial_t *radial = (paint_radial_t *)paint; |
228 grad_stop_t *old_stops; | 230 grad_stop_t *old_stops; |
229 | 231 |
230 old_stops = radial->stops; | 232 old_stops = radial->stops; |
231 radial->n_stops = n_stops; | 233 radial->n_stops = n_stops; |
232 radial->stops = stops; | 234 radial->stops = stops; |
233 radial->flags |= RDF_DIRTY; | 235 radial->flags |= RDF_DIRTY; |
234 | 236 |
258 | 260 |
259 static | 261 static |
260 void paint_image_free(redraw_man_t *rdman, paint_t *paint) { | 262 void paint_image_free(redraw_man_t *rdman, paint_t *paint) { |
261 paint_image_t *paint_img = (paint_image_t *)paint; | 263 paint_image_t *paint_img = (paint_image_t *)paint; |
262 mb_img_data_t *img_data; | 264 mb_img_data_t *img_data; |
263 | 265 |
264 mbe_surface_destroy(paint_img->surf); | 266 mbe_surface_destroy(paint_img->surf); |
265 img_data = paint_img->img; | 267 img_data = paint_img->img; |
266 MB_IMG_DATA_FREE(img_data); | 268 MB_IMG_DATA_FREE(img_data); |
267 paint_destroy(&paint_img->paint); | 269 paint_destroy(&paint_img->paint); |
268 free(paint); | 270 free(paint); |
280 paint_image_t *paint; | 282 paint_image_t *paint; |
281 | 283 |
282 paint = O_ALLOC(paint_image_t); | 284 paint = O_ALLOC(paint_image_t); |
283 if(paint == NULL) | 285 if(paint == NULL) |
284 return NULL; | 286 return NULL; |
285 | 287 |
286 paint_init(&paint->paint, MBP_IMAGE, | 288 paint_init(&paint->paint, MBP_IMAGE, |
287 paint_image_prepare, paint_image_free); | 289 paint_image_prepare, paint_image_free); |
288 paint->img = img; | 290 paint->img = img; |
289 paint->surf = mbe_image_surface_create_for_data(img->content, | 291 paint->surf = mbe_image_surface_create_for_data(img->content, |
290 img->fmt, | 292 img->fmt, |
294 if(paint->surf == NULL) { | 296 if(paint->surf == NULL) { |
295 paint_destroy(&paint->paint); | 297 paint_destroy(&paint->paint); |
296 free(paint); | 298 free(paint); |
297 return NULL; | 299 return NULL; |
298 } | 300 } |
299 | 301 |
300 paint->ptn = mbe_pattern_create_for_surface(paint->surf); | 302 paint->ptn = mbe_pattern_create_for_surface(paint->surf); |
301 if(paint->ptn == NULL) { | 303 if(paint->ptn == NULL) { |
302 paint_destroy(&paint->paint); | 304 paint_destroy(&paint->paint); |
303 mbe_surface_destroy(paint->surf); | 305 mbe_surface_destroy(paint->surf); |
304 free(paint); | 306 free(paint); |
314 * corresponding points in image space. It is used to resample | 316 * corresponding points in image space. It is used to resample |
315 * the image to generate pixels of result image. | 317 * the image to generate pixels of result image. |
316 */ | 318 */ |
317 void paint_image_set_matrix(paint_t *paint, co_aix matrix[6]) { | 319 void paint_image_set_matrix(paint_t *paint, co_aix matrix[6]) { |
318 paint_image_t *img_paint = (paint_image_t *)paint; | 320 paint_image_t *img_paint = (paint_image_t *)paint; |
319 | 321 |
320 mbe_pattern_set_matrix(img_paint->ptn, matrix); | 322 mbe_pattern_set_matrix(img_paint->ptn, matrix); |
321 } | 323 } |
322 | 324 |
323 void paint_image_get_size(paint_t *paint, int *w, int *h) { | 325 void paint_image_get_size(paint_t *paint, int *w, int *h) { |
324 paint_image_t *ipaint = (paint_image_t *)paint; | 326 paint_image_t *ipaint = (paint_image_t *)paint; |
325 | 327 |
326 ASSERT(paint->pnt_type == MBP_IMAGE); | 328 ASSERT(paint->pnt_type == MBP_IMAGE); |
327 *w = ipaint->img->w; | 329 *w = ipaint->img->w; |
328 *h = ipaint->img->h; | 330 *h = ipaint->img->h; |
329 } | 331 } |