changeset 826:94041f085797

Merge from main stream
author Thinker K.F. Li <thinker@codemud.net>
date Tue, 14 Sep 2010 05:55:30 +0800
parents e83956ba22d7 (diff) 586e50f82c1f (current diff)
children 7eb5421a9864
files src/redraw_man.c
diffstat 1 files changed, 48 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/redraw_man.c	Tue Sep 14 01:08:39 2010 +0800
+++ b/src/redraw_man.c	Tue Sep 14 05:55:30 2010 +0800
@@ -530,13 +530,15 @@
 
     return cr;
 #else
-    return NULL;
+    return (mbe_t *)malloc(16);
 #endif
 }
 
 static void canvas_free(mbe_t *canvas) {
 #ifndef UNITTEST
     mbe_destroy(canvas);
+#else
+    free(canvas);
 #endif
 }
 
@@ -2191,6 +2193,7 @@
 
 static void update_cached_canvas_2_parent(redraw_man_t *rdman,
 					  coord_t *coord) {
+#ifndef UNITTEST
     mbe_t *pcanvas, *canvas;
     mbe_surface_t *surface;
     mbe_pattern_t *pattern;
@@ -2210,6 +2213,7 @@
     mbe_pattern_set_matrix(pattern, reverse);
     mbe_set_source(pcanvas, pattern);
     mbe_paint_with_alpha(pcanvas, coord->opacity);
+#endif
 }
 
 static int draw_coord_shapes_in_dirty_areas(redraw_man_t *rdman,
@@ -2613,6 +2617,7 @@
     co_aix w, h;
     int trans_cnt;
     int draw_cnt;
+    redraw_man_t *last_draw;
 };
 
 void sh_dummy_free(shape_t *sh) {
@@ -2671,6 +2676,7 @@
 
     dummy = (sh_dummy_t *)shape;
     dummy->draw_cnt++;
+    dummy->last_draw = cr;
 }
 
 static void dummy_paint_prepare(paint_t *paint, mbe_t *cr) {
@@ -2814,6 +2820,8 @@
     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);
+
+    redraw_man_destroy(rdman);
 }
 
 static void
@@ -2848,11 +2856,44 @@
     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);
+    
+    redraw_man_destroy(rdman);
+}
+
+static void
+test_own_canvas_redraw(void) {
+    redraw_man_t *rdman;
+    redraw_man_t _rdman;
+    coord_t *coord1, *coord2;
+    sh_dummy_t *sh;
+    paint_t *paint;
+
+    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);
+
+    paint = dummy_paint_new(rdman);
+    rdman_paint_fill(rdman, paint, (shape_t *)sh);
+    
+    rdman_redraw_all(rdman);
+
+    CU_ASSERT(sh->draw_cnt == 1);
+    CU_ASSERT(sh->last_draw == _coord_get_canvas(coord2));
+
+    rdman_paint_free(rdman, paint);
+    redraw_man_destroy(rdman);
 }
 
 CU_pSuite get_redraw_man_suite(void) {
@@ -2864,6 +2905,7 @@
     CU_ADD_TEST(suite, test_setup_canvas_info);
     CU_ADD_TEST(suite, test_own_canvas_area);
     CU_ADD_TEST(suite, test_own_canvas);
+    CU_ADD_TEST(suite, test_own_canvas_redraw);
 
     return suite;
 }