Skip to content

Conversation

@No0ne558
Copy link
Contributor

Description

This PR addresses button highlighting issues and introduces memory efficiency optimizations targeted for the Raspberry Pi CM5.

Changes

  • fix: Remove broken static tile cache causing button highlighting bugs
    The static cache optimization in Layer::Rectangle() was fundamentally broken - static variables persisted across all rendering calls, causing stale cache values to be used when different buttons needed different textures.

    • Remove static current_tile, current_origin_x, current_origin_y cache
    • Each Rectangle() call now properly sets XSetTile and XSetTSOrigin
    • Ensures correct texture rendering for all button states
  • fix: Preload all textures to fix button highlighting bug
    The lazy texture loading optimization conflicted with the static tile cache in Layer::Rectangle(), causing buttons to incorrectly show highlighted state.

    • Add PreloadAllTextures() function to load all textures at startup
    • Call PreloadAllTextures() after ResetView() during initialization
    • Ensures consistent Pixmap values before any rendering occurs
  • perf: Add memory efficiency optimizations for Raspberry Pi CM5
    Object Pool System:

    • Add object_pool.hh with thread-safe ObjectPool template
    • Add PooledObject RAII wrapper for automatic return to pool
    • Add BufferPool for fixed-size char buffer pooling
    • Configurable max pool size (default 64 objects)

    Thread Pool & Async I/O:

    • Add thread_pool.hh with ThreadPool for async operations
    • Add WriteBehindBuffer for deferred writes
    • Add CloseAsync() for non-blocking printer operations
    • Add 5-second socket timeouts to prevent hangs

    Memory Management Improvements:

    • Convert Report* to std::unique_ptr in 8 zone files
    • Add O(1) Count() caching for DList/SList (was O(n))
    • Add lazy texture loading with LRU cache in term_view
    • Reduce CharQueue default size from 2MB to 256KB
    • Add RemoveAndDelete() helpers for linked lists
    • Add RAII for KeyValueInputFile/KeyValueOutputFile

    Quick Fixes:

    • Cache term->GetSettings() pointer in hot paths
    • Fix socket leaks in socket.cc and loader_main.cc

    Target: Raspberry Pi CM5 with 2GB RAM optimization
    Tests: 83/83 passing

Testing

All tests pass (83/83). Manual testing on Raspberry Pi CM5 recommended for memory optimizations.

Object Pool System:
- Add src/core/object_pool.hh with thread-safe ObjectPool<T> template
- Add PooledObject<T> RAII wrapper for automatic return to pool
- Add BufferPool<Size> for fixed-size char buffer pooling
- Configurable max pool size (default 64 objects)

Thread Pool & Async I/O:
- Add src/core/thread_pool.hh with ThreadPool for async operations
- Add WriteBehindBuffer for deferred writes
- Add CloseAsync() for non-blocking printer operations
- Add 5-second socket timeouts to prevent hangs

Memory Management Improvements:
- Convert Report* to std::unique_ptr<Report> in 8 zone files
- Add O(1) Count() caching for DList/SList (was O(n))
- Add lazy texture loading with LRU cache in term_view
- Reduce CharQueue default size from 2MB to 256KB
- Add RemoveAndDelete() helpers for linked lists
- Add RAII for KeyValueInputFile/KeyValueOutputFile

Quick Fixes:
- Cache term->GetSettings() pointer in hot paths
- Fix socket leaks in socket.cc and loader_main.cc

Target: Raspberry Pi CM5 with 2GB RAM optimization
Tests: 83/83 passing
The lazy texture loading optimization conflicted with the static tile
cache in Layer::Rectangle(), causing buttons to incorrectly show
highlighted state.

- Add PreloadAllTextures() function to load all textures at startup
- Call PreloadAllTextures() after ResetView() during initialization
- Ensures consistent Pixmap values before any rendering occurs
The static cache optimization in Layer::Rectangle() was fundamentally
broken - static variables persisted across all rendering calls, causing
stale cache values to be used when different buttons needed different
textures.

- Remove static current_tile, current_origin_x, current_origin_y cache
- Each Rectangle() call now properly sets XSetTile and XSetTSOrigin
- Ensures correct texture rendering for all button states
@No0ne558 No0ne558 merged commit e898370 into ViewTouch:dev Jan 10, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants