Mercurial > MadButterfly
comparison src/redraw_man.c @ 519:7a1b17ebb3b4 Android_Skia
Change documentation for zeroing
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Thu, 17 Dec 2009 16:09:46 +0800 |
parents | d186d1e24458 |
children | f106b57b8660 |
comparison
equal
deleted
inserted
replaced
518:3a7bce43ec6e | 519:7a1b17ebb3b4 |
---|---|
227 * Separated lists should be maintained for each cached coord and it's | 227 * Separated lists should be maintained for each cached coord and it's |
228 * descendants. | 228 * descendants. |
229 * | 229 * |
230 * \section cache_imp Implementation of Cache | 230 * \section cache_imp Implementation of Cache |
231 * Both cached coords and coords that opacity != 1 need a canvas to | 231 * Both cached coords and coords that opacity != 1 need a canvas to |
232 * draw descendants on. Both cases are traded in the same way. | 232 * draw descendants on. Both cases are traded in the same way. Every |
233 * Every of them own a canvas_info to describe canvas and related | 233 * of them own a canvas_info to describe canvas and related |
234 * information. aggr_matrix of descendants must be adjusted to make | 234 * information. aggr_matrix of descendants must be adjusted to make |
235 * left-top of range just at origin of canvas. It can save space by setting | 235 * left-top of bounding box just at origin (0, 0) of canvas. It saves |
236 * just large enough to hold rendering result of descendants. The process | 236 * space to give a canvas just enough for rending descadants. The |
237 * of adjusting is zeroing. | 237 * process of adjusting left-top of bounding box is zeroing. |
238 * | 238 * |
239 * Following is rules. | 239 * Following is rules. |
240 * - zeroing on a cached coord is performed by adjust coord_t::aggr_matrix | 240 * - zeroing on a cached coord is performed by adjust coord_t::aggr_matrix |
241 * of the cached coord and descendnats. | 241 * of the cached coord and descendnats. |
242 * - Clean coords works just like before without change. | 242 * - Clean coords works just like before without change. |
243 * - in preorder | 243 * - in preorder |
244 * - never perform zeroing on root_coord. | 244 * - never perform zeroing on root_coord. |
245 * - zeroing on cached coords marked with \ref COF_MUST_ZEROING. | 245 * - do zeroing on cached coords marked with \ref COF_MUST_ZEROING. |
246 * - when clean a descendant that moves out-side of it's canvas, | 246 * - when clean a descendant that moves out-side of it's canvas, |
247 * respective cached coord is marked with \ref COF_MUST_ZEROING. | 247 * respective cached coord is marked with \ref COF_MUST_ZEROING. |
248 * - zeroing is performed immediately after clean coords. | 248 * - zeroing is performed immediately after clean coords. |
249 * - zeroing will not propagate acrossing boundary of cached coord. | 249 * - zeroing will not be propagated to ancestors of a cached coord. |
250 * - It will be stopped at descendants which are cached coords. | 250 * - It will be stopped once a cached coord being found. |
251 * - coord_t::cur_area and coord_t::aggr_matrix of cached coords | 251 * - coord_t::cur_area and coord_t::aggr_matrix of cached coords |
252 * must be ajdusted. | 252 * must be ajdusted. |
253 * - the area of a cached coord is defined in parent space. | 253 * - the area of a cached coord is defined in parent space. |
254 * - areas of descendants are defined in space defined by aggr_matrix of | 254 * - areas of descendants are defined in space defined by aggr_matrix of |
255 * cached coord. | 255 * cached coord. |
256 * - parent know the area in where cached coord and descendnats will | 256 * - coord_t::aggr_matrix of cached coord defines coordination of |
257 * descendants. | |
258 * - the parent knows the area in where cached coord and descendnats will | |
257 * be draw. | 259 * be draw. |
258 * - cached coords keep their private dirty area list. | 260 * - cached coords keep their private dirty area list. |
259 * - private dirty areas of a cached coord are transformed and added to | 261 * - private dirty areas of a cached coord are transformed and added to |
260 * parent cached coord. | 262 * parent cached coord. |
261 * - aggregates areas before adding to parent. | 263 * - aggregates areas before adding to parent. |
1490 area->h = h; | 1492 area->h = h; |
1491 DARRAY_CLEAN(_coord_get_dirty_areas(coord)); | 1493 DARRAY_CLEAN(_coord_get_dirty_areas(coord)); |
1492 add_dirty_area(rdman, coord, area); | 1494 add_dirty_area(rdman, coord, area); |
1493 } | 1495 } |
1494 | 1496 |
1495 /*! \brief Add canvas owner of dirty geos to coord_t::zeroing_coords. | 1497 /*! \brief Add canvas owner of dirty geos to redraw_man_t::zeroing_coords. |
1496 * | 1498 * |
1497 * All possible coords that need a zeroing have at least one dirty geo. | 1499 * All possible coords that need a zeroing have at least one dirty geo. |
1498 */ | 1500 */ |
1499 static int add_rdman_zeroing_coords(redraw_man_t *rdman) { | 1501 static int add_rdman_zeroing_coords(redraw_man_t *rdman) { |
1500 int i; | 1502 int i; |
1501 int n_dirty_geos; | 1503 int n_dirty_geos; |
1502 geo_t **dirty_geos, *geo; | 1504 geo_t **dirty_geos, *geo; |
1503 int n_dirty_coords; | 1505 int n_dirty_coords; |
1504 coord_t **dirty_coords, *coord; | 1506 coord_t **dirty_coords, *coord; |
1505 | 1507 |
1508 /* Mark all cached ancestor coords of dirty geos */ | |
1506 n_dirty_geos = rdman->dirty_geos.num; | 1509 n_dirty_geos = rdman->dirty_geos.num; |
1507 dirty_geos = rdman->dirty_geos.ds; | 1510 dirty_geos = rdman->dirty_geos.ds; |
1508 for(i = 0; i < n_dirty_geos; i++) { | 1511 for(i = 0; i < n_dirty_geos; i++) { |
1509 geo = dirty_geos[i]; | 1512 geo = dirty_geos[i]; |
1510 coord = geo_get_coord(geo)->canvas_info->owner; | 1513 coord = geo_get_coord(geo)->canvas_info->owner; |
1514 break; | 1517 break; |
1515 coord = coord->parent->canvas_info->owner; | 1518 coord = coord->parent->canvas_info->owner; |
1516 } | 1519 } |
1517 } | 1520 } |
1518 | 1521 |
1522 /* Mark all cached ancestor coords of dirty coords */ | |
1519 n_dirty_coords = rdman->dirty_coords.num; | 1523 n_dirty_coords = rdman->dirty_coords.num; |
1520 dirty_coords = rdman->dirty_coords.ds; | 1524 dirty_coords = rdman->dirty_coords.ds; |
1521 for(i = 0; i < n_dirty_coords; i++) { | 1525 for(i = 0; i < n_dirty_coords; i++) { |
1522 coord = dirty_coords[i]->canvas_info->owner; | 1526 coord = dirty_coords[i]->canvas_info->owner; |
1523 while(!coord_get_flags(coord, COF_MUST_ZEROING | COF_TEMP_MARK)) { | 1527 while(!coord_get_flags(coord, COF_MUST_ZEROING | COF_TEMP_MARK)) { |
1526 break; | 1530 break; |
1527 coord = coord->parent->canvas_info->owner; | 1531 coord = coord->parent->canvas_info->owner; |
1528 } | 1532 } |
1529 } | 1533 } |
1530 | 1534 |
1535 /* Add all marked coords into redraw_man_t::zeroing_coords list */ | |
1531 FOR_COORDS_PREORDER(rdman->root_coord, coord) { | 1536 FOR_COORDS_PREORDER(rdman->root_coord, coord) { |
1532 if(!coord_get_flags(coord, COF_TEMP_MARK)) { | 1537 if(!coord_get_flags(coord, COF_TEMP_MARK)) { |
1533 preorder_coord_skip_subtree(coord); | 1538 preorder_coord_skip_subtree(coord); |
1534 continue; | 1539 continue; |
1535 } | 1540 } |
1536 add_zeroing_coord(rdman, coord); | 1541 add_zeroing_coord(rdman, coord); |
1542 | |
1537 coord_clear_flags(coord, COF_TEMP_MARK); | 1543 coord_clear_flags(coord, COF_TEMP_MARK); |
1538 } | 1544 } |
1539 | 1545 |
1540 return OK; | 1546 return OK; |
1541 } | 1547 } |
2108 DARRAY_CLEAN(_coord_get_dirty_areas(coord)); | 2114 DARRAY_CLEAN(_coord_get_dirty_areas(coord)); |
2109 } | 2115 } |
2110 rdman->n_dirty_areas = 0; | 2116 rdman->n_dirty_areas = 0; |
2111 } | 2117 } |
2112 | 2118 |
2119 /* clear COF_MUST_ZEROING flag for coords */ | |
2113 coords = rdman->zeroing_coords.ds; | 2120 coords = rdman->zeroing_coords.ds; |
2114 for(i = 0; i < rdman->zeroing_coords.num; i++) { | 2121 for(i = 0; i < rdman->zeroing_coords.num; i++) { |
2115 coord = coords[i]; | 2122 coord = coords[i]; |
2116 coord_clear_flags(coord, COF_MUST_ZEROING); | 2123 coord_clear_flags(coord, COF_MUST_ZEROING); |
2117 } | 2124 } |