From ec27b82531b4240fcad56ac7dc29d2faac3850c0 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Tue, 4 Mar 2025 12:51:58 +0000 Subject: [PATCH] Fix #11226: Don't draw story page elements that won't be visible. When drawing the story page elements, all of them were drawn even if they are not visible. This can be a significant performance hit for long strings. --- src/story_gui.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/story_gui.cpp b/src/story_gui.cpp index a9108508ea..1880f49730 100644 --- a/src/story_gui.cpp +++ b/src/story_gui.cpp @@ -706,7 +706,11 @@ public: /* Page elements */ this->EnsureStoryPageElementLayout(); for (const LayoutCacheElement &ce : this->layout_cache) { + if (ce.bounds.bottom - scrollpos < fr.top) continue; + y_offset = ce.bounds.top - scrollpos; + if (y_offset > fr.bottom) return; + switch (ce.pe->type) { case SPET_TEXT: y_offset = DrawStringMultiLine(ce.bounds.left, ce.bounds.right, ce.bounds.top - scrollpos, ce.bounds.bottom - scrollpos,