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:
parent
8583db7225
commit
68f8349fe8
13 changed files with 220 additions and 56 deletions
|
|
@ -172,14 +172,27 @@ protected:
|
|||
void updateRenderTexture();
|
||||
|
||||
public:
|
||||
// Mark this drawable as needing redraw (#116 - propagates up parent chain)
|
||||
void markDirty();
|
||||
// #144: Dirty flag system - content vs composite
|
||||
// content_dirty: THIS drawable's texture needs rebuild (color/text/sprite changed)
|
||||
// composite_dirty: Parent needs to re-composite children (position changed)
|
||||
|
||||
// Mark content as dirty - texture needs rebuild, propagates up
|
||||
void markDirty(); // Legacy method - calls markContentDirty
|
||||
void markContentDirty();
|
||||
|
||||
// Mark only composite as dirty - position changed, texture still valid
|
||||
// Only notifies parent, doesn't set own render_dirty
|
||||
void markCompositeDirty();
|
||||
|
||||
// Check if this drawable needs redraw
|
||||
bool isDirty() const { return render_dirty; }
|
||||
bool isCompositeDirty() const { return composite_dirty; }
|
||||
|
||||
// Clear dirty flag (called after rendering)
|
||||
void clearDirty() { render_dirty = false; }
|
||||
// Clear dirty flags (called after rendering)
|
||||
void clearDirty() { render_dirty = false; composite_dirty = false; }
|
||||
|
||||
protected:
|
||||
bool composite_dirty = true; // #144: Needs re-composite (child positions changed)
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue