mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-11-08 10:29:00 +00:00
Replaces DynamicArena by LinearAllocator for GUI
Also DynamicArena causes an assertion when there are too many GUI elements. LinearAllocator consumes similar amount of memory in total but reduces a chance to get the assertion.
This commit is contained in:
1 file changed
+4
-5
@@ -22,8 +22,8 @@
|
||||
|
||||
#include "gui/ObjectBases/IGUIObject.h"
|
||||
#include "lib/alignment.h"
|
||||
#include "lib/allocators/DynamicArena.h"
|
||||
#include "ps/memory/AllocatorAdapter.h"
|
||||
#include "ps/memory/LinearAllocator.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
@@ -59,11 +59,10 @@ public:
|
||||
template<typename... Args>
|
||||
static void RecurseVisibleObject(IGUIObject* object, void(IGUIObject::* callbackFunction)(Args... args), Args&&... args)
|
||||
{
|
||||
using Arena = Allocators::DynamicArena<128 * KiB>;
|
||||
using ObjectListAllocator = PS::Memory::AllocatorAdapter<VisibleObject, Arena>;
|
||||
Arena arena;
|
||||
PS::Memory::LinearAllocator allocator{128 * KiB, 4 * MiB};
|
||||
using ObjectListAllocator = PS::Memory::AllocatorAdapter<VisibleObject, PS::Memory::LinearAllocator>;
|
||||
|
||||
std::vector<VisibleObject, ObjectListAllocator> visibleObjects((ObjectListAllocator(arena)));
|
||||
std::vector<VisibleObject, ObjectListAllocator> visibleObjects((ObjectListAllocator(allocator)));
|
||||
CollectVisibleObjectsRecursively(object->GetVisibleChildren(), &visibleObjects);
|
||||
for (VisibleObject& visibleObject : visibleObjects)
|
||||
visibleObject.bufferedZ = visibleObject.object->GetBufferedZ();
|
||||
|
||||
Reference in new issue
Block a user