Files
SUB-OS/include/kernel/ktime.h
T
subhobhai943andClaude Opus 4.8 2c2e2d536e perf(gui): scene-dirty compositor + cursor overlay + 60 FPS pacer + animations
Rework the compositor so it stops repainting the whole screen every frame,
tripling the frame rate (17 -> 54 FPS at HD) and adding smooth animation.

- Scene-dirty skipping (gui/gui_desktop.c): the full scene is recomposited only
  when something other than the bare pointer changed -- input, an open animation,
  or a ~10 Hz heartbeat for live content (clock, graphs). Idle and pointer-only
  frames skip the recomposite entirely.
- Cursor save-under (gui/gui_cursor.c): the pointer is an overlay that stashes
  and restores the pixels beneath it, so moving the mouse never forces a full
  repaint -- pointer motion runs at the frame cap.
- 60 FPS frame pacer: each iteration is timed against the monotonic clock and
  padded to a 16.666 ms budget with the new ktime_delay_us() (HPET-precise
  busy-wait), giving consistent pacing instead of a free-running spin.
- Window open animation (gui/gui_wm.c): new windows grow from 60% to full size
  with a cubic ease-out over ~160 ms; gui_wm_update() drives it and reports
  while any window is still animating so the compositor keeps redrawing.
- Default display mode set to 1280x720 (HD) -- the sweet spot where the
  software compositor sustains a near-60 FPS cursor with headroom for effects.

Kernel: kernel/time/ktime.c gains ktime_delay_us(), a precise HPET-based delay
(bounded PIT fallback) used by the pacer.

Verified live (screenshotted): boots to 1280x720, logs in, tray reads ~54 FPS
(green) while the pointer moves, no cursor ghosting, windows render cleanly.
Clean build on x86_64/aarch64/armv8i; 0 panics / 0 OOM.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Fh5z6V7nGPbHvqVG5p4CXX
2026-08-25 23:05:44 +05:30

22 lines
742 B
C

#ifndef _KERNEL_KTIME_H
#define _KERNEL_KTIME_H
// Unified monotonic high-resolution clock. Prefers the HPET (nanosecond grade)
// and falls back to the 100 Hz timer tick when no HPET is present.
#include <stdint.h>
#include <stdbool.h>
void ktime_init(void);
uint64_t ktime_ns(void); // nanoseconds since ktime_init
uint64_t ktime_us(void);
uint64_t ktime_ms(void);
const char* ktime_source(void); // "HPET" or "PIT"
bool ktime_is_highres(void); // true when backed by the HPET
// Busy-wait for the given number of microseconds against the monotonic clock.
// Precise when HPET-backed; used by the compositor's 60 FPS frame pacer.
void ktime_delay_us(uint64_t us);
#endif // _KERNEL_KTIME_H