Mercurial > MadButterfly
comparison tools/mb_c_source.m4 @ 159:b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
- Life-cycle of shapes and paints are managed by rdman.
- Add redraw_man_t::free_objs to collect objects their freeing are
postonsed.
Know Issue:
- Bullet of tank are not removed from screen when it is go out the range
of the map.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Sun, 05 Oct 2008 23:32:58 +0800 |
parents | 6ce68c1f7405 |
children | 530bb7728546 |
comparison
equal
deleted
inserted
replaced
158:c1cdd3fcd28f | 159:b90abd31a281 |
---|---|
51 define([SHAPE_TRANSLATE],) | 51 define([SHAPE_TRANSLATE],) |
52 define([SHAPE_MATRIX],) | 52 define([SHAPE_MATRIX],) |
53 divert[]]) | 53 divert[]]) |
54 | 54 |
55 define([S_ADD_LINEAR_PAINT],[ | 55 define([S_ADD_LINEAR_PAINT],[ |
56 obj->$1 = paint_linear_new(rdman, $2, $3, $4, $5); | 56 obj->$1 = rdman_paint_linear_new(rdman, $2, $3, $4, $5); |
57 ifelse(COUNT($6),0,,[dnl | 57 ifelse(COUNT($6),0,,[dnl |
58 stops = (grad_stop_t *)malloc(sizeof(grad_stop_t) * n_$1_stops); | 58 stops = (grad_stop_t *)malloc(sizeof(grad_stop_t) * n_$1_stops); |
59 memcpy(stops, $1_stops, sizeof(grad_stop_t) * n_$1_stops); | 59 memcpy(stops, $1_stops, sizeof(grad_stop_t) * n_$1_stops); |
60 paint_linear_stops(obj->$1, n_$1_stops, stops); | 60 paint_linear_stops(obj->$1, n_$1_stops, stops); |
61 ])dnl | 61 ])dnl |
62 ]) | 62 ]) |
63 | 63 |
64 define([S_ADD_RADIAL_PAINT],[ | 64 define([S_ADD_RADIAL_PAINT],[ |
65 obj->$1 = paint_radial_new(rdman, $2, $3, $4); | 65 obj->$1 = rdman_paint_radial_new(rdman, $2, $3, $4); |
66 ifelse(COUNT($5),0,,[ | 66 ifelse(COUNT($5),0,,[ |
67 stops = (grad_stop_t *)malloc(sizeof(grad_stop_t) * n_$1_stops); | 67 stops = (grad_stop_t *)malloc(sizeof(grad_stop_t) * n_$1_stops); |
68 memcpy(stops, $1_stops, sizeof(grad_stop_t) * n_$1_stops); | 68 memcpy(stops, $1_stops, sizeof(grad_stop_t) * n_$1_stops); |
69 paint_radial_stops(obj->$1, n_$1_stops, stops); | 69 paint_radial_stops(obj->$1, n_$1_stops, stops); |
70 ])dnl | 70 ])dnl |
83 memcpy(stops, $2_stops, sizeof(grad_stop_t) * n_$2_stops); | 83 memcpy(stops, $2_stops, sizeof(grad_stop_t) * n_$2_stops); |
84 paint_linear_stops(obj->$1, n_$2_stops, stops); | 84 paint_linear_stops(obj->$1, n_$2_stops, stops); |
85 ]]) | 85 ]]) |
86 | 86 |
87 define([S_ADD_RECT],[[ | 87 define([S_ADD_RECT],[[ |
88 obj->$1 = sh_rect_new($2, $3, $4, $5, $6, $7); | 88 obj->$1 = rdman_shape_rect_new(rdman, $2, $3, $4, $5, $6, $7); |
89 rdman_add_shape(rdman, obj->$1, obj->$8); | 89 rdman_add_shape(rdman, obj->$1, obj->$8); |
90 ]]) | 90 ]]) |
91 | 91 |
92 define([S_ADD_PATH],[[ | 92 define([S_ADD_PATH],[[ |
93 obj->$1 = sh_path_new("$2"); | 93 obj->$1 = rdman_shape_path_new(rdman, "$2"); |
94 rdman_add_shape(rdman, obj->$1, obj->$3); | 94 rdman_add_shape(rdman, obj->$1, obj->$3); |
95 ]]) | 95 ]]) |
96 | 96 |
97 define([S_ADD_COORD],[[ | 97 define([S_ADD_COORD],[[ |
98 obj->$1 = rdman_coord_new(rdman, obj->$2); | 98 obj->$1 = rdman_coord_new(rdman, obj->$2); |
99 ]]) | 99 ]]) |
100 | 100 |
101 define([S_ADD_TEXT],[[ | 101 define([S_ADD_TEXT],[[ |
102 obj->$1 = sh_text_new("$2", $3, $4, $5, cairo_get_font_face(rdman->cr)); | 102 obj->$1 = rdman_shape_text_new(rdman, "$2", $3, $4, $5, |
103 cairo_get_font_face(rdman->cr)); | |
103 rdman_add_shape(rdman, obj->$1, obj->$6); | 104 rdman_add_shape(rdman, obj->$1, obj->$6); |
104 ]]) | 105 ]]) |
105 | 106 |
106 define([S_FILL_SHAPE_WITH_PAINT],[dnl | 107 define([S_FILL_SHAPE_WITH_PAINT],[dnl |
107 [ rdman_paint_fill(rdman, obj->$2, obj->$1); | 108 [ rdman_paint_fill(rdman, obj->$2, obj->$1); |
110 define([S_STROKE_SHAPE_WITH_PAINT],[dnl | 111 define([S_STROKE_SHAPE_WITH_PAINT],[dnl |
111 [ rdman_paint_stroke(rdman, obj->$2, obj->$1); | 112 [ rdman_paint_stroke(rdman, obj->$2, obj->$1); |
112 ]]) | 113 ]]) |
113 | 114 |
114 define([S_FILL_SHAPE],[dnl | 115 define([S_FILL_SHAPE],[dnl |
115 [ obj->$1_fill = paint_color_new(rdman, $2, $3, $4, $5); | 116 [ obj->$1_fill = rdman_paint_color_new(rdman, $2, $3, $4, $5); |
116 rdman_paint_fill(rdman, obj->$1_fill, obj->$1); | 117 rdman_paint_fill(rdman, obj->$1_fill, obj->$1); |
117 ]]) | 118 ]]) |
118 | 119 |
119 define([S_STROKE_SHAPE],[dnl | 120 define([S_STROKE_SHAPE],[dnl |
120 [ obj->$1_stroke = paint_color_new(rdman, $2, $3, $4, $5); | 121 [ obj->$1_stroke = rdman_paint_color_new(rdman, $2, $3, $4, $5); |
121 rdman_paint_stroke(rdman, obj->$1_stroke, obj->$1); | 122 rdman_paint_stroke(rdman, obj->$1_stroke, obj->$1); |
122 ]]) | 123 ]]) |
123 | 124 |
124 define([S_STROKE_WIDTH],[dnl | 125 define([S_STROKE_WIDTH],[dnl |
125 [ obj->$1->stroke_width = $2; | 126 [ obj->$1->stroke_width = $2; |
201 divert[]]) | 202 divert[]]) |
202 | 203 |
203 define([F_ADD_LINEAR_PAINT],[[ | 204 define([F_ADD_LINEAR_PAINT],[[ |
204 stops = paint_linear_stops(obj->$1, 0, NULL); | 205 stops = paint_linear_stops(obj->$1, 0, NULL); |
205 free(stops); | 206 free(stops); |
206 obj->$1->free(obj->$1); | 207 rdman_paint_free(rdman, obj->$1); |
207 ]]) | 208 ]]) |
208 | 209 |
209 define([F_ADD_RADIAL_PAINT],[[ | 210 define([F_ADD_RADIAL_PAINT],[[ |
210 stops = paint_radial_stops(obj->$1, 0, NULL); | 211 stops = paint_radial_stops(obj->$1, 0, NULL); |
211 free(stops); | 212 free(stops); |
212 obj->$1->free(obj->$1); | 213 rdman_paint_free(rdman, obj->$1); |
213 ]]) | 214 ]]) |
214 | 215 |
215 define([F_ADD_PATH],[[ | 216 define([F_ADD_PATH],[[ |
216 rdman_remove_shape(rdman, obj->$1); | 217 rdman_shape_free(rdman, obj->$1); |
217 obj->$1->free(obj->$1); | |
218 ]]) | 218 ]]) |
219 | 219 |
220 define([F_ADD_RECT],[[ | 220 define([F_ADD_RECT],[[ |
221 rdman_remove_shape(rdman, obj->$1); | 221 rdman_shape_free(rdman, obj->$1); |
222 obj->$1->free(obj->$1); | |
223 ]]) | 222 ]]) |
224 | 223 |
225 define([F_ADD_TEXT],[[ | 224 define([F_ADD_TEXT],[[ |
226 rdman_remove_shape(rdman, obj->$1); | 225 rdman_shape_free(rdman, obj->$1); |
227 obj->$1->free(obj->$1); | |
228 ]]) | 226 ]]) |
229 | 227 |
230 define([F_FILL_SHAPE],[[ | 228 define([F_FILL_SHAPE],[[ |
231 obj->$1_fill->free(obj->$1_fill); | 229 rdman_paint_free(rdman, obj->$1_fill); |
232 ]]) | 230 ]]) |
233 | 231 |
234 define([F_STROKE_SHAPE],[[ | 232 define([F_STROKE_SHAPE],[[ |
235 obj->$1_stroke->free(obj->$1_stroke); | 233 rdman_paint_free(rdman, obj->$1_stroke); |
236 ]]) | 234 ]]) |
237 | 235 |
238 define([CLEAR_VARS],[divert([-1]) | 236 define([CLEAR_VARS],[divert([-1]) |
239 define([FIMPORT],[IMPORT(]QUOTE($[]1)[,[F_])]) | 237 define([FIMPORT],[IMPORT(]QUOTE($[]1)[,[F_])]) |
240 FIMPORT([ADD_LINEAR_PAINT]) | 238 FIMPORT([ADD_LINEAR_PAINT]) |