Index: client/clinet.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/clinet.c,v retrieving revision 1.77 diff -u -r1.77 clinet.c --- client/clinet.c 2002/12/08 22:55:24 1.77 +++ client/clinet.c 2002/12/14 07:11:41 @@ -336,7 +336,7 @@ close_socket_callback(&aconnection); } - unqueue_mapview_update(); + unqueue_mapview_updates(); } /************************************************************************** @@ -388,7 +388,7 @@ } out: - unqueue_mapview_update(); + unqueue_mapview_updates(); } #ifdef WIN32_NATIVE Index: client/mapview_common.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v retrieving revision 1.22 diff -u -r1.22 mapview_common.c --- client/mapview_common.c 2002/12/06 22:25:12 1.22 +++ client/mapview_common.c 2002/12/14 07:11:41 @@ -20,6 +20,7 @@ #include "log.h" #include "map.h" #include "support.h" +#include "timing.h" #include "mapview_g.h" @@ -382,6 +383,7 @@ { int map_view_x0, map_view_y0, map_win_width, map_win_height; int map_tile_width, map_tile_height; + struct timer *t=new_timer_start(TIMER_USER,TIMER_ACTIVE); get_mapview_dimensions(&map_view_x0, &map_view_y0, &map_win_width, &map_win_height); @@ -402,6 +404,9 @@ } show_city_descriptions(); + freelog(LOG_NORMAL, "update_map_canvas_visible of %dx%d = %fms", + map_win_width, map_win_height, + 1000.0 * read_timer_seconds_free(t)); } /************************************************************************** @@ -590,7 +595,7 @@ } } -static bool need_mapview_update = FALSE; +static enum update_type needed_updates = UPDATE_NONE; /************************************************************************** This function, along with unqueue_mapview_update(), helps in updating @@ -609,23 +614,25 @@ faster too. But it's a bit of a hack to insert this code into the packet-handling code. **************************************************************************/ -void queue_mapview_update(void) +void queue_mapview_update(enum update_type update) { - need_mapview_update = TRUE; + needed_updates |= update; } /************************************************************************** See comment for queue_mapview_update(). **************************************************************************/ -void unqueue_mapview_update(void) +void unqueue_mapview_updates(void) { - freelog(LOG_DEBUG, "unqueue_mapview_update: need_update=%d", - need_mapview_update ? 1 : 0); + freelog(LOG_DEBUG, "unqueue_mapview_update: needed_updates=%d", + needed_updates); - if (need_mapview_update) { + if (needed_updates & UPDATE_MAP_CANVAS_VISIBLE) { update_map_canvas_visible(); - need_mapview_update = FALSE; + } else if (needed_updates & UPDATE_CITY_DESCRIPTIONS) { + update_city_descriptions(); } + needed_updates = UPDATE_NONE; } /************************************************************************** Index: client/mapview_common.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.h,v retrieving revision 1.16 diff -u -r1.16 mapview_common.h --- client/mapview_common.h 2002/11/29 10:01:58 1.16 +++ client/mapview_common.h 2002/12/14 07:11:41 @@ -114,6 +114,13 @@ D_MB_LR = D_M_L | D_M_R | D_B_L | D_B_R }; +enum update_type { + /* Masks */ + UPDATE_NONE = 0, + UPDATE_CITY_DESCRIPTIONS = 1, + UPDATE_MAP_CANVAS_VISIBLE = 2 +}; + void refresh_tile_mapcanvas(int x, int y, bool write_to_screen); enum color_std get_grid_color(int x1, int y1, int x2, int y2); @@ -147,7 +154,7 @@ size_t growth_buffer_len, enum color_std *grwoth_color); -void queue_mapview_update(void); -void unqueue_mapview_update(void); +void queue_mapview_update(enum update_type update); +void unqueue_mapview_updates(void); #endif /* FC__MAPVIEW_COMMON_H */ Index: client/packhand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v retrieving revision 1.264 diff -u -r1.264 packhand.c --- client/packhand.c 2002/12/11 10:39:41 1.264 +++ client/packhand.c 2002/12/14 07:11:42 @@ -348,7 +348,7 @@ /* update the descriptions if necessary */ if (update_descriptions && tile_visible_mapcanvas(packet->x, packet->y)) { - queue_mapview_update(); + queue_mapview_update(UPDATE_CITY_DESCRIPTIONS); } assert(pcity->id == packet->id); @@ -489,7 +489,7 @@ } if (draw_map_grid && get_client_state() == CLIENT_GAME_RUNNING_STATE) { - queue_mapview_update(); + queue_mapview_update(UPDATE_CITY_DESCRIPTIONS); } else { refresh_tile_mapcanvas(pcity->x, pcity->y, TRUE); } Index: client/gui-gtk-2.0/gui_main.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/gui_main.c,v retrieving revision 1.34 diff -u -r1.34 gui_main.c --- client/gui-gtk-2.0/gui_main.c 2002/12/13 19:15:12 1.34 +++ client/gui-gtk-2.0/gui_main.c 2002/12/14 07:11:43 @@ -74,6 +74,7 @@ GtkWidget *map_vertical_scrollbar; GdkPixmap *map_canvas_store; /* this pixmap acts as a backing store * for the map_canvas widget */ +GdkPixmap *map_canvas_store2; int map_canvas_store_twidth = 1; int map_canvas_store_theight = 1; Index: client/gui-gtk-2.0/gui_main.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/gui_main.h,v retrieving revision 1.4 diff -u -r1.4 gui_main.h --- client/gui-gtk-2.0/gui_main.h 2002/11/30 20:06:49 1.4 +++ client/gui-gtk-2.0/gui_main.h 2002/12/14 07:11:43 @@ -35,6 +35,7 @@ extern GdkPixmap * black50; extern GdkPixmap * mask_bitmap; extern GdkPixmap * map_canvas_store; +extern GdkPixmap * map_canvas_store2; extern int map_canvas_store_twidth; extern int map_canvas_store_theight; extern GdkPixmap * overview_canvas_store; Index: client/gui-gtk-2.0/mapview.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/mapview.c,v retrieving revision 1.32 diff -u -r1.32 mapview.c --- client/gui-gtk-2.0/mapview.c 2002/12/13 19:15:12 1.32 +++ client/gui-gtk-2.0/mapview.c 2002/12/14 07:11:43 @@ -817,6 +817,9 @@ if (map_canvas_store) { g_object_unref(map_canvas_store); } + if (map_canvas_store2) { + g_object_unref(map_canvas_store2); + } map_canvas_store_twidth = tile_width; map_canvas_store_theight = tile_height; @@ -826,6 +829,11 @@ tile_height * NORMAL_TILE_HEIGHT, -1); + map_canvas_store2 = gdk_pixmap_new(ev->window, + tile_width * NORMAL_TILE_WIDTH, + tile_height * NORMAL_TILE_HEIGHT, + -1); + gdk_gc_set_foreground(fill_bg_gc, colors_standard[COLOR_STD_BLACK]); gdk_draw_rectangle(map_canvas_store, fill_bg_gc, TRUE, 0, 0, -1, -1); update_map_canvas_scrollbars_size(); @@ -1203,12 +1211,29 @@ } } +/* Hack to draw city descs correctly through both update_city_descriptions + * (which supports a second layer of buffering) and + * update_map_canvas_visible (which does not). */ +static bool in_update_city_descriptions = FALSE; + /************************************************************************** Update display of descriptions associated with cities on the main map. **************************************************************************/ void update_city_descriptions(void) { - update_map_canvas_visible(); + struct timer *t = new_timer_start(TIMER_USER,TIMER_ACTIVE); + int width, height; + + gdk_window_get_size(map_canvas->window, &width, &height); + gdk_draw_pixmap(map_canvas_store2, civ_gc, map_canvas_store, + 0, 0, 0, 0, width, height); + in_update_city_descriptions = TRUE; + show_city_descriptions(); + in_update_city_descriptions = FALSE; + gdk_draw_pixmap(map_canvas->window, civ_gc, map_canvas_store2, + 0, 0, 0, 0, width, height); + freelog(LOG_NORMAL, "update_city_descriptions = %fms", + 1000.0 * read_timer_seconds_free(t)); } /************************************************************************** @@ -1221,6 +1246,8 @@ enum color_std color; int extra_width = 0; PangoLayout *layout; + GdkPixmap *pixmap = in_update_city_descriptions ? map_canvas_store2 : + map_canvas->window; /* FIXME: layout should be statically declared */ layout = pango_layout_new(gdk_pango_context_get()); @@ -1257,7 +1284,7 @@ rect2.width = 0; } - gtk_draw_shadowed_string(map_canvas->window, + gtk_draw_shadowed_string(pixmap, toplevel->style->black_gc, toplevel->style->white_gc, canvas_x - (rect.width + rect2.width) / 2, @@ -1267,7 +1294,7 @@ pango_layout_set_font_description(layout, city_productions_font); pango_layout_set_text(layout, buffer2, -1); gdk_gc_set_foreground(civ_gc, colors_standard[color]); - gtk_draw_shadowed_string(map_canvas->window, + gtk_draw_shadowed_string(pixmap, toplevel->style->black_gc, civ_gc, canvas_x - (rect.width + rect2.width) / 2 @@ -1287,7 +1314,7 @@ pango_layout_set_text(layout, buffer, -1); pango_layout_get_pixel_extents(layout, &rect, NULL); - gtk_draw_shadowed_string(map_canvas->window, + gtk_draw_shadowed_string(pixmap, toplevel->style->black_gc, toplevel->style->white_gc, canvas_x - rect.width / 2,