Mercurial > MadButterfly
comparison src/redraw_man.c @ 538:a1d49b6355c3 Android_Skia
Clear flags for clearing procedure and draw dirty cached ones
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Mon, 24 May 2010 11:59:27 +0800 |
parents | 3a7e3c1cd6e6 |
children | ce11e889ea4e |
comparison
equal
deleted
inserted
replaced
537:3a7e3c1cd6e6 | 538:a1d49b6355c3 |
---|---|
1656 return OK; | 1656 return OK; |
1657 } | 1657 } |
1658 | 1658 |
1659 /*! \brief Zeroing coords in redraw_man_t::zeroing_coords. | 1659 /*! \brief Zeroing coords in redraw_man_t::zeroing_coords. |
1660 * | 1660 * |
1661 * \note redraw_man_t::zeroing_coords must in ascent partial order of tree. | 1661 * \note redraw_man_t::zeroing_coords must in descent partial order of |
1662 * tree. The size of a cached coord is effected by cached | |
1663 * descendants. | |
1662 */ | 1664 */ |
1663 static int zeroing_rdman_coords(redraw_man_t *rdman) { | 1665 static int zeroing_rdman_coords(redraw_man_t *rdman) { |
1664 int i; | 1666 int i; |
1665 coords_t *all_zeroing; | 1667 coords_t *all_zeroing; |
1666 coord_t *coord; | 1668 coord_t *coord; |
1667 | 1669 |
1668 all_zeroing = &rdman->zeroing_coords; | 1670 all_zeroing = &rdman->zeroing_coords; |
1669 /* From leaft to root. | 1671 /*! Zeroing is performed from leaves to root. |
1670 * REASON: The size of canvas is also effected by cached descedants. | 1672 * |
1673 * REASON: The size of canvas is also effected by cached | |
1674 * descedants. A cached coord is only effected by parent | |
1675 * cached coord when it-self is dirty. When a cached | |
1676 * coord is dirty, it is clean (compute aggregated matrix) | |
1677 * by recomputing a scale for x and y-axis from aggregated | |
1678 * matrix of parent coord. And, cleaning coord is | |
1679 * performed before zeroing. It means ancestors of a | |
1680 * cached coord would not effect it when zeroing. | |
1671 */ | 1681 */ |
1672 for(i = all_zeroing->num - 1; i >= 0; i--) { | 1682 for(i = all_zeroing->num - 1; i >= 0; i--) { |
1673 coord = all_zeroing->ds[i]; | 1683 coord = all_zeroing->ds[i]; |
1674 zeroing_coord(rdman, coord); | 1684 zeroing_coord(rdman, coord); |
1675 compute_pcache_area(coord); | 1685 compute_pcache_area(coord); |
1677 | 1687 |
1678 return OK; | 1688 return OK; |
1679 } | 1689 } |
1680 | 1690 |
1681 /*! \brief Compute pcache_area for coords whoes pcache_area is dirty. | 1691 /*! \brief Compute pcache_area for coords whoes pcache_area is dirty. |
1692 * | |
1693 * coord_t::dirty_pcache_area_coords also includes part of coords in | |
1694 * coord_t::zeroing_coords. The pcache_area of coords that is in | |
1695 * coord_t::dirty_pcache_area_coords, but is not in | |
1696 * coord_t::zeroing_coords should be computed here. | |
1697 * zeroing_rdman_coords() is responsible for computing pcache_area for | |
1698 * zeroing ones. | |
1682 */ | 1699 */ |
1683 static int | 1700 static int |
1684 compute_rdman_coords_pcache_area(redraw_man_t *rdman) { | 1701 compute_rdman_coords_pcache_area(redraw_man_t *rdman) { |
1685 coords_t *all_coords; | 1702 coords_t *all_coords; |
1686 coord_t *coord; | 1703 coord_t *coord; |
1872 coord_get_pcache_last_area(coord)); | 1889 coord_get_pcache_last_area(coord)); |
1873 } | 1890 } |
1874 | 1891 |
1875 /* Remove temporary mark */ | 1892 /* Remove temporary mark */ |
1876 for(i = 0; i < n_zeroing; i++) { | 1893 for(i = 0; i < n_zeroing; i++) { |
1877 coord_clear_flags(zeroing[i], COF_TEMP_MARK); | 1894 coord_clear_flags(zeroings[i], COF_TEMP_MARK); |
1878 } | 1895 } |
1879 for(i = 0; i < n_dpca_coords; i++) { | 1896 for(i = 0; i < n_dpca_coords; i++) { |
1880 coord_clear_flags(dpca_coords[i], COF_TEMP_MARK); | 1897 coord_clear_flags(dpca_coords[i], COF_TEMP_MARK); |
1881 } | |
1882 | |
1883 return OK; | |
1884 } | |
1885 | |
1886 /* Aggregate dirty areas for root coord. | |
1887 * | |
1888 * Because, root coord has no parent coord, so its aggregation dirty | |
1889 * areas are not added into dirty_areas of ancestral cached coord. | |
1890 * So, it is aggregated in a separated function. | |
1891 */ | |
1892 static int add_rdman_cached_dirty_areas(redraw_man_t *rdman) { | |
1893 int i; | |
1894 coord_t *coord, **dirty_coords; | |
1895 int n_dirty_coords; | |
1896 | |
1897 n_dirty_coords = rdman->dirty_coords.num; | |
1898 dirty_coords = rdman->dirty_coords.ds; | |
1899 for(i = 0; i < n_dirty_coords; i++) { | |
1900 coord = dirty_coords[i]; | |
1901 if(coord_is_cached(coord) && !coord_is_root(coord)) { | |
1902 add_dirty_area(rdman, coord->parent, coord->cur_area); | |
1903 add_dirty_area(rdman, coord->parent, coord->last_area); | |
1904 } | |
1905 } | 1898 } |
1906 | 1899 |
1907 return OK; | 1900 return OK; |
1908 } | 1901 } |
1909 | 1902 |
1993 | 1986 |
1994 r = add_rdman_aggr_dirty_areas(rdman); | 1987 r = add_rdman_aggr_dirty_areas(rdman); |
1995 if(r != OK) | 1988 if(r != OK) |
1996 return ERR; | 1989 return ERR; |
1997 | 1990 |
1998 r = add_rdman_cached_dirty_areas(rdman); | 1991 /* |
1999 if(r != OK) | 1992 * Clear all flags setted by this function |
2000 return ERR; | 1993 */ |
2001 | |
2002 coords = rdman->dirty_coords.ds; | 1994 coords = rdman->dirty_coords.ds; |
2003 for(i = 0; i < rdman->dirty_coords.num; i++) | 1995 for(i = 0; i < rdman->dirty_coords.num; i++) |
2004 coord_clear_flags(coords[i], COF_JUST_CLEAN); | 1996 coord_clear_flags(coords[i], COF_JUST_CLEAN); |
1997 coords = rdman->zeroing_coords.ds; | |
1998 for(i = 0; i < rdman->zeroing_coords.num; i++) | |
1999 coord_clear_flags(coords[i], | |
2000 COF_JUST_CLEAN | COF_JUST_ZERO | COF_SKIP_ZERO); | |
2001 coords = rdman->dirty_pcache_area_coords.ds; | |
2002 for(i = 0; i < rdman->dirty_pcache_area_coords.num; i++) | |
2003 coord_clear_flags(coords[i], | |
2004 COF_JUST_CLEAN | COF_JUST_ZERO | COF_SKIP_ZERO); | |
2005 | 2005 |
2006 return OK; | 2006 return OK; |
2007 } | 2007 } |
2008 | 2008 |
2009 | 2009 |
2242 | 2242 |
2243 return OK; | 2243 return OK; |
2244 } | 2244 } |
2245 | 2245 |
2246 static void draw_shapes_in_dirty_areas(redraw_man_t *rdman) { | 2246 static void draw_shapes_in_dirty_areas(redraw_man_t *rdman) { |
2247 int num; | |
2248 coord_t **zeroings; | |
2249 coord_t *coord; | |
2247 int i; | 2250 int i; |
2248 coord_t *coord; | 2251 |
2249 | 2252 zeroings = rdman->zeroing_coords.ds; |
2250 for(i = rdman->zeroing_coords.num - 1; i >= 0; i--) { | 2253 num = rdman->zeroing_coords.num; |
2251 coord = rdman->zeroing_coords.ds[i]; | 2254 for(i = num - 1; i >= 0; i--) { |
2255 coord = zeroings[i]; | |
2252 draw_dirty_cached_coord(rdman, coord); | 2256 draw_dirty_cached_coord(rdman, coord); |
2253 } | 2257 } |
2254 | 2258 |
2255 draw_dirty_cached_coord(rdman, rdman->root_coord); | 2259 draw_dirty_cached_coord(rdman, rdman->root_coord); |
2256 } | 2260 } |
2326 } | 2330 } |
2327 | 2331 |
2328 DARRAY_CLEAN(&rdman->dirty_coords); | 2332 DARRAY_CLEAN(&rdman->dirty_coords); |
2329 DARRAY_CLEAN(&rdman->dirty_geos); | 2333 DARRAY_CLEAN(&rdman->dirty_geos); |
2330 DARRAY_CLEAN(&rdman->zeroing_coords); | 2334 DARRAY_CLEAN(&rdman->zeroing_coords); |
2335 DARRAY_CLEAN(&rdman->dirty_pcache_area_coords); | |
2331 | 2336 |
2332 /* Free postponsed removing */ | 2337 /* Free postponsed removing */ |
2333 free_free_objs(rdman); | 2338 free_free_objs(rdman); |
2334 | 2339 |
2335 redraw = rdman_get_redraw_subject(rdman); | 2340 redraw = rdman_get_redraw_subject(rdman); |