diff src/mb_types.h @ 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 c1cdd3fcd28f
children 147c93163ef0
line wrap: on
line diff
--- a/src/mb_types.h	Fri Oct 03 10:22:08 2008 +0800
+++ b/src/mb_types.h	Sun Oct 05 23:32:58 2008 +0800
@@ -12,20 +12,26 @@
 typedef struct _shnode shnode_t;
 typedef struct _paint paint_t;
 
+struct _redraw_man;
+
 /*! \brief Base of paint types.
  *
- * Paints should be freed by users by calling paint_t::free() of
+ * Paints should be freed by users by calling rdman_paint_free() of
  * the paint.
  *
  * \todo move member functions to a seperate structure and setup a
  * singleton fro each paint type.
  */
 struct _paint {
+    int flags;
     void (*prepare)(paint_t *paint, cairo_t *cr);
-    void (*free)(paint_t *paint);
+    void (*free)(struct _redraw_man *rdman, paint_t *paint);
     STAILQ(shnode_t) members;
+    paint_t *pnt_next;		/*!< \brief Collect all paints of a rdman. */
 };
 
+#define PNTF_FREE 0x1
+
 struct _shnode {
     shape_t *shape;
     shnode_t *next;
@@ -110,7 +116,10 @@
 				 * of parent. */
 
     int num_members;
-    STAILQ(geo_t) members;	/*!< All geo_t members in this coord. */
+    STAILQ(geo_t) members;	/*!< \brief All geo_t members in this coord. */
+
+    STAILQ(shape_t) shapes;	/*!< \brief All shapes managed by the rdman. */
+
     subject_t *mouse_event;
 } coord_t;
 #define COF_DIRTY 0x1
@@ -158,6 +167,7 @@
     co_aix stroke_width;
     int stroke_linecap:2;
     int stroke_linejoin:2;
+    struct _shape *sh_next;	/*!< Link all shapes of a rdman together. */
     void (*free)(shape_t *shape);
 };
 enum { SHT_UNKNOW, SHT_PATH, SHT_TEXT, SHT_RECT };