mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-11-01 01:20:05 +00:00
Lock the ImGui font atlas when processing a frame
This commit is contained in:
parent
d3a3c3db36
commit
2e9f5818cd
4 changed files with 27 additions and 0 deletions
|
|
@ -45,12 +45,19 @@ public:
|
||||||
const std::vector<std::string>& styles);
|
const std::vector<std::string>& styles);
|
||||||
|
|
||||||
std::string fontCachePath_ {};
|
std::string fontCachePath_ {};
|
||||||
|
|
||||||
|
std::shared_mutex imguiFontAtlasMutex_ {};
|
||||||
};
|
};
|
||||||
|
|
||||||
FontManager::FontManager() : p(std::make_unique<Impl>()) {}
|
FontManager::FontManager() : p(std::make_unique<Impl>()) {}
|
||||||
|
|
||||||
FontManager::~FontManager() {};
|
FontManager::~FontManager() {};
|
||||||
|
|
||||||
|
std::shared_mutex& FontManager::imgui_font_atlas_mutex()
|
||||||
|
{
|
||||||
|
return p->imguiFontAtlasMutex_;
|
||||||
|
}
|
||||||
|
|
||||||
std::shared_ptr<types::ImGuiFont>
|
std::shared_ptr<types::ImGuiFont>
|
||||||
FontManager::GetImGuiFont(const std::string& family,
|
FontManager::GetImGuiFont(const std::string& family,
|
||||||
const std::vector<std::string>& styles,
|
const std::vector<std::string>& styles,
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
#include <scwx/qt/types/imgui_font.hpp>
|
#include <scwx/qt/types/imgui_font.hpp>
|
||||||
|
|
||||||
|
#include <shared_mutex>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
namespace scwx
|
namespace scwx
|
||||||
|
|
@ -19,6 +21,8 @@ public:
|
||||||
explicit FontManager();
|
explicit FontManager();
|
||||||
~FontManager();
|
~FontManager();
|
||||||
|
|
||||||
|
std::shared_mutex& imgui_font_atlas_mutex();
|
||||||
|
|
||||||
std::shared_ptr<types::ImGuiFont>
|
std::shared_ptr<types::ImGuiFont>
|
||||||
GetImGuiFont(const std::string& family,
|
GetImGuiFont(const std::string& family,
|
||||||
const std::vector<std::string>& styles,
|
const std::vector<std::string>& styles,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include <scwx/qt/map/map_widget.hpp>
|
#include <scwx/qt/map/map_widget.hpp>
|
||||||
#include <scwx/qt/gl/gl.hpp>
|
#include <scwx/qt/gl/gl.hpp>
|
||||||
|
#include <scwx/qt/manager/font_manager.hpp>
|
||||||
#include <scwx/qt/manager/placefile_manager.hpp>
|
#include <scwx/qt/manager/placefile_manager.hpp>
|
||||||
#include <scwx/qt/manager/radar_product_manager.hpp>
|
#include <scwx/qt/manager/radar_product_manager.hpp>
|
||||||
#include <scwx/qt/manager/settings_manager.hpp>
|
#include <scwx/qt/manager/settings_manager.hpp>
|
||||||
|
|
@ -1028,6 +1029,10 @@ void MapWidget::paintGL()
|
||||||
// Setup ImGui Frame
|
// Setup ImGui Frame
|
||||||
ImGui::SetCurrentContext(p->imGuiContext_);
|
ImGui::SetCurrentContext(p->imGuiContext_);
|
||||||
|
|
||||||
|
// Lock ImGui font atlas prior to new ImGui frame
|
||||||
|
std::shared_lock imguiFontAtlasLock {
|
||||||
|
manager::FontManager::Instance().imgui_font_atlas_mutex()};
|
||||||
|
|
||||||
// Start ImGui Frame
|
// Start ImGui Frame
|
||||||
ImGui_ImplQt_NewFrame(this);
|
ImGui_ImplQt_NewFrame(this);
|
||||||
ImGui_ImplOpenGL3_NewFrame();
|
ImGui_ImplOpenGL3_NewFrame();
|
||||||
|
|
@ -1059,6 +1064,9 @@ void MapWidget::paintGL()
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
|
||||||
|
// Unlock ImGui font atlas after rendering
|
||||||
|
imguiFontAtlasLock.unlock();
|
||||||
|
|
||||||
// Paint complete
|
// Paint complete
|
||||||
Q_EMIT WidgetPainted();
|
Q_EMIT WidgetPainted();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#include <scwx/qt/ui/imgui_debug_widget.hpp>
|
#include <scwx/qt/ui/imgui_debug_widget.hpp>
|
||||||
|
#include <scwx/qt/manager/font_manager.hpp>
|
||||||
#include <scwx/qt/model/imgui_context_model.hpp>
|
#include <scwx/qt/model/imgui_context_model.hpp>
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
@ -109,6 +110,10 @@ void ImGuiDebugWidget::paintGL()
|
||||||
{
|
{
|
||||||
ImGui::SetCurrentContext(p->currentContext_);
|
ImGui::SetCurrentContext(p->currentContext_);
|
||||||
|
|
||||||
|
// Lock ImGui font atlas prior to new ImGui frame
|
||||||
|
std::shared_lock imguiFontAtlasLock {
|
||||||
|
manager::FontManager::Instance().imgui_font_atlas_mutex()};
|
||||||
|
|
||||||
ImGui_ImplQt_NewFrame(this);
|
ImGui_ImplQt_NewFrame(this);
|
||||||
ImGui_ImplOpenGL3_NewFrame();
|
ImGui_ImplOpenGL3_NewFrame();
|
||||||
|
|
||||||
|
|
@ -131,6 +136,9 @@ void ImGuiDebugWidget::paintGL()
|
||||||
|
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
|
||||||
|
// Unlock ImGui font atlas after rendering
|
||||||
|
imguiFontAtlasLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ui
|
} // namespace ui
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue