Mercurial > MadButterfly
comparison src/redraw_man.c @ 816:0e56a1ca19b2
Testcases for caching coords
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Mon, 13 Sep 2010 13:25:34 +0800 |
parents | 4badbfa8f386 |
children | 387d1c597632 |
comparison
equal
deleted
inserted
replaced
815:4badbfa8f386 | 816:0e56a1ca19b2 |
---|---|
582 | 582 |
583 RM_MEMBER(coord, geo); | 583 RM_MEMBER(coord, geo); |
584 coord->num_members--; | 584 coord->num_members--; |
585 } | 585 } |
586 | 586 |
587 static coord_canvas_info_t *coord_canvas_info_new(redraw_man_t *rdman, | 587 /*! \brief Create a new canvas and respective info struct for a coord. |
588 coord_t *coord, | 588 */ |
589 mbe_t *canvas) { | 589 static coord_canvas_info_t * |
590 coord_canvas_info_new(redraw_man_t *rdman, coord_t *coord, | |
591 mbe_t *canvas) { | |
590 coord_canvas_info_t *info; | 592 coord_canvas_info_t *info; |
591 | 593 |
592 info = (coord_canvas_info_t *)elmpool_elm_alloc(rdman->coord_canvas_pool); | 594 info = (coord_canvas_info_t *)elmpool_elm_alloc(rdman->coord_canvas_pool); |
593 if(info == NULL) | 595 if(info == NULL) |
594 return info; | 596 return info; |
1241 */ | 1243 */ |
1242 static void setup_canvas_info(redraw_man_t *rdman, coord_t *coord) { | 1244 static void setup_canvas_info(redraw_man_t *rdman, coord_t *coord) { |
1243 if(coord->parent == NULL) | 1245 if(coord->parent == NULL) |
1244 return; | 1246 return; |
1245 | 1247 |
1246 if(coord->opacity != 1 || coord_is_cached(coord)) { | 1248 if(coord->opacity != 1 || coord_is_always_cached(coord)) { |
1247 if(!coord_is_cached(coord)) { | 1249 if(!coord_is_cached(coord)) { |
1248 /* canvas is assigned latter, in zeroing_coord() */ | 1250 /* canvas is assigned latter, in zeroing_coord() */ |
1249 coord->canvas_info = coord_canvas_info_new(rdman, coord, NULL); | 1251 coord->canvas_info = coord_canvas_info_new(rdman, coord, NULL); |
1250 coord_set_flags(coord, COF_OWN_CANVAS); | 1252 coord_set_flags(coord, COF_OWN_CANVAS); |
1251 } | 1253 } |
1979 FOR_COORD_MEMBERS(coord, geo) { | 1981 FOR_COORD_MEMBERS(coord, geo) { |
1980 GEO_SWAP(geo); | 1982 GEO_SWAP(geo); |
1981 } | 1983 } |
1982 } | 1984 } |
1983 | 1985 |
1986 /* XXX: some geo may swap two times. Should avoid it. | |
1987 */ | |
1984 geos = rdman->dirty_geos.ds; | 1988 geos = rdman->dirty_geos.ds; |
1985 for(i = 0; i < rdman->dirty_geos.num; i++) { | 1989 for(i = 0; i < rdman->dirty_geos.num; i++) { |
1986 geo = geos[i]; | 1990 geo = geos[i]; |
1987 GEO_SWAP(geo); | 1991 GEO_SWAP(geo); |
1988 } | 1992 } |
2752 | 2756 |
2753 redraw_man_destroy(rdman); | 2757 redraw_man_destroy(rdman); |
2754 CU_ASSERT(test_free_pass == 4); | 2758 CU_ASSERT(test_free_pass == 4); |
2755 } | 2759 } |
2756 | 2760 |
2761 static void | |
2762 test_setup_canvas_info(void) { | |
2763 redraw_man_t *rdman; | |
2764 redraw_man_t _rdman; | |
2765 coord_t *coord; | |
2766 | |
2767 redraw_man_init(&_rdman, NULL, NULL); | |
2768 rdman = &_rdman; | |
2769 | |
2770 coord = rdman_coord_new(rdman, rdman->root_coord); | |
2771 CU_ASSERT(coord->parent == rdman->root_coord); | |
2772 | |
2773 coord_set_opacity(coord, 0.9); | |
2774 setup_canvas_info(rdman, coord); | |
2775 | |
2776 CU_ASSERT(coord->canvas_info != rdman->root_coord->canvas_info); | |
2777 | |
2778 coord_set_opacity(coord, 1); | |
2779 setup_canvas_info(rdman, coord); | |
2780 | |
2781 CU_ASSERT(coord->canvas_info == rdman->root_coord->canvas_info); | |
2782 } | |
2783 | |
2784 static void | |
2785 test_own_canvas(void) { | |
2786 redraw_man_t *rdman; | |
2787 redraw_man_t _rdman; | |
2788 coord_t *coord1, *coord2; | |
2789 sh_dummy_t *sh; | |
2790 | |
2791 redraw_man_init(&_rdman, NULL, NULL); | |
2792 rdman = &_rdman; | |
2793 | |
2794 coord1 = rdman_coord_new(rdman, rdman->root_coord); | |
2795 CU_ASSERT(coord1->parent == rdman->root_coord); | |
2796 | |
2797 coord2 = rdman_coord_new(rdman, coord1); | |
2798 CU_ASSERT(coord2->parent == coord1); | |
2799 | |
2800 coord_set_opacity(coord2, 0.9); | |
2801 rdman_coord_changed(rdman, coord2); | |
2802 | |
2803 sh = (shape_t *)sh_dummy_new(rdman, 100, 100, 20, 20); | |
2804 rdman_add_shape(rdman, (shape_t *)sh, coord2); | |
2805 rdman_shape_changed(rdman, (shape_t *)sh); | |
2806 | |
2807 clean_rdman_coords(rdman); | |
2808 | |
2809 /* Parent cached coord must be updated */ | |
2810 CU_ASSERT(_coord_get_dirty_areas(rdman->root_coord)->num >= 1); | |
2811 } | |
2812 | |
2757 CU_pSuite get_redraw_man_suite(void) { | 2813 CU_pSuite get_redraw_man_suite(void) { |
2758 CU_pSuite suite; | 2814 CU_pSuite suite; |
2759 | 2815 |
2760 suite = CU_add_suite("Suite_redraw_man", NULL, NULL); | 2816 suite = CU_add_suite("Suite_redraw_man", NULL, NULL); |
2761 CU_ADD_TEST(suite, test_rdman_redraw_changed); | 2817 CU_ADD_TEST(suite, test_rdman_redraw_changed); |
2762 CU_ADD_TEST(suite, test_rdman_free_objs); | 2818 CU_ADD_TEST(suite, test_rdman_free_objs); |
2819 CU_ADD_TEST(suite, test_setup_canvas_info); | |
2820 CU_ADD_TEST(suite, test_own_canvas); | |
2763 | 2821 |
2764 return suite; | 2822 return suite; |
2765 } | 2823 } |
2766 | 2824 |
2767 #endif /* UNITTEST */ | 2825 #endif /* UNITTEST */ |