Mercurial > MadButterfly
comparison src/redraw_man.c @ 850:33fd5fdc8b48 abs_n_rel_center
Keep cache to parent device matrix in canvas_info.
This can avoid to compute matrix repeatly.
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Mon, 20 Sep 2010 22:43:43 +0800 |
parents | ce6cd06adccf |
children | 85f22a771e4a |
comparison
equal
deleted
inserted
replaced
847:dfe28355bded | 850:33fd5fdc8b48 |
---|---|
1283 } | 1283 } |
1284 } | 1284 } |
1285 | 1285 |
1286 /* \brief Compute matrix from cached canvas to parent device space. | 1286 /* \brief Compute matrix from cached canvas to parent device space. |
1287 */ | 1287 */ |
1288 static void compute_cached_2_pdev_matrix(coord_t *coord, | 1288 static void compute_cached_2_pdev_matrix(coord_t *coord) { |
1289 co_aix canvas2pdev_matrix[6]) { | 1289 co_aix *canvas2pdev_matrix = coord_get_2pdev(coord); |
1290 coord_t *parent; | 1290 coord_t *parent; |
1291 co_aix *aggr; | 1291 co_aix *aggr; |
1292 co_aix *matrix, *paggr; | 1292 co_aix *matrix, *paggr; |
1293 co_aix scale_x, scale_y; | 1293 co_aix scale_x, scale_y; |
1294 co_aix shift_x, shift_y; | 1294 co_aix shift_x, shift_y; |
1310 canvas2p[3] = 0; | 1310 canvas2p[3] = 0; |
1311 canvas2p[4] = scale_y; | 1311 canvas2p[4] = scale_y; |
1312 canvas2p[5] = shift_y; | 1312 canvas2p[5] = shift_y; |
1313 | 1313 |
1314 matrix_mul(paggr, canvas2p, canvas2pdev_matrix); | 1314 matrix_mul(paggr, canvas2p, canvas2pdev_matrix); |
1315 | |
1316 compute_reverse(canvas2pdev_matrix, coord_get_2pdev_rev(coord)); | |
1315 } | 1317 } |
1316 | 1318 |
1317 /*! \brief Compute area in parent cached coord for a cached coord. | 1319 /*! \brief Compute area in parent cached coord for a cached coord. |
1318 * | 1320 * |
1319 * The coordination system of cached coord and descendants is resized, | 1321 * The coordination system of cached coord and descendants is resized, |
1324 * ancestral cached coord can be retreived by shifting and resizing | 1326 * ancestral cached coord can be retreived by shifting and resizing |
1325 * canvas box in reverse and transform to coordination system of | 1327 * canvas box in reverse and transform to coordination system of |
1326 * ancestral cached coord. | 1328 * ancestral cached coord. |
1327 */ | 1329 */ |
1328 static void compute_pcache_area(coord_t *coord) { | 1330 static void compute_pcache_area(coord_t *coord) { |
1329 co_aix cached2pdev[6]; | 1331 co_aix *cached2pdev = coord_get_2pdev(coord); |
1330 int c_w, c_h; | 1332 int c_w, c_h; |
1331 canvas_t *canvas; | 1333 canvas_t *canvas; |
1332 coord_canvas_info_t *canvas_info; | 1334 coord_canvas_info_t *canvas_info; |
1333 co_aix poses[4][2]; | 1335 co_aix poses[4][2]; |
1334 | 1336 |
1335 canvas_info = coord->canvas_info; | 1337 canvas_info = coord->canvas_info; |
1336 SWAP(canvas_info->pcache_cur_area, canvas_info->pcache_last_area, | 1338 SWAP(canvas_info->pcache_cur_area, canvas_info->pcache_last_area, |
1337 area_t *); | 1339 area_t *); |
1338 compute_cached_2_pdev_matrix(coord, cached2pdev); | |
1339 | 1340 |
1340 canvas = _coord_get_canvas(coord); | 1341 canvas = _coord_get_canvas(coord); |
1341 canvas_get_size(canvas, &c_w, &c_h); | 1342 canvas_get_size(canvas, &c_w, &c_h); |
1342 | 1343 |
1343 poses[0][0] = 0; | 1344 poses[0][0] = 0; |
1738 */ | 1739 */ |
1739 for(i = all_zeroing->num - 1; i >= 0; i--) { | 1740 for(i = all_zeroing->num - 1; i >= 0; i--) { |
1740 coord = all_zeroing->ds[i]; | 1741 coord = all_zeroing->ds[i]; |
1741 if(coord_is_zeroing(coord)) | 1742 if(coord_is_zeroing(coord)) |
1742 zeroing_coord(rdman, coord); | 1743 zeroing_coord(rdman, coord); |
1744 compute_cached_2_pdev_matrix(coord); | |
1743 /* This is required by ancester cached ones to perform | 1745 /* This is required by ancester cached ones to perform |
1744 * zeroing. | 1746 * zeroing. |
1745 */ | 1747 */ |
1746 compute_pcache_area(coord); | 1748 compute_pcache_area(coord); |
1747 } | 1749 } |
1758 static void add_aggr_dirty_areas_to_ancestor(redraw_man_t *rdman, | 1760 static void add_aggr_dirty_areas_to_ancestor(redraw_man_t *rdman, |
1759 coord_t *coord) { | 1761 coord_t *coord) { |
1760 int i; | 1762 int i; |
1761 int n_areas; | 1763 int n_areas; |
1762 co_aix poses0[2][2], poses1[2][2]; | 1764 co_aix poses0[2][2], poses1[2][2]; |
1763 co_aix canvas2pdev_matrix[6]; | 1765 co_aix *canvas2pdev_matrix; |
1764 area_t **areas, *area; | 1766 area_t **areas, *area; |
1765 area_t *area0, *area1; | 1767 area_t *area0, *area1; |
1766 coord_t *parent, *pcached_coord; | 1768 coord_t *parent, *pcached_coord; |
1767 | 1769 |
1768 n_areas = _coord_get_dirty_areas(coord)->num; | 1770 n_areas = _coord_get_dirty_areas(coord)->num; |
1835 } | 1837 } |
1836 | 1838 |
1837 parent = coord_get_parent(coord); | 1839 parent = coord_get_parent(coord); |
1838 pcached_coord = coord_get_cached(parent); | 1840 pcached_coord = coord_get_cached(parent); |
1839 | 1841 |
1840 compute_cached_2_pdev_matrix(coord, canvas2pdev_matrix); | 1842 canvas2pdev_matrix = coord_get_2pdev(coord); |
1841 | 1843 |
1842 /* Add dirty areas to parent cached coord. */ | 1844 /* Add dirty areas to parent cached coord. */ |
1843 matrix_trans_pos(canvas2pdev_matrix, poses0[0], poses0[0] + 1); | 1845 matrix_trans_pos(canvas2pdev_matrix, poses0[0], poses0[0] + 1); |
1844 matrix_trans_pos(canvas2pdev_matrix, poses0[1], poses0[1] + 1); | 1846 matrix_trans_pos(canvas2pdev_matrix, poses0[1], poses0[1] + 1); |
1845 area_init(area0, 2, poses0); | 1847 area_init(area0, 2, poses0); |
2181 } | 2183 } |
2182 | 2184 |
2183 static void update_cached_canvas_2_parent(redraw_man_t *rdman, | 2185 static void update_cached_canvas_2_parent(redraw_man_t *rdman, |
2184 coord_t *coord) { | 2186 coord_t *coord) { |
2185 mbe_t *pcanvas, *canvas; | 2187 mbe_t *pcanvas, *canvas; |
2186 co_aix reverse[6]; | 2188 co_aix *c2pdev_reverse; |
2187 co_aix canvas2pdev_matrix[6]; | |
2188 | 2189 |
2189 if(coord_is_root(coord)) | 2190 if(coord_is_root(coord)) |
2190 return; | 2191 return; |
2191 | 2192 |
2192 compute_cached_2_pdev_matrix(coord, canvas2pdev_matrix); | 2193 c2pdev_reverse = coord_get_2pdev_rev(coord); |
2193 compute_reverse(canvas2pdev_matrix, reverse); | |
2194 | 2194 |
2195 canvas = _coord_get_canvas(coord); | 2195 canvas = _coord_get_canvas(coord); |
2196 pcanvas = _coord_get_canvas(coord->parent); | 2196 pcanvas = _coord_get_canvas(coord->parent); |
2197 #ifndef UNITTEST | 2197 #ifndef UNITTEST |
2198 _update_cached_canvas_2_parent(rdman, reverse, canvas, pcanvas, | 2198 _update_cached_canvas_2_parent(rdman, c2pdev_reverse, canvas, pcanvas, |
2199 coord->opacity); | 2199 coord->opacity); |
2200 #else | 2200 #else |
2201 memcpy(((mock_mbe_t *)canvas)->parent_2_cache, reverse, | 2201 memcpy(((mock_mbe_t *)canvas)->parent_2_cache, c2pdev_reverse, |
2202 sizeof(co_aix) * 6); | 2202 sizeof(co_aix) * 6); |
2203 #endif | 2203 #endif |
2204 } | 2204 } |
2205 | 2205 |
2206 static int draw_coord_shapes_in_dirty_areas(redraw_man_t *rdman, | 2206 static int draw_coord_shapes_in_dirty_areas(redraw_man_t *rdman, |