Skip to content

Commit

Permalink
Resize the canvas a bit less often in map_canvas_resized
Browse files Browse the repository at this point in the history
The cached mapview texture always gets resized in tile_width/height increments.
One needs to redraw only when the cache got resized, not every time. The code
doing that had been broken since 9bd5b4a; fix
it.
  • Loading branch information
lmoureaux committed Jul 30, 2022
1 parent ea9fe79 commit 9f76f55
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions client/mapview_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2496,9 +2496,8 @@ void map_canvas_resized(int width, int height)
/ (tileset_tile_height(tileset));
int full_width = tile_width * tileset_tile_width(tileset);
int full_height = tile_height * tileset_tile_height(tileset);
bool tile_size_changed;

// Resized
bool cache_resized = width != mapview.width || height != mapview.height;

/* Since a resize is only triggered when the tile_*** changes, the canvas
* width and height must include the entire backing store - otherwise
Expand All @@ -2508,10 +2507,8 @@ void map_canvas_resized(int width, int height)
mapview.store_width = full_width;
mapview.store_height = full_height;

// use that function to clear cache
tile_size_changed = true;
// If the tile size has changed, resize the canvas.
if (tile_size_changed) {
// If the cache size has changed, resize the canvas.
if (cache_resized) {
if (mapview.store) {
delete mapview.store;
delete mapview.tmp_store;
Expand All @@ -2523,7 +2520,7 @@ void map_canvas_resized(int width, int height)
}

if (!map_is_empty() && can_client_change_view()) {
if (tile_size_changed) {
if (cache_resized) {
if (center_tile != nullptr) {
int x_left, y_top;
float gui_x, gui_y;
Expand Down

0 comments on commit 9f76f55

Please sign in to comment.