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

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Widgets
using (var hueBitmap = new Bitmap(256, 256))
{
var hueSheet = new Sheet(new Size(256, 256), false);
var hueSheet = new Sheet(new Size(256, 256));
hueSprite = new Sprite(hueSheet, new Rectangle(0, 0, 256, 1), TextureChannel.Alpha);
var bitmapData = hueBitmap.LockBits(hueBitmap.Bounds(),