Allow empty sprites to be allocated.

This commit is contained in:
Paul Chote
2013-11-30 09:26:37 +13:00
parent 9acba84acc
commit 01155a655a

View File

@@ -55,6 +55,10 @@ namespace OpenRA.Graphics
public Sprite Add(byte[] src, Size size) { return Add(src, size, float2.Zero); }
public Sprite Add(byte[] src, Size size, float2 spriteOffset)
{
// Don't bother allocating empty sprites
if (size.Width == 0 || size.Height == 0)
return new Sprite(current, Rectangle.Empty, spriteOffset, channel, BlendMode.Alpha);
var rect = Allocate(size, spriteOffset);
Util.FastCopyIntoChannel(rect, src);
current.CommitData();