You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This introduces mechanisms to eliminate per-frame heap allocations from
the rendering hot path and provide memory visibility for constrained
devices:
Scratch arena: a 32 KB bump allocator on twin_screen_t, reset per screen
update. Polygon edge arrays (poly.c), composite mask pixmaps (path.c),
and convex hull arrays (hull.c) allocate from the arena first, falling
back to malloc only when exhausted. Save/restore semantics support
nested temporary allocations.
Reusable object caches: a 4-element path cache (acquire/release) avoids
repeated create/destroy for stroke rendering temporaries. A grow-only A8
mask cache on twin_screen_t eliminates per-composite malloc for masks
exceeding the scratch arena.
Inline path storage: struct _twin_path embeds 64-point and 4-sublen
arrays, avoiding heap allocation entirely for typical small paths
(rectangles, circles, rounded rectangles). Growth from inline to heap
uses malloc+memcpy; destroy only frees heap-allocated arrays.
Memory tracking (CONFIG_MEMORY_STATS, default y): twin_malloc/twin_free
wrapper macros route all core allocations through a tracking layer that
maintains current/peak byte counters and alloc/free counts. The tracker
uses a linear-scan table with inline storage -- no heap allocation for
bookkeeping itself. Public API: twin_memory_{get_info,reset_peak}.
twin_destroy() logs stats after teardown. CI workflow captures memory
statistics from headless test runs.
Budget-aware APIs: twin_pixmap_create_budget() computes the largest
pixmap fitting a byte budget while preserving aspect ratio.
twin_tvg_to_pixmap_budget() auto-scales TVG rendering to fit a memory
budget. CONFIG_TVG_MEMORY_BUDGET Kconfig option caps per-image memory.
The ARGB32-only restriction on TVG rendering is removed -- RGB16 now
works, halving memory for opaque content.
Additional optimizations: the image viewer app evicts previous pixmaps
instead of caching all six TVG images simultaneously. Background
loading skips full-screen scaling when the source fits within screen
dimensions. twin_destroy() centralizes screen teardown that backends
previously omitted.
Closes#149
0 commit comments