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
@@ -58,7 +58,10 @@ const IS_TOUCH = matchMedia('(pointer: coarse)').matches; // hoisted: a matchMed
|
||||
// nearly double the pixels it can show, on exactly the hardware least able to afford it. The same
|
||||
// near-1:1 logic per tier: dpr 3 -> 4, dpr 2 -> 3, dpr 1 -> 2.
|
||||
// THIS IS THE FIRST KNOB TO TURN DOWN if the phone ever stutters: it is the whole fill-rate budget.
|
||||
export const RES = Math.max(2, Math.min(4, Math.ceil((devicePixelRatio || 3) * 1.35)));
|
||||
// `let`, not const: TUNE.lowPower caps it at 3 live (fitViewport re-reads on every fit) — importers
|
||||
// see the change through the module binding.
|
||||
const RES_AUTO = Math.max(2, Math.min(4, Math.ceil((devicePixelRatio || 3) * 1.35)));
|
||||
export let RES = RES_AUTO;
|
||||
export let W = 480, H = 270;
|
||||
|
||||
// Split responsibility, and the split is deliberate:
|
||||
@@ -111,6 +114,10 @@ function fitBox() {
|
||||
|
||||
export function fitViewport() { // landscape 480x270; portrait 270 wide and as TALL as the phone is
|
||||
fitBox();
|
||||
// battery saver: RES 4 -> 3 is −44% of pixels painted per frame, by far the biggest lever there
|
||||
// is. Sprites are 224px sources, so at 3 they still draw at-or-below 1:1 — softer than 4, never
|
||||
// mushy. main.js re-calls fitViewport when the panel flips the knob.
|
||||
RES = TUNE.lowPower >= 0.5 ? Math.min(3, RES_AUTO) : RES_AUTO;
|
||||
const portrait = (cv.clientHeight || innerHeight) > (cv.clientWidth || innerWidth);
|
||||
// Portrait height ADAPTS to the device. A fixed 270x480 is 9:16, but a modern iPhone is taller
|
||||
// (~390x844 = 0.46), so width bound the fit and ~150 CSS px of screen went unused at the bottom.
|
||||
|
||||
Reference in new issue
Block a user