comparison src/redraw_man.c @ 160:147c93163ef0

Fix bug of tank that bullet is not hidden when go out the map.
author Thinker K.F. Li <thinker@branda.to>
date Wed, 08 Oct 2008 03:57:56 +0800
parents b90abd31a281
children c7e5b8779bb5
comparison
equal deleted inserted replaced
159:b90abd31a281 160:147c93163ef0
426 426
427 if(rdman_is_dirty(rdman) && geo != NULL) { 427 if(rdman_is_dirty(rdman) && geo != NULL) {
428 if(geo->flags & GEF_FREE) 428 if(geo->flags & GEF_FREE)
429 return ERR; 429 return ERR;
430 430
431 geo->flags |= GEF_FREE | GEF_HIDDEN; 431 geo->flags |= GEF_FREE;
432 sh_hide(shape);
432 if(!(geo->flags & GEF_DIRTY)) { 433 if(!(geo->flags & GEF_DIRTY)) {
433 r = add_dirty_geo(rdman, geo); 434 r = add_dirty_geo(rdman, geo);
434 if(r != OK) 435 if(r != OK)
435 return ERR; 436 return ERR;
436 } 437 }
573 } 574 }
574 FORMEMBERS(coord, member) { 575 FORMEMBERS(coord, member) {
575 if(!(member->flags & GEF_FREE)) 576 if(!(member->flags & GEF_FREE))
576 return ERR; 577 return ERR;
577 } 578 }
578 coord->flags |= COF_FREE | COF_HIDDEN; 579 coord->flags |= COF_FREE;
580 coord_hide(coord);
579 if(!(coord->flags & COF_DIRTY)) { 581 if(!(coord->flags & COF_DIRTY)) {
580 r = add_dirty_coord(rdman, coord); 582 r = add_dirty_coord(rdman, coord);
581 if(r != OK) 583 if(r != OK)
582 return ERR; 584 return ERR;
583 } 585 }
633 } 635 }
634 636
635 /*! \brief Mark a coord is changed. 637 /*! \brief Mark a coord is changed.
636 * 638 *
637 * A changed coord_t object is marked as dirty and put 639 * A changed coord_t object is marked as dirty and put
638 * into dirty_coords list. 640 * into dirty_coords list. rdman_coord_changed() should be called
641 * for a coord after it been changed to notify redraw manager to
642 * redraw shapes grouped by it.
639 */ 643 */
640 int rdman_coord_changed(redraw_man_t *rdman, coord_t *coord) { 644 int rdman_coord_changed(redraw_man_t *rdman, coord_t *coord) {
641 coord_t *child; 645 coord_t *child;
642 646
643 if(coord->flags & COF_DIRTY) 647 if(coord->flags & COF_DIRTY)
644 return OK; 648 return OK;
645 649
646 add_dirty_coord(rdman, coord); 650 add_dirty_coord(rdman, coord);
651
652 if(coord->flags & COF_HIDDEN)
653 return OK;
647 654
648 /* Make child coords dirty. */ 655 /* Make child coords dirty. */
649 for(child = preorder_coord_subtree(coord, coord); 656 for(child = preorder_coord_subtree(coord, coord);
650 child != NULL; 657 child != NULL;
651 child = preorder_coord_subtree(coord, child)) { 658 child = preorder_coord_subtree(coord, child)) {
726 #endif /* UNITTEST */ 733 #endif /* UNITTEST */
727 } 734 }
728 shape->geo->flags &= ~GEF_DIRTY; 735 shape->geo->flags &= ~GEF_DIRTY;
729 736
730 if(is_coord_subtree_hidden(shape->coord)) 737 if(is_coord_subtree_hidden(shape->coord))
731 shape->geo->flags |= GEF_HIDDEN; 738 sh_hide(shape);
732 else 739 else
733 shape->geo->flags &= ~GEF_HIDDEN; 740 sh_show(shape);
734 } 741 }
735 742
736 /*! \brief Setup canvas for the coord. 743 /*! \brief Setup canvas for the coord.
737 * 744 *
738 * Own a canvas or inherit it from parent. 745 * Own a canvas or inherit it from parent.
1027 geo_t *member; 1034 geo_t *member;
1028 coord_t *child; 1035 coord_t *child;
1029 cairo_t *canvas; 1036 cairo_t *canvas;
1030 int mem_idx; 1037 int mem_idx;
1031 1038
1039 if(coord->flags & COF_HIDDEN)
1040 return OK;
1041
1032 canvas = coord->canvas; 1042 canvas = coord->canvas;
1033 member = FIRST_MEMBER(coord); 1043 member = FIRST_MEMBER(coord);
1034 mem_idx = 0; 1044 mem_idx = 0;
1035 child = FIRST_CHILD(coord); 1045 child = FIRST_CHILD(coord);
1036 while(child != NULL || member != NULL) { 1046 while(child != NULL || member != NULL) {
1043 if((!(member->flags & GEF_HIDDEN)) && 1053 if((!(member->flags & GEF_HIDDEN)) &&
1044 is_geo_in_areas(member, n_areas, areas)) { 1054 is_geo_in_areas(member, n_areas, areas)) {
1045 draw_shape(rdman, canvas, member->shape); 1055 draw_shape(rdman, canvas, member->shape);
1046 dirty = 1; 1056 dirty = 1;
1047 } 1057 }
1058
1048 member = NEXT_MEMBER(member); 1059 member = NEXT_MEMBER(member);
1049 mem_idx++; 1060 mem_idx++;
1050 } 1061 }
1051 } 1062 }
1052 1063
1117 */ 1128 */
1118 clean_canvas(rdman->cr); 1129 clean_canvas(rdman->cr);
1119 draw_shapes_in_areas(rdman, n_dirty_areas, dirty_areas); 1130 draw_shapes_in_areas(rdman, n_dirty_areas, dirty_areas);
1120 copy_cr_2_backend(rdman, rdman->dirty_areas.num, 1131 copy_cr_2_backend(rdman, rdman->dirty_areas.num,
1121 rdman->dirty_areas.ds); 1132 rdman->dirty_areas.ds);
1122 rdman->dirty_areas.num = 0;
1123 reset_clip(rdman); 1133 reset_clip(rdman);
1124 } 1134 }
1125 rdman->dirty_areas.num = 0; 1135 rdman->dirty_areas.num = 0;
1126 1136
1127 /* Free postponsed removing */ 1137 /* Free postponsed removing */