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
39 lines
1.2 KiB
C
39 lines
1.2 KiB
C
#ifndef _GUI_DESKTOP_H
|
|
#define _GUI_DESKTOP_H
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
|
|
#define GUI_TASKBAR_HEIGHT 32
|
|
#define GUI_DESKTOP_ICON_W 72
|
|
#define GUI_DESKTOP_ICON_H 64
|
|
|
|
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);
|
|
void gui_desktop_render_context_menu(void);
|
|
|
|
void gui_desktop_toggle_start_menu(void);
|
|
bool gui_desktop_is_start_menu_open(void);
|
|
void gui_desktop_open_context_menu(int mx, int my);
|
|
void gui_desktop_close_menus(void);
|
|
|
|
// Returns true if the click was consumed by desktop chrome (taskbar, menus,
|
|
// icons) rather than falling through to the window manager.
|
|
bool gui_desktop_handle_click(int mx, int my);
|
|
|
|
// Height of the area windows may occupy (screen minus taskbar).
|
|
int gui_desktop_workarea_height(void);
|
|
|
|
void gui_desktop_request_exit(void);
|
|
int gui_desktop_run(void);
|
|
|
|
#endif // _GUI_DESKTOP_H
|