mirror of
https://github.com/subhobhai943/SUB-OS.git
synced 2026-10-26 00:52:50 +00:00
perf(gui): Present only changed pixels and cache the wallpaper
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
This commit is contained in:
1 parent
65b7a709cc
commit
2136b6fb4c
4 files changed
+199
-11
No files matched your search
@@ -11,6 +11,10 @@
|
||||
void gui_desktop_init(void);
|
||||
|
||||
void gui_desktop_render_background(void);
|
||||
|
||||
// Drop the cached wallpaper so the next background render repaints it. Needed
|
||||
// when the resolution changes or the framebuffer is handed to another owner.
|
||||
void gui_desktop_invalidate_background(void);
|
||||
void gui_desktop_render_icons(void);
|
||||
void gui_desktop_render_taskbar(void);
|
||||
void gui_desktop_render_start_menu(void);
|
||||
|
||||
Reference in new issue
Block a user