changeset 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 c96f38ad4bb6
children c990a9a9648f
files include/mb_redraw_man.h src/X_supp.c src/redraw_man.c src/shape_path.c src/shape_rect.c
diffstat 5 files changed, 28 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/include/mb_redraw_man.h	Sun Jan 25 00:20:34 2009 +0800
+++ b/include/mb_redraw_man.h	Sun Jan 25 16:07:43 2009 +0800
@@ -83,6 +83,9 @@
     mb_img_ldr_t *img_ldr;	/*!< \brief Image Loader.
 				 *	This is initialized by backend.
 				 */
+    co_aix w, h;		/*!< \brief Size of viewport
+				 *	This is initialized by backend.
+				 */
 };
 
 extern int redraw_man_init(redraw_man_t *rdman, cairo_t *cr,
--- a/src/X_supp.c	Sun Jan 25 00:20:34 2009 +0800
+++ b/src/X_supp.c	Sun Jan 25 16:07:43 2009 +0800
@@ -449,6 +449,8 @@
     //        to get the xmb_rt->tman for the animation. We should relocate the tman
     //	      to the redraw_man_t instead.
     xmb_rt->rdman->rt = xmb_rt;
+    xmb_rt->rdman->w = w;
+    xmb_rt->rdman->h = h;
 
     xmb_rt->tman = mb_tman_new();
 
--- 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);
--- a/src/shape_path.c	Sun Jan 25 00:20:34 2009 +0800
+++ b/src/shape_path.c	Sun Jan 25 16:07:43 2009 +0800
@@ -788,10 +788,10 @@
 	poses = (co_aix (*)[2])(path->dev_data + path->cmd_len);
 	geo_from_positions(path->shape.geo, arg_len / 2, poses);
 	area = shape->geo->cur_area;
-	area->x -= shape->stroke_width/2 + 1;
-	area->y -= shape->stroke_width/2 + 1;
-	area->w += shape->stroke_width + 2;
-	area->h += shape->stroke_width + 2;
+	area->x -= shape->stroke_width / 2 + 0.5;
+	area->y -= shape->stroke_width / 2 + 0.5;
+	area->w += shape->stroke_width + 1;
+	area->h += shape->stroke_width + 1;
     }
 }
 
--- a/src/shape_rect.c	Sun Jan 25 00:20:34 2009 +0800
+++ b/src/shape_rect.c	Sun Jan 25 16:07:43 2009 +0800
@@ -122,10 +122,10 @@
     if(shape->stroke) {
 	area = shape->geo->cur_area;
 	width = shape->stroke_width;
-	area->x -= width / 2 + 1;
-	area->y -= width / 2 + 1;
-	area->w += width + 2;
-	area->h += width + 2;
+	area->x -= width / 2 + 0.5;
+	area->y -= width / 2 + 0.5;
+	area->w += width + 1;
+	area->h += width + 1;
     }
 }