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.
This commit is contained in:
2026-05-12 18:43:05 +02:00
parent 28ea2fa553
commit bdd64cad07
+9 -7
View File
@@ -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,