Lazily generate buffer in Sheet.

The managed byte buffer is created on demand, meaning a newly allocated sheet will not waste memory holding onto the buffer until some changes are actually required to be written. This avoids a newly allocated sheet wasting memory on buffers that do not differ from their backing texture.
This commit is contained in:
RoosterDragon
2014-10-13 21:09:28 +01:00
committed by RoosterDragon
parent e6852e2b50
commit ff16690b86
7 changed files with 44 additions and 25 deletions

View File

@@ -33,7 +33,7 @@ namespace OpenRA.Graphics
throw new SheetOverflowException("Terrain sheet overflow. Try increasing the tileset SheetSize parameter.");
allocated = true;
return new Sheet(new Size(tileset.SheetSize, tileset.SheetSize), true);
return new Sheet(new Size(tileset.SheetSize, tileset.SheetSize));
};
sheetBuilder = new SheetBuilder(SheetType.Indexed, allocate);