feat: add glyph caching to PygameDisplay for performance #28

Closed
opened 2026-03-18 11:23:50 +00:00 by david · 0 comments
Owner

Summary

Add glyph cache to PygameDisplay to improve rendering performance.

Changes

  • Add _glyph_cache dictionary to cache rendered font surfaces
  • Modify show() to use cached glyphs instead of re-rendering each frame
  • Use blits() for batch rendering (multiple blits in one call)
  • Add comprehensive TestRenderBorder tests to verify border rendering
  • Update NullDisplay.show() to support border=True for headless testing consistency

Performance

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

  • All 553 tests pass (17 skipped)
  • Added 8 new tests for render_border() function
  • Added test test_show_with_border_uses_render_border for TerminalDisplay

Complements issue #25 (terminal display wobble fixes) and #27 (effects_plugins refactor).

## Summary Add glyph cache to PygameDisplay to improve rendering performance. ## Changes - Add `_glyph_cache` dictionary to cache rendered font surfaces - Modify `show()` to use cached glyphs instead of re-rendering each frame - Use `blits()` for batch rendering (multiple blits in one call) - Add comprehensive `TestRenderBorder` tests to verify border rendering - Update `NullDisplay.show()` to support `border=True` for headless testing consistency ## Performance 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 - All 553 tests pass (17 skipped) - Added 8 new tests for `render_border()` function - Added test `test_show_with_border_uses_render_border` for TerminalDisplay ## Related Complements issue #25 (terminal display wobble fixes) and #27 (effects_plugins refactor).
david closed this issue 2026-03-18 22:03:21 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: klubhaus/sideline#28