mirror of
https://github.com/subhobhai943/SUB-OS.git
synced 2026-10-25 16:52:29 +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);
|
||||
|
||||
@@ -42,6 +42,18 @@ void gui_gfx_draw_string_shadow(int x, int y, const char* str, uint32_t fg, uint
|
||||
void gui_gfx_draw_string_16_shadow(int x, int y, const char* str, uint32_t fg, uint32_t shadow);
|
||||
void gui_gfx_draw_shadow(int x, int y, int w, int h, int blur);
|
||||
void gui_gfx_blit(int dx, int dy, int w, int h, const uint32_t* src_buf);
|
||||
|
||||
// Push the composited frame to the display. Only the pixels that differ from
|
||||
// the previous frame are written, so an idle desktop costs almost no
|
||||
// framebuffer traffic.
|
||||
void gui_gfx_present(void);
|
||||
|
||||
// Force the next present to push the whole screen. Needed whenever something
|
||||
// outside the compositor has drawn over the framebuffer, such as the kernel
|
||||
// console before the desktop takes the display back.
|
||||
void gui_gfx_invalidate(void);
|
||||
|
||||
// Pixels written to the framebuffer by the last present. Diagnostic only.
|
||||
uint64_t gui_gfx_last_present_pixels(void);
|
||||
|
||||
#endif // _GUI_GFX_H
|
||||
Reference in new issue
Block a user