+static void update_index_to_pixmap_each(ProcessInfo *key,
+ HashedProcessData *value,
+ ProcessList *process_list)
+{
+ guint array_index = processlist_get_index_from_data(process_list, value);
+
+ g_assert(array_index < process_list->index_to_pixmap->len);
+
+ GdkPixmap **pixmap =
+ (GdkPixmap**)&g_ptr_array_index(process_list->index_to_pixmap, array_index);
+
+ *pixmap = value->pixmap;
+}
+
+
+static void update_index_to_pixmap(ProcessList *process_list)
+{
+ g_ptr_array_set_size(process_list->index_to_pixmap,
+ g_hash_table_size(process_list->process_hash));
+ g_hash_table_foreach(process_list->process_hash,
+ (GHFunc)update_index_to_pixmap_each,
+ process_list);
+}
+
+
+static void update_pixmap_size_each(ProcessInfo *key,
+ HashedProcessData *value,
+ guint width)
+{
+ GdkPixmap *old_pixmap = value->pixmap;
+
+ value->pixmap =
+ gdk_pixmap_new(old_pixmap,
+ width,
+ value->height,
+ -1);
+
+ gdk_pixmap_unref(old_pixmap);
+}
+
+
+void update_pixmap_size(ProcessList *process_list, guint width)
+{
+ g_hash_table_foreach(process_list->process_hash,
+ (GHFunc)update_pixmap_size_each,
+ (gpointer)width);
+}
+
+
+typedef struct _CopyPixmap {
+ GdkDrawable *dest;
+ GdkGC *gc;
+ GdkDrawable *src;
+ gint xsrc, ysrc, xdest, ydest, width, height;
+} CopyPixmap;
+
+static void copy_pixmap_region_each(ProcessInfo *key,
+ HashedProcessData *value,
+ CopyPixmap *cp)
+{
+ GdkPixmap *src = cp->src;
+ GdkPixmap *dest = cp->dest;
+
+ if(dest == NULL)
+ dest = value->pixmap;
+ if(src == NULL)
+ src = value->pixmap;
+
+ gdk_draw_drawable (dest,
+ cp->gc,
+ src,
+ cp->xsrc, cp->ysrc,
+ cp->xdest, cp->ydest,
+ cp->width, cp->height);
+}
+
+
+
+
+void copy_pixmap_region(ProcessList *process_list, GdkDrawable *dest,
+ GdkGC *gc, GdkDrawable *src,
+ gint xsrc, gint ysrc,
+ gint xdest, gint ydest, gint width, gint height)
+{
+ CopyPixmap cp = { dest, gc, src, xsrc, ysrc, xdest, ydest, width, height };
+
+ g_hash_table_foreach(process_list->process_hash,
+ (GHFunc)copy_pixmap_region_each,
+ &cp);
+}
+
+
+
+typedef struct _RectanglePixmap {
+ gboolean filled;
+ gint x, y, width, height;
+ GdkGC *gc;
+} RectanglePixmap;
+
+static void rectangle_pixmap_each(ProcessInfo *key,
+ HashedProcessData *value,
+ RectanglePixmap *rp)
+{
+ if(rp->height == -1)
+ rp->height = value->height;
+
+ gdk_draw_rectangle (value->pixmap,
+ rp->gc,
+ rp->filled,
+ rp->x, rp->y,
+ rp->width, rp->height);
+}
+
+
+
+
+void rectangle_pixmap(ProcessList *process_list, GdkGC *gc,
+ gboolean filled, gint x, gint y, gint width, gint height)
+{
+ RectanglePixmap rp = { filled, x, y, width, height, gc };
+
+ g_hash_table_foreach(process_list->process_hash,
+ (GHFunc)rectangle_pixmap_each,
+ &rp);
+}
+
+
+/* Renders each pixmaps into on big drawable */
+void copy_pixmap_to_screen(ProcessList *process_list,
+ GdkDrawable *dest,
+ GdkGC *gc,
+ gint x, gint y,
+ gint width, gint height)
+{
+ gint cell_height =
+ get_cell_height(process_list,
+ (GtkTreeView*)process_list->process_list_widget);
+ cell_height = 24; //FIXME
+ /* Get indexes */
+ gint begin = floor(y/(double)cell_height);
+ gint end = MIN(ceil((y+height)/(double)cell_height),
+ process_list->index_to_pixmap->len);
+ gint i;
+ g_warning("begin : %i, end : %i", begin,end);
+ for(i=begin; i<end; i++) {
+ g_assert(i<process_list->index_to_pixmap->len);
+ /* Render the pixmap to the screen */
+ GdkPixmap *pixmap =
+ (GdkPixmap*)g_ptr_array_index(process_list->index_to_pixmap, i);
+
+ gdk_draw_drawable (dest,
+ gc,
+ pixmap,
+ x, 0,
+ x, i*cell_height,
+ width, cell_height);
+
+ }
+
+
+}
+
+
+
+
+
+
+