comparison src/redraw_man.c @ 119:257a1d314bcd

Bug of insert sort
author Thinker K.F. Li <thinker@branda.to>
date Sun, 14 Sep 2008 21:08:25 +0800
parents 3895d2224e67
children 76ba6fd61c7d
comparison
equal deleted inserted replaced
118:c9c6810a96c1 119:257a1d314bcd
41 int i, j; 41 int i, j;
42 unsigned int val; 42 unsigned int val;
43 43
44 for(i = 1; i < num; i++) { 44 for(i = 1; i < num; i++) {
45 val = *(unsigned int *)(elms[i] + off); 45 val = *(unsigned int *)(elms[i] + off);
46 for(j = i - 1; j > 0; j--) { 46 for(j = i; j > 0; j--) {
47 if(*(unsigned int *)(elms[j - 1] + off) <= val) 47 if(*(unsigned int *)(elms[j - 1] + off) <= val)
48 break; 48 break;
49 elms[j] = elms[j - 1]; 49 elms[j] = elms[j - 1];
50 } 50 }
51 elms[j] = elms[i]; 51 elms[j] = elms[i];
982 982
983 struct _sh_dummy { 983 struct _sh_dummy {
984 shape_t shape; 984 shape_t shape;
985 co_aix x, y; 985 co_aix x, y;
986 co_aix w, h; 986 co_aix w, h;
987 int trans_cnt;
987 int draw_cnt; 988 int draw_cnt;
988 }; 989 };
989 990
990 shape_t *sh_dummy_new(co_aix x, co_aix y, co_aix w, co_aix h) { 991 shape_t *sh_dummy_new(co_aix x, co_aix y, co_aix w, co_aix h) {
991 sh_dummy_t *dummy; 992 sh_dummy_t *dummy;
998 999
999 dummy->x = x; 1000 dummy->x = x;
1000 dummy->y = y; 1001 dummy->y = y;
1001 dummy->w = w; 1002 dummy->w = w;
1002 dummy->h = h; 1003 dummy->h = h;
1004 dummy->trans_cnt = 0;
1003 dummy->draw_cnt = 0; 1005 dummy->draw_cnt = 0;
1004 1006
1005 return (shape_t *)dummy; 1007 return (shape_t *)dummy;
1006 } 1008 }
1007 1009
1028 poses[1][1] = y2; 1030 poses[1][1] = y2;
1029 1031
1030 if(shape->geo) 1032 if(shape->geo)
1031 geo_from_positions(shape->geo, 2, poses); 1033 geo_from_positions(shape->geo, 2, poses);
1032 } 1034 }
1035 dummy->trans_cnt++;
1033 } 1036 }
1034 1037
1035 void sh_dummy_fill(shape_t *shape, cairo_t *cr) { 1038 void sh_dummy_fill(shape_t *shape, cairo_t *cr) {
1036 sh_dummy_t *dummy; 1039 sh_dummy_t *dummy;
1037 1040
1132 coords[i]->matrix[5] = 10 + i * 100; 1135 coords[i]->matrix[5] = 10 + i * 100;
1133 rdman_coord_changed(rdman, coords[i]); 1136 rdman_coord_changed(rdman, coords[i]);
1134 rdman_add_shape(rdman, shapes[i], coords[i]); 1137 rdman_add_shape(rdman, shapes[i], coords[i]);
1135 } 1138 }
1136 rdman_redraw_all(rdman); 1139 rdman_redraw_all(rdman);
1140 CU_ASSERT(dummys[0]->trans_cnt == 1);
1141 CU_ASSERT(dummys[1]->trans_cnt == 1);
1142 CU_ASSERT(dummys[2]->trans_cnt == 1);
1137 CU_ASSERT(dummys[0]->draw_cnt == 1); 1143 CU_ASSERT(dummys[0]->draw_cnt == 1);
1138 CU_ASSERT(dummys[1]->draw_cnt == 1); 1144 CU_ASSERT(dummys[1]->draw_cnt == 1);
1139 CU_ASSERT(dummys[2]->draw_cnt == 1); 1145 CU_ASSERT(dummys[2]->draw_cnt == 1);
1140 1146
1141 coords[2]->matrix[2] = 100; 1147 coords[2]->matrix[2] = 100;
1142 coords[2]->matrix[5] = 100; 1148 coords[2]->matrix[5] = 100;
1149 rdman_coord_changed(rdman, coords[0]);
1143 rdman_coord_changed(rdman, coords[2]); 1150 rdman_coord_changed(rdman, coords[2]);
1144 rdman_redraw_changed(rdman); 1151 rdman_redraw_changed(rdman);
1145 1152
1146 CU_ASSERT(dummys[0]->draw_cnt == 1); 1153 CU_ASSERT(dummys[0]->draw_cnt == 2);
1147 CU_ASSERT(dummys[1]->draw_cnt == 2); 1154 CU_ASSERT(dummys[1]->draw_cnt == 2);
1148 CU_ASSERT(dummys[2]->draw_cnt == 2); 1155 CU_ASSERT(dummys[2]->draw_cnt == 2);
1149 1156
1150 paint->free(paint); 1157 paint->free(paint);
1151 redraw_man_destroy(rdman); 1158 redraw_man_destroy(rdman);