[Freeciv-Dev] (PR#8719) call show_city_descriptions from update_map_canv
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] (PR#8719) call show_city_descriptions from update_map_canvas |
From: |
"Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx> |
Date: |
Wed, 12 May 2004 01:45:53 -0700 |
Reply-to: |
rt@xxxxxxxxxxx |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=8719 >
This patch calls show_city_descriptions directly from within
update_map_canvas. show_city_descriptions therefore is given a canvas
rectangle over which it is to do its update.
The advantage of this is that there is no need to do manual city redraws
after a partial update. Several callers of update_map_canvas therefore
become much simpler, and about 50 lines of code are removed.
This may also make drawing faster in some cases, since when the mapview
scrolls a small amount there is no need to redraw all of the city names.
It is still not perfect because some city names may be drawn twice.
With anti-aliased text this is not correct. However the current code
does this already; since we now draw fewer city names this actually
improves the behavior slightly. But a full fix will have to wait for a
later patch.
jason
? eff
Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.113
diff -u -r1.113 mapview_common.c
--- client/mapview_common.c 11 May 2004 20:01:43 -0000 1.113
+++ client/mapview_common.c 11 May 2004 21:18:24 -0000
@@ -72,55 +72,6 @@
canvas_y += NORMAL_TILE_HEIGHT - UNIT_TILE_HEIGHT;
update_map_canvas(canvas_x, canvas_y, UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT);
- if (update_city_text_in_refresh_tile
- && (draw_city_names || draw_city_productions)) {
- /* FIXME: update_map_canvas() will overwrite the city descriptions.
- * This is a workaround that redraws the city descriptions (most of
- * the time). Although it seems inefficient to redraw the
- * descriptions for so many tiles, remember that most of them don't
- * have cities on them.
- *
- * This workaround is unnecessary for clients that use a separate
- * buffer for the city descriptions, and will not work well for
- * anti-aliased text (since it uses partial transparency). Thus some
- * clients may turn it off by setting
- * update_city_text_in_refresh_tile. */
- int canvas_x, canvas_y;
- struct city *pcity;
-
- if (is_isometric) {
- /* We assume the city description will be directly below the city,
- * with a width of 1-2 tiles and a height of less than one tile.
- * Remember that units are 50% taller than the normal tile height.
- * 9
- * 7 8
- * 6 4 5
- * 2 3
- * 1
- * Tile 1 is the one being updated; we redraw the city description
- * for tiles 2-8 (actually we end up drawing 1 as well). */
- rectangle_iterate(x - 2, y - 2, 3, 3, city_x, city_y) {
- if ((pcity = map_get_city(city_x, city_y))) {
- map_to_canvas_pos(&canvas_x, &canvas_y, city_x, city_y);
- show_city_desc(pcity, canvas_x, canvas_y);
- }
- } rectangle_iterate_end;
- } else {
- /* We assume the city description will be held in the three tiles
- * right below the city.
- * 234
- * 1
- * Tile 1 is the one being updated; we redraw the city description
- * for tiles 2, 3, and 4. */
- rectangle_iterate(x - 1, y - 1, 3, 1, city_x, city_y) {
- if ((pcity = map_get_city(city_x, city_y))) {
- map_to_canvas_pos(&canvas_x, &canvas_y, city_x, city_y);
- show_city_desc(pcity, canvas_x, canvas_y);
- }
- } rectangle_iterate_end;
- }
- }
-
if (write_to_screen) {
flush_dirty();
}
@@ -445,7 +396,6 @@
update_map_canvas(update_x0 - gui_x0, common_y0 - gui_y0,
update_x1 - update_x0, common_y1 - common_y0);
}
- show_city_descriptions();
} else {
update_map_canvas_visible();
}
@@ -1388,6 +1338,8 @@
} gui_rect_iterate_end;
}
+ show_city_descriptions(canvas_x, canvas_y, width, height);
+
dirty_rect(canvas_x, canvas_y, width, height);
}
@@ -1407,13 +1359,13 @@
canvas_put_rectangle(mapview_canvas.store, COLOR_STD_BLACK,
0, 0, mapview_canvas.width, mapview_canvas.height);
update_map_canvas(0, 0, mapview_canvas.width, mapview_canvas.height);
- show_city_descriptions();
}
/**************************************************************************
Show descriptions for all cities visible on the map canvas.
**************************************************************************/
-void show_city_descriptions(void)
+void show_city_descriptions(int canvas_x, int canvas_y,
+ int width, int height)
{
const int dx = MAX(MAX_CITY_DESC_WIDTH - NORMAL_TILE_WIDTH, 0);
const int dy = MAX_CITY_DESC_HEIGHT;
@@ -1442,10 +1394,9 @@
* We must draw H2 extra pixels above and (W2 - W1) / 2 extra pixels
* to each side of the mapview.
*/
- gui_rect_iterate(mapview_canvas.gui_x0 - dx / 2,
- mapview_canvas.gui_y0 - dy,
- mapview_canvas.width + dx,
- mapview_canvas.height + dy,
+ gui_rect_iterate(mapview_canvas.gui_x0 + canvas_x - dx / 2,
+ mapview_canvas.gui_y0 + canvas_y - dy,
+ width + dx, width + dy,
map_x, map_y, draw) {
int canvas_x, canvas_y;
struct city *pcity;
Index: client/mapview_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.h,v
retrieving revision 1.61
diff -u -r1.61 mapview_common.h
--- client/mapview_common.h 11 May 2004 20:01:43 -0000 1.61
+++ client/mapview_common.h 11 May 2004 21:18:24 -0000
@@ -271,7 +271,8 @@
void update_map_canvas(int canvas_x, int canvas_y, int width, int height);
void update_map_canvas_visible(void);
-void show_city_descriptions(void);
+void show_city_descriptions(int canvas_x, int canvas_y,
+ int width, int height);
bool show_unit_orders(struct unit *punit);
void draw_segment(int src_x, int src_y, enum direction8 dir);
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.363
diff -u -r1.363 packhand.c
--- client/packhand.c 28 Apr 2004 00:54:24 -0000 1.363
+++ client/packhand.c 11 May 2004 21:18:24 -0000
@@ -590,7 +590,6 @@
update_map_canvas(canvas_x - (width - NORMAL_TILE_WIDTH) / 2,
canvas_y - (height - NORMAL_TILE_HEIGHT) / 2,
width, height);
- queue_mapview_update(UPDATE_CITY_DESCRIPTIONS);
} else {
refresh_tile_mapcanvas(pcity->x, pcity->y, FALSE);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#8719) call show_city_descriptions from update_map_canvas,
Jason Short <=
|
|