Changed the definition of the TexturePacker.Add() method, to reduce generated garbage.

This commit is contained in:
the_fiddler 2007-11-08 15:54:07 +00:00
parent 4772bfee9e
commit ab757425f3

View file

@ -40,7 +40,7 @@ namespace OpenTK
/// <returns>A System.Drawing.Rectangle containing the coordinates of the packed item.</returns> /// <returns>A System.Drawing.Rectangle containing the coordinates of the packed item.</returns>
/// <exception cref="InvalidOperationException">Occurs if the item is larger than the available TexturePacker area</exception> /// <exception cref="InvalidOperationException">Occurs if the item is larger than the available TexturePacker area</exception>
/// <exception cref="ArgumentException">Occurs if the item already exists in the TexturePacker.</exception> /// <exception cref="ArgumentException">Occurs if the item already exists in the TexturePacker.</exception>
public Rectangle Add(T item) public void Add(T item, out Rectangle rect)
{ {
if (item.Width > root.Rect.Width || item.Height > root.Rect.Height) if (item.Width > root.Rect.Width || item.Height > root.Rect.Height)
throw new InvalidOperationException("The item is too large for this TexturePacker"); throw new InvalidOperationException("The item is too large for this TexturePacker");
@ -55,7 +55,7 @@ namespace OpenTK
throw new InvalidOperationException("There is not enough space to add this item. Consider calling the Clear() method."); throw new InvalidOperationException("There is not enough space to add this item. Consider calling the Clear() method.");
//items.Add(item, node); //items.Add(item, node);
return node.Rect; rect = node.Rect;
} }
//throw new ArgumentException("The item already exists in the TexturePacker.", "item"); //throw new ArgumentException("The item already exists in the TexturePacker.", "item");
} }