feat: Implement texture caching system with dirty flag optimization (closes #144)

- Add cache_subtree property on Frame for opt-in RenderTexture caching
- Add PyTexture::from_rendered() factory for runtime texture creation
- Add snapshot= parameter to Sprite for creating sprites from Frame content
- Implement content_dirty vs composite_dirty distinction:
  - markContentDirty(): content changed, invalidate self and ancestors
  - markCompositeDirty(): position changed, ancestors need recomposite only
- Update all UIDrawable position setters to use markCompositeDirty()
- Add quick exit workaround for cleanup segfaults

Benchmark: deep_nesting_cached is 3.7x faster (0.09ms vs 0.35ms)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
John McCardle 2025-11-28 19:30:24 -05:00
commit 68f8349fe8
13 changed files with 220 additions and 56 deletions

View file

@ -338,9 +338,14 @@ void GameEngine::run()
running = false;
}
}
// Clean up before exiting the run loop
cleanup();
// #144: Quick exit to avoid cleanup segfaults in Python/C++ destructor ordering
// This is a pragmatic workaround - proper cleanup would require careful
// attention to shared_ptr cycles and Python GC interaction
std::_Exit(0);
}
std::shared_ptr<Timer> GameEngine::getTimer(const std::string& name)