Mercurial > MadButterfly
diff src/redraw_man.c @ 19:cf6d65398619
More animation demo
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Sat, 02 Aug 2008 15:38:54 +0800 |
parents | 0f3baa488a62 |
children | 74d3d5dc9aaa |
line wrap: on
line diff
--- a/src/redraw_man.c Sat Aug 02 14:45:42 2008 +0800 +++ b/src/redraw_man.c Sat Aug 02 15:38:54 2008 +0800 @@ -464,17 +464,18 @@ paint_t *fill; fill = shape->fill; - if(fill) + if(fill) { fill->prepare(fill, rdman->cr); - switch(shape->sh_type) { - case SHT_PATH: - sh_path_draw(shape, rdman->cr); - break; + switch(shape->sh_type) { + case SHT_PATH: + sh_path_draw(shape, rdman->cr); + break; #ifdef UNITTEST - default: - sh_dummy_draw(shape, rdman->cr); - break; + default: + sh_dummy_draw(shape, rdman->cr); + break; #endif /* UNITTEST */ + } } } @@ -719,6 +720,7 @@ #ifdef UNITTEST #include <CUnit/Basic.h> +#include "paint.h" struct _sh_dummy { shape_t shape; @@ -779,6 +781,26 @@ dummy->draw_cnt++; } +static void dummy_paint_prepare(paint_t *paint, cairo_t *cr) { +} + +static void dummy_paint_free(paint_t *paint) { + if(paint) + free(paint); +} + +paint_t *dummy_paint_new(redraw_man_t *rdman) { + paint_t *paint; + + paint = (paint_t *)malloc(sizeof(paint_t)); + if(paint == NULL) + return NULL; + + paint_init(paint, dummy_paint_prepare, dummy_paint_free); + + return paint; +} + void test_rdman_find_overlaid_shapes(void) { redraw_man_t rdman; geo_t geo; @@ -834,6 +856,7 @@ coord_t *coords[3]; shape_t *shapes[3]; sh_dummy_t **dummys; + paint_t *paint; redraw_man_t *rdman; redraw_man_t _rdman; int i; @@ -842,8 +865,10 @@ rdman = &_rdman; redraw_man_init(rdman, NULL); + paint = dummy_paint_new(rdman); for(i = 0; i < 3; i++) { shapes[i] = sh_dummy_new(0, 0, 50, 50); + rdman_paint_fill(rdman, paint, shapes[i]); coords[i] = rdman_coord_new(rdman, rdman->root_coord); coords[i]->matrix[2] = 10 + i * 100; coords[i]->matrix[5] = 10 + i * 100; @@ -863,6 +888,9 @@ CU_ASSERT(dummys[0]->draw_cnt == 1); CU_ASSERT(dummys[1]->draw_cnt == 2); CU_ASSERT(dummys[2]->draw_cnt == 2); + + paint->free(paint); + redraw_man_destroy(rdman); } CU_pSuite get_redraw_man_suite(void) {