changeset 490:5d0b2761f89c Android_Skia

Reset stroke and fill for shapes when a paint is freed. - reset stroke or/and fill of shapes with a freeing paint. - remove a shape from member lists of paints of stroke and fill when the shape being freed.
author Thinker K.F. Li <thinker@branda.to>
date Mon, 23 Nov 2009 18:04:22 +0800
parents 23c7667b3ec0
children 4291f16f3a09
files include/mb_redraw_man.h src/redraw_man.c
diffstat 2 files changed, 46 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/include/mb_redraw_man.h	Sun Nov 22 20:41:27 2009 +0800
+++ b/include/mb_redraw_man.h	Mon Nov 23 18:04:22 2009 +0800
@@ -157,25 +157,31 @@
 #define _rdman_paint_remove_child(rdman, paint, shape)		\
     do {							\
 	if((shape)->fill == (shape)->stroke &&			\
-	   (shape)->stroke == paint)				\
+	   (shape)->stroke == (paint))				\
 	    break;						\
 	_rdman_paint_real_remove_child(rdman, paint, shape);	\
     } while(0)
-#define rdman_paint_fill(rdman, paint, shape)		\
-    do {						\
-	if((shape)->fill == paint)			\
-	    break;					\
-	_rdman_paint_remove_child(rdman, paint, shape);	\
-	_rdman_paint_child(rdman, paint, shape);	\
-	(shape)->fill = paint;				\
+#define rdman_paint_fill(rdman, paint, shape)			\
+    do {							\
+	if((shape)->fill == paint)				\
+	    break;						\
+	if((shape)->fill)					\
+	    _rdman_paint_remove_child(rdman, (shape)->fill,	\
+				      shape);			\
+	if(paint)						\
+	    _rdman_paint_child(rdman, paint, shape);		\
+	(shape)->fill = paint;					\
     } while(0)
-#define rdman_paint_stroke(rdman, paint, shape)		\
-    do {						\
-	if((shape)->stroke == paint)			\
-	    break;					\
-	_rdman_paint_remove_child(rdman, paint, shape);	\
-	_rdman_paint_child(rdman, paint, shape);	\
-	(shape)->stroke = paint;			\
+#define rdman_paint_stroke(rdman, paint, shape)			\
+    do {							\
+	if((shape)->stroke == paint)				\
+	    break;						\
+	if((shape)->stroke)					\
+	    _rdman_paint_remove_child(rdman, (shape)->stroke,	\
+				      shape);			\
+	if(paint)						\
+	    _rdman_paint_child(rdman, paint, shape);		\
+	(shape)->stroke = paint;				\
     } while(0)
 extern int rdman_paint_changed(redraw_man_t *rdman, paint_t *paint);
 
--- a/src/redraw_man.c	Sun Nov 22 20:41:27 2009 +0800
+++ b/src/redraw_man.c	Mon Nov 23 18:04:22 2009 +0800
@@ -746,6 +746,10 @@
 	rdman_shape_free(rdman, saved_shape);
     
     coord_canvas_info_free(rdman, rdman->root_coord->canvas_info);
+
+    /* XXX: paints are not freed, here.  All resources of paints would
+     * be reclaimed by freeing elmpools.
+     */
     
     elmpool_free(rdman->coord_pool);
     elmpool_free(rdman->geo_pool);
@@ -841,6 +845,11 @@
 	return OK;
     }
 
+    if(shape->stroke != NULL)
+	rdman_paint_stroke(rdman, (paint_t *)NULL, shape);
+    if(shape->fill != NULL)
+	rdman_paint_fill(rdman, (paint_t *)NULL, shape);
+    
     if(geo != NULL) {
 	subject_free(geo->mouse_event);
 	geo_detach_coord(geo, shape->coord);
@@ -854,6 +863,7 @@
 
     if(rdman->last_mouse_over == (mb_obj_t *)shape)
 	rdman->last_mouse_over = NULL;
+
     
     return OK;
 }
@@ -871,6 +881,7 @@
 
 int rdman_paint_free(redraw_man_t *rdman, paint_t *paint) {
     shnode_t *shnode, *saved_shnode;
+    shape_t *shape;
 
     if(rdman_is_dirty(rdman)) {
 	if(!(paint->flags & PNTF_FREE))
@@ -885,12 +896,26 @@
     FORPAINTMEMBERS(paint, shnode) {
 	if(saved_shnode) {
 	    RM_PAINTMEMBER(paint, saved_shnode);
+	    
+	    shape = saved_shnode->shape;
+	    if(shape->stroke == paint)
+		rdman_paint_stroke(rdman, (paint_t *)NULL, shape);
+	    if(shape->fill == paint)
+		rdman_paint_fill(rdman, (paint_t *)NULL, shape);
+	    
 	    shnode_free(rdman, saved_shnode);
 	}
 	saved_shnode = shnode;
     }
     if(saved_shnode) {
 	RM_PAINTMEMBER(paint, saved_shnode);
+	
+	shape = saved_shnode->shape;
+	if(shape->stroke == paint)
+	    rdman_paint_stroke(rdman, (paint_t *)NULL, shape);
+	if(shape->fill == paint)
+	    rdman_paint_fill(rdman, (paint_t *)NULL, shape);
+	
 	shnode_free(rdman, saved_shnode);
     }