[Freeciv-Dev] (PR#7293) Performance of Freeciv
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=7293 >
Please try this patch. It queues individual tile updates. Should be
much faster in the slow cases. It may be slower in the fast cases, however.
Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.72
diff -u -r1.72 mapview_common.c
--- client/mapview_common.c 2004/01/16 02:08:50 1.72
+++ client/mapview_common.c 2004/01/23 18:58:17
@@ -1427,9 +1427,12 @@
}
static enum update_type needed_updates = UPDATE_NONE;
+bool need_tile_update;
+int update_x0, update_y0, update_x1, update_y1;
/**************************************************************************
- This function, along with unqueue_mapview_update(), helps in updating
+ This function, along with unqueue_mapview_updates() and
+ queue_mapview_update_tiles(), helps in updating
the mapview when a packet is received. Previously, we just called
update_map_canvas when (for instance) a city update was received.
Not only would this often end up with a lot of duplicated work, but it
@@ -1451,6 +1454,31 @@
}
/**************************************************************************
+ This function marks a set of tiles for being updated. The actual
+ update is done later, when unqueue_mapview_updates is called. See
+ queue_mapview_update().
+**************************************************************************/
+void queue_mapview_update_tiles(int x, int y, int width, int height)
+{
+ if (needed_updates & UPDATE_MAP_CANVAS_VISIBLE) {
+ return;
+ }
+
+ if (need_tile_update) {
+ update_x0 = MIN(update_x0, x);
+ update_y0 = MIN(update_y0, y);
+ update_x1 = MAX(update_x1, x + width);
+ update_y1 = MAX(update_y1, y + height);
+ } else {
+ update_x0 = x;
+ update_y0 = y;
+ update_x1 = x + width;
+ update_y1 = y + height;
+ }
+ need_tile_update = TRUE;
+}
+
+/**************************************************************************
See comment for queue_mapview_update().
**************************************************************************/
void unqueue_mapview_updates(void)
@@ -1460,10 +1488,18 @@
if (needed_updates & UPDATE_MAP_CANVAS_VISIBLE) {
update_map_canvas_visible();
- } else if (needed_updates & UPDATE_CITY_DESCRIPTIONS) {
- update_city_descriptions();
+ } else {
+ if (need_tile_update) {
+ update_map_canvas(update_x0, update_y0,
+ update_x1 - update_x0, update_y1 - update_y0, FALSE);
+ }
+ if (needed_updates & UPDATE_CITY_DESCRIPTIONS) {
+ update_city_descriptions();
+ }
}
+
needed_updates = UPDATE_NONE;
+ need_tile_update = FALSE;
flush_dirty();
}
Index: client/mapview_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.h,v
retrieving revision 1.39
diff -u -r1.39 mapview_common.h
--- client/mapview_common.h 2003/09/30 19:01:22 1.39
+++ client/mapview_common.h 2004/01/23 18:58:17
@@ -183,6 +183,7 @@
enum color_std *grwoth_color);
void queue_mapview_update(enum update_type update);
+void queue_mapview_update_tiles(int x, int y, int width, int height);
void unqueue_mapview_updates(void);
void map_to_overview_pos(int *overview_x, int *overview_y,
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.345
diff -u -r1.345 packhand.c
--- client/packhand.c 2004/01/20 21:52:07 1.345
+++ client/packhand.c 2004/01/23 18:58:17
@@ -554,9 +554,9 @@
if ((draw_map_grid || draw_borders) && can_client_change_view()) {
/* We have to make sure we update any workers on the map grid, then
* redraw the city descriptions on top of them. */
- update_map_canvas(pcity->x - CITY_MAP_SIZE / 2,
- pcity->y - CITY_MAP_SIZE / 2,
- CITY_MAP_SIZE, CITY_MAP_SIZE, FALSE);
+ queue_mapview_update_tiles(pcity->x - CITY_MAP_SIZE / 2,
+ pcity->y - CITY_MAP_SIZE / 2,
+ CITY_MAP_SIZE, CITY_MAP_SIZE);
queue_mapview_update(UPDATE_CITY_DESCRIPTIONS);
} else {
refresh_tile_mapcanvas(pcity->x, pcity->y, FALSE);
- [Freeciv-Dev] Re: (PR#7293) Performance of Freeciv, Christian Knoke, 2004/01/22
- [Freeciv-Dev] Re: (PR#7293) Performance of Freeciv, Raimar Falke, 2004/01/22
- [Freeciv-Dev] Re: (PR#7293) Performance of Freeciv, Christian Knoke, 2004/01/22
- [Freeciv-Dev] Re: (PR#7293) Performance of Freeciv, Per I. Mathisen, 2004/01/22
- [Freeciv-Dev] Re: (PR#7293) Performance of Freeciv, Raimar Falke, 2004/01/22
- [Freeciv-Dev] Re: (PR#7293) Performance of Freeciv, Raimar Falke, 2004/01/23
- [Freeciv-Dev] (PR#7293) Performance of Freeciv,
Jason Short <=
- [Freeciv-Dev] Re: (PR#7293) Performance of Freeciv, Raimar Falke, 2004/01/24
- [Freeciv-Dev] Re: (PR#7293) Performance of Freeciv, Jason Short, 2004/01/24
|
|