forked from Dynamitos/Seele
Basic renderhierarchy async updates
This commit is contained in:
1 parent
5dfc8300c5
commit
a6f784e6a1
11 files changed
+123
-24
No files matched your search
@@ -3,12 +3,18 @@
|
||||
using namespace Seele;
|
||||
using namespace Seele::UI;
|
||||
|
||||
RenderElement::RenderElement()
|
||||
void AddElementRenderHierarchyUpdate::apply(Array<RenderElement>& elements)
|
||||
{
|
||||
|
||||
for(auto element : elements)
|
||||
{
|
||||
if(element.parent == parent)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RenderElement::~RenderElement()
|
||||
void RemoveElementRenderHierarchyUpdate::apply(Array<RenderElement>& elements)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -23,10 +29,45 @@ RenderHierarchy::~RenderHierarchy()
|
||||
|
||||
}
|
||||
|
||||
void RenderHierarchy::updateHierarchyIndices()
|
||||
void RenderHierarchy::addElement(PElement addedElement)
|
||||
{
|
||||
for (uint32 i = 0; i < drawElements.size(); i++)
|
||||
std::lock_guard lock(updateLock);
|
||||
updates.add(new AddElementRenderHierarchyUpdate{
|
||||
addedElement.getHandle(),
|
||||
addedElement->getParent().getHandle()
|
||||
}));
|
||||
}
|
||||
|
||||
void RenderHierarchy::removeElement(PElement elementToRemove)
|
||||
{
|
||||
std::lock_guard lock(updateLock);
|
||||
updates.add(new RemoveElementRenderHierarchyUpdate{
|
||||
elementToRemove.getHandle(),
|
||||
});
|
||||
}
|
||||
|
||||
void RenderHierarchy::moveElement(PElement elementToMove, PElement newParent)
|
||||
{
|
||||
std::lock_guard lock(updateLock);
|
||||
updates.add(new AddElementRenderHierarchyUpdate{
|
||||
elementToMove.getHandle(),
|
||||
newParent.getHandle()
|
||||
});
|
||||
updates.add(new RemoveElementRenderHierarchyUpdate{
|
||||
elementToMove.getHandle()
|
||||
});
|
||||
}
|
||||
|
||||
void RenderHierarchy::updateHierarchy()
|
||||
{
|
||||
Array<RenderHierarchyUpdate*> localUpdates;
|
||||
{ // make a local copy of the updates so we dont hold the lock for too long
|
||||
std::lock_guard lock(updateLock);
|
||||
localUpdates = updates;
|
||||
updates.clear();
|
||||
}
|
||||
for(auto update : localUpdates)
|
||||
{
|
||||
drawElements[i].hierarchyIndex = i;
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user