|
@@ -168,9 +168,6 @@
|
|
#endif
|
|
#endif
|
|
|
|
|
|
#include <new>
|
|
#include <new>
|
|
-#define IMGUI_INTERNAL_USE
|
|
|
|
-#include "immem.h"
|
|
|
|
-#undef IMGUI_INTERNAL_USE
|
|
|
|
|
|
|
|
// Block sizes for each memory. Don't really know about the optimized values
|
|
// Block sizes for each memory. Don't really know about the optimized values
|
|
#define DRAWLIST_BLOCK_SIZE 128
|
|
#define DRAWLIST_BLOCK_SIZE 128
|
|
@@ -645,10 +642,6 @@ struct ImGuiState
|
|
ImGuiTextBuffer LogClipboard;
|
|
ImGuiTextBuffer LogClipboard;
|
|
int LogAutoExpandMaxDepth;
|
|
int LogAutoExpandMaxDepth;
|
|
|
|
|
|
- // Memory Pools
|
|
|
|
- PoolAlloc<ImDrawList> DrawListPool;
|
|
|
|
- PoolAlloc<ImGuiWindow> GuiWindowPool;
|
|
|
|
-
|
|
|
|
ImGuiState()
|
|
ImGuiState()
|
|
{
|
|
{
|
|
Initialized = false;
|
|
Initialized = false;
|
|
@@ -954,7 +947,7 @@ ImGuiWindow::ImGuiWindow(const char* name, ImVec2 default_pos, ImVec2 default_si
|
|
FocusIdxRequestCurrent = IM_INT_MAX;
|
|
FocusIdxRequestCurrent = IM_INT_MAX;
|
|
FocusIdxRequestNext = IM_INT_MAX;
|
|
FocusIdxRequestNext = IM_INT_MAX;
|
|
|
|
|
|
- ImDrawList *buff = GImGui.DrawListPool.alloc();
|
|
|
|
|
|
+ void *buff = GImGui.IO.MallocFn(sizeof(ImDrawList));
|
|
IM_ASSERT(buff);
|
|
IM_ASSERT(buff);
|
|
DrawList = new(buff) ImDrawList();
|
|
DrawList = new(buff) ImDrawList();
|
|
}
|
|
}
|
|
@@ -962,7 +955,7 @@ ImGuiWindow::ImGuiWindow(const char* name, ImVec2 default_pos, ImVec2 default_si
|
|
ImGuiWindow::~ImGuiWindow()
|
|
ImGuiWindow::~ImGuiWindow()
|
|
{
|
|
{
|
|
DrawList->~ImDrawList();
|
|
DrawList->~ImDrawList();
|
|
- GImGui.DrawListPool.free(DrawList);
|
|
|
|
|
|
+ GImGui.IO.FreeFn(DrawList);
|
|
DrawList = NULL;
|
|
DrawList = NULL;
|
|
StrDup_Free(Name);
|
|
StrDup_Free(Name);
|
|
Name = NULL;
|
|
Name = NULL;
|
|
@@ -1044,7 +1037,9 @@ static ImGuiIniData* FindWindowSettings(const char* name)
|
|
if (ImStricmp(ini->Name, name) == 0)
|
|
if (ImStricmp(ini->Name, name) == 0)
|
|
return ini;
|
|
return ini;
|
|
}
|
|
}
|
|
- ImGuiIniData* ini = new ImGuiIniData();
|
|
|
|
|
|
+
|
|
|
|
+ void *buff = GImGui.IO.MallocFn(sizeof(ImGuiIniData));
|
|
|
|
+ ImGuiIniData* ini = new(buff) ImGuiIniData();
|
|
ini->Name = StrDup(name);
|
|
ini->Name = StrDup(name);
|
|
ini->Collapsed = false;
|
|
ini->Collapsed = false;
|
|
ini->Pos = ImVec2(FLT_MAX,FLT_MAX);
|
|
ini->Pos = ImVec2(FLT_MAX,FLT_MAX);
|
|
@@ -1073,12 +1068,12 @@ static void LoadSettings()
|
|
return;
|
|
return;
|
|
if (fseek(f, 0, SEEK_SET))
|
|
if (fseek(f, 0, SEEK_SET))
|
|
return;
|
|
return;
|
|
- char* f_data = new char[f_size+1];
|
|
|
|
|
|
+ char* f_data = (char*)g.IO.MallocFn(f_size+1);
|
|
f_size = (long)fread(f_data, 1, f_size, f); // Text conversion alter read size so let's not be fussy about return value
|
|
f_size = (long)fread(f_data, 1, f_size, f); // Text conversion alter read size so let's not be fussy about return value
|
|
fclose(f);
|
|
fclose(f);
|
|
if (f_size == 0)
|
|
if (f_size == 0)
|
|
{
|
|
{
|
|
- delete[] f_data;
|
|
|
|
|
|
+ g.IO.FreeFn(f_data);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
f_data[f_size] = 0;
|
|
f_data[f_size] = 0;
|
|
@@ -1112,7 +1107,7 @@ static void LoadSettings()
|
|
line_start = line_end+1;
|
|
line_start = line_end+1;
|
|
}
|
|
}
|
|
|
|
|
|
- delete[] f_data;
|
|
|
|
|
|
+ g.IO.FreeFn(f_data);
|
|
}
|
|
}
|
|
|
|
|
|
static void SaveSettings()
|
|
static void SaveSettings()
|
|
@@ -1188,9 +1183,6 @@ void NewFrame()
|
|
|
|
|
|
g.LogClipboard.init();
|
|
g.LogClipboard.init();
|
|
|
|
|
|
- g.DrawListPool.create(DRAWLIST_BLOCK_SIZE, g.IO.MallocFn, g.IO.FreeFn);
|
|
|
|
- g.GuiWindowPool.create(GUIWINDOW_BLOCK_SIZE, g.IO.MallocFn, g.IO.FreeFn);
|
|
|
|
-
|
|
|
|
LoadSettings();
|
|
LoadSettings();
|
|
if (!g.IO.Font)
|
|
if (!g.IO.Font)
|
|
{
|
|
{
|
|
@@ -1198,7 +1190,8 @@ void NewFrame()
|
|
const void* fnt_data;
|
|
const void* fnt_data;
|
|
unsigned int fnt_size;
|
|
unsigned int fnt_size;
|
|
ImGui::GetDefaultFontData(&fnt_data, &fnt_size, NULL, NULL);
|
|
ImGui::GetDefaultFontData(&fnt_data, &fnt_size, NULL, NULL);
|
|
- g.IO.Font = new ImBitmapFont();
|
|
|
|
|
|
+ void *buff = g.IO.MallocFn(sizeof(ImBitmapFont));
|
|
|
|
+ g.IO.Font = new(buff) ImBitmapFont();
|
|
g.IO.Font->LoadFromMemory(fnt_data, fnt_size);
|
|
g.IO.Font->LoadFromMemory(fnt_data, fnt_size);
|
|
g.IO.FontHeight = g.IO.Font->GetFontSize();
|
|
g.IO.FontHeight = g.IO.Font->GetFontSize();
|
|
}
|
|
}
|
|
@@ -1319,15 +1312,17 @@ void Shutdown()
|
|
|
|
|
|
for (size_t i = 0; i < g.Windows.size(); i++) {
|
|
for (size_t i = 0; i < g.Windows.size(); i++) {
|
|
g.Windows[i]->~ImGuiWindow();
|
|
g.Windows[i]->~ImGuiWindow();
|
|
- g.GuiWindowPool.free(g.Windows[i]);
|
|
|
|
|
|
+ g.IO.FreeFn(g.Windows[i]);
|
|
}
|
|
}
|
|
g.Windows.clear();
|
|
g.Windows.clear();
|
|
g.CurrentWindowStack.clear();
|
|
g.CurrentWindowStack.clear();
|
|
g.FocusedWindow = NULL;
|
|
g.FocusedWindow = NULL;
|
|
g.HoveredWindow = NULL;
|
|
g.HoveredWindow = NULL;
|
|
g.HoveredWindowExcludingChilds = NULL;
|
|
g.HoveredWindowExcludingChilds = NULL;
|
|
- for (size_t i = 0; i < g.Settings.size(); i++)
|
|
|
|
- delete g.Settings[i];
|
|
|
|
|
|
+ for (size_t i = 0; i < g.Settings.size(); i++) {
|
|
|
|
+ g.Settings[i]->~ImGuiIniData();
|
|
|
|
+ g.IO.FreeFn(g.Settings[i]);
|
|
|
|
+ }
|
|
g.Settings.clear();
|
|
g.Settings.clear();
|
|
g.RenderDrawLists.clear();
|
|
g.RenderDrawLists.clear();
|
|
g.ColorEditModeStorage.Clear();
|
|
g.ColorEditModeStorage.Clear();
|
|
@@ -1338,7 +1333,8 @@ void Shutdown()
|
|
}
|
|
}
|
|
if (g.IO.Font)
|
|
if (g.IO.Font)
|
|
{
|
|
{
|
|
- delete g.IO.Font;
|
|
|
|
|
|
+ g.IO.Font->~ImBitmapFont();
|
|
|
|
+ g.IO.FreeFn(g.IO.Font);
|
|
g.IO.Font = NULL;
|
|
g.IO.Font = NULL;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1348,9 +1344,6 @@ void Shutdown()
|
|
g.PrivateClipboard = NULL;
|
|
g.PrivateClipboard = NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- g.DrawListPool.destroy();
|
|
|
|
- g.GuiWindowPool.destroy();
|
|
|
|
-
|
|
|
|
g.LogClipboard.destroy();
|
|
g.LogClipboard.destroy();
|
|
|
|
|
|
g.Initialized = false;
|
|
g.Initialized = false;
|
|
@@ -1831,7 +1824,7 @@ bool Begin(const char* name, bool* open, ImVec2 size, float fill_alpha, ImGuiWin
|
|
ImGuiWindow* window = FindWindow(name);
|
|
ImGuiWindow* window = FindWindow(name);
|
|
if (!window)
|
|
if (!window)
|
|
{
|
|
{
|
|
- ImGuiWindow *buff = GImGui.GuiWindowPool.alloc();
|
|
|
|
|
|
+ void *buff = g.IO.MallocFn(sizeof(ImGuiWindow));
|
|
IM_ASSERT(buff);
|
|
IM_ASSERT(buff);
|
|
|
|
|
|
if (flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Tooltip))
|
|
if (flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Tooltip))
|