diff 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
line wrap: on
line diff
--- a/src/redraw_man.c	Sun Jan 25 00:20:34 2009 +0800
+++ b/src/redraw_man.c	Sun Jan 25 16:07:43 2009 +0800
@@ -1028,13 +1028,22 @@
 }
 
 #ifndef UNITTEST
-static void clean_canvas(cairo_t *cr) {
+static void clean_canvas(cairo_t *cr, co_aix w, co_aix h) {
     /*! \todo clean to background color. */
     cairo_set_source_rgb(cr, 1, 1, 1);
+#if 1
+    /* For some unknown reasons, cairo_paint() can not erease
+     * painted graphic cleanly.  So, cairo_fill() are used to
+     * replace it.
+     */
+    cairo_rectangle(cr, 0, 0, w, h);
+    cairo_fill(cr);
+#else
     cairo_paint(cr);
+#endif
 }
 
-static void clean_canvas_black(cairo_t *cr) {
+static void clean_canvas_black(cairo_t *cr, co_aix w, co_aix h) {
     /*! \todo clean to background color. */
     cairo_set_source_rgba(cr, 0, 0, 0, 0);
     cairo_paint(cr);
@@ -1064,10 +1073,10 @@
     cairo_paint(rdman->backend);
 }
 #else /* UNITTEST */
-static void clean_canvas(cairo_t *cr) {
+static void clean_canvas(cairo_t *cr, co_aix w, co_aix h) {
 }
 
-static void clean_canvas_black(cairo_t *cr) {
+static void clean_canvas_black(cairo_t *cr, co_aix w, co_aix h) {
 }
 
 static void reset_clip(redraw_man_t *rdman) {
@@ -1142,7 +1151,7 @@
 
     if(dirty && coord->flags & COF_OWN_CANVAS) {
 	update_canvas_2_parent(rdman, coord);
-	clean_canvas_black(coord->canvas);
+	clean_canvas_black(coord->canvas, rdman->w, rdman->h);
     }
 
     return dirty;
@@ -1204,7 +1213,7 @@
 	/*! \brief Draw shapes in preorder of coord tree and support opacity
 	 * rules.
 	 */
-	clean_canvas(rdman->cr);
+	clean_canvas(rdman->cr, rdman->w, rdman->h);
 	draw_shapes_in_areas(rdman, n_dirty_areas, dirty_areas);
 	copy_cr_2_backend(rdman, rdman->dirty_areas.num,
 			  rdman->dirty_areas.ds);