From c1b289cc27eafb2e170af87bd9b3be64979a6120 Mon Sep 17 00:00:00 2001 From: DanS Date: Tue, 13 Oct 2026 08:23:30 -0500 Subject: [PATCH] perf(console): cull off-screen wrapped rows A long wrapped console line could extend far past the viewport, yet every sub-row was still measured and drawn. - Sub-rows that fall entirely outside the clip rect are now skipped. The per-row ordinal still advances for a culled row, so scanline parity is unchanged. No visible change; only off-screen rows are skipped. Co-Authored-By: Claude Opus 4.8 --- src/ui/windows/console_tab.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/ui/windows/console_tab.cpp b/src/ui/windows/console_tab.cpp index b00fffe..8c72013 100644 --- a/src/ui/windows/console_tab.cpp +++ b/src/ui/windows/console_tab.cpp @@ -1064,6 +1064,8 @@ void ConsoleTab::drawVisibleLines(float padX, float lineHeight, bool hasTextFilt ImDrawList* dl = ImGui::GetWindowDrawList(); ImU32 selColor = WithAlpha(Secondary(), 80); + const float clipMinY = dl->GetClipRectMin().y; + const float clipMaxY = dl->GetClipRectMax().y; // A fold triangle clicked this frame; applied after the loop so we don't mutate the model // mid-draw. -1 = none. @@ -1165,6 +1167,15 @@ void ConsoleTab::drawVisibleLines(float padX, float lineHeight, bool hasTextFilt const char* segStart = line.text.c_str() + seg.byteStart; const char* segEnd = line.text.c_str() + seg.byteEnd; + // Row-granularity cull: a long wrapped line may extend far past the viewport, so skip + // sub-rows entirely outside the clip rect. The ordinal still advances once per sub-row + // (culled or not) so scanline parity is unchanged. + const bool rowVisible = rowY + seg.height >= clipMinY && rowY <= clipMaxY; + if (!rowVisible) { + ++scanRowOrdinal; + continue; + } + if (s_scanline_enabled && lineHeight > 0.0f) { scanline_rows_.push_back({rowY, rowY + seg.height, scanRowOrdinal}); }