1
0
mirror of synced 2024-11-24 15:50:16 +01:00

fix: Drastically improve pattern highlighting performance

This commit is contained in:
WerWolv 2022-07-01 19:05:53 +02:00
parent ef5fbba56b
commit 2d982e2088
3 changed files with 30 additions and 32 deletions

@ -1 +1 @@
Subproject commit f33fc83cedb1e74bd4f583c90ff77b397e7b5c03
Subproject commit 661ecab439922a923bb6ce1c01546044983d3bac

View File

@ -173,12 +173,12 @@ namespace hex::init {
auto meanScale = std::midpoint(xScale, yScale);
// On Macs with a retina display (basically all modern ones we care about), the OS reports twice
// the actual monitor scale for some obscure reason. Get rid of this here so ImHex doesn't look
// extremely huge with native scaling on macOS.
#if defined(OS_MACOS)
meanScale /= 2;
#endif
// On Macs with a retina display (basically all modern ones we care about), the OS reports twice
// the actual monitor scale for some obscure reason. Get rid of this here so ImHex doesn't look
// extremely huge with native scaling on macOS.
#if defined(OS_MACOS)
meanScale /= 2;
#endif
if (meanScale <= 0.0) {
meanScale = 1.0;

View File

@ -230,43 +230,39 @@ namespace hex::plugin::builtin {
});
ImHexApi::HexEditor::addBackgroundHighlightingProvider([](u64 address, const u8 *data, size_t size) -> std::optional<color_t> {
ImHexApi::HexEditor::addBackgroundHighlightingProvider([this](u64 address, const u8 *data, size_t size) -> std::optional<color_t> {
hex::unused(data, size);
const auto &patterns = ImHexApi::Provider::get()->getPatternLanguageRuntime().getPatterns();
for (const auto &pattern : patterns) {
auto child = pattern->getPattern(address);
if (child != nullptr) {
return child->getColor();
}
}
if (this->m_runningEvaluators != 0)
return std::nullopt;
return std::nullopt;
const auto pattern = ImHexApi::Provider::get()->getPatternLanguageRuntime().getPattern(address, size);
if (pattern != nullptr)
return pattern->getColor();
else
return std::nullopt;
});
ImHexApi::HexEditor::addTooltipProvider([this](u64 address, const u8 *data, size_t size) {
hex::unused(data, size);
auto &patterns = ImHexApi::Provider::get()->getPatternLanguageRuntime().getPatterns();
for (auto &pattern : patterns) {
auto child = pattern->getPattern(address);
if (child != nullptr) {
ImGui::BeginTooltip();
auto pattern = ImHexApi::Provider::get()->getPatternLanguageRuntime().getPattern(address);
if (pattern != nullptr) {
ImGui::BeginTooltip();
if (ImGui::BeginTable("##tooltips", 1, ImGuiTableFlags_NoHostExtendX | ImGuiTableFlags_RowBg | ImGuiTableFlags_NoClip)) {
ImGui::TableNextRow();
ImGui::TableNextColumn();
if (ImGui::BeginTable("##tooltips", 1, ImGuiTableFlags_NoHostExtendX | ImGuiTableFlags_RowBg | ImGuiTableFlags_NoClip)) {
ImGui::TableNextRow();
ImGui::TableNextColumn();
this->drawPatternTooltip(child);
this->drawPatternTooltip(pattern);
auto tooltipColor = (child->getColor() & 0x00FF'FFFF) | 0x7000'0000;
ImGui::PushStyleColor(ImGuiCol_TableRowBg, tooltipColor);
ImGui::PushStyleColor(ImGuiCol_TableRowBgAlt, tooltipColor);
ImGui::EndTable();
ImGui::PopStyleColor(2);
}
ImGui::EndTooltip();
auto tooltipColor = (pattern->getColor() & 0x00FF'FFFF) | 0x7000'0000;
ImGui::PushStyleColor(ImGuiCol_TableRowBg, tooltipColor);
ImGui::PushStyleColor(ImGuiCol_TableRowBgAlt, tooltipColor);
ImGui::EndTable();
ImGui::PopStyleColor(2);
}
ImGui::EndTooltip();
}
});
}
@ -787,6 +783,8 @@ namespace hex::plugin::builtin {
this->m_lastEvaluationError = runtime.getError();
}
runtime.flattenPatterns();
this->m_lastEvaluationLog = runtime.getConsoleLog();
this->m_lastEvaluationOutVars = runtime.getOutVariables();
this->m_runningEvaluators--;