Mercurial > MadButterfly
comparison src/redraw_man.c @ 896:ae86e03acb6d
Merge abs_n_rel_center
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Tue, 28 Sep 2010 17:28:13 +0800 |
parents | 8a2d676d9fa3 |
children | 960e2395973d |
comparison
equal
deleted
inserted
replaced
894:460b2629be30 | 896:ae86e03acb6d |
---|---|
610 */ | 610 */ |
611 static coord_canvas_info_t * | 611 static coord_canvas_info_t * |
612 coord_canvas_info_new(redraw_man_t *rdman, coord_t *coord, | 612 coord_canvas_info_new(redraw_man_t *rdman, coord_t *coord, |
613 mbe_t *canvas) { | 613 mbe_t *canvas) { |
614 coord_canvas_info_t *info; | 614 coord_canvas_info_t *info; |
615 static co_aix id[6] = {1, 0, 0, 0, 1, 0}; | |
615 | 616 |
616 info = (coord_canvas_info_t *)elmpool_elm_alloc(rdman->coord_canvas_pool); | 617 info = (coord_canvas_info_t *)elmpool_elm_alloc(rdman->coord_canvas_pool); |
617 if(info == NULL) | 618 if(info == NULL) |
618 return info; | 619 return info; |
619 | 620 |
622 DARRAY_INIT(&info->dirty_areas); | 623 DARRAY_INIT(&info->dirty_areas); |
623 | 624 |
624 bzero(info->pcache_areas, sizeof(area_t) * 2); | 625 bzero(info->pcache_areas, sizeof(area_t) * 2); |
625 info->pcache_cur_area = &info->pcache_areas[0]; | 626 info->pcache_cur_area = &info->pcache_areas[0]; |
626 info->pcache_last_area = &info->pcache_areas[1]; | 627 info->pcache_last_area = &info->pcache_areas[1]; |
628 memcpy(info->cache_2_pdev, id, sizeof(co_aix) * 6); | |
629 memcpy(info->cache_2_pdev_rev, id, sizeof(co_aix) * 6); | |
630 memcpy(info->aggr_2_pdev, id, sizeof(co_aix) * 6); | |
631 memcpy(info->aggr_2_pdev_rev, id, sizeof(co_aix) * 6); | |
627 | 632 |
628 return info; | 633 return info; |
629 } | 634 } |
630 | 635 |
631 static void coord_canvas_info_free(redraw_man_t *rdman, | 636 static void coord_canvas_info_free(redraw_man_t *rdman, |
1308 } | 1313 } |
1309 } | 1314 } |
1310 | 1315 |
1311 /* \brief Compute matrix from cached canvas to parent device space. | 1316 /* \brief Compute matrix from cached canvas to parent device space. |
1312 */ | 1317 */ |
1313 static void compute_cached_2_pdev_matrix(coord_t *coord, | 1318 static void compute_cached_2_pdev_matrix(coord_t *coord) { |
1314 co_aix canvas2pdev_matrix[6]) { | 1319 co_aix *canvas2pdev_matrix = coord_get_2pdev(coord); |
1315 coord_t *parent; | 1320 coord_t *parent; |
1316 co_aix *aggr; | 1321 co_aix *aggr; |
1317 co_aix *matrix, *paggr; | 1322 co_aix *matrix, *paggr; |
1318 co_aix scale_x, scale_y; | 1323 co_aix scale_x, scale_y; |
1319 co_aix shift_x, shift_y; | 1324 co_aix shift_x, shift_y; |
1335 canvas2p[3] = 0; | 1340 canvas2p[3] = 0; |
1336 canvas2p[4] = scale_y; | 1341 canvas2p[4] = scale_y; |
1337 canvas2p[5] = shift_y; | 1342 canvas2p[5] = shift_y; |
1338 | 1343 |
1339 matrix_mul(paggr, canvas2p, canvas2pdev_matrix); | 1344 matrix_mul(paggr, canvas2p, canvas2pdev_matrix); |
1345 | |
1346 compute_reverse(canvas2pdev_matrix, coord_get_2pdev_rev(coord)); | |
1340 } | 1347 } |
1341 | 1348 |
1342 /*! \brief Compute area in parent cached coord for a cached coord. | 1349 /*! \brief Compute area in parent cached coord for a cached coord. |
1343 * | 1350 * |
1344 * The coordination system of cached coord and descendants is resized, | 1351 * The coordination system of cached coord and descendants is resized, |
1349 * ancestral cached coord can be retreived by shifting and resizing | 1356 * ancestral cached coord can be retreived by shifting and resizing |
1350 * canvas box in reverse and transform to coordination system of | 1357 * canvas box in reverse and transform to coordination system of |
1351 * ancestral cached coord. | 1358 * ancestral cached coord. |
1352 */ | 1359 */ |
1353 static void compute_pcache_area(coord_t *coord) { | 1360 static void compute_pcache_area(coord_t *coord) { |
1354 co_aix cached2pdev[6]; | 1361 co_aix *cached2pdev = coord_get_2pdev(coord); |
1355 int c_w, c_h; | 1362 int c_w, c_h; |
1356 canvas_t *canvas; | 1363 canvas_t *canvas; |
1357 coord_canvas_info_t *canvas_info; | 1364 coord_canvas_info_t *canvas_info; |
1358 co_aix poses[4][2]; | 1365 co_aix poses[4][2]; |
1359 | 1366 |
1360 canvas_info = coord->canvas_info; | 1367 canvas_info = coord->canvas_info; |
1361 SWAP(canvas_info->pcache_cur_area, canvas_info->pcache_last_area, | 1368 SWAP(canvas_info->pcache_cur_area, canvas_info->pcache_last_area, |
1362 area_t *); | 1369 area_t *); |
1363 compute_cached_2_pdev_matrix(coord, cached2pdev); | |
1364 | 1370 |
1365 canvas = _coord_get_canvas(coord); | 1371 canvas = _coord_get_canvas(coord); |
1366 canvas_get_size(canvas, &c_w, &c_h); | 1372 canvas_get_size(canvas, &c_w, &c_h); |
1367 | 1373 |
1368 poses[0][0] = 0; | 1374 poses[0][0] = 0; |
1764 */ | 1770 */ |
1765 for(i = all_zeroing->num - 1; i >= 0; i--) { | 1771 for(i = all_zeroing->num - 1; i >= 0; i--) { |
1766 coord = all_zeroing->ds[i]; | 1772 coord = all_zeroing->ds[i]; |
1767 if(coord_is_zeroing(coord)) | 1773 if(coord_is_zeroing(coord)) |
1768 zeroing_coord(rdman, coord); | 1774 zeroing_coord(rdman, coord); |
1775 compute_cached_2_pdev_matrix(coord); | |
1769 /* This is required by ancester cached ones to perform | 1776 /* This is required by ancester cached ones to perform |
1770 * zeroing. | 1777 * zeroing. |
1771 */ | 1778 */ |
1772 compute_pcache_area(coord); | 1779 compute_pcache_area(coord); |
1780 } | |
1781 | |
1782 return OK; | |
1783 } | |
1784 | |
1785 /*! \brief Update aggregated cache_2_pdev matrix for cached coords. | |
1786 * | |
1787 * This is perfromed from root to leaves. Aggregated cache_2_pdev is | |
1788 * named as aggr_2_pdev field of canvas_info_t. It is the matrix to | |
1789 * transform a point from space of a cached coord to the space of root | |
1790 * coord. | |
1791 */ | |
1792 static int | |
1793 update_aggr_pdev(redraw_man_t *rdman) { | |
1794 int i; | |
1795 coords_t *all_zeroing; | |
1796 coord_t *coord, *parent_cached; | |
1797 | |
1798 all_zeroing = &rdman->zeroing_coords; | |
1799 for(i = 0; i < all_zeroing->num; i++) { | |
1800 coord = all_zeroing->ds[i]; | |
1801 parent_cached = coord_get_cached(coord_get_parent(coord)); | |
1802 matrix_mul(coord_get_2pdev(parent_cached), | |
1803 coord_get_2pdev(coord), | |
1804 coord_get_aggr2pdev(coord)); | |
1805 matrix_mul(coord_get_2pdev_rev(coord), | |
1806 coord_get_2pdev_rev(parent_cached), | |
1807 coord_get_aggr2pdev_rev(coord)); | |
1773 } | 1808 } |
1774 | 1809 |
1775 return OK; | 1810 return OK; |
1776 } | 1811 } |
1777 | 1812 |
1784 static void add_aggr_dirty_areas_to_ancestor(redraw_man_t *rdman, | 1819 static void add_aggr_dirty_areas_to_ancestor(redraw_man_t *rdman, |
1785 coord_t *coord) { | 1820 coord_t *coord) { |
1786 int i; | 1821 int i; |
1787 int n_areas; | 1822 int n_areas; |
1788 co_aix poses0[2][2], poses1[2][2]; | 1823 co_aix poses0[2][2], poses1[2][2]; |
1789 co_aix canvas2pdev_matrix[6]; | 1824 co_aix *canvas2pdev_matrix; |
1790 area_t **areas, *area; | 1825 area_t **areas, *area; |
1791 area_t *area0, *area1; | 1826 area_t *area0, *area1; |
1792 coord_t *parent, *pcached_coord; | 1827 coord_t *parent, *pcached_coord; |
1793 | 1828 |
1794 n_areas = _coord_get_dirty_areas(coord)->num; | 1829 n_areas = _coord_get_dirty_areas(coord)->num; |
1861 } | 1896 } |
1862 | 1897 |
1863 parent = coord_get_parent(coord); | 1898 parent = coord_get_parent(coord); |
1864 pcached_coord = coord_get_cached(parent); | 1899 pcached_coord = coord_get_cached(parent); |
1865 | 1900 |
1866 compute_cached_2_pdev_matrix(coord, canvas2pdev_matrix); | 1901 canvas2pdev_matrix = coord_get_2pdev(coord); |
1867 | 1902 |
1868 /* Add dirty areas to parent cached coord. */ | 1903 /* Add dirty areas to parent cached coord. */ |
1869 matrix_trans_pos(canvas2pdev_matrix, poses0[0], poses0[0] + 1); | 1904 matrix_trans_pos(canvas2pdev_matrix, poses0[0], poses0[0] + 1); |
1870 matrix_trans_pos(canvas2pdev_matrix, poses0[1], poses0[1] + 1); | 1905 matrix_trans_pos(canvas2pdev_matrix, poses0[1], poses0[1] + 1); |
1871 area_init(area0, 2, poses0); | 1906 area_init(area0, 2, poses0); |
2027 r = zeroing_rdman_coords(rdman); | 2062 r = zeroing_rdman_coords(rdman); |
2028 if(r != OK) | 2063 if(r != OK) |
2029 return ERR; | 2064 return ERR; |
2030 | 2065 |
2031 r = add_rdman_aggr_dirty_areas(rdman); | 2066 r = add_rdman_aggr_dirty_areas(rdman); |
2067 if(r != OK) | |
2068 return ERR; | |
2069 | |
2070 r = update_aggr_pdev(rdman); | |
2032 if(r != OK) | 2071 if(r != OK) |
2033 return ERR; | 2072 return ERR; |
2034 | 2073 |
2035 /* | 2074 /* |
2036 * Clear all flags setted by zeroing. | 2075 * Clear all flags setted by zeroing. |
2127 #endif /* UNITTEST */ | 2166 #endif /* UNITTEST */ |
2128 } | 2167 } |
2129 | 2168 |
2130 fill = shape->fill; | 2169 fill = shape->fill; |
2131 if(shape->fill) { | 2170 if(shape->fill) { |
2132 fill->prepare(fill, cr); | 2171 fill->prepare(fill, cr, shape); |
2133 if(shape->stroke) | 2172 if(shape->stroke) |
2134 fill_path_preserve(rdman, cr); | 2173 fill_path_preserve(rdman, cr); |
2135 else | 2174 else |
2136 fill_path(rdman, cr); | 2175 fill_path(rdman, cr); |
2137 } | 2176 } |
2138 | 2177 |
2139 stroke = shape->stroke; | 2178 stroke = shape->stroke; |
2140 if(stroke) { | 2179 if(stroke) { |
2141 stroke->prepare(stroke, cr); | 2180 stroke->prepare(stroke, cr, shape); |
2142 set_shape_stroke_param(shape, cr); | 2181 set_shape_stroke_param(shape, cr); |
2143 stroke_path(rdman, cr); | 2182 stroke_path(rdman, cr); |
2144 } | 2183 } |
2145 } | 2184 } |
2146 } | 2185 } |
2207 } | 2246 } |
2208 | 2247 |
2209 static void update_cached_canvas_2_parent(redraw_man_t *rdman, | 2248 static void update_cached_canvas_2_parent(redraw_man_t *rdman, |
2210 coord_t *coord) { | 2249 coord_t *coord) { |
2211 mbe_t *pcanvas, *canvas; | 2250 mbe_t *pcanvas, *canvas; |
2212 co_aix reverse[6]; | 2251 co_aix *c2pdev_reverse; |
2213 co_aix canvas2pdev_matrix[6]; | |
2214 | 2252 |
2215 if(coord_is_root(coord)) | 2253 if(coord_is_root(coord)) |
2216 return; | 2254 return; |
2217 | 2255 |
2218 compute_cached_2_pdev_matrix(coord, canvas2pdev_matrix); | 2256 c2pdev_reverse = coord_get_2pdev_rev(coord); |
2219 compute_reverse(canvas2pdev_matrix, reverse); | |
2220 | 2257 |
2221 canvas = _coord_get_canvas(coord); | 2258 canvas = _coord_get_canvas(coord); |
2222 pcanvas = _coord_get_canvas(coord->parent); | 2259 pcanvas = _coord_get_canvas(coord->parent); |
2223 #ifndef UNITTEST | 2260 #ifndef UNITTEST |
2224 _update_cached_canvas_2_parent(rdman, reverse, canvas, pcanvas, | 2261 _update_cached_canvas_2_parent(rdman, c2pdev_reverse, canvas, pcanvas, |
2225 coord->opacity); | 2262 coord->opacity); |
2226 #else | 2263 #else |
2227 memcpy(((mock_mbe_t *)canvas)->parent_2_cache, reverse, | 2264 memcpy(((mock_mbe_t *)canvas)->parent_2_cache, c2pdev_reverse, |
2228 sizeof(co_aix) * 6); | 2265 sizeof(co_aix) * 6); |
2229 #endif | 2266 #endif |
2230 } | 2267 } |
2231 | 2268 |
2232 static int draw_coord_shapes_in_dirty_areas(redraw_man_t *rdman, | 2269 static int draw_coord_shapes_in_dirty_areas(redraw_man_t *rdman, |
2342 if(coord_get_flags(coord, COF_TEMP_MARK)) | 2379 if(coord_get_flags(coord, COF_TEMP_MARK)) |
2343 continue; | 2380 continue; |
2344 draw_dirty_cached_coord(rdman, coord); | 2381 draw_dirty_cached_coord(rdman, coord); |
2345 coord_set_flags(coord, COF_TEMP_MARK); | 2382 coord_set_flags(coord, COF_TEMP_MARK); |
2346 } | 2383 } |
2347 for(i = 0; i < num; i++) | 2384 for(i = 0; i < num; i++) { |
2385 coord = zeroings[i]; | |
2348 coord_clear_flags(coord, COF_TEMP_MARK); | 2386 coord_clear_flags(coord, COF_TEMP_MARK); |
2387 } | |
2349 | 2388 |
2350 draw_dirty_cached_coord(rdman, rdman->root_coord); | 2389 draw_dirty_cached_coord(rdman, rdman->root_coord); |
2351 } | 2390 } |
2352 | 2391 |
2353 | 2392 |