Mercurial > MadButterfly
comparison src/redraw_man.c @ 37:943acee7f346
update exposed area
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Wed, 06 Aug 2008 10:14:45 +0800 |
parents | 581a03196093 |
children | 8d219ebd729e |
comparison
equal
deleted
inserted
replaced
36:51a20f240ce3 | 37:943acee7f346 |
---|---|
76 static int add_dirty_area(redraw_man_t *rdman, area_t *area) { | 76 static int add_dirty_area(redraw_man_t *rdman, area_t *area) { |
77 int max_dirty_areas; | 77 int max_dirty_areas; |
78 int r; | 78 int r; |
79 | 79 |
80 if(rdman->n_dirty_areas >= rdman->max_dirty_areas) { | 80 if(rdman->n_dirty_areas >= rdman->max_dirty_areas) { |
81 /* every geo object and coord object can contribute 2 areas. */ | 81 /* every geo object and coord object can contribute 2 areas. |
82 max_dirty_areas = (rdman->n_geos + rdman->n_coords) * 2; | 82 * rdman_draw_area() may also contribute 1 area. |
83 */ | |
84 max_dirty_areas = (rdman->n_geos + rdman->n_coords) * 2 + 1; | |
83 r = extend_memblk((void **)&rdman->dirty_areas, | 85 r = extend_memblk((void **)&rdman->dirty_areas, |
84 sizeof(area_t *) * rdman->n_dirty_areas, | 86 sizeof(area_t *) * rdman->n_dirty_areas, |
85 sizeof(area_t *) * max_dirty_areas); | 87 sizeof(area_t *) * max_dirty_areas); |
86 if(r != OK) | 88 if(r != OK) |
87 return ERR; | 89 return ERR; |
614 } | 616 } |
615 cairo_clip(cr); | 617 cairo_clip(cr); |
616 } | 618 } |
617 | 619 |
618 static void reset_clip(redraw_man_t *rdman) { | 620 static void reset_clip(redraw_man_t *rdman) { |
619 cairo_reset_clip(rdman->cr); | |
620 cairo_reset_clip(rdman->backend); | 621 cairo_reset_clip(rdman->backend); |
621 } | 622 } |
622 | 623 |
623 static void copy_cr_2_backend(redraw_man_t *rdman, int n_dirty_areas, | 624 static void copy_cr_2_backend(redraw_man_t *rdman, int n_dirty_areas, |
624 area_t **dirty_areas) { | 625 area_t **dirty_areas) { |
721 | 722 |
722 r = clean_rdman_dirties(rdman); | 723 r = clean_rdman_dirties(rdman); |
723 if(r != OK) | 724 if(r != OK) |
724 return ERR; | 725 return ERR; |
725 | 726 |
727 clean_canvas(rdman->cr); | |
728 | |
726 for(geo = STAILQ_HEAD(rdman->all_geos); | 729 for(geo = STAILQ_HEAD(rdman->all_geos); |
727 geo != NULL; | 730 geo != NULL; |
728 geo = STAILQ_NEXT(geo_t, next, geo)) { | 731 geo = STAILQ_NEXT(geo_t, next, geo)) { |
729 draw_shape(rdman, geo->shape); | 732 draw_shape(rdman, geo->shape); |
730 } | 733 } |
731 copy_cr_2_backend(rdman, 0, NULL); | 734 copy_cr_2_backend(rdman, 0, NULL); |
732 rdman->n_dirty_areas = 0; | 735 rdman->n_dirty_areas = 0; |
733 | 736 |
734 return OK; | 737 return OK; |
738 } | |
739 | |
740 int rdman_redraw_area(redraw_man_t *rdman, co_aix x, co_aix y, | |
741 co_aix w, co_aix h) { | |
742 area_t area; | |
743 int r; | |
744 | |
745 area.x = x; | |
746 area.y = y; | |
747 area.w = w; | |
748 area.h = h; | |
749 add_dirty_area(rdman, &area); | |
750 | |
751 r = rdman_redraw_changed(rdman); | |
752 | |
753 return r; | |
735 } | 754 } |
736 | 755 |
737 int rdman_force_clean(redraw_man_t *rdman) { | 756 int rdman_force_clean(redraw_man_t *rdman) { |
738 int r; | 757 int r; |
739 | 758 |