The battery pass: paint less, wake less
- opaque canvas: the compositor stops alpha-blending 2.5Mpx at 60Hz - settled modals and the death summary idle at 20-24 fps; play untouched - TUNE.lowPower caps RES at 3 (-44% pixels/frame), flippable live Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
911035af00
commit
3b6a82c97d
6 files changed
+43
-4
No files matched your search
@@ -18,9 +18,19 @@ let last = performance.now();
|
||||
// next frame without the scene moving on underneath you. Halting rAF instead (the old test recipe)
|
||||
// freezes the picture too, which is useless for looking at a shot.
|
||||
let paused = false;
|
||||
// CALM STATES RUN SLOW. The battery bill is fill-rate × frame-rate, and two screens can sit on a
|
||||
// phone for minutes while fully static: a SETTLED modal (the world is frozen behind it — only the
|
||||
// blink still moves) and the death summary once its fade and gore have played out. 20-odd fps
|
||||
// there is invisible and thirds the drain; live play stays at TUNE.fps, untouched — the 60 was a
|
||||
// feel decision and this deliberately never applies to anything that moves.
|
||||
const calmFps = () => G.modal && G.modal.in >= 1 ? 20
|
||||
: G.mode === 'eaten' && G.eatenT > EATEN_RESTART + 1 ? 24 : 0;
|
||||
let lowPowerApplied = false; // the last lowPower state fitViewport was run under (T-panel flips it live)
|
||||
function frame(now) {
|
||||
requestAnimationFrame(frame); // schedule FIRST: one bad frame must never kill the loop (a thrown error froze the game for good)
|
||||
if (TUNE.fps && now - last < 1000 / TUNE.fps - 2) return; // frame cap (battery): skip RAF ticks until it's our beat
|
||||
if ((TUNE.lowPower >= 0.5) !== lowPowerApplied) { lowPowerApplied = TUNE.lowPower >= 0.5; fitViewport(); }
|
||||
const cap = calmFps() || TUNE.fps;
|
||||
if (cap && now - last < 1000 / cap - 2) return; // frame cap (battery): skip RAF ticks until it's our beat
|
||||
// THE MENU IS OPAQUE (#intro: fixed, inset 0, solid background). Painting the whole court at RES
|
||||
// density behind it — for the minutes a phone idles on the splash and stats screens — was pure
|
||||
// battery burn nobody could see. The world holds still too; nothing on it predates the menu.
|
||||
|
||||
Reference in new issue
Block a user