forked from genewildish/Mainline
feat: add glyph caching to PygameDisplay for performance #28
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Add glyph cache to PygameDisplay to improve rendering performance.
Changes
_glyph_cachedictionary to cache rendered font surfacesshow()to use cached glyphs instead of re-rendering each frameblits()for batch rendering (multiple blits in one call)TestRenderBordertests to verify border renderingNullDisplay.show()to supportborder=Truefor headless testing consistencyPerformance
Reduces per-frame overhead from O(n) font.render() calls to O(1) for repeated characters.
Expected improvement: 2-5x faster rendering, enabling 60fps+ on typical content.
Testing
render_border()functiontest_show_with_border_uses_render_borderfor TerminalDisplayRelated
Complements issue #25 (terminal display wobble fixes) and #27 (effects_plugins refactor).