Make map preview generation fast.

- Change Map.LoadMapTiles and Map.LoadResourceTiles to read the whole stream into memory before processing individual bytes. This removes the cost of significant overhead from repeated calls to ReadUInt8/16.
- Remove significant UI jank caused by the map chooser by not including the placeholder widget. The maps render fast enough that it is no longer worthwhile and it was causing a lot of flushes which were the source of the jank.
- Trigger async generation for all maps when the chooser is loaded. This means in practice all previews will be ready by the time the user begins to scroll the selection. Since generation is fast, there is no issue with scrolling straight to the bottom and having to wait for the backlog to clear.
This commit is contained in:
RoosterDragon
2014-05-31 17:55:56 +01:00
parent ee7573d01c
commit 9dbbc23967
7 changed files with 30 additions and 47 deletions

View File

@@ -69,27 +69,24 @@ namespace OpenRA
Sprite minimap;
bool generatingMinimap;
public Sprite Minimap
public Sprite GetMinimap()
{
get
if (minimap != null)
return minimap;
if (!generatingMinimap && Status == MapStatus.Available)
{
if (minimap != null)
return minimap;
if (!generatingMinimap && Status == MapStatus.Available)
{
generatingMinimap = true;
cache.CacheMinimap(this);
}
return null;
generatingMinimap = true;
cache.CacheMinimap(this);
}
set
{
minimap = value;
generatingMinimap = false;
}
return null;
}
public void SetMinimap(Sprite minimap)
{
this.minimap = minimap;
generatingMinimap = false;
}
public MapPreview(string uid, MapCache cache)