changeset 821:bfdc82bbd6e4

Merge from the head
author wycc
date Tue, 14 Sep 2010 00:25:44 +0800
parents 7875e8026e86 (current diff) 856c919659cc (diff)
children 586e50f82c1f
files
diffstat 2 files changed, 113 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/include/mb_types.h	Fri Sep 10 08:33:07 2010 +0800
+++ b/include/mb_types.h	Tue Sep 14 00:25:44 2010 +0800
@@ -260,6 +260,7 @@
 #define COF_SKIP_ZERO 0x2000	/*!< \brief The coord just skip zeroing.
 				 * No real zeroing was performed.
 				 */
+#define COF_ALWAYS_CACHE 0x4000	/*!< \brief The coord always own a canvas */
 /* @} */
 
 extern void matrix_mul(co_aix *m1, co_aix *m2, co_aix *dst);
@@ -298,6 +299,7 @@
     } while(0)
 #define coord_is_root(co) ((co)->parent == NULL)
 #define coord_is_cached(co) ((co)->flags & COF_OWN_CANVAS)
+#define coord_is_always_cached(co) ((co)->flags & COF_ALWAYS_CACHE)
 #define coord_is_fast_cached(co) ((co)->flags & COF_FAST_MASK)
 #define coord_is_precise_cached(co) ((co)->flags & COF_PRECISE_MASK)
 #define coord_is_zeroing(co) ((co)->flags & COF_MUST_ZEROING)
--- a/src/redraw_man.c	Fri Sep 10 08:33:07 2010 +0800
+++ b/src/redraw_man.c	Tue Sep 14 00:25:44 2010 +0800
@@ -584,9 +584,11 @@
     coord->num_members--;
 }
 
-static coord_canvas_info_t *coord_canvas_info_new(redraw_man_t *rdman,
-						  coord_t *coord,
-						  mbe_t *canvas) {
+/*! \brief Create a new canvas and respective info struct for a coord.
+ */
+static coord_canvas_info_t *
+coord_canvas_info_new(redraw_man_t *rdman, coord_t *coord,
+		      mbe_t *canvas) {
     coord_canvas_info_t *info;
 
     info = (coord_canvas_info_t *)elmpool_elm_alloc(rdman->coord_canvas_pool);
@@ -1243,7 +1245,7 @@
     if(coord->parent == NULL)
 	return;
 
-    if(coord->opacity != 1 || coord_is_cached(coord)) {
+    if(coord->opacity != 1 || coord_is_always_cached(coord)) {
 	if(!coord_is_cached(coord)) {
 	    /* canvas is assigned latter, in zeroing_coord() */
 	    coord->canvas_info = coord_canvas_info_new(rdman, coord, NULL);
@@ -1280,7 +1282,7 @@
     paggr = coord_get_aggr_matrix(parent);
     
     scale_x = matrix[0] / aggr[0];
-    scale_y = matrix[3] / aggr[3];
+    scale_y = matrix[4] / aggr[4];
     shift_x = matrix[2] - scale_x * aggr[2];
     shift_y = matrix[5] - scale_y * aggr[5];
 
@@ -1577,7 +1579,7 @@
 	}
 	/* Shift space */
 	aggr = coord_get_aggr_matrix(cur);
-	aggr[3] -= min_x;
+	aggr[2] -= min_x;
 	aggr[5] -= min_y;
 	
 	FOR_COORD_MEMBERS(coord, geo) {
@@ -1850,11 +1852,12 @@
     n_zeroing = rdman->zeroing_coords.num;
     zeroings = rdman->zeroing_coords.ds;
     for(i = 0; i < n_zeroing; i++) {
+	coord = zeroings[i];
+	
 	if(coord_get_flags(coord, COF_TEMP_MARK))
 	    continue;
 	coord_set_flags(coord, COF_TEMP_MARK);
 	
-	coord = zeroings[i];
 	pcached_coord = coord_get_cached(coord_get_parent(coord));
 	
 	if(coord_is_root(coord) || IS_CACHE_REDRAW_ALL(pcached_coord))
@@ -1876,11 +1879,12 @@
     n_dpca_coords = rdman->dirty_pcache_area_coords.num;
     dpca_coords = rdman->dirty_pcache_area_coords.ds;
     for(i = 0; i < n_dpca_coords; i++) {
+	coord = dpca_coords[i];
+	
 	if(coord_get_flags(coord, COF_TEMP_MARK))
 	    continue;
 	coord_set_flags(coord, COF_TEMP_MARK);
 
-	coord = dpca_coords[i];
 	pcached_coord = coord_get_cached(coord_get_parent(coord));
 	
 	if(coord_is_root(coord) || IS_CACHE_REDRAW_ALL(pcached_coord))
@@ -1980,6 +1984,8 @@
 	}
     }
     
+    /* XXX: some geo may swap two times.  Should avoid it.
+     */
     geos = rdman->dirty_geos.ds;
     for(i = 0; i < rdman->dirty_geos.num; i++) {
 	geo = geos[i];
@@ -2753,12 +2759,109 @@
     CU_ASSERT(test_free_pass == 4);
 }
 
+static void
+test_setup_canvas_info(void) {
+    redraw_man_t *rdman;
+    redraw_man_t _rdman;
+    coord_t *coord;
+
+    redraw_man_init(&_rdman, NULL, NULL);
+    rdman = &_rdman;
+    
+    coord = rdman_coord_new(rdman, rdman->root_coord);
+    CU_ASSERT(coord->parent == rdman->root_coord);
+
+    coord_set_opacity(coord, 0.9);
+    setup_canvas_info(rdman, coord);
+
+    CU_ASSERT(coord->canvas_info != rdman->root_coord->canvas_info);
+
+    coord_set_opacity(coord, 1);
+    setup_canvas_info(rdman, coord);
+
+    CU_ASSERT(coord->canvas_info == rdman->root_coord->canvas_info);
+}
+
+static void
+test_own_canvas_area(void) {
+    redraw_man_t *rdman;
+    redraw_man_t _rdman;
+    coord_t *coord1, *coord2;
+    sh_dummy_t *sh;
+
+    redraw_man_init(&_rdman, NULL, NULL);
+    rdman = &_rdman;
+    
+    coord1 = rdman_coord_new(rdman, rdman->root_coord);
+    CU_ASSERT(coord1->parent == rdman->root_coord);
+
+    coord2 = rdman_coord_new(rdman, coord1);
+    CU_ASSERT(coord2->parent == coord1);
+
+    coord_set_opacity(coord2, 0.9);
+    rdman_coord_changed(rdman, coord2);
+
+    sh = (shape_t *)sh_dummy_new(rdman, 100, 100, 20, 20);
+    rdman_add_shape(rdman, (shape_t *)sh, coord2);
+    rdman_shape_changed(rdman, (shape_t *)sh);
+
+    clean_coord(rdman, coord2);
+
+    /* Parent cached coord must be updated */
+    CU_ASSERT(geo_get_area(coord2)->x == 100);
+    CU_ASSERT(geo_get_area(coord2)->y == 100);
+    CU_ASSERT(geo_get_area(coord2)->w <= 22 && geo_get_area(coord2)->w >= 19);
+    CU_ASSERT(geo_get_area(coord2)->h <= 22 && geo_get_area(coord2)->h >= 19);
+}
+
+static void
+test_own_canvas(void) {
+    redraw_man_t *rdman;
+    redraw_man_t _rdman;
+    coord_t *coord1, *coord2;
+    sh_dummy_t *sh;
+
+    redraw_man_init(&_rdman, NULL, NULL);
+    rdman = &_rdman;
+    
+    coord1 = rdman_coord_new(rdman, rdman->root_coord);
+    CU_ASSERT(coord1->parent == rdman->root_coord);
+
+    coord2 = rdman_coord_new(rdman, coord1);
+    CU_ASSERT(coord2->parent == coord1);
+
+    coord_set_opacity(coord2, 0.9);
+    rdman_coord_changed(rdman, coord2);
+
+    sh = (shape_t *)sh_dummy_new(rdman, 100, 100, 20, 20);
+    rdman_add_shape(rdman, (shape_t *)sh, coord2);
+    rdman_shape_changed(rdman, (shape_t *)sh);
+
+    rdman_clean_dirties(rdman);
+
+    /* Parent cached coord must be updated */
+    CU_ASSERT(_coord_get_dirty_areas(rdman->root_coord)->num == 1);
+
+    CU_ASSERT(geo_get_area(coord2)->x == 0);
+    CU_ASSERT(geo_get_area(coord2)->y == 0);
+    CU_ASSERT(geo_get_area(coord2)->w <= 22 && geo_get_area(coord2)->w >= 19);
+    CU_ASSERT(geo_get_area(coord2)->h <= 22 && geo_get_area(coord2)->h >= 19);
+    
+    CU_ASSERT(geo_get_area(coord1)->x == 100);
+    CU_ASSERT(geo_get_area(coord1)->y == 100);
+    CU_ASSERT(geo_get_area(coord1)->w <= 22 && geo_get_area(coord1)->w >= 19);
+    CU_ASSERT(geo_get_area(coord1)->h <= 22 && geo_get_area(coord1)->h >= 19);
+}
+
 CU_pSuite get_redraw_man_suite(void) {
     CU_pSuite suite;
 
     suite = CU_add_suite("Suite_redraw_man", NULL, NULL);
     CU_ADD_TEST(suite, test_rdman_redraw_changed);
     CU_ADD_TEST(suite, test_rdman_free_objs);
+    CU_ADD_TEST(suite, test_setup_canvas_info);
+    CU_ADD_TEST(suite, test_own_canvas_area);
+    CU_ADD_TEST(suite, test_own_canvas);
 
     return suite;
 }