class GUIMeshBatches

Maintains a set of meshes used for drawing GUI elements.

When possible GUI render elements will be merged into the same mesh (i.e. a batch) in order to reduce render time. Additionally, each batch maintains a list of dirty regions that need to be updated by the GUI renderer.

Public

Constructors

GUIMeshBatches

GUIMeshBatches(GUIWidget *parentWidget)

Methods

Add

void Add(GUIRenderable *guiElement)

Iterates over all the render elements in the GUI elements and adds them to suitable batches.

Remove

void Remove(GUIRenderable *guiElement)

Removes all render elements in the provided GUI element from their current set of batches.

RebuildDirty

GUIDrawGroupRenderDataUpdate RebuildDirty(bool forceRebuildMeshes)

Rebuilds any dirty internal data and returns the data structure required for updating the GUI renderer.

MarkContentDirty

void MarkContentDirty(GUIRenderable *guiElement)

Notifies the system that element's contents were marked as dirty.

MarkMeshDirty

void MarkMeshDirty(GUIRenderable *guiElement)

Notifies the system that element's mesh was marked as dirty.

Private

Methods

AllocateBatchId

u32 AllocateBatchId()

Returns a unique batch id.

FreeBatchId

void FreeBatchId(u32 id)

Frees a batch id allocated with AllocateBatchId().

SplitDepthRange

u32 SplitDepthRange(u32 depthRangeIndex, u32 depth)

Splits the provided depth range at the specified depth.

Returns the index of second half of the depth range.

CollapseDepthRange

bool CollapseDepthRange(u32 depthRangeIndex)

Attempts to collapse the provided depth range and the previous depth range into a single depth range.

Returns true if the merge was performed.

RebuildMesh

void RebuildMesh(Batch &batch)

Builds a mesh used for rendering the provided batch.

RebuildMeshes

void RebuildMeshes()

Rebuilds the GUI element meshes.

Add

void Add(BatchedGUIElement &batchedGuiElement, u32 renderElementIndex, u32 depthRangeIndex)

Adds a specific render element of a GUI element to a batch in the depth range at the provided index.

Caller is responsible for ensuring the element falls within the correct depth range.

Add

void Add(BatchedGUIElement &batchedGuiElement, u32 renderElementIndex)

Adds a specific render element of a GUI element to a batch in a suitable depth range.

Add

Batch *Add(BatchedGUIElement &batchedGuiElement, const BatchedGUIRenderElement &batchedGuiRenderElement, const BatchedMaterial &batchedMaterial, u32 depthRangeIndex)

Adds the specified render element of a GUI element to the specified depth range.

Based on the provided material information a new batch will be created in the depth range, or the render element will be appended to an existing batch. Batch it was added to will be returned.

Remove

void Remove(BatchedGUIElement &batchedGuiElement, u32 renderElementIndex, u32 depthRangeIndex)

Removes a specific render element in the provided GUI element from their batch in the provided depth range.

Caller is responsible for ensuring the provided draw group is contained in the provided depth range.

Remove

void Remove(BatchedGUIElement &batchedGuiElement, u32 renderElementIndex)

Removes a specific render element in the provided GUI element from their current batch.

MarkBoundsDirty

void MarkBoundsDirty(const BatchedGUIElement &element)

Marks region covered by of all the batches associated with the element as dirty, so they will be redrawn on the next frame.

If element is being resized or moved, this should be called on the old position/size, as well as on the new position/size.

MarkBoundsDirty

void MarkBoundsDirty(const BatchedGUIElement &element, u32 batchId)

Marks region covered by of a particular batch associated with the element as dirty, so it will be redrawn on the next frame.

If element is being resized or moved, this should be called on the old position/size, as well as on the new position/size.

staticGetRenderData

static GUIBatchRenderData GetRenderData(const Batch &batch)

Builds a structure with information required for rendering the provided batch.

staticCalculateBounds

static Area2I CalculateBounds(Batch &batch)

Calculates the bounds of all elements in all the batches in the provided batch.

staticCreateBatchedMaterial

static BatchedMaterial CreateBatchedMaterial(const BatchedGUIRenderElement &batchedGuiRenderElement)

Creates information about a material for the provided render element.

staticCreateBatchedMaterial

static BatchedMaterial CreateBatchedMaterial(const GUIRenderable &guiElement, u32 renderElementIndex)

Creates information about a material for the provided render element.

Fields

mDepthRanges

Vector<BatchesInDepthRange> mDepthRanges

mBatches

UnorderedMap<u32, Batch> mBatches

mElements

UnorderedMap<GUIRenderable *, BatchedGUIElement> mElements

mDirtyElements

UnorderedMap<GUIRenderable *, u32> mDirtyElements

mDirtyRegionsForRemovedBatches

Vector<Area2I> mDirtyRegionsForRemovedBatches

mBatchesOutOfDateInRenderer

bool mBatchesOutOfDateInRenderer

mWidget

GUIWidget * mWidget

mNextDepthRangeId

u32 mNextDepthRangeId

mNextBatchId

u32 mNextBatchId

mFreeBatchIds

Vector<u32> mFreeBatchIds