class
TreeTextureAtlasLayout
Organizes a set of textures into a single larger texture (an atlas) by minimizing empty space.
Uses a tree structure to minimize wasted space. Elements can be dynamically added and removed from the layout.
Public
Constructors
TreeTextureAtlasLayout
Methods
AddElement
Attempts to add a new element in the layout.
- size
- Size of the element to add, in pixels.
Returns: Location at which the element was stored, or null if no free space was located.
RemoveElement
Removes an element from the provided node.
Grow
Grows the atlas without changing existing allocations.
New size cannot be smaller than existing size.
Clear
Removes all entries from the layout.
IsEmpty
Checks have any elements been added to the layout.
IsPageEmpty
Checks is a specific page empty.
GetSize
Returns the size of the atlas texture, in pixels.
Private
Methods
GetFreeNodeBucketForSize
Finds a bucket that stores nodes of the provided size.
AlignSize
Aligns the provided size to the alignment requested in layout settings.
PadSize
Applies padding to the size as requested in layout settings.
Split
Splits a node and returns leftover rectangles, if there are any.
FindBestFreeNode
Finds the index of the best fitting node that can be the provided area.
Returns ~0u if no such node can be found.
RegisterFreeNode
Registers the node in the appropriate free node bucket.
AllocateNode
Allocates a new mode in the nodes array and returns the allocated index.
This method will attempt to recycle unused nodes before allocating new nodes.
FreeNode
Marks the node as unused and frees it for re-allocation.
FreePage
Frees a page.
Assumes the page contains only the root node.
MergeWithNextSibling
Attempts to merge the next sibling of the provided node into the node, if the sibling exists and is free.
Fields
mSettings
mNodes
mPages
mUnusedNodeListHead
Index into mNodex of the first unused node, stored as a linked list. ~0u if no unused nodes.