comparison src/redraw_man.c @ 270:cd6af7da32c9

Fix the problem that clean_canvas() can not clean canvas cleanly. - For some unknown reasons, cairo_paint() can not clean painted graphics cleanly. - Use cairo_rectangle() and cairo_fill() to replace cairo_paint().
author Thinker K.F. Li <thinker@branda.to>
date Sun, 25 Jan 2009 16:07:43 +0800
parents 29acbd8a0dd0
children 248a40d51473
comparison
equal deleted inserted replaced
269:c96f38ad4bb6 270:cd6af7da32c9
1026 } 1026 }
1027 } 1027 }
1028 } 1028 }
1029 1029
1030 #ifndef UNITTEST 1030 #ifndef UNITTEST
1031 static void clean_canvas(cairo_t *cr) { 1031 static void clean_canvas(cairo_t *cr, co_aix w, co_aix h) {
1032 /*! \todo clean to background color. */ 1032 /*! \todo clean to background color. */
1033 cairo_set_source_rgb(cr, 1, 1, 1); 1033 cairo_set_source_rgb(cr, 1, 1, 1);
1034 #if 1
1035 /* For some unknown reasons, cairo_paint() can not erease
1036 * painted graphic cleanly. So, cairo_fill() are used to
1037 * replace it.
1038 */
1039 cairo_rectangle(cr, 0, 0, w, h);
1040 cairo_fill(cr);
1041 #else
1034 cairo_paint(cr); 1042 cairo_paint(cr);
1035 } 1043 #endif
1036 1044 }
1037 static void clean_canvas_black(cairo_t *cr) { 1045
1046 static void clean_canvas_black(cairo_t *cr, co_aix w, co_aix h) {
1038 /*! \todo clean to background color. */ 1047 /*! \todo clean to background color. */
1039 cairo_set_source_rgba(cr, 0, 0, 0, 0); 1048 cairo_set_source_rgba(cr, 0, 0, 0, 0);
1040 cairo_paint(cr); 1049 cairo_paint(cr);
1041 } 1050 }
1042 1051
1062 make_clip(rdman->backend, n_dirty_areas, dirty_areas); 1071 make_clip(rdman->backend, n_dirty_areas, dirty_areas);
1063 1072
1064 cairo_paint(rdman->backend); 1073 cairo_paint(rdman->backend);
1065 } 1074 }
1066 #else /* UNITTEST */ 1075 #else /* UNITTEST */
1067 static void clean_canvas(cairo_t *cr) { 1076 static void clean_canvas(cairo_t *cr, co_aix w, co_aix h) {
1068 } 1077 }
1069 1078
1070 static void clean_canvas_black(cairo_t *cr) { 1079 static void clean_canvas_black(cairo_t *cr, co_aix w, co_aix h) {
1071 } 1080 }
1072 1081
1073 static void reset_clip(redraw_man_t *rdman) { 1082 static void reset_clip(redraw_man_t *rdman) {
1074 } 1083 }
1075 1084
1140 } 1149 }
1141 } 1150 }
1142 1151
1143 if(dirty && coord->flags & COF_OWN_CANVAS) { 1152 if(dirty && coord->flags & COF_OWN_CANVAS) {
1144 update_canvas_2_parent(rdman, coord); 1153 update_canvas_2_parent(rdman, coord);
1145 clean_canvas_black(coord->canvas); 1154 clean_canvas_black(coord->canvas, rdman->w, rdman->h);
1146 } 1155 }
1147 1156
1148 return dirty; 1157 return dirty;
1149 } 1158 }
1150 1159
1202 dirty_areas = rdman->dirty_areas.ds; 1211 dirty_areas = rdman->dirty_areas.ds;
1203 if(n_dirty_areas > 0) { 1212 if(n_dirty_areas > 0) {
1204 /*! \brief Draw shapes in preorder of coord tree and support opacity 1213 /*! \brief Draw shapes in preorder of coord tree and support opacity
1205 * rules. 1214 * rules.
1206 */ 1215 */
1207 clean_canvas(rdman->cr); 1216 clean_canvas(rdman->cr, rdman->w, rdman->h);
1208 draw_shapes_in_areas(rdman, n_dirty_areas, dirty_areas); 1217 draw_shapes_in_areas(rdman, n_dirty_areas, dirty_areas);
1209 copy_cr_2_backend(rdman, rdman->dirty_areas.num, 1218 copy_cr_2_backend(rdman, rdman->dirty_areas.num,
1210 rdman->dirty_areas.ds); 1219 rdman->dirty_areas.ds);
1211 reset_clip(rdman); 1220 reset_clip(rdman);
1212 } 1221 }