mirror of
https://github.com/subhobhai943/SUB-OS.git
synced 2026-10-25 16:52:29 +00:00
The compositor recomposited and re-uploaded the entire screen on every pass of its loop. At the 1280x720 the desktop actually boots into, gui_gfx_present() memcpy'd 3.6 MB into the framebuffer per frame, and the background underneath it was recomputed pixel by pixel every time. Present only the damage - Keep a RAM shadow of what the framebuffer currently holds and diff the back buffer against it, pushing just the changed span of each row. Reading the shadow costs a RAM access; the framebuffer write it avoids costs far more, and the framebuffer is never read back. - Each row is narrowed to its first and last differing pixel rather than tracked as a set of runs: one memcpy per row keeps the loop tight, and a row that changed in two distant places is rare enough that bridging the gap is cheaper than the bookkeeping. - gui_gfx_invalidate() forces a full push for when something outside the compositor owns the screen, which the desktop calls on entry and on exit around the framebuffer console. Cache the wallpaper - The vertical gradient, the blended grid and the branding text never change between frames, so they are painted once into a cached buffer and blitted back per frame. The cache is keyed on resolution and the grid setting, so toggling the grid from the context menu still repaints it. No drawing code changed: the damage is derived from the frame itself, so every widget, window and app keeps rendering exactly as before. Measured in QEMU at 1280x720: an idle desktop with two windows open went from 921600 pixels per frame to 3609, about 0.4% of a full blit. A screendump of the running desktop is unchanged -- wallpaper, grid, icons, both windows, taskbar and cursor all render identically. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_0161Jh7uCEMLYEMNPsjC1LKf