changeset 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
files src/redraw_man.c
diffstat 1 files changed, 40 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/src/redraw_man.c	Sat May 22 22:31:18 2010 +0800
+++ b/src/redraw_man.c	Mon May 24 11:59:27 2010 +0800
@@ -1658,7 +1658,9 @@
 
 /*! \brief Zeroing coords in redraw_man_t::zeroing_coords.
  *
- * \note redraw_man_t::zeroing_coords must in ascent partial order of tree.
+ * \note redraw_man_t::zeroing_coords must in descent partial order of
+ *	 tree.  The size of a cached coord is effected by cached
+ *	 descendants.
  */
 static int zeroing_rdman_coords(redraw_man_t *rdman) {
     int i;
@@ -1666,8 +1668,16 @@
     coord_t *coord;
    
     all_zeroing = &rdman->zeroing_coords;
-    /* From leaft to root.
-     * REASON: The size of canvas is also effected by cached descedants.
+    /*! Zeroing is performed from leaves to root.
+     *
+     * REASON: The size of canvas is also effected by cached
+     *         descedants.  A cached coord is only effected by parent
+     *         cached coord when it-self is dirty.  When a cached
+     *         coord is dirty, it is clean (compute aggregated matrix)
+     *         by recomputing a scale for x and y-axis from aggregated
+     *         matrix of parent coord.  And, cleaning coord is
+     *         performed before zeroing.  It means ancestors of a
+     *         cached coord would not effect it when zeroing.
      */
     for(i = all_zeroing->num - 1; i >= 0; i--) {
 	coord = all_zeroing->ds[i];
@@ -1679,6 +1689,13 @@
 }
 
 /*! \brief Compute pcache_area for coords whoes pcache_area is dirty.
+ *
+ * coord_t::dirty_pcache_area_coords also includes part of coords in
+ * coord_t::zeroing_coords.  The pcache_area of coords that is in
+ * coord_t::dirty_pcache_area_coords, but is not in
+ * coord_t::zeroing_coords should be computed here.
+ * zeroing_rdman_coords() is responsible for computing pcache_area for
+ * zeroing ones.
  */
 static int
 compute_rdman_coords_pcache_area(redraw_man_t *rdman) {
@@ -1874,7 +1891,7 @@
 
     /* Remove temporary mark */
     for(i = 0; i < n_zeroing; i++) {
-	coord_clear_flags(zeroing[i], COF_TEMP_MARK);
+	coord_clear_flags(zeroings[i], COF_TEMP_MARK);
     }
     for(i = 0; i < n_dpca_coords; i++) {
 	coord_clear_flags(dpca_coords[i], COF_TEMP_MARK);
@@ -1883,30 +1900,6 @@
     return OK;
 }
 
-/* Aggregate dirty areas for root coord.
- *
- * Because, root coord has no parent coord, so its aggregation dirty
- * areas are not added into dirty_areas of ancestral cached coord.
- * So, it is aggregated in a separated function.
- */
-static int add_rdman_cached_dirty_areas(redraw_man_t *rdman) {
-    int i;
-    coord_t *coord, **dirty_coords;
-    int n_dirty_coords;
-
-    n_dirty_coords = rdman->dirty_coords.num;
-    dirty_coords = rdman->dirty_coords.ds;
-    for(i = 0; i < n_dirty_coords; i++) {
-	coord = dirty_coords[i];
-	if(coord_is_cached(coord) && !coord_is_root(coord)) {
-	    add_dirty_area(rdman, coord->parent, coord->cur_area);
-	    add_dirty_area(rdman, coord->parent, coord->last_area);
-	}
-    }
-
-    return OK;
-}
-
 /* \brief Clean dirty coords and shapes.
  *
  * The procedure of clean dirty coords and shapes include 3 major steps.
@@ -1995,13 +1988,20 @@
     if(r != OK)
 	return ERR;
 
-    r = add_rdman_cached_dirty_areas(rdman);
-    if(r != OK)
-	return ERR;
-
+    /*
+     * Clear all flags setted by this function
+     */
     coords = rdman->dirty_coords.ds;
     for(i = 0; i < rdman->dirty_coords.num; i++)
 	coord_clear_flags(coords[i], COF_JUST_CLEAN);
+    coords = rdman->zeroing_coords.ds;
+    for(i = 0; i < rdman->zeroing_coords.num; i++)
+	coord_clear_flags(coords[i],
+			  COF_JUST_CLEAN | COF_JUST_ZERO | COF_SKIP_ZERO);
+    coords = rdman->dirty_pcache_area_coords.ds;
+    for(i = 0; i < rdman->dirty_pcache_area_coords.num; i++)
+	coord_clear_flags(coords[i],
+			  COF_JUST_CLEAN | COF_JUST_ZERO | COF_SKIP_ZERO);
     
     return OK;
 }
@@ -2244,11 +2244,15 @@
 }
 
 static void draw_shapes_in_dirty_areas(redraw_man_t *rdman) {
+    int num;
+    coord_t **zeroings;
+    coord_t *coord;
     int i;
-    coord_t *coord;
 
-    for(i = rdman->zeroing_coords.num - 1; i >= 0; i--) {
-	coord = rdman->zeroing_coords.ds[i];
+    zeroings = rdman->zeroing_coords.ds;
+    num = rdman->zeroing_coords.num;
+    for(i = num - 1; i >= 0; i--) {
+	coord = zeroings[i];
 	draw_dirty_cached_coord(rdman, coord);
     }
 
@@ -2328,6 +2332,7 @@
     DARRAY_CLEAN(&rdman->dirty_coords);
     DARRAY_CLEAN(&rdman->dirty_geos);
     DARRAY_CLEAN(&rdman->zeroing_coords);
+    DARRAY_CLEAN(&rdman->dirty_pcache_area_coords);
     
     /* Free postponsed removing */
     free_free_objs(rdman);