Mercurial > MadButterfly
comparison include/mb_types.h @ 314:6c350fc92ae3
Cache rednering result is now workable.
- Know issues
- For unknow issue, CAIRO_OPERATOR_CLEAR will not be limited by clipping.
Image will be cleaned in a strange way. Maybe, it is a bug of Cairo.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Thu, 05 Mar 2009 00:54:42 +0800 |
parents | f894b30676e9 |
children | c1afd14caa85 |
comparison
equal
deleted
inserted
replaced
313:5737548e922f | 314:6c350fc92ae3 |
---|---|
12 typedef struct _area area_t; | 12 typedef struct _area area_t; |
13 typedef struct _shnode shnode_t; | 13 typedef struct _shnode shnode_t; |
14 typedef struct _paint paint_t; | 14 typedef struct _paint paint_t; |
15 typedef struct _mb_obj mb_obj_t; | 15 typedef struct _mb_obj mb_obj_t; |
16 typedef struct _mb_sprite mb_sprite_t; | 16 typedef struct _mb_sprite mb_sprite_t; |
17 /*! \todo Replace cairo_t with canvas_t. */ | |
18 typedef cairo_t canvas_t; | |
17 | 19 |
18 struct _redraw_man; | 20 struct _redraw_man; |
19 | 21 |
20 /* \defgroup mb_obj_grp Object type | 22 /* \defgroup mb_obj_grp Object type |
21 * @{ | 23 * @{ |
131 #define geo_pos_is_in(g, _x, _y) area_pos_is_in((g)->cur_area, _x, _y) | 133 #define geo_pos_is_in(g, _x, _y) area_pos_is_in((g)->cur_area, _x, _y) |
132 #define geo_get_area(g) ((g)->cur_area) | 134 #define geo_get_area(g) ((g)->cur_area) |
133 #define geo_get_flags(g, mask) ((g)->flags & (mask)) | 135 #define geo_get_flags(g, mask) ((g)->flags & (mask)) |
134 #define geo_set_flags(g, mask) do {(g)->flags |= mask;} while(0) | 136 #define geo_set_flags(g, mask) do {(g)->flags |= mask;} while(0) |
135 #define geo_clear_flags(g, mask) do {(g)->flags &= ~(mask);} while(0) | 137 #define geo_clear_flags(g, mask) do {(g)->flags &= ~(mask);} while(0) |
136 | 138 #define geo_get_coord(g) sh_get_coord(geo_get_shape(g)) |
139 | |
140 /*! \defgroup coord Coordination | |
141 * @{ | |
142 */ | |
143 typedef struct _coord coord_t; | |
144 | |
145 DARRAY(areas, area_t *); | |
146 | |
147 /*! \brief Canvas information for a coord. | |
148 */ | |
149 typedef struct _coord_canvas_info { | |
150 coord_t *owner; /*!< Cached one or opacity == 1 */ | |
151 canvas_t *canvas; | |
152 areas_t dirty_areas; /*!< \brief Areas should be updated | |
153 * in canvas. | |
154 */ | |
155 area_t aggr_dirty_areas[2]; /*!< Used to aggregate updates to parent. */ | |
156 area_t cached_dirty_area; /*!< Used to dirty an area in cached space. */ | |
157 } coord_canvas_info_t; | |
137 | 158 |
138 /*! \brief A coordination system. | 159 /*! \brief A coordination system. |
139 * | 160 * |
140 * It have a transform function defined by matrix to transform | 161 * It have a transform function defined by matrix to transform |
141 * coordination from source space to target space. | 162 * coordination from source space to target space. |
150 * child00 -> child01 -> child02 [label="sibling"]; | 171 * child00 -> child01 -> child02 [label="sibling"]; |
151 * child10 -> child11 [label="sibling"]; | 172 * child10 -> child11 [label="sibling"]; |
152 * } | 173 * } |
153 * \enddot | 174 * \enddot |
154 */ | 175 */ |
155 typedef struct _coord { | 176 struct _coord { |
156 mb_obj_t obj; | 177 mb_obj_t obj; |
157 unsigned int order; | 178 unsigned int order; |
158 unsigned int flags; | 179 unsigned int flags; /*!< \sa \ref coord_flags */ |
159 co_aix opacity; | 180 co_aix opacity; |
160 /*! Own one or inherit from an ancestor. | 181 /*! Own one or inherit from an ancestor. |
161 * Setup it when clean coords. | 182 * Setup it when clean coords. |
162 * \sa | 183 * \sa |
163 * - \ref COF_OWN_CANVAS | 184 * - \ref COF_OWN_CANVAS |
164 * - \ref redraw | 185 * - \ref redraw |
165 */ | 186 */ |
166 cairo_t *canvas; | 187 coord_canvas_info_t *canvas_info; |
167 area_t *cur_area, *last_area; | 188 area_t *cur_area, *last_area; |
168 area_t areas[2]; | 189 area_t areas[2]; |
169 | 190 |
170 co_aix matrix[6]; | 191 co_aix matrix[6]; |
171 co_aix aggr_matrix[6]; | 192 co_aix aggr_matrix[6]; |
178 | 199 |
179 int num_members; | 200 int num_members; |
180 STAILQ(geo_t) members; /*!< \brief All geo_t members in this coord. */ | 201 STAILQ(geo_t) members; /*!< \brief All geo_t members in this coord. */ |
181 | 202 |
182 subject_t *mouse_event; | 203 subject_t *mouse_event; |
183 } coord_t; | 204 }; |
205 /*! \defgroup coord_flags Coord Flags | |
206 * @{ | |
207 */ | |
184 #define COF_DIRTY 0x1 | 208 #define COF_DIRTY 0x1 |
185 #define COF_HIDDEN 0x2 /*!< A coord is hidden. */ | 209 #define COF_HIDDEN 0x2 /*!< A coord is hidden. */ |
186 #define COF_OWN_CANVAS 0x4 /*!< A coord owns a canvas or inherit it | 210 #define COF_OWN_CANVAS 0x4 /*!< A coord owns a canvas or inherit it |
187 * from an ancestor. | 211 * from an ancestor. |
188 */ | 212 */ |
189 #define COF_SKIP_TRIVAL 0x8 /*!< temporary skip descendants | 213 #define COF_SKIP_TRIVAL 0x8 /*!< temporary skip descendants |
190 * when trivaling. | 214 * when trivaling. |
191 */ | 215 */ |
192 #define COF_FREE 0x10 | 216 #define COF_FREE 0x10 |
217 #define COF_FAST_CACHE 0x20 /*!< \brief Cache raster image in fast way. | |
218 * \sa \ref img_cache | |
219 */ | |
220 #define COF_PRECISE_CACHE 0x40 /*!< \brief Cache raster image in | |
221 * precise way. | |
222 * \sa \ref img_cache | |
223 */ | |
224 #define COF_CACHE_MASK 0x60 | |
225 #define COF_ANCESTOR_CACHE 0x80 /*!< \brief One ancestor is cached. | |
226 * \sa \ref img_cache | |
227 */ | |
228 #define COF_MUST_ZEROING 0x100 /*!< \sa \ref cache_imp */ | |
229 #define COF_JUST_CLEAN 0x200 /*!< \brief This coord is just cleaned by | |
230 * last clean. | |
231 */ | |
232 #define COF_TEMP_MARK 0x400 /*!< \brief Temporary mark a coord. */ | |
233 /* @} */ | |
234 | |
235 extern void matrix_mul(co_aix *m1, co_aix *m2, co_aix *dst); | |
236 extern void matrix_trans_pos(co_aix *matrix, co_aix *x, co_aix *y); | |
193 | 237 |
194 extern void coord_init(coord_t *co, coord_t *parent); | 238 extern void coord_init(coord_t *co, coord_t *parent); |
195 extern void coord_trans_pos(coord_t *co, co_aix *x, co_aix *y); | 239 extern void coord_trans_pos(coord_t *co, co_aix *x, co_aix *y); |
196 extern co_aix coord_trans_size(coord_t *co, co_aix size); | 240 extern co_aix coord_trans_size(coord_t *co, co_aix size); |
197 extern void compute_aggr_of_coord(coord_t *coord); | 241 extern void compute_aggr_of_coord(coord_t *coord); |
242 extern void compute_aggr_of_cached_coord(coord_t *coord); | |
243 extern void compute_reverse(co_aix *orig, co_aix *reverse); | |
198 extern void update_aggr_matrix(coord_t *start); | 244 extern void update_aggr_matrix(coord_t *start); |
199 extern coord_t *preorder_coord_subtree(coord_t *root, coord_t *last); | 245 extern coord_t *preorder_coord_subtree(coord_t *root, coord_t *last); |
200 extern coord_t *postorder_coord_subtree(coord_t *root, coord_t *last); | 246 extern coord_t *postorder_coord_subtree(coord_t *root, coord_t *last); |
201 #define preorder_coord_skip_subtree(sub) \ | 247 #define preorder_coord_skip_subtree(sub) \ |
202 do { (sub)->flags |= COF_SKIP_TRIVAL; } while(0) | 248 do { (sub)->flags |= COF_SKIP_TRIVAL; } while(0) |
203 #define coord_hide(co) \ | 249 #define coord_hide(co) \ |
204 do { \ | 250 do { \ |
205 (co)->flags |= COF_HIDDEN; \ | 251 (co)->flags |= COF_HIDDEN; \ |
206 } while(0) | 252 } while(0) |
207 #define coord_show(co) do { co->flags &= ~COF_HIDDEN; } while(0) | 253 #define coord_show(co) do { co->flags &= ~COF_HIDDEN; } while(0) |
254 #define coord_fast_cache(co) \ | |
255 do { \ | |
256 (co)->flags = \ | |
257 ((co)->flags & ~COF_CACHE_MASK) | COF_FAST_CACHE; \ | |
258 } while(0) | |
259 #define coord_precise_cache(co) \ | |
260 do { \ | |
261 (co)->flags = \ | |
262 ((co)->flags & ~COF_CACHE_MASK) | COF_PRECISE_CACHE; \ | |
263 } while(0) | |
264 #define coord_nocache(co) \ | |
265 do { \ | |
266 (co)->flags &= ~COF_CACHE_MASK; \ | |
267 } while(0) | |
268 #define coord_is_root(co) ((co)->parent == NULL) | |
269 #define coord_is_cached(co) ((co)->flags & COF_CACHE_MASK) | |
270 #define coord_is_fast_cached(co) ((co)->flags & COF_FAST_MASK) | |
271 #define coord_is_precise_cached(co) ((co)->flags & COF_PRECISE_MASK) | |
272 #define coord_is_zeroing(co) ((co)->flags & COF_MUST_ZEROING) | |
273 #define coord_set_zeroing(co) \ | |
274 do { (co)->flags |= COF_MUST_ZEROING; } while(0) | |
275 #define coord_clear_zeroing(co) \ | |
276 do { (co)->flags &= ~COF_MUST_ZEROING; } while(0) | |
277 #define coord_set_flags(co, _flags) \ | |
278 do { (co)->flags |= (_flags); } while(0) | |
279 #define coord_get_flags(co, _flags) ((co)->flags & (_flags)) | |
280 #define coord_clear_flags(co, _flags) \ | |
281 do { (co)->flags &= ~(_flags); } while(0) | |
208 #define coord_get_mouse_event(coord) ((coord)->mouse_event) | 282 #define coord_get_mouse_event(coord) ((coord)->mouse_event) |
209 #define coord_get_aggr_matrix(coord) ((coord)->aggr_matrix) | 283 #define coord_get_aggr_matrix(coord) ((coord)->aggr_matrix) |
210 #define FOR_COORDS_POSTORDER(coord, cur) \ | 284 #define FOR_COORDS_POSTORDER(coord, cur) \ |
211 for((cur) = postorder_coord_subtree((coord), NULL); \ | 285 for((cur) = postorder_coord_subtree((coord), NULL); \ |
212 (cur) != NULL; \ | 286 (cur) != NULL; \ |
236 for(shape = geo_get_shape_safe(STAILQ_HEAD((coord)->members)); \ | 310 for(shape = geo_get_shape_safe(STAILQ_HEAD((coord)->members)); \ |
237 shape != NULL; \ | 311 shape != NULL; \ |
238 shape = geo_get_shape_safe(STAILQ_NEXT(geo_t, coord_next, \ | 312 shape = geo_get_shape_safe(STAILQ_NEXT(geo_t, coord_next, \ |
239 sh_get_geo(shape)))) | 313 sh_get_geo(shape)))) |
240 #define coord_get_area(coord) ((coord)->cur_area) | 314 #define coord_get_area(coord) ((coord)->cur_area) |
315 #define _coord_get_canvas(coord) ((coord)->canvas_info->canvas) | |
316 #define _coord_set_canvas(coord, _canvas) \ | |
317 do { \ | |
318 (coord)->canvas_info->canvas = _canvas; \ | |
319 } while(0) | |
320 #define _coord_get_dirty_areas(coord) (&(coord)->canvas_info->dirty_areas) | |
321 | |
322 /* @} */ | |
241 | 323 |
242 /*! \brief A grahpic shape. | 324 /*! \brief A grahpic shape. |
243 * | 325 * |
244 * \dot | 326 * \dot |
245 * digraph G { | 327 * digraph G { |