Mercurial > MadButterfly
comparison src/redraw_man.c @ 541:f42419c08a65 Android_Skia
Swap geo_t::cur_area and geo_t::last_area correctly.
See comment of GEO_SWAP() in redraw_man.c.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Mon, 24 May 2010 21:09:32 +0800 |
parents | 43b26ac2f69b |
children | b42d69ab8857 d2f2ed27b84d |
comparison
equal
deleted
inserted
replaced
540:43b26ac2f69b | 541:f42419c08a65 |
---|---|
1488 */ | 1488 */ |
1489 static | 1489 static |
1490 void zeroing_coord(redraw_man_t *rdman, coord_t *coord) { | 1490 void zeroing_coord(redraw_man_t *rdman, coord_t *coord) { |
1491 coord_t *cur; | 1491 coord_t *cur; |
1492 area_t *area, *saved_area; | 1492 area_t *area, *saved_area; |
1493 geo_t *geo; | |
1493 co_aix min_x, min_y; | 1494 co_aix min_x, min_y; |
1494 co_aix max_x, max_y; | 1495 co_aix max_x, max_y; |
1495 co_aix x, y; | 1496 co_aix x, y; |
1496 int w, h; | 1497 int w, h; |
1497 int c_w, c_h; | 1498 int c_w, c_h; |
1577 /* Shift space */ | 1578 /* Shift space */ |
1578 aggr = coord_get_aggr_matrix(cur); | 1579 aggr = coord_get_aggr_matrix(cur); |
1579 aggr[3] -= min_x; | 1580 aggr[3] -= min_x; |
1580 aggr[5] -= min_y; | 1581 aggr[5] -= min_y; |
1581 | 1582 |
1583 FOR_COORD_MEMBERS(coord, geo) { | |
1584 /* \see GEO_SWAP() */ | |
1585 if(!geo_get_flags(geo, GEF_SWAP)) | |
1586 SWAP(geo->cur_area, geo->last_area, area_t *); | |
1587 } | |
1582 coord_clean_members_n_compute_area(cur); | 1588 coord_clean_members_n_compute_area(cur); |
1583 } | 1589 } |
1584 | 1590 |
1585 /* | 1591 /* |
1586 * Setup canvas | 1592 * Setup canvas |
1896 coord_clear_flags(dpca_coords[i], COF_TEMP_MARK); | 1902 coord_clear_flags(dpca_coords[i], COF_TEMP_MARK); |
1897 } | 1903 } |
1898 | 1904 |
1899 return OK; | 1905 return OK; |
1900 } | 1906 } |
1907 | |
1908 /*! \brief Swap geo_t::cur_area and geo_t::last_area for a geo_t. | |
1909 * | |
1910 * It is call by rdman_clean_dirties() to swap areas for members of | |
1911 * dirty coord in redraw_man_t::dirty_coords and dirty geos in | |
1912 * redraw_man_t::dirty_geos. | |
1913 * | |
1914 * zeroing_coord() would also swap some areas for members of | |
1915 * descendants of a cached coord. But, only members that was not | |
1916 * swapped, without GEF_SWAP flag, in this round of redrawing. | |
1917 * zeroing_coord() would not mark geos with GEF_SWAP since it not not | |
1918 * referenced later. We don't mark geos in zeroing_coord() because we | |
1919 * don't want to unmark it later. To unmark it, we should re-travel | |
1920 * forest of cached coords in redraw_man_t::zeroing_coords. It is | |
1921 * expansive. | |
1922 */ | |
1923 #define GEO_SWAP(g) \ | |
1924 if(!geo_get_flags((g), GEF_SWAP)) { \ | |
1925 SWAP((g)->cur_area, (g)->last_area, area_t *); \ | |
1926 geo_set_flags((g), GEF_SWAP); \ | |
1927 } | |
1901 | 1928 |
1902 /* \brief Clean dirty coords and shapes. | 1929 /* \brief Clean dirty coords and shapes. |
1903 * | 1930 * |
1904 * The procedure of clean dirty coords and shapes include 3 major steps. | 1931 * The procedure of clean dirty coords and shapes include 3 major steps. |
1905 * | 1932 * |
1938 static int rdman_clean_dirties(redraw_man_t *rdman) { | 1965 static int rdman_clean_dirties(redraw_man_t *rdman) { |
1939 int r; | 1966 int r; |
1940 int i; | 1967 int i; |
1941 coord_t **coords, *coord; | 1968 coord_t **coords, *coord; |
1942 geo_t **geos; | 1969 geo_t **geos; |
1970 geo_t *geo; | |
1943 | 1971 |
1944 /* coord_t::cur_area of coords are temporary pointed to | 1972 /* coord_t::cur_area of coords are temporary pointed to |
1945 * coord_canvas_info_t::owner_mems_area for store area | 1973 * coord_canvas_info_t::owner_mems_area for store area |
1946 * by clean_coord(). | 1974 * by clean_coord(). |
1947 */ | 1975 */ |
1948 coords = rdman->dirty_coords.ds; | 1976 coords = rdman->dirty_coords.ds; |
1949 for(i = 0; i < rdman->dirty_coords.num; i++) { | 1977 for(i = 0; i < rdman->dirty_coords.num; i++) { |
1950 coord = coords[i]; | 1978 coord = coords[i]; |
1951 SWAP(coord->cur_area, coord->last_area, area_t *); | 1979 SWAP(coord->cur_area, coord->last_area, area_t *); |
1980 FOR_COORD_MEMBERS(coord, geo) { | |
1981 GEO_SWAP(geo); | |
1982 } | |
1952 } | 1983 } |
1953 | 1984 |
1954 geos = rdman->dirty_geos.ds; | 1985 geos = rdman->dirty_geos.ds; |
1955 for(i = 0; i < rdman->dirty_geos.num; i++) | 1986 for(i = 0; i < rdman->dirty_geos.num; i++) { |
1956 if(geos[i]->flags & GEF_DIRTY) | 1987 geo = geos[i]; |
1957 SWAP(geos[i]->cur_area, geos[i]->last_area, area_t *); | 1988 GEO_SWAP(geo); |
1958 | 1989 } |
1990 | |
1959 r = clean_rdman_coords(rdman); | 1991 r = clean_rdman_coords(rdman); |
1960 if(r != OK) | 1992 if(r != OK) |
1961 return ERR; | 1993 return ERR; |
1962 | 1994 |
1963 /* TODO: save area of cached coord and descendants in | 1995 /* TODO: save area of cached coord and descendants in |
1989 | 2021 |
1990 /* | 2022 /* |
1991 * Clear all flags setted by zeroing. | 2023 * Clear all flags setted by zeroing. |
1992 */ | 2024 */ |
1993 coords = rdman->dirty_coords.ds; | 2025 coords = rdman->dirty_coords.ds; |
1994 for(i = 0; i < rdman->dirty_coords.num; i++) | 2026 for(i = 0; i < rdman->dirty_coords.num; i++) { |
1995 coord_clear_flags(coords[i], COF_JUST_CLEAN); | 2027 coord = coords[i]; |
2028 coord_clear_flags(coord, COF_JUST_CLEAN); | |
2029 /* \see GEO_SWAP() */ | |
2030 FOR_COORD_MEMBERS(coord, geo) { | |
2031 geo_clear_flags(geo, GEF_SWAP); | |
2032 } | |
2033 } | |
1996 coords = rdman->zeroing_coords.ds; | 2034 coords = rdman->zeroing_coords.ds; |
1997 for(i = 0; i < rdman->zeroing_coords.num; i++) | 2035 for(i = 0; i < rdman->zeroing_coords.num; i++) |
1998 coord_clear_flags(coords[i], | 2036 coord_clear_flags(coords[i], |
1999 COF_JUST_CLEAN | COF_JUST_ZERO | COF_SKIP_ZERO); | 2037 COF_JUST_CLEAN | COF_JUST_ZERO | COF_SKIP_ZERO); |
2000 coords = rdman->dirty_pcache_area_coords.ds; | 2038 coords = rdman->dirty_pcache_area_coords.ds; |
2001 for(i = 0; i < rdman->dirty_pcache_area_coords.num; i++) | 2039 for(i = 0; i < rdman->dirty_pcache_area_coords.num; i++) |
2002 coord_clear_flags(coords[i], | 2040 coord_clear_flags(coords[i], |
2003 COF_JUST_CLEAN | COF_JUST_ZERO | COF_SKIP_ZERO); | 2041 COF_JUST_CLEAN | COF_JUST_ZERO | COF_SKIP_ZERO); |
2042 | |
2043 /* \see GEO_SWAP() */ | |
2044 for(i = 0; i < rdman->dirty_geos.num; i++) { | |
2045 geo = geos[i]; | |
2046 geo_clear_flags(geo, GEF_SWAP); | |
2047 } | |
2004 | 2048 |
2005 return OK; | 2049 return OK; |
2006 } | 2050 } |
2007 | 2051 |
2008 | 2052 |