From bdd64cad07583c525c5ffa7872425a6110e897c3 Mon Sep 17 00:00:00 2001 From: Jon Kazama Date: Tue, 12 May 2026 18:43:05 +0200 Subject: [PATCH] perf(ui): cache GetWindowDrawList per frame in SettingsOverview (F7.3) DrawCard used to call ImGui.GetWindowDrawList once per card, so a frame with 10 settings cards took 10 draw-list lookups. The list is the same for every card in the same frame, so Draw() now resolves it once and passes the pointer down. Pattern parity with ChatLogWindow's frame-local draw-list handling. --- HellionChat/Ui/SettingsOverview.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/HellionChat/Ui/SettingsOverview.cs b/HellionChat/Ui/SettingsOverview.cs index 29b6eb8..be64b06 100644 --- a/HellionChat/Ui/SettingsOverview.cs +++ b/HellionChat/Ui/SettingsOverview.cs @@ -79,11 +79,13 @@ internal sealed class SettingsOverview // 110f accommodates two-line subtexts; wrap width is matched in DrawCard. var cardHeight = 110f; + // One draw-list lookup per frame instead of one per card. + var drawList = ImGui.GetWindowDrawList(); var cardDefs = BuildCardDefs(); for (var i = 0; i < cardDefs.Length; i++) { var (icon, title, subtext) = cardDefs[i]; - DrawCard(i, icon, title, subtext, cardWidth, cardHeight); + DrawCard(i, icon, title, subtext, cardWidth, cardHeight, drawList); if ((i + 1) % columns != 0 && i != cardDefs.Length - 1) ImGui.SameLine(); @@ -96,7 +98,8 @@ internal sealed class SettingsOverview string title, string subtext, float w, - float h + float h, + ImDrawListPtr drawList ) { // BeginGroup makes the card a single layout item so SameLine works @@ -108,8 +111,7 @@ internal sealed class SettingsOverview var hovered = ImGui.IsItemHovered(); var bgColor = hovered ? 0xFF22303Fu : 0xFF1A2538u; - var draw = ImGui.GetWindowDrawList(); - draw.AddRectFilled(cursorBefore, cursorBefore + new Vector2(w, h), bgColor, 4f); + drawList.AddRectFilled(cursorBefore, cursorBefore + new Vector2(w, h), bgColor, 4f); var iconPos = cursorBefore + new Vector2(16f, 12f); var titlePos = cursorBefore + new Vector2(16f, 40f); @@ -120,15 +122,15 @@ internal sealed class SettingsOverview using (_window.Plugin.FontManager.FontAwesome.Push()) { - draw.AddText(iconPos, titleColor, icon.ToIconString()); + drawList.AddText(iconPos, titleColor, icon.ToIconString()); } - draw.AddText(titlePos, titleColor, title); + drawList.AddText(titlePos, titleColor, title); // Subtext wraps at card inner width (16px padding each side) via DrawList // to avoid expanding the group bounds and breaking SameLine in the card row. var subtextWrapWidth = w - 32f; - draw.AddText( + drawList.AddText( ImGui.GetFont(), ImGui.GetFontSize(), subtextPos,