triplea-game / triplea

TripleA is a turn based strategy game and board game engine, similar to Axis & Allies or Risk.
https://triplea-game.org/
GNU General Public License v3.0
1.33k stars 392 forks source link

Map drawing is very slow for high resolution maps (e.g. GoT) #6813

Open asvitkine opened 4 years ago

asvitkine commented 4 years ago

How can the problem be recreated?

  1. Play a map with a high resolution background, for example "Game of Thrones".
  2. Right-click the map and move the mouse to drag-scroll the map.
  3. Observe the lag between moving the cursor and the map following.

Do you have any ideas for an expected fix?

Yes, working on it. :)

Some things I'm trying:

Attach a Save Game

N/A

If playing a prerelease, which version are you using?

Game Version: 2.0 TOT

If playing a prerelease, does this happen on the latest release?

Is there anything else we should know?

asvitkine commented 4 years ago

Actually, investigating more, the default performance is not as bad as I had observed originally.

Instead, I was looking at a fix for white lines sometimes being shown and found that:

    g2d.setRenderingHint(
    -    RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
    +    RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);

Fixes the issue.

However, the above resulted in much worse performance. (2ms per tile drawn as opposed to 0.4ms before).

My changes above actually bring this back down. However, the white lines are re-introduced. Seeing if I can get the best of both worlds...

RoiEXLab commented 4 years ago

If map zoom is applied, generate tile images at the zoom level, rather than scaling them when drawing.

This is what it used to be like, but zooming in meant that it would redraw the entire map. But at default scale (1) it shouldn't really affect performance in any way I think