diff src/X_main.c @ 159:b90abd31a281

Postponse free of coords, shapes, and paints when the rdman is dirty. - Life-cycle of shapes and paints are managed by rdman. - Add redraw_man_t::free_objs to collect objects their freeing are postonsed. Know Issue: - Bullet of tank are not removed from screen when it is go out the range of the map.
author Thinker K.F. Li <thinker@branda.to>
date Sun, 05 Oct 2008 23:32:58 +0800
parents a6763f080da5
children c7e5b8779bb5
line wrap: on
line diff
--- a/src/X_main.c	Fri Oct 03 10:22:08 2008 +0800
+++ b/src/X_main.c	Sun Oct 05 23:32:58 2008 +0800
@@ -148,15 +148,15 @@
     coord2 = rdman_coord_new(&rdman, rdman.root_coord);
     coord3 = rdman_coord_new(&rdman, rdman.root_coord);
 
-    fill1 = paint_color_new(&rdman, 1, 1, 0, 0.5);
-    fill2 = paint_color_new(&rdman, 0, 1, 1, 0.5);
-    stroke = paint_color_new(&rdman, 0.4, 0.4, 0.4, 1);
-    text_stroke = paint_color_new(&rdman, 0.5, 0.5, 0.5, 1);
+    fill1 = rdman_paint_color_new(&rdman, 1, 1, 0, 0.5);
+    fill2 = rdman_paint_color_new(&rdman, 0, 1, 1, 0.5);
+    stroke = rdman_paint_color_new(&rdman, 0.4, 0.4, 0.4, 1);
+    text_stroke = rdman_paint_color_new(&rdman, 0.5, 0.5, 0.5, 1);
 
     face = cairo_get_font_face(tmpcr);
-    text = sh_text_new("hello \xe6\xbc\xa2\xe5\xad\x97", 10, h / 4,
-		       36.0, face);
-    text_fill = paint_radial_new(&rdman, 100, h / 4, 70);
+    text = rdman_shape_text_new(&rdman, "hello \xe6\xbc\xa2\xe5\xad\x97",
+				10, h / 4, 36.0, face);
+    text_fill = rdman_paint_radial_new(&rdman, 100, h / 4, 70);
     grad_stop_init(text_stops, 0, 0.2, 0.9, 0.2, 1);
     grad_stop_init(text_stops + 1, 1, 0.9, 0.2, 0.2, 0.1);
     paint_radial_stops(text_fill, 2, text_stops);
@@ -165,7 +165,7 @@
     rdman_paint_fill(&rdman, text_fill, text);
     rdman_add_shape(&rdman, text, coord3);
 
-    path1 = sh_path_new("M 22,89.36218 C -34,-0.63782 39,-9.637817 82,12.36218 C 125,34.36218 142,136.36218 142,136.36218 C 100.66667,125.36218 74.26756,123.42795 22,89.36218 z ");
+    path1 = rdman_shape_path_new(&rdman, "M 22,89.36218 C -34,-0.63782 39,-9.637817 82,12.36218 C 125,34.36218 142,136.36218 142,136.36218 C 100.66667,125.36218 74.26756,123.42795 22,89.36218 z ");
     rdman_paint_fill(&rdman, fill1, path1);
     rdman_paint_stroke(&rdman, stroke, path1);
     coord1->matrix[0] = 0.8;
@@ -174,7 +174,7 @@
     coord1->matrix[4] = 0.8;
     coord1->matrix[5] = 20;
 
-    path2 = sh_path_new("M 22,89.36218 C -34,-0.63782 39,-9.637817 82,12.36218 C 125,34.36218 142,136.36218 142,136.36218 C 100.66667,125.36218 74.26756,123.42795 22,89.36218 z ");
+    path2 = rdman_shape_path_new(&rdman, "M 22,89.36218 C -34,-0.63782 39,-9.637817 82,12.36218 C 125,34.36218 142,136.36218 142,136.36218 C 100.66667,125.36218 74.26756,123.42795 22,89.36218 z ");
     rdman_paint_fill(&rdman, fill2, path2);
     rdman_paint_stroke(&rdman, stroke, path2);
     coord2->matrix[0] = -0.8;
@@ -189,12 +189,12 @@
     rdman_add_shape(&rdman, (shape_t *)path2, coord2);
 
     
-    fill3 = paint_linear_new(&rdman, 50, 50, 150, 150);
+    fill3 = rdman_paint_linear_new(&rdman, 50, 50, 150, 150);
     grad_stop_init(fill3_stops, 0, 1, 0, 0, 0.5);
     grad_stop_init(fill3_stops + 1, 0.5, 0, 1, 0, 0.5);
     grad_stop_init(fill3_stops + 2, 1, 0, 0, 1, 0.5);
     paint_linear_stops(fill3, 3, fill3_stops);
-    rect = sh_rect_new(50, 50, 100, 100, 20, 20);
+    rect = rdman_shape_rect_new(&rdman, 50, 50, 100, 100, 20, 20);
     rdman_paint_fill(&rdman, fill3, rect);
     rdman_add_shape(&rdman, (shape_t *)rect, rdman.root_coord);
 
@@ -243,16 +243,16 @@
 	mb_tman_free(tman);
     }
 
-    fill1->free(fill1);
-    fill2->free(fill2);
-    stroke->free(stroke);
-    text_stroke->free(text_stroke);
-    text_fill->free(text_fill);
+    rdman_paint_free(&rdman, fill1);
+    rdman_paint_free(&rdman, fill2);
+    rdman_paint_free(&rdman, stroke);
+    rdman_paint_free(&rdman, text_stroke);
+    rdman_paint_free(&rdman, text_fill);
+    rdman_shape_free(&rdman, path1);
+    rdman_shape_free(&rdman, path2);
+    rdman_shape_free(&rdman, rect);
+    rdman_shape_free(&rdman, text);
     redraw_man_destroy(&rdman);
-    path1->free(path1);
-    path2->free(path2);
-    rect->free(rect);
-    text->free(text);
     cairo_destroy(tmpcr);
     cairo_surface_destroy(tmpsuf);
 }