impr: Drastically reduce font-related memory usage

This commit is contained in:
WerWolv
2025-02-10 12:02:05 +01:00
parent e1580e51cf
commit 02b5df03ab
4 changed files with 41 additions and 4 deletions

View File

@@ -53,6 +53,36 @@ namespace hex::fonts {
FontAtlas(const FontAtlas &) = delete;
FontAtlas &operator=(const FontAtlas &) = delete;
FontAtlas(FontAtlas &&other) noexcept {
m_fontAtlas = other.m_fontAtlas;
other.m_fontAtlas = nullptr;
m_defaultConfig = other.m_defaultConfig;
m_fontSizes = std::move(other.m_fontSizes);
m_fontConfigs = std::move(other.m_fontConfigs);
m_glyphRange = std::move(other.m_glyphRange);
m_fontData = std::move(other.m_fontData);
}
FontAtlas& operator=(FontAtlas &&other) noexcept {
if (this != &other) {
if (m_fontAtlas != nullptr) {
IM_DELETE(m_fontAtlas);
}
m_fontAtlas = other.m_fontAtlas;
other.m_fontAtlas = nullptr;
m_defaultConfig = other.m_defaultConfig;
m_fontSizes = std::move(other.m_fontSizes);
m_fontConfigs = std::move(other.m_fontConfigs);
m_glyphRange = std::move(other.m_glyphRange);
m_fontData = std::move(other.m_fontData);
}
return *this;
}
~FontAtlas() {
if (m_fontAtlas != nullptr) {
m_fontAtlas->Locked = false;