Depth effects

This commit is contained in:
James Babcock committed 2026-09-22 10:59:51 -07:00
1 parent 4320021222
commit 392554dd37
26 files changed
+623 -136

No files matched your search

+1 -1
View File
@@ -26,7 +26,7 @@ export type FirmwareInfo = {
};
/** The Faceclaw firmware revision this build of the app needs. */
export const REQUIRED_FACECLAW_FIRMWARE_VERSION = 25;
export const REQUIRED_FACECLAW_FIRMWARE_VERSION = 26;
const FACECLAW_PREFIX = "Faceclaw/";
const LEGACY_PREFIX = "EVENCFW";
+34 -34
View File
@@ -19,12 +19,12 @@ export type FirmwarePatchSet = {
export const CFW_PATCH_SET: FirmwarePatchSet = {
"base": "g2_2.3.0.24.bin",
"baseSha256": "187ccf2bcc5c17a212106e8a376745511e8289c4232b634a7ea94b9bf25a0979",
"outputSha256": "986930903c6ea41ad7fd7ed15c73c0a1af00cc9b58604abfe2092a79745bb641",
"outputSha256": "dc9808a442dd475f3cb2c2945a5afa1408458222842cd9fef6288e435920c9b0",
"patches": [
{
"offset": 1045797,
"old": "38b584b0",
"new": "5cf337be",
"new": "5cf339be",
"desc": "ring receiver entry: timestamped unfiltered reports under framebuffer lease"
},
{
@@ -36,49 +36,49 @@ export const CFW_PATCH_SET: FirmwarePatchSet = {
{
"offset": 1437923,
"old": "fef788ff",
"new": "fdf246fb",
"new": "fdf248fb",
"desc": "cfw_ancs_event"
},
{
"offset": 1437951,
"old": "fef7e8fb",
"new": "fdf280f8",
"new": "fdf282f8",
"desc": "cfw_ancs_open"
},
{
"offset": 1437969,
"old": "fef7e7fb",
"new": "fdf297f8",
"new": "fdf299f8",
"desc": "cfw_ancs_close"
},
{
"offset": 1388387,
"old": "39694d00",
"new": "755e7d00",
"new": "795e7d00",
"desc": "connection-bound ANCS EUS write callback"
},
{
"offset": 971497,
"old": "fff717f8",
"new": "6ef367ff",
"new": "6ef369ff",
"desc": "bl faceclaw_input_bridge_received (ring relay and ordered private transport before worker pool)"
},
{
"offset": 971845,
"old": "fef769ff",
"new": "6ef3b9fe",
"new": "6ef3bbfe",
"desc": "bl faceclaw_input_bridge_received (ring relay and ordered private transport before worker pool)"
},
{
"offset": 979579,
"old": "fdf74ef8",
"new": "6cf39eff",
"new": "6cf3a0ff",
"desc": "bl faceclaw_input_bridge_received (ring relay and ordered private transport before worker pool)"
},
{
"offset": 1428895,
"old": "f8f76cfd",
"new": "fcf292f8",
"new": "fcf294f8",
"desc": "bl cfw_receive_packet (private SID-f0 probe before TPL reassembly)"
},
{
@@ -108,145 +108,145 @@ export const CFW_PATCH_SET: FirmwarePatchSet = {
{
"offset": 1248487,
"old": "d4f712fb",
"new": "2af3bef8",
"new": "2af3c0f8",
"desc": "bl settings_send_wrapper (append caps field 100)"
},
{
"offset": 1246183,
"old": "f5f7e2f8",
"new": "2af360fa",
"new": "2af362fa",
"desc": "bl settings_decode_wrapper (Faceclaw lease field 101)"
},
{
"offset": 975219,
"old": "02f083fc",
"new": "6cf3c2fa",
"new": "6cf3c4fa",
"desc": "bl faceclaw_display_start @ 0x467d68 (fail-open wake takeover)"
},
{
"offset": 975411,
"old": "02f023fc",
"new": "6cf330fb",
"new": "6cf332fb",
"desc": "bl faceclaw_display_start_headup @ 0x467e28 (fail-open wake takeover)"
},
{
"offset": 975103,
"old": "07f085fb",
"new": "6df370ff",
"new": "6df372ff",
"desc": "bl headup_gate (head-up sensor event -> EvenHub sys event 12 under lease)"
},
{
"offset": 830549,
"old": "19f03efb",
"new": "91f31ff9",
"new": "91f321f9",
"desc": "bl gesture_ring_press_mode (observe ring touch-down, preserve stock dispatch)"
},
{
"offset": 830795,
"old": "1ff071ff",
"new": "91f3d8f8",
"new": "91f3daf8",
"desc": "bl gesture_press (owned event 9 before stock menu gate)"
},
{
"offset": 830887,
"old": "1ff043ff",
"new": "91f3d2f8",
"new": "91f3d4f8",
"desc": "bl gesture_short_long (Faceclaw lease gates event 11 vs stock Menu path)"
},
{
"offset": 831763,
"old": "1ff08dfd",
"new": "90f308ff",
"new": "90f30aff",
"desc": "bl gesture_release (owned event 10 before stock menu gate)"
},
{
"offset": 1570209,
"old": "7fb50600",
"new": "dbf24fbc",
"new": "dbf251bc",
"desc": "even_ai_display_ctrl entry -> conditional Faceclaw lease trampoline"
},
{
"offset": 1051545,
"old": "f6f787f9",
"new": "55f3fbfb",
"new": "55f3fdfb",
"desc": "bl display_copy_hook @ 0x47a78e (640x480 direct framebuffer)"
},
{
"offset": 1051861,
"old": "f6f7e9f8",
"new": "55f35dfb",
"new": "55f35ffb",
"desc": "bl display_copy_hook @ 0x47a8ca (640x480 direct framebuffer)"
},
{
"offset": 1262237,
"old": "d9f7d0fd",
"new": "26f333f9",
"new": "26f335f9",
"desc": "bl faceclaw_send_wear_event @ 0x4ade92 (outside onboarding)"
},
{
"offset": 1262337,
"old": "d9f79efd",
"new": "26f301f9",
"new": "26f303f9",
"desc": "bl faceclaw_send_wear_event @ 0x4adef6 (outside onboarding)"
},
{
"offset": 1309405,
"old": "67f02dff",
"new": "1af319fa",
"new": "1af31bfa",
"desc": "bl compass_decode_capture (sample-matched GAF diagnostics)"
},
{
"offset": 1307865,
"old": "fff7c9fb",
"new": "1af397fd",
"new": "1af399fd",
"desc": "bl compass_report_event (stock UI + heading with diagnostics over BLE)"
},
{
"offset": 1300937,
"old": "00210170",
"new": "1cf37dfa",
"new": "1cf37ffa",
"desc": "bl compass_preserve_accuracy (retain magnetic calibration under Faceclaw framebuffer lease)"
},
{
"offset": 4537963,
"old": "",
"new": "b0b581ea00039b0701d0034637e0c2b110f0030315d000f1010ca2f1010e0023cc5c9e45c45403f1010404d0634413f003032346f4d121440319121b102a14d302e00346102a10d3d1f800c0d1f804e0cc688d68103adc609d60c3f804e043f810cb0f2a01f11001eed8042a07d300bf51f8045b043a032a43f8045bf8d8002a08bfb0bd0139013b11f8015f013a03f8015ff9d1b0bd00bf884218bf002a00d1704710b50b1a38bf431a934207d288420ad281ea00039b0726d0034669e0fff79fffbde81040704781ea000300eb020c9b0701eb020e42d15fea8c732bd0a0f1010c00bf8b1813f801ec8418531e04f801ec04d0624412f003021a46f2d101eb030e00eb030c17e0830736d0a2f1010c00f1010e002300bfcc5c9c45c45403f1010404d0734413f003032346f4d1121b2144031922e01346042b0ed3aef10402acf1040152f80449043b032b41f80449f8d802f1040e01f1040c1a4653b1aef10101acf1010300bf11f80149013a03f80149f9d1bde8104070470346042a06d351f8044b043a032a43f8044bf8d8002af0d00139013b00bf11f8014f013a03f8014ff9d1e6e700bf2de9f04fc5b04ff690454ef66c6b4ff29c591446cff6ff75ccf2ff0bc2f229094ff6ff78002701260d93cde90e0106e048f2a351c0f24501bff32f8f8847d9f800a0bff35f8fd9f800000321cff680710140b1f1005fbff35f8f03d10168594500f0ac804ff45c7007f0b4f8002800f0eb8129464218373182f8707382f8717382f8727382f8737382f8747382f8757382f8767382f8777382f8787382f8797382f87a7382f87b7382f87c7382f87d7382f87e7382f87f7382f8807382f8817382f8827382f8837382f8847382f8857382f8867382f8877382f8887382f8897382f88a7382f88b7382f88c7382f88d7382f88e7382f88f7382f8907382f8917382f8927382f8937382f8947382f8957382f8967382f8977382f8987382f8997382f89a7382f89b7382f89c7382f89d7382f89e7382f89f7382f8a07382f8a17382f8a27382f8a37382f8a47382f8a57382f8a6738ed1c0f800b08672a0f81c80a0f81e80a0f82080a0f82280a0f82480a0f82680a0f82880a0f82a80a0f82c80a0f82e80a0f83080a0f83280a0f83480a0f83680a0f83880a0f83a8059e8001f51457ff445afbff35f8f00bf49e8000121b159e8001f5145f8d039e70f99012641ea04410024c0f8701206e048f2a351c0f24501bff32f8f8847d9f80070bff35f8fd9f800000321cff680710140b1f1005fbff35f8f03d10168594500f0ac804ff45c7006f0e6ff002800f01d8129464218373182f8704382f8714382f8724382f8734382f8744382f8754382f8764382f8774382f8784382f8794382f87a4382f87b4382f87c4382f87d4382f87e4382f87f4382f8804382f8814382f8824382f8834382f8844382f8854382f8864382f8874382f8884382f8894382f88a4382f88b4382f88c4382f88d4382f88e4382f88f4382f8904382f8914382f8924382f8934382f8944382f8954382f8964382f8974382f8984382f8994382f89a4382f89b4382f89c4382f89d4382f89e4382f89f4382f8a04382f8a14382f8a24382f8a34382f8a44382f8a54382f8a6438ed1c0f800b08672a0f81c80a0f81e80a0f82080a0f82280a0f82480a0f82680a0f82880a0f82a80a0f82c80a0f82e80a0f83080a0f83280a0f83480a0f83680a0f83880a0f83a8059e8001fb9427ff445afbff35f8f00bf49e8000121b159e8001fb942f8d039e7d0f874a242f6f766c0f24406baf1000fbff35f8f4ad006f19a0250464ff0ff314ff0ff379047002840f08f810f98002861d00e980778a7f1170002285bd80f980c2840f078810e9e7078b178084300f07281f0780138022800f26d81b279f379747a42ea0322337a307942ea0342717942ea0463b27af67a192f42ea062200f07f83172f40f09583002a40f05481fe2800f0cb87812800f0bd87002840f0d28751ea030040f0478101f062b904460020b047e8b104f51d7151e800afbaf1000f0cd1bff35f8f00bf41e80002002a00f0e78051e800afbaf1000ff5d00021bff32f8f0029bff35f8f00f0d680824692e74ff0ff3729e147f6df40c0f24f008047002701261197adf8487006e048f2a351c0f24501bff32f8f8847d9f80040bff35f8fd9f800000321cff680710140b1f1005fbff35f8f03d10168594500f0b3804ff45c7006f09afe002800f0ab8029464218373182f8707382f8717382f8727382f8737382f8747382f8757382f8767382f8777382f8787382f8797382f87a7382f87b7382f87c7382f87d7382f87e7382f87f7382f8807382f8817382f8827382f8837382f8847382f8857382f8867382f8877382f8887382f8897382f88a7382f88b7382f88c7382f88d7382f88e7382f88f7382f8907382f8917382f8927382f8937382f8947382f8957382f8967382f8977382f8987382f8997382f89a7382f89b7382f89c7382f89d7382f89e7382f89f7382f8a07382f8a17382f8a27382f8a37382f8a47382f8a57382f8a6738ed1c0f800b08672a0f81c80a0f81e80a0f82080a0f82280a0f82480a0f82680a0f82880a0f82a80a0f82c80a0f82e80a0f83080a0f83280a0f83480a0f83680a0f83880a0f83a8059e8001fa1427ff445afbff35f8f00bf49e8000159b159e8001fa142f8d039e706f5a9718847bae601211ee700200e9999b10f9a8ab1097801f07f02b2f10b0418bf0124b2f11c0618bf01268a2924dc0b2926d01c2924d03fe00d9010a804f0e1f94ff0ff3701269df84900002810a818bf4ff0ff3704f0fffa054646b99df8480028b94af21f30c0f247004c3080470d98002818bfc56013e09c2901d08b291bd160b14af21f31c0f247010746884797f8641119b997f80413384669b14ff0ff3742f6f760c0f2440000f5807150468847384645b0bde8f08f0d9010a8264004f0a0f90e98007800f07f040f2c2ddd142c40f3a981152c00f01183162c00f01c831d2c40f0da830f9801380228c0f04f850e994878897840ea0124b4f5007f00f2468504eb4400032101eb40000f99884240f03d8505f02ffe002800f038850c96002601270f9400f055bd092c00f3d180052c00f00c82072c40f0af83002706e048f2a351c0f24501bff32f8f8847d9f80040bff35f8fd9f800000321cff680710140b1f1005fbff35f8f03d10168594500f085864ff45c7006f033fd002800f07d86294600bf4218373182f8707382f8717382f8727382f8737382f8747382f8757382f8767382f8777382f8787382f8797382f87a7382f87b7382f87c7382f87d7382f87e7382f87f7382f8807382f8817382f8827382f8837382f8847382f8857382f8867382f8877382f8887382f8897382f88a7382f88b7382f88c7382f88d7382f88e7382f88f7382f8907382f8917382f8927382f8937382f8947382f895738Line truncated
"new": "b0b581ea00039b0701d0034637e0c2b110f0030315d000f1010ca2f1010e0023cc5c9e45c45403f1010404d0634413f003032346f4d121440319121b102a14d302e00346102a10d3d1f800c0d1f804e0cc688d68103adc609d60c3f804e043f810cb0f2a01f11001eed8042a07d300bf51f8045b043a032a43f8045bf8d8002a08bfb0bd0139013b11f8015f013a03f8015ff9d1b0bd00bf884218bf002a00d1704710b50b1a38bf431a934207d288420ad281ea00039b0726d0034669e0fff79fffbde81040704781ea000300eb020c9b0701eb020e42d15fea8c732bd0a0f1010c00bf8b1813f801ec8418531e04f801ec04d0624412f003021a46f2d101eb030e00eb030c17e0830736d0a2f1010c00f1010e002300bfcc5c9c45c45403f1010404d0734413f003032346f4d1121b2144031922e01346042b0ed3aef10402acf1040152f80449043b032b41f80449f8d802f1040e01f1040c1a4653b1aef10101acf1010300bf11f80149013a03f80149f9d1bde8104070470346042a06d351f8044b043a032a43f8044bf8d8002af0d00139013b00bf11f8014f013a03f8014ff9d1e6e700bf2de9f04fc7b04ff690454ef66c6b4ff29c591446cff6ff75ccf2ff0bc2f229094ff6ff78002701260f93cde9100106e048f2a351c0f24501bff32f8f8847d9f800a0bff35f8fd9f800000321cff680710140b1f1005fbff35f8f03d10168594500f0ac804ff45c7007f0b6f8002800f0eb8129464218373182f8707382f8717382f8727382f8737382f8747382f8757382f8767382f8777382f8787382f8797382f87a7382f87b7382f87c7382f87d7382f87e7382f87f7382f8807382f8817382f8827382f8837382f8847382f8857382f8867382f8877382f8887382f8897382f88a7382f88b7382f88c7382f88d7382f88e7382f88f7382f8907382f8917382f8927382f8937382f8947382f8957382f8967382f8977382f8987382f8997382f89a7382f89b7382f89c7382f89d7382f89e7382f89f7382f8a07382f8a17382f8a27382f8a37382f8a47382f8a57382f8a6738ed1c0f800b08672a0f81c80a0f81e80a0f82080a0f82280a0f82480a0f82680a0f82880a0f82a80a0f82c80a0f82e80a0f83080a0f83280a0f83480a0f83680a0f83880a0f83a8059e8001f51457ff445afbff35f8f00bf49e8000121b159e8001f5145f8d039e71199012641ea04410024c0f8701206e048f2a351c0f24501bff32f8f8847d9f80070bff35f8fd9f800000321cff680710140b1f1005fbff35f8f03d10168594500f0ac804ff45c7006f0e8ff002800f01d8129464218373182f8704382f8714382f8724382f8734382f8744382f8754382f8764382f8774382f8784382f8794382f87a4382f87b4382f87c4382f87d4382f87e4382f87f4382f8804382f8814382f8824382f8834382f8844382f8854382f8864382f8874382f8884382f8894382f88a4382f88b4382f88c4382f88d4382f88e4382f88f4382f8904382f8914382f8924382f8934382f8944382f8954382f8964382f8974382f8984382f8994382f89a4382f89b4382f89c4382f89d4382f89e4382f89f4382f8a04382f8a14382f8a24382f8a34382f8a44382f8a54382f8a6438ed1c0f800b08672a0f81c80a0f81e80a0f82080a0f82280a0f82480a0f82680a0f82880a0f82a80a0f82c80a0f82e80a0f83080a0f83280a0f83480a0f83680a0f83880a0f83a8059e8001fb9427ff445afbff35f8f00bf49e8000121b159e8001fb942f8d039e7d0f874a242f6f766c0f24406baf1000fbff35f8f4ad006f19a0250464ff0ff314ff0ff379047002840f08f811198002861d010980778a7f1170002285bd811980c2840f07881109e7078b178084300f07281f0780138022800f26d81b279f379747a42ea0322337a307942ea0342717942ea0463b27af67a192f42ea062200f07f83172f40f09583002a40f05481fe2800f0c987812800f0bb87002840f0d08751ea030040f0478101f060b904460020b047e8b104f51d7151e800afbaf1000f0cd1bff35f8f00bf41e80002002a00f0e78051e800afbaf1000ff5d00021bff32f8f0029bff35f8f00f0d680824692e74ff0ff3729e147f6df40c0f24f008047002701261397adf8507006e048f2a351c0f24501bff32f8f8847d9f80040bff35f8fd9f800000321cff680710140b1f1005fbff35f8f03d10168594500f0b3804ff45c7006f09cfe002800f0ab8029464218373182f8707382f8717382f8727382f8737382f8747382f8757382f8767382f8777382f8787382f8797382f87a7382f87b7382f87c7382f87d7382f87e7382f87f7382f8807382f8817382f8827382f8837382f8847382f8857382f8867382f8877382f8887382f8897382f88a7382f88b7382f88c7382f88d7382f88e7382f88f7382f8907382f8917382f8927382f8937382f8947382f8957382f8967382f8977382f8987382f8997382f89a7382f89b7382f89c7382f89d7382f89e7382f89f7382f8a07382f8a17382f8a27382f8a37382f8a47382f8a57382f8a6738ed1c0f800b08672a0f81c80a0f81e80a0f82080a0f82280a0f82480a0f82680a0f82880a0f82a80a0f82c80a0f82e80a0f83080a0f83280a0f83480a0f83680a0f83880a0f83a8059e8001fa1427ff445afbff35f8f00bf49e8000159b159e8001fa142f8d039e706f5a9718847bae601211ee70020109999b1119a8ab1097801f07f02b2f10b0418bf0124b2f11c0618bf01268a2924dc0b2926d01c2924d03fe00f9012a804f0e3f94ff0ff3701269df85100002812a818bf4ff0ff3704f001fb054646b99df8500028b94af21f30c0f247004c3080470f98002818bfc56013e09c2901d08b291bd160b14af21f31c0f247010746884797f8641119b997f80413384669b14ff0ff3742f6f760c0f2440000f5807150468847384647b0bde8f08f0f9012a8264004f0a2f91098007800f07f040f2c2ddd142c40f3a981152c00f01183162c00f01c831d2c40f0da83119801380228c0f04d8510994878897840ea0124b4f5007f00f2448504eb4400032101eb40001199884240f03b8505f031fe002800f036850e9600260127119400f053bd092c00f3d180052c00f00c82072c40f0af83002706e048f2a351c0f24501bff32f8f8847d9f80040bff35f8fd9f800000321cff680710140b1f1005fbff35f8f03d10168594500f083864ff45c7006f035fd002800f07b86294600bf4218373182f8707382f8717382f8727382f8737382f8747382f8757382f8767382f8777382f8787382f8797382f87a7382f87b7382f87c7382f87d7382f87e7382f87f7382f8807382f8817382f8827382f8837382f8847382f8857382f8867382f8877382f8887382f8897382f88a7382f88b7382f88c7382f88d7382f88e7382f88f7382f8907382f8917382f8927382f8937382f8947382f895738Line truncated
"desc": "append injected blobs to main-app payload"
},
{
"offset": 779123,
"old": "805a3900",
"new": "04403a00",
"new": "dc443a00",
"desc": "main-app subheader payload size (ps)"
},
{
"offset": 152,
"old": "005b3900",
"new": "84403a00",
"new": "5c453a00",
"desc": "main-app TOC entry size (ps + 128)"
},
{
"offset": 779243,
"old": "805a3904",
"new": "04403a04",
"new": "dc443a04",
"desc": "main-app preamble length (low 24 bits)"
},
{
"offset": 779247,
"old": "effdbcea",
"new": "4c01635d",
"new": "fe2d93a9",
"desc": "[5] ota/s200_firmware_ota.bin preamble crc32"
},
{
"offset": 156,
"old": "c0c6322a",
"new": "155cd97f",
"new": "13f7ac84",
"desc": "[5] ota/s200_firmware_ota.bin component crc32c (TOC)"
},
{
"offset": 779127,
"old": "c0c6322a",
"new": "155cd97f",
"new": "13f7ac84",
"desc": "[5] ota/s200_firmware_ota.bin component crc32c (subheader)"
}
]
+6 -2
View File
@@ -1,3 +1,4 @@
import { encodePresentation } from "./presentation-wire";
/**
* Marshals deferred-draw identity (text glyphs and icon images) to the Kotlin
* side for the texture-cache pipeline (CFW modes 18/19/20; see
@@ -84,6 +85,7 @@ const fwRegistered = new Set<string>();
* unseen ink members' rasters with the Kotlin FwGlyphAtlas as a side effect.
*/
function prepareFwTextRun(placed: PlacedFwText): boolean {
if (!textureAtlasAvailable()) return false;
if (!inRange16(placed.x) || !inRange16(placed.y)) return false;
if (placed.glyphs.length === 0 || placed.glyphs.length > 255) return false;
let registration: Array<{ cp: number; data: NonNullable<ReturnType<PlacedFwText["font"]["fwGlyphWireData"]>> }> | null = null;
@@ -152,7 +154,7 @@ function inRange16(v: number): boolean {
* in draw order. Returns null when nothing is expressible (or without a native atlas).
*/
export function prepareFrameDraws(draws: readonly DeferredDraw[]): ArrayBuffer | null {
if (!textureAtlasAvailable() || draws.length === 0) return null;
if (draws.length === 0) return null;
// Pass 1: resolve ids, register unseen rasters, size the buffer.
let registration: Map<FontWireState, RegistrationGroup> | null = null;
@@ -175,7 +177,8 @@ export function prepareFrameDraws(draws: readonly DeferredDraw[]): ArrayBuffer |
(placed.glyph.coverage ? group.aaGlyphs : group.glyphs).push(placed.glyph);
} else if (placed.kind === "image") {
if (!inRange16(placed.x) || !inRange16(placed.y)) continue;
if (imageId(placed) !== null) bytes += IMAGE_RECORD_BYTES;
if (placed.presentation) bytes += encodePresentation(placed).length;
else if (imageId(placed) !== null) bytes += IMAGE_RECORD_BYTES;
} else {
const ok = prepareFwTextRun(placed);
fwRunOk.set(placed, ok);
@@ -207,6 +210,7 @@ export function prepareFrameDraws(draws: readonly DeferredDraw[]): ArrayBuffer |
offset += GLYPH_RECORD_BYTES;
} else if (placed.kind === "image") {
if (!inRange16(placed.x) || !inRange16(placed.y)) continue;
if (placed.presentation) { const bytes = encodePresentation(placed); new Uint8Array(out.buffer).set(bytes, offset); offset += bytes.length; continue; }
const id = imageId(placed);
if (id === null) continue;
out.setUint8(offset, 1);
+47 -6
View File
@@ -73,6 +73,7 @@ export type PlacedGlyph = {
* from the moment it is placed.
*/
export type PlacedImage = {
presentation?: { mode?: "image" | "masked-image"; radius: number; background: number; border: number; depth: number; occlusions?: readonly { x: number; y: number; width: number; height: number }[] };
kind: "image";
source: GrayImage;
x: number;
@@ -391,6 +392,7 @@ export class GrayImage {
hash = mixInt(hash, placed.source.width);
hash = mixInt(hash, placed.source.height);
hash = mixInt(hash, placed.source.sourceContentHash32());
if (placed.presentation) { const p = placed.presentation; for (const value of [p.radius, p.background, p.border, p.depth, p.mode === "image" ? 1 : p.mode === "masked-image" ? 2 : 0]) hash = mixInt(hash, value); }
} else {
hash = mixInt(hash, 0xf17e);
hash = mixInt(hash, placed.font.atlasTag);
@@ -501,6 +503,24 @@ export class GrayImage {
this.drawList.push({ kind: "fwtext", font, x, y, value: clampByte(value), glyphs });
}
/** Retain the selected row separately from the menu surface for glasses-side composition. */
drawMenuSelection(source: GrayImage, x: number, y: number, background: number, border: number, radius = 8, depth = 2): void {
this.drawList.push({ kind: "image", source: source.withDrawsBaked(), x, y,
presentation: { radius, background, border, depth } });
}
/** Replay an image at stereo depth. Masked images preserve intentional gray8 black (1). */
drawDepthImage(source: GrayImage, x: number, y: number, depth: number, masked = false): void {
this.drawList.push({ kind: "image", source: source.withDrawsBaked(), x, y,
presentation: { mode: masked ? "masked-image" : "image", radius: 0, background: 0, border: 0, depth } });
}
copyPresentationsInto(target: GrayImage, dx: number, dy: number): void {
for (const placed of this.drawList) if (placed.kind === "image" && placed.presentation) {
target.drawList.push({ ...placed, x: placed.x + dx, y: placed.y + dy });
}
}
/**
* Bake this image's deferred draws into its own pixels and clear the list.
* Used where later raster must be able to cover earlier draws within the
@@ -513,7 +533,8 @@ export class GrayImage {
if (placed.kind === "glyph") {
rasterizeGlyph(this, placed.font, placed.glyph, placed.x, placed.y, placed.value);
} else if (placed.kind === "image") {
this.bitBlt(placed.source, placed.x, placed.y, { transparentZero: true });
if (placed.presentation) { const one = new GrayImage(this.width, this.height); one.drawList.push(placed); one.bakeDrawsInto(this, 0, 0); }
else this.bitBlt(placed.source, placed.x, placed.y, { transparentZero: true });
} else {
placed.font.bakeFwTextRun(this, placed, 0, 0);
}
@@ -534,7 +555,7 @@ export class GrayImage {
const copy = new GrayImage(this.width, this.height, 0);
copy.pixels.set(this.pixels);
for (const placed of this.drawList) {
if (placed.kind === "image") {
if (placed.kind === "image" && !placed.presentation) {
copy.bitBlt(placed.source, placed.x, placed.y, { transparentZero: true });
}
}
@@ -544,7 +565,10 @@ export class GrayImage {
if (value !== 0) pixels[i] = dimValue(value, scale);
}
for (const placed of this.drawList) {
if (placed.kind !== "image") {
if (placed.kind === "image" && placed.presentation) {
const p = placed.presentation;
copy.drawList.push({ ...placed, source: placed.source.dimmed(factor), presentation: { ...p, background: dimValue(p.background, scale), border: dimValue(p.border, scale) } });
} else if (placed.kind !== "image") {
copy.drawList.push({ ...placed, value: dimValue(placed.value, scale) });
}
}
@@ -556,11 +580,11 @@ export class GrayImage {
* Returns this image unchanged when there are none, otherwise a baked copy
* with an empty draw list.
*/
withDrawsBaked(): GrayImage {
withDrawsBaked(presentations = true): GrayImage {
if (!this.drawList.length) return this;
const baked = new GrayImage(this.width, this.height, 0);
baked.pixels.set(this.pixels);
this.bakeDrawsInto(baked, 0, 0);
this.bakeDrawsInto(baked, 0, 0, presentations);
return baked;
}
@@ -579,11 +603,28 @@ export class GrayImage {
}
/** Rasterize this image's deferred draws into target, translated by (dx, dy). */
bakeDrawsInto(target: GrayImage, dx: number, dy: number): void {
bakeDrawsInto(target: GrayImage, dx: number, dy: number, presentations = true): void {
for (const placed of this.drawList) {
if (placed.kind === "glyph") {
rasterizeGlyph(target, placed.font, placed.glyph, placed.x + dx, placed.y + dy, placed.value);
} else if (placed.kind === "image") {
if (placed.presentation) {
if (!presentations) continue;
if (placed.presentation.mode) {
target.bitBlt(placed.source, placed.x + dx, placed.y + dy, { transparentZero: true });
continue;
}
const { radius, background, border } = placed.presentation;
const fill = new GrayImage(placed.source.width, placed.source.height);
fill.fillRoundedRect(0, 0, fill.width, fill.height, background, radius);
for (let y = 0; y < fill.height; y++) for (let x = 0; x < fill.width; x++) {
const tx = placed.x + dx + x, ty = placed.y + dy + y;
if (tx >= 0 && ty >= 0 && tx < target.width && ty < target.height) {
const i = ty * target.width + tx; target.pixels[i] = Math.max(target.pixels[i], fill.pixels[y * fill.width + x]);
}
}
target.drawRoundedRect(placed.x + dx, placed.y + dy, fill.width, fill.height, border, radius);
}
target.bitBlt(placed.source, placed.x + dx, placed.y + dy, { transparentZero: true });
} else {
placed.font.bakeFwTextRun(target, placed, dx, dy);
+56 -19
View File
@@ -1,4 +1,4 @@
import { GrayImage, type DeferredDraw } from "./image";
import { GrayImage, type DeferredDraw, type PlacedImage } from "./image";
/**
* The unit apps (and the shell) submit to the compositor: instead of one
@@ -8,20 +8,17 @@ import { GrayImage, type DeferredDraw } from "./image";
* transparent, 1 is black (the two quantize to the same 4bpp shade, so
* reserving 0 costs nothing visible).
*
* This representation exists to carry structure the wire pipeline will later
* exploit: a plane's glyph list can become on-glasses display-list references
* (texture cache), and the offset can diverge per lens for stereo depth. For
* now the compositor boundary just flattens (flattenPlanes) and feeds the
* existing incremental-update and screen-preview pipeline.
* Static planes form the incremental screen buffer. Planes with stereo depth
* and retained presentation draws replay from resources in the root display list.
*/
export type Plane = {
shellKey?: number;
depth?: number;
dimUnderneath?: number;
image: GrayImage;
/**
* Offset of the plane's top-left within the submitted frame. Applied
* identically to both lenses for now; a per-lens divergence (stereo depth
* for floating overlays) is the planned extension.
* before any per-lens horizontal offset from depth.
*/
x: number;
y: number;
@@ -72,8 +69,9 @@ export function flattenPlanes(
/**
* Flatten planes and also return the frame's deferred draws (glyphs and
* images), translated into frame coordinates and in bake order (plane order,
* then each image's draw order). The flattened image has every draw baked in,
* exactly as flattenPlanes produces; the list preserves the draws' identity
* then each image's draw order). Regular draws are baked into the image;
* selected-menu presentation records remain unbaked for root-list replay.
* The list preserves the draws' identity
* so the texture-cache pipeline can replay them as on-glasses cached draws
* (see graphics/glyph-wire.ts).
*/
@@ -81,15 +79,54 @@ export function flattenPlanesWithDraws(
planes: readonly Plane[],
size?: { width: number; height: number },
): { image: GrayImage; draws: DeferredDraw[] } {
const image = flattenPlanes(planes, size);
const rasters = planes.map(p => p.image.withDrawsBaked(false));
const image = flattenPlanes(planes.map((plane, i) => ({ ...plane, image: plane.depth ? new GrayImage(plane.image.width, plane.image.height) : rasters[i]! })), size);
const draws: DeferredDraw[] = [];
for (const plane of planes) {
for (const placed of plane.image.draws) {
draws.push(
plane.x === 0 && plane.y === 0
? placed
: { ...placed, x: placed.x + plane.x, y: placed.y + plane.y },
);
for (const [index, plane] of planes.entries()) {
const retained: DeferredDraw[] = [];
if (plane.depth) {
// Keep the whole menu off the screen buffer, including its black background.
const raster = rasters[index]!;
let left = raster.width, top = raster.height, right = -1, bottom = -1;
for (let y = 0; y < raster.height; y++) for (let x = 0; x < raster.width; x++) if (raster.pixels[y*raster.width+x]) {
left = Math.min(left,x); top = Math.min(top,y); right = Math.max(right,x); bottom = Math.max(bottom,y);
}
if (right >= left) {
const crop = new GrayImage(right-left+1,bottom-top+1);
for(let y=0;y<crop.height;y++) crop.pixels.set(raster.pixels.subarray((y+top)*raster.width+left,(y+top)*raster.width+right+1),y*crop.width);
retained.push({ kind: "image", source: crop, x: left, y: top,
presentation: { mode: "masked-image", radius: 0, background: 0, border: 0, depth: plane.depth } });
}
}
const planeDraws = plane.depth ? [...retained, ...plane.image.draws.filter(d => d.kind === "image" && d.presentation).map(d => {
const draw = d as PlacedImage;
return { ...draw, presentation: { ...draw.presentation!, depth: draw.presentation!.depth + plane.depth! } };
})] : plane.image.draws;
for (const placed of planeDraws) {
const translated = { ...placed, x: placed.x + plane.x, y: placed.y + plane.y };
if (translated.kind === "image" && translated.presentation) {
// Restore opaque pixels from later planes after replaying this row. The screen
// already contains those pixels; rect copies preserve rounded/irregular occlusion.
const occlusions: { x: number; y: number; width: number; height: number }[] = [];
const depth = translated.presentation.depth;
const leftShift = Math.floor(depth / 2), rightShift = -Math.floor((depth + 1) / 2);
const left = Math.max(0, translated.x + Math.min(leftShift, rightShift));
const right = Math.min(image.width, translated.x + translated.source.width + Math.max(leftShift, rightShift));
for (let y = Math.max(0, translated.y); y < Math.min(image.height, translated.y + translated.source.height); y++) {
let start = -1;
for (let x = left; x <= right; x++) {
const covered = x < right && planes.some((p, i) => i > index && !p.depth && x >= p.x && y >= p.y && x < p.x + p.image.width && y < p.y + p.image.height && rasters[i]!.pixels[(y-p.y)*p.image.width+x-p.x] !== 0);
if (covered && start < 0) start = x;
if (!covered && start >= 0) {
const previous = occlusions.find(r => r.x === start && r.width === x - start && r.y + r.height === y);
if (previous) previous.height++; else occlusions.push({ x: start, y, width: x-start, height: 1 });
start = -1;
}
}
}
translated.presentation = { ...translated.presentation, occlusions };
}
draws.push(translated);
}
}
return { image, draws };
@@ -102,6 +139,6 @@ export function flattenPlanesWithDraws(
*/
export function planesFingerprint(planes: readonly Plane[]): string {
return planes
.map((plane) => `${plane.x},${plane.y}+${plane.image.width}x${plane.image.height}:${plane.image.fingerprint()}`)
.map((plane) => `${plane.depth ?? 0}:${plane.x},${plane.y}+${plane.image.width}x${plane.image.height}:${plane.image.fingerprint()}`)
.join("|");
}
+64
View File
@@ -0,0 +1,64 @@
import type { PlacedImage } from './image'
/** Bridge record: tag 3 (selection), 4 (image), 5 (gray8-masked image), signed xy, u16 wh/radius, gray fill/stroke, signed depth, restore-count, gray pixels, restore rectangles. */
export function encodePresentation(draw: PlacedImage): Uint8Array {
const p = draw.presentation!
const { width, height, pixels } = draw.source
if (width < 1 || height < 1 || width > 640 || height > 480 || 5 + Math.ceil(width / 2) * height > 65536) throw new Error('Presentation image exceeds the resource size limit')
if (!Number.isInteger(p.depth) || p.depth < -128 || p.depth > 127) throw new Error('Invalid menu depth')
if ((p.occlusions?.length ?? 0) > 2048) throw new Error('Too many menu occlusion rectangles')
const bytes = new Uint8Array(16 + width * height + (p.occlusions?.length ?? 0) * 8), view = new DataView(bytes.buffer)
bytes[0] = p.mode === "image" ? 4 : p.mode === "masked-image" ? 5 : 3
view.setInt16(1, draw.x, true); view.setInt16(3, draw.y, true)
view.setUint16(5, width, true); view.setUint16(7, height, true); view.setUint16(9, p.radius, true)
bytes[11] = p.background; bytes[12] = p.border; view.setInt8(13, p.depth)
view.setUint16(14, p.occlusions?.length ?? 0, true)
bytes.set(pixels, 16)
let offset = 16 + pixels.length
for (const rect of p.occlusions ?? []) {
view.setUint16(offset, rect.x, true); view.setUint16(offset + 2, rect.y, true)
view.setUint16(offset + 4, rect.width, true); view.setUint16(offset + 6, rect.height, true); offset += 8
}
return bytes
}
export type Selection = { mode?: "image" | "masked-image"; x: number; y: number; width: number; height: number; radius: number; background: number; border: number; depth: number; pixels: Uint8Array; occlusions: { x: number; y: number; width: number; height: number }[] }
export function readPresentation(bytes: Uint8Array, offset: number): { selection: Selection; end: number } {
const v = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength), w = v.getUint16(offset + 5, true), h = v.getUint16(offset + 7, true)
const selection: Selection = { mode: bytes[offset] === 4 ? "image" : bytes[offset] === 5 ? "masked-image" : undefined, x: v.getInt16(offset+1,true), y: v.getInt16(offset+3,true), width:w, height:h,
radius:v.getUint16(offset+9,true), background:bytes[offset+11]!, border:bytes[offset+12]!, depth:v.getInt8(offset+13),
pixels:bytes.slice(offset+16,offset+16+w*h), occlusions:[] }
let end=offset+16+w*h
for(let i=0;i<v.getUint16(offset+14,true);i++) { selection.occlusions.push({x:v.getUint16(end,true),y:v.getUint16(end+2,true),width:v.getUint16(end+4,true),height:v.getUint16(end+6,true)});end+=8 }
return {selection,end}
}
export function presentationRecords(buffer: ArrayBuffer | null): Selection[] {
if (!buffer) return []
const bytes=new Uint8Array(buffer), result:Selection[]=[]
for(let p=0;p<bytes.length;) {
if(bytes[p]===3 || bytes[p]===4 || bytes[p]===5) { const record=readPresentation(bytes,p);result.push(record.selection);p=record.end }
else if(bytes[p]===0) p+=12
else if(bytes[p]===1) p+=9
else if(bytes[p]===2) p+=7+bytes[p+6]!*7
else break
}
return result
}
export function paintPresentation(output: Uint8Array, screen: Uint8Array, width: number, height: number, row: Selection, right = false): void {
const q=(n:number)=>Math.min(15,(n+8)>>4), shift=right?-Math.floor((row.depth+1)/2):Math.floor(row.depth/2)
const inside=(x:number,y:number,w:number,h:number,r:number)=>{
if(x<0||y<0||x>=w||y>=h) return false
r=Math.min(r,Math.floor(w/2),Math.floor(h/2))
const dx=Math.max(0,2*r-(2*Math.min(x,w-1-x)+1)),dy=Math.max(0,2*r-(2*Math.min(y,h-1-y)+1))
return dx*dx+dy*dy<=4*r*r
}
for(let yy=0;yy<row.height;yy++) for(let xx=0;xx<row.width;xx++) {
const x=row.x+xx+shift,y=row.y+yy
if(x<0||y<0||x>=width||y>=height) continue
const i=y*width+x
if(!row.mode && inside(xx,yy,row.width,row.height,row.radius)) output[i]=!inside(xx-1,yy-1,row.width-2,row.height-2,Math.max(0,row.radius-1))?q(row.border)*16:Math.max(output[i]!,q(row.background)*16)
const value=q(row.pixels[yy*row.width+xx]!)
if(row.mode === "masked-image" ? row.pixels[yy*row.width+xx] !== 0 : value !== 0) output[i]=value*16
}
for(const r of row.occlusions) for(let yy=r.y;yy<r.y+r.height;yy++) for(let xx=r.x;xx<r.x+r.width;xx++) if(xx>=0&&yy>=0&&xx<width&&yy<height) output[yy*width+xx]=q(screen[yy*width+xx]!)*16
}
+13 -7
View File
@@ -1,18 +1,20 @@
import { GrayImage } from './image'
import { encodePresentation } from "./presentation-wire"
import { GrayImage, type PlacedImage } from './image'
import type { Plane } from './plane'
/** Crop one independently owned, opaque shell surface; never split it into tiles. */
export function shellCrop(image: GrayImage, x: number, y: number, width: number, height: number, key: number): Plane {
const baked = image.withDrawsBaked(), crop = new GrayImage(width, height, 0)
const baked = image.withDrawsBaked(false), crop = new GrayImage(width, height, 0)
for (let row = 0; row < height; row++) crop.pixels.set(baked.pixels.subarray((y + row) * image.width + x, (y + row) * image.width + x + width), row * width)
image.copyPresentationsInto(crop, -x, -y)
return { image: crop, x, y, shellKey: key }
}
/** Shared Kotlin receives original 8-bit pixels and quantizes once, before composing. */
export function encodeShellScene(planes: readonly Plane[]): Uint8Array {
const layers: { image: GrayImage; x: number; y: number; key: number; dim: number }[] = []
const layers: { image: GrayImage; x: number; y: number; key: number; depth: number; dim: number; selections: Uint8Array[] }[] = []
for (const plane of planes) {
const image = plane.image.withDrawsBaked()
const image = plane.image.withDrawsBaked(false)
let left = image.width, top = image.height, right = -1, bottom = -1
for (let y = 0; y < image.height; y++) for (let x = 0; x < image.width; x++) {
if (image.pixels[y * image.width + x] === 0) continue
@@ -22,12 +24,16 @@ export function encodeShellScene(planes: readonly Plane[]): Uint8Array {
const w = right - left + 1, h = bottom - top + 1
if (5 + Math.ceil(w / 2) * h > 65536) throw new Error(`Shell surface ${plane.shellKey} exceeds 64 KiB (${w}×${h})`)
const cropped = shellCrop(image, left, top, w, h, plane.shellKey!)
layers.push({ image: cropped.image, x: plane.x + left, y: plane.y + top, key: plane.shellKey!, dim: Math.round((plane.dimUnderneath ?? 1) * 256) })
const selections = plane.image.draws
.filter((d): d is PlacedImage => d.kind === "image" && !!d.presentation)
.map(d => encodePresentation({ ...d, x: d.x + plane.x, y: d.y + plane.y,
presentation: { ...d.presentation!, depth: d.presentation!.depth + (plane.depth ?? 0) } }))
layers.push({ depth: plane.depth ?? 0, selections, image: cropped.image, x: plane.x + left, y: plane.y + top, key: plane.shellKey!, dim: Math.round((plane.dimUnderneath ?? 1) * 256) })
}
const result = new Uint8Array(2 + layers.reduce((n, l) => n + 14 + l.image.pixels.length, 0))
const result = new Uint8Array(2 + layers.reduce((n, l) => n + 16 + l.image.pixels.length + l.selections.reduce((n, b) => n + b.length, 0), 0))
const view = new DataView(result.buffer); let p = 0
const word = (n: number) => { view.setUint16(p, n, true); p += 2 }
word(layers.length)
for (const l of layers) { word(l.key); word(l.x); word(l.y); word(l.image.width); word(l.image.height); word(l.dim); word(0); result.set(l.image.pixels, p); p += l.image.pixels.length }
for (const l of layers) { word(l.key); word(l.x); word(l.y); word(l.image.width); word(l.image.height); word(l.dim); word(l.selections.length); word(l.depth); result.set(l.image.pixels, p); p += l.image.pixels.length; for (const selection of l.selections) { result.set(selection, p); p += selection.length } }
return result
}
+13 -5
View File
@@ -1,3 +1,4 @@
import { presentationRecords, readPresentation, paintPresentation, type Selection } from "./presentation-wire"
/** Platform-independent 8bpp surface composition for the local display. */
import type { TextureFrame } from '../g2/texture-planner'
export type SurfaceRect = { x: number; y: number; width: number; height: number }
@@ -5,7 +6,7 @@ export type SurfaceConfiguration = SurfaceRect & {
zOrder: number
transparency: 'opaque' | 'color-key'
}
type Surface = SurfaceConfiguration & { pixels: Uint8Array; visible: boolean }
type Surface = SurfaceConfiguration & { pixels: Uint8Array; visible: boolean; selections: Selection[] }
export class SurfaceCompositor {
private readonly surfaces = new Map<string, Surface>()
@@ -25,7 +26,7 @@ export class SurfaceCompositor {
const previous = this.surfaces.get(id)
const pixels = previous?.width === options.width && previous.height === options.height
? previous.pixels : new Uint8Array(options.width * options.height)
this.surfaces.set(id, { ...options, pixels, visible: previous?.visible ?? true })
this.surfaces.set(id, { ...options, pixels, visible: previous?.visible ?? true, selections: previous?.selections ?? [] })
}
removeSurface(id: string): void { this.surfaces.delete(id) }
setSurfaceVisible(id: string, visible: boolean): void {
@@ -45,6 +46,7 @@ export class SurfaceCompositor {
|| rect.width <= 0 || rect.height <= 0 || pixels.length !== rect.width * rect.height) {
throw new Error('Invalid frame buffer or rectangle')
}
surface.selections = presentationRecords(_draws)
const left = Math.max(0, rect.x), right = Math.min(surface.width, rect.x + rect.width)
const top = Math.max(0, rect.y), bottom = Math.min(surface.height, rect.y + rect.height)
for (let y = top; y < bottom; y++) {
@@ -74,19 +76,25 @@ export class SurfaceCompositor {
}
}
}
const screen = output.slice()
if (!surfaces.some(s => s.zOrder > 1) && (this.shellScene || surfaces.some(s => s.selections.length))) {
for(let i=0;i<output.length;i++) output[i]=Math.min(15,(output[i]!+8)>>4)*16
for(const surface of surfaces) for(const row of surface.selections) paintPresentation(output,screen,this.width,this.height,{...row,x:row.x+surface.x,y:row.y+surface.y,occlusions:row.occlusions.map(r=>({...r,x:r.x+surface.x,y:r.y+surface.y}))})
}
if (this.shellScene && !surfaces.some(s => s.zOrder > 1)) {
const quantize = (v: number) => Math.min(15, (v + 8) >> 4)
for (let i=0;i<output.length;i++) output[i]=quantize(output[i])*16
const bytes=this.shellScene, view=new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength)
let p=2
for(let i=0;i<view.getUint16(0,true);i++) {
const x=view.getInt16(p+2,true), y=view.getInt16(p+4,true), w=view.getUint16(p+6,true), h=view.getUint16(p+8,true), dim=view.getUint16(p+10,true)
p+=14
const x=view.getInt16(p+2,true), y=view.getInt16(p+4,true), w=view.getUint16(p+6,true), h=view.getUint16(p+8,true), dim=view.getUint16(p+10,true), selections=view.getUint16(p+12,true), shift=Math.floor(view.getInt16(p+14,true)/2)
p+=16
if(dim<256) for(let j=0;j<output.length;j++) output[j]=Math.floor((output[j]/16)*dim/256)*16
for(let yy=0;yy<h;yy++) for(let xx=0;xx<w;xx++) {
if(x+xx>=0 && y+yy>=0 && x+xx<this.width && y+yy<this.height) output[(y+yy)*this.width+x+xx]=quantize(bytes[p+yy*w+xx])*16
if(x+xx+shift>=0 && y+yy>=0 && x+xx+shift<this.width && y+yy<this.height) output[(y+yy)*this.width+x+xx+shift]=quantize(bytes[p+yy*w+xx])*16
}
p+=w*h
for(let j=0;j<selections;j++) { const record=readPresentation(bytes,p);p=record.end;paintPresentation(output,screen,this.width,this.height,record.selection) }
}
}
return output
+11 -1
View File
@@ -1,3 +1,5 @@
import { GrayImage } from "../graphics/image"
import { encodeShellScene } from "../graphics/shell-scene"
import { decodeImageBytes } from './image-bytes.ios'
import * as protocol from '../g2/ble-protocol.ios'
import { CfwTransport, parseCfwAcks } from '../g2/cfw-transport.ios'
@@ -31,7 +33,7 @@ export function runKotlinProtocolSmokeTest(): void {
c.submitSurfaceFrame('test', new Uint8Array([0, 16, 255, 32, 48, 64]), { x: 0, y: 0, width: 3, height: 2 })
assert(hex(c.composite()) === '0010ff203040', 'composition')
assert(hex(protocol.packGray4(c.composite(), 3, 2)) === '01f02340', 'packing')
c.setShellScene(new Uint8Array([1,0,1,0,0,0,0,0,1,0,1,0,128,0,0,0,255]))
c.setShellScene(new Uint8Array([1,0,1,0,0,0,0,0,1,0,1,0,128,0,0,0,0,0,255]))
assert(hex(c.composite()) === 'f00070101020', 'shell scene bridge and 4bpp composition')
c.setScreenBlanked(true); assert(c.composite().every(p => p === 0), 'blanking')
const textures = new IosTexturePlanner(), textured = new SurfaceCompositor(4, 2)
@@ -46,6 +48,14 @@ export function runKotlinProtocolSmokeTest(): void {
assert(textures.plan(null, packed, snapshot.textures, 1)?.resourceCommands.length === 0, 'texture reuse')
textures.reset()
assert((textures.plan(null, packed, snapshot.textures, 1)?.resourceCommands.length ?? 0) > 0, 'texture reset')
const selectedSurface = new GrayImage(8, 4, 1)
selectedSurface.drawMenuSelection(new GrayImage(4, 2, 255), 1, 1, 16, 48, 0, 2)
const selectedPreview = new SurfaceCompositor(8, 4)
selectedPreview.setShellScene(encodeShellScene([{ image: selectedSurface, x: 0, y: 0, shellKey: 100 }]))
const selectedSnapshot = selectedPreview.compositeFrame()
assert(selectedSnapshot.pixels[10] === 240 && selectedSnapshot.pixels[9] === 0, 'menu selection depth and bridge')
const selectedPlan = new IosTexturePlanner().plan(null, protocol.packGray4(selectedSnapshot.pixels, 8, 4), selectedSnapshot.textures, 1)
assert(!!selectedPlan && selectedPlan.payload[0] === 28 && selectedPlan.resourceCommands.some(c => c[0] === 29), 'menu resource planning')
const changed = new Uint8Array(16); changed[0] = 255
assert(buildBoundingBoxPayload(new Uint8Array(16), changed, 8, 4, 1)?.[0] === 3, 'image update')
assert(lvglMetrics('/nonexistent/faceclaw-font').length === 0, 'font bridge')
+2 -1
View File
@@ -80,6 +80,7 @@ export interface LayerContext {
}
export interface Layer {
readonly depth?: number;
paintParts?(): Plane[];
readonly paintOverBase?: boolean;
/**
@@ -284,7 +285,7 @@ export class LayerStack {
return canvas;
}),
);
const ownPlane: Plane = { image, x: 0, y: 0, shellKey: key, dimUnderneath: layer.dimUnderneath === false ? 1 : layer.dimUnderneath };
const ownPlane: Plane = { image, x: 0, y: 0, shellKey: key, depth: layer.depth, dimUnderneath: layer.dimUnderneath === false ? 1 : layer.dimUnderneath };
if (index <= 0) {
this.lastBaseDim = dimSoFar;
return [ownPlane];
+13 -16
View File
@@ -19,6 +19,8 @@ const MENU_HIGHLIGHT_SELECTED_BACKGROUND_FILL = 15;
const MENU_HIGHLIGHT_SELECTED_BORDER_STROKE = 45;
export type MenuLayout = {
/** Stereo depth of the menu surface; selected rows add +2. */
depth?: number;
/** Left edge, or "center" to center horizontally on the painted surface. */
x: number | "center";
y: number;
@@ -192,6 +194,8 @@ export class MenuLayer implements Layer {
private selectedIndex = 0;
private scrollRow = 0;
get depth(): number { return this.layout.depth ?? 0; }
get dimUnderneath(): false | number {
return this.layout.dimUnderneath ?? false;
}
@@ -227,7 +231,7 @@ export class MenuLayer implements Layer {
const maxHeight = Math.min(
this.layout.maxHeight ?? image.height - y - DEFAULT_MENU_Y,
image.height - y,
this.layout.squareCorners ? Math.floor(65530 / Math.ceil(width / 2)) : Infinity,
(this.layout.squareCorners || this.depth !== 0) ? Math.floor(65530 / Math.ceil(width / 2)) : Infinity,
);
const footerHeight = this.layout.footer ? MENU_FOOTER_GAP + lineStep(font) : 0;
const contentHeight = chromeTop + this.items.length * rowHeight + footerHeight + MENU_BODY_PADDING;
@@ -266,22 +270,14 @@ export class MenuLayer implements Layer {
const rowY = bodyY + (index - this.scrollRow) * rowHeight;
const selected = index === this.selectedIndex;
const disabled = isMenuItemDisabled(item);
if (selected) {
drawSelectionHighlight(
image,
x + 12,
rowY,
width - 24,
rowHeight - 1,
focused,
8,
);
}
const row = selected ? new GrayImage(width - 24, rowHeight - 1, 0) : image;
const textX = selected ? 10 : x + 22;
const textY = selected ? 0 : rowY;
if (item.render) {
item.render({
image,
x: x + 22,
y: rowY,
image: row,
x: textX,
y: textY,
width: width - 44,
height: rowHeight - 3,
selected,
@@ -290,8 +286,9 @@ export class MenuLayer implements Layer {
ctx,
});
} else {
image.drawText(font, x + 22, rowY + LIST_ROW_TEXT_INSET, item.label, disabled ? 70 : selected ? 255 : 200);
row.drawText(font, textX, textY + LIST_ROW_TEXT_INSET, item.label, disabled ? 70 : selected ? 255 : 200);
}
if (selected) image.drawMenuSelection(row, x + 12, rowY, focused ? MENU_HIGHLIGHT_SELECTED_BACKGROUND_FILL : 0, MENU_HIGHLIGHT_SELECTED_BORDER_STROKE, 8, 2);
}
if (this.items.length > visibleRowCount) {
+11 -5
View File
@@ -228,7 +228,7 @@ export class ShellChromeLayer implements Layer {
const canvas = new GrayImage(G2_LENS_WIDTH, G2_LENS_HEIGHT, 0);
this.drawTopBar(canvas, state);
const left = sidebarStripVisible(state.focus, state.foregroundAppId) ? SIDEBAR_WIDTH : 0;
parts.push(shellCrop(canvas, left, windowTop(state.foregroundHeightMode, state.foregroundAppId), G2_LENS_WIDTH-left, TOP_BAR_HEIGHT, 2));
parts.push({ ...shellCrop(canvas, left, windowTop(state.foregroundHeightMode, state.foregroundAppId), G2_LENS_WIDTH-left, TOP_BAR_HEIGHT, 2), depth: -2 });
drawAmbientCards(canvas, parts);
return parts;
}
@@ -288,14 +288,16 @@ export class ShellChromeLayer implements Layer {
// the icon drawn inverted. Only the right column touches the separator;
// a selected overflow icon gets a self-contained box instead.
const sep = SIDEBAR_WIDTH - 1;
// Start beside the app content, leaving the area alongside the top bar open.
const sepTop = Math.max(bandTop, windowTop(state.foregroundHeightMode, state.foregroundAppId) + TOP_BAR_HEIGHT);
const selVisible = state.selectedIndex >= this.scrollRow && state.selectedIndex < lastVisible;
const selSlot = selVisible ? slotOf(state.selectedIndex) : null;
const selTabTop = selSlot && selSlot.column === firstColumn ? selSlot.y - 2 : null;
if (selTabTop !== null) {
image.drawLine(sep, bandTop, sep, selTabTop, BORDER_VALUE);
image.drawLine(sep, sepTop, sep, selTabTop, BORDER_VALUE);
image.drawLine(sep, selTabTop + iconSize + 4, sep, bandBottom - 1, BORDER_VALUE);
} else {
image.drawLine(sep, bandTop, sep, bandBottom - 1, BORDER_VALUE);
image.drawLine(sep, sepTop, sep, bandBottom - 1, BORDER_VALUE);
}
for (let index = this.scrollRow; index < lastVisible; index++) {
@@ -312,13 +314,17 @@ export class ShellChromeLayer implements Layer {
// slot, so anything wider would clip at the screen edge.
drawSelectionBox(image, left, y - 2, variant.columnWidth, iconSize + 4, focused);
}
window.drawIcon(image, x, y, iconSize, focused);
// Paint unselected icons into their own resource so only the replayed copy moves.
const icon = selected ? image : new GrayImage(iconSize, iconSize + 1);
const iconX = selected ? x : 0, iconY = selected ? y : 1;
window.drawIcon(icon, iconX, iconY, iconSize, focused);
if (window.attention) {
// Black dot on the white focused tab, white dot otherwise. A deferred
// image (not a raster fill) so it renders above the icon, which is
// itself a deferred draw.
image.drawImage(attentionDot(focused ? SHELL_OPAQUE_BLACK : 255), x + iconSize - 7, y - 1);
icon.drawImage(attentionDot(focused ? SHELL_OPAQUE_BLACK : 255), iconX + iconSize - 7, iconY - 1);
}
if (!selected) image.drawDepthImage(icon, x, y - 1, -2);
}
// Chevrons center over the icon area, which in the one-column variant is
+1
View File
@@ -233,6 +233,7 @@ class ShellOverlayMenuLayer extends MenuLayer {
squareCorners: true,
footer,
dimUnderneath: CONTEXT_MENU_DIM,
depth: 4,
});
}
+1
View File
@@ -24,6 +24,7 @@ export const WINDOW_MENU_LAYOUT: MenuLayout = {
minHeight: 150,
footer: gestureHints([[GESTURE_LONG_PRESS, "system menu"]]),
dimUnderneath: CONTEXT_MENU_DIM,
depth: 4,
};
export class WindowMenuLayer extends MenuLayer {
@@ -1,6 +1,6 @@
package com.faceclaw.app
/** Revision 25 wire grammar, shared by scene planning and the local renderer. */
/** Revision 26 wire grammar, shared by scene planning and the local renderer. */
object DrawProtocol {
const val DRAW = 26
const val ROOT = 27
@@ -15,8 +15,19 @@ object DrawProtocol {
const val CURRENT = 65534
fun u16(b: ByteArray, p: Int): Int = (b[p].toInt() and 255) or ((b[p + 1].toInt() and 255) shl 8)
fun word(n: Int) = byteArrayOf(n.toByte(), (n ushr 8).toByte())
fun call(op: Int, args: ByteArray, target: Int? = null): ByteArray =
byteArrayOf(op.toByte(), if (target == null) 0 else 1) + (target?.let { word(it) } ?: byteArrayOf()) + args
fun call(op: Int, args: ByteArray, target: Int? = null, depth: Int? = null): ByteArray {
require(depth == null || depth in -128..127)
val flags = (if (target == null) 0 else 1) or (if (depth == null) 0 else 2)
return byteArrayOf(op.toByte(), flags.toByte()) + (target?.let { word(it) } ?: byteArrayOf()) +
(depth?.let { byteArrayOf(it.toByte()) } ?: byteArrayOf()) + args
}
fun depthOffset(depth: Int, right: Boolean): Int =
if (right) -floorHalf(depth + 1) else floorHalf(depth)
private fun floorHalf(n: Int): Int = if (n < 0) (n - 1) / 2 else n / 2
fun roundedRect(x: Int, y: Int, width: Int, height: Int, radius: Int, background: Int, border: Int = 16, depth: Int? = null): ByteArray {
require(width in 1..640 && height in 1..480 && radius in 0..65535 && background in 0..15 && border in 0..16)
return call(8, word(x) + word(y) + word(width) + word(height) + word(radius) + byteArrayOf(background.toByte(), border.toByte()), depth = depth)
}
fun sequence(calls: List<ByteArray>): ByteArray {
require(calls.size <= 4096)
val out = ByteSink(); out.write(word(calls.size))
@@ -26,8 +37,8 @@ object DrawProtocol {
fun message(calls: List<ByteArray>) = byteArrayOf(DRAW.toByte()) + sequence(calls)
fun displayList(calls: List<ByteArray>) = byteArrayOf(LIST.toByte()) + sequence(calls)
fun root(id: Int) = byteArrayOf(ROOT.toByte()) + word(id)
fun image(id: Int, x: Int, y: Int, options: Int = 15, target: Int? = null) =
call(4, word(id) + word(x) + word(y) + byteArrayOf(options.toByte()), target)
fun image(id: Int, x: Int, y: Int, options: Int = 15, target: Int? = null, depth: Int? = null) =
call(4, word(id) + word(x) + word(y) + byteArrayOf(options.toByte()), target, depth)
fun lut(width: Int, height: Int, factor: Int): ByteArray {
val table = ByteArray(8) { i ->
(((i * 2 * factor / 256).coerceIn(0, 15) shl 4) or ((i * 2 + 1) * factor / 256).coerceIn(0, 15)).toByte()
@@ -60,7 +71,7 @@ object DrawProtocol {
flush()
return call(1, out.toByteArray(), target)
}
/** Internal optimizer formats are translated here; they are never sent to revision 25. */
/** Internal optimizer formats are translated here; they are never sent to revision 26. */
fun fromOptimized(payload: ByteArray, width: Int = 640, height: Int = 480): List<ByteArray> {
return when (val mode = payload[0].toInt() and 127) {
8 -> {
@@ -25,18 +25,19 @@ class ScenePlanner(private val cache: ResourceCacheState) {
CachedResource(DrawProtocol.rawImage(layer.width, layer.height), keys[i])
} }
owned.keys.retainAll(keys.toSet()); pixels.keys.retainAll(keys.toSet())
cache.pin(surfaces)
val selectedResources = scene.allSelections.map { it.resource }
cache.pin(surfaces + selectedResources)
val absent = surfaces.map { cache.resourceId(it) < 0 }
val ids = cache.prepare(surfaces)
check(ids.all { it >= 0 }) { "Shell surfaces exceed the resource budget" }
val prepared = cache.prepare(surfaces + selectedResources)
val ids = prepared.copyOfRange(0, surfaces.size)
val selectedIds = prepared.copyOfRange(surfaces.size, prepared.size)
check(prepared.all { it >= 0 }) { "Shell surfaces exceed the resource budget" }
commands.addAll(cache.drainCommands(3600))
val rootCalls = ArrayList<ByteArray>()
val rootCalls = scene.calls(width, height, ids, selectedIds)
for ((i, layer) in scene.layers.withIndex()) {
val old = if (absent[i]) null else pixels[keys[i]]
commands.addAll(DrawProtocol.messages(pixelCalls(old, layer.packed, layer.width, layer.height, ids[i])))
pixels[keys[i]] = layer.packed
if (layer.dim < 256) rootCalls.add(DrawProtocol.lut(width, height, layer.dim))
rootCalls.add(DrawProtocol.image(ids[i], layer.x, layer.y))
}
val base = if (incremental) previous else null
val texture = if (textures) TexturePlanner.plan(base, screen, width, height, draws, cache, firstId, multiRect, maxRects) else null
@@ -48,7 +49,7 @@ class ScenePlanner(private val cache: ResourceCacheState) {
val rootId = cache.prepare(listOf(list))[0]
check(rootId >= 0) { "No space for root display list" }
commands.addAll(cache.drainCommands(3600))
cache.pin(surfaces + list)
cache.pin(surfaces + selectedResources + list)
val evicted = commands.any { it[0].toInt() == ResourceCacheState.EVICT_MODE }
if (evicted) commands.add(0, DrawProtocol.root(DrawProtocol.SCREEN))
if (root != rootId || evicted) commands.add(DrawProtocol.root(rootId))
@@ -1,18 +1,27 @@
package com.faceclaw.app
/** Reference interpreter. It uses the firmware's packed rows, clipping, LUT and call grammar. */
class DisplayListRenderer(private val resources: Map<Int, ByteArray>, private val builtin: ((Int, Int) -> BuiltinGlyph)? = null) {
class DisplayListRenderer(private val resources: Map<Int, ByteArray>, private val builtin: ((Int, Int) -> BuiltinGlyph)? = null, private val rightLens: Boolean = false) {
class BuiltinGlyph(val image: ByteArray, val advance: Int, val x: Int = 0, val y: Int = 0)
class Target(val bytes: ByteArray, val width: Int, val height: Int, val offset: Int = 0) {
class Target(val bytes: ByteArray, val width: Int, val height: Int, val offset: Int = 0, val shiftX: Int = 0) {
val stride = (width + 1) / 2
init { require(width > 0 && height > 0 && offset >= 0 && bytes.size - offset >= stride * height) }
fun get(x: Int, y: Int) = (bytes[offset + y * stride + x / 2].toInt() ushr (if (x % 2 == 0) 4 else 0)) and 15
fun put(x: Int, y: Int, v: Int) {
fun shifted(dx: Int) = Target(bytes, width, height, offset, shiftX + dx)
fun put(localX: Int, y: Int, v: Int) {
val x = localX + shiftX
if (x !in 0 until width || y !in 0 until height) return
val index = offset + y * stride + x / 2; val old = bytes[index].toInt()
bytes[index] = (if (x % 2 == 0) (old and 15) or (v shl 4) else (old and 240) or v).toByte()
}
}
private fun roundedContains(x: Int, y: Int, w: Int, h: Int, radius: Int): Boolean {
if (x !in 0 until w || y !in 0 until h) return false
val r = minOf(radius, w / 2, h / 2)
val dx = maxOf(0, 2 * r - (2 * minOf(x, w - 1 - x) + 1))
val dy = maxOf(0, 2 * r - (2 * minOf(y, h - 1 - y) + 1))
return dx * dx + dy * dy <= 4 * r * r
}
private class Image(val width: Int, val height: Int, val pixels: IntArray)
private fun word(b: ByteArray, p: Int): Int { require(p >= 0 && p + 2 <= b.size); return DrawProtocol.u16(b, p) }
private fun signed(b: ByteArray, p: Int) = word(b, p).toShort().toInt()
@@ -77,9 +86,10 @@ class DisplayListRenderer(private val resources: Map<Int, ByteArray>, private va
repeat(count) {
val n = word(b, pos); pos += 2; require(n >= 2 && n <= b.size - pos && budget[0]-- > 0)
val call = b.copyOfRange(pos, pos + n); pos += n
val flags = call[1].toInt() and 255; require(flags <= 1)
val flags = call[1].toInt() and 255; require(flags <= 3)
var t = inherited; var header = 2
if (flags == 1) { val id = word(call, 2); refs.add(id); t = target(id); header += 2 }
if (flags and 1 != 0) { val id = word(call, 2); refs.add(id); t = target(id).shifted(inherited.shiftX); header += 2 }
if (flags and 2 != 0) { require(header < call.size); t = t.shifted(DrawProtocol.depthOffset(call[header++].toInt(), rightLens)) }
val p = call.copyOfRange(header, call.size)
when (call[0].toInt()) {
1 -> {
@@ -132,9 +142,24 @@ class DisplayListRenderer(private val resources: Map<Int, ByteArray>, private va
6 -> {
require(p.size == 16); val x = word(p, 0); val y = word(p, 2); val w = word(p, 4); val h = word(p, 6)
require(w > 0 && h > 0 && x + w <= t.width && y + h <= t.height)
if (apply) for(yy in y until y + h) for(xx in x until x + w) { val v = t.get(xx, yy)
if (apply) for(yy in y until y + h) for(xx in x until x + w) {
if (xx + t.shiftX !in 0 until t.width) continue
val v = t.get(xx + t.shiftX, yy)
t.put(xx, yy, (p[8 + v / 2].toInt() ushr (if(v % 2 == 0) 4 else 0)) and 15) }
}
8 -> {
require(p.size == 12)
val x = signed(p, 0); val y = signed(p, 2); val w = word(p, 4); val h = word(p, 6)
val radius = word(p, 8); val fill = p[10].toInt() and 255; val border = p[11].toInt() and 255
require(w in 1..640 && h in 1..480 && fill <= 15 && border <= 16)
if (apply) for (yy in 0 until h) for (xx in 0 until w) {
if (!roundedContains(xx, yy, w, h, radius)) continue
val tx = x + xx + t.shiftX; val ty = y + yy
if (tx !in 0 until t.width || ty !in 0 until t.height) continue
val edge = !roundedContains(xx - 1, yy - 1, w - 2, h - 2, maxOf(0, radius - 1))
t.put(x + xx, ty, if (edge && border < 16) border else maxOf(fill, t.get(tx, ty)))
}
}
7 -> { require(p.size == 2); executeList(word(p, 0), t, screen, apply, stack, budget, refs) }
else -> error("Unknown draw opcode")
}
@@ -0,0 +1,56 @@
package com.faceclaw.app
/** A retained selection or image, replayed at stereo depth over the screen and shell surfaces. */
class MenuSelection(val x: Int, val y: Int, val width: Int, val height: Int, val radius: Int,
val background: Int, val border: Int, val depth: Int, val packed: ByteArray, val occlusions: List<IntArray> = emptyList(), val kind: Int = 3, val mask: List<IntArray> = emptyList()) {
val resource = CachedResource(DrawProtocol.rawImage(width, height, packed))
val fingerprint = "$kind,${mask.joinToString { it.joinToString() }},$x,$y,$width,$height,$radius,$background,$border,$depth,${resource.hash},${occlusions.joinToString { it.joinToString() }}"
fun translated(dx: Int, dy: Int) = MenuSelection(x + dx, y + dy, width, height, radius, background, border, depth, packed, occlusions.map { intArrayOf(it[0] + dx, it[1] + dy, it[2], it[3]) }, kind, mask)
fun calls(id: Int): List<ByteArray> {
val image = when (kind) {
3 -> listOf(DrawProtocol.roundedRect(x, y, width, height, radius, background, border, depth),
DrawProtocol.image(id, x, y, 31, depth = depth))
4 -> listOf(DrawProtocol.image(id, x, y, 31, depth = depth))
// Gray8 zero is transparent but gray8 one is opaque black. Rect copies preserve
// that distinction after packing, including the transparent corners of app menus.
5 -> mask.map { r -> DrawProtocol.call(2, DrawProtocol.word(id) +
r.flatMap { DrawProtocol.word(it).toList() }.toByteArray() +
DrawProtocol.word(x + r[0]) + DrawProtocol.word(y + r[1]), depth = depth) }
else -> error("Invalid presentation kind")
}
return image + occlusions.map { r -> DrawProtocol.call(2, DrawProtocol.word(DrawProtocol.SCREEN) + r.flatMap { DrawProtocol.word(it).toList() }.toByteArray() + DrawProtocol.word(r[0]) + DrawProtocol.word(r[1])) }
}
companion object {
/** The caller has consumed the presentation tag (3, 4 or 5). Colors cross the bridge in gray8, pixels in gray8 rows. */
fun read(reader: ByteReader, kind: Int = 3): MenuSelection {
require(kind in 3..5)
require(reader.remaining() >= 15)
val x = reader.getShort().toInt(); val y = reader.getShort().toInt()
val w = reader.getShort().toInt() and 65535; val h = reader.getShort().toInt() and 65535
val radius = reader.getShort().toInt() and 65535
val background = BmpUtil.nibbleForGray(reader.get() and 255)
val border = BmpUtil.nibbleForGray(reader.get() and 255)
val depth = reader.get().toByte().toInt()
val count = reader.getShort().toInt() and 65535
require(count <= 2048)
require(w in 1..640 && h in 1..480 && 5 + (w + 1) / 2 * h <= 65536 && reader.remaining() >= w * h)
val gray = ByteArray(w * h); reader.get(gray)
require(reader.remaining() >= count * 8)
val occlusions = List(count) { IntArray(4) { reader.getShort().toInt() and 65535 } }
val mask = ArrayList<IntArray>()
if (kind == 5) for (yy in 0 until h) {
var start = -1
for (xx in 0..w) {
val covered = xx < w && gray[yy * w + xx].toInt() != 0
if (covered && start < 0) start = xx
if (!covered && start >= 0) {
val previous = mask.lastOrNull { it[0] == start && it[2] == xx - start && it[1] + it[3] == yy }
if (previous != null) previous[3]++ else mask.add(intArrayOf(start, yy, xx - start, 1))
start = -1
}
}
}
return MenuSelection(x, y, w, h, radius, background, border, depth, BmpUtil.pack4bppFromGray8(gray, w, h), occlusions, kind, mask)
}
}
}
@@ -1,19 +1,29 @@
package com.faceclaw.app
/** Immutable shell snapshot. Keys identify writable surfaces across repaints, not their pixels. */
class ShellScene(val layers: List<Layer>) {
class Layer(val key: Int, val x: Int, val y: Int, val width: Int, val height: Int, val dim: Int, val packed: ByteArray)
val fingerprint: String = layers.joinToString(";") { "${it.key},${it.x},${it.y},${it.width},${it.height},${it.dim},${CachedResource(it.packed).hash}" }
fun preview(screenGray: ByteArray, width: Int, height: Int): ByteArray {
val screen = BmpUtil.pack4bppFromGray8(screenGray, width, height)
val output = ByteArray(screen.size); val resources = HashMap<Int, ByteArray>(); val calls = ArrayList<ByteArray>()
for ((id, layer) in layers.withIndex()) {
class ShellScene(val layers: List<Layer>, val selections: List<MenuSelection> = emptyList()) {
class Layer(val key: Int, val x: Int, val y: Int, val width: Int, val height: Int, val dim: Int, val packed: ByteArray, val selections: List<MenuSelection> = emptyList(), val depth: Int = 0)
val allSelections = selections + layers.flatMap { it.selections }
val fingerprint: String = layers.joinToString(";") { "${it.key},${it.x},${it.y},${it.width},${it.height},${it.dim},${it.depth},${CachedResource(it.packed).hash},${it.selections.joinToString { row -> row.fingerprint }}" } + selections.joinToString { it.fingerprint }
fun calls(width: Int, height: Int, surfaces: IntArray, selected: IntArray): List<ByteArray> {
val calls = ArrayList<ByteArray>(); var rowId = 0
for (row in selections) calls.addAll(row.calls(selected[rowId++]))
for ((index, layer) in layers.withIndex()) {
if (layer.dim < 256) calls.add(DrawProtocol.lut(width, height, layer.dim))
resources[id] = DrawProtocol.rawImage(layer.width, layer.height, layer.packed)
calls.add(DrawProtocol.image(id, layer.x, layer.y))
calls.add(DrawProtocol.image(surfaces[index], layer.x, layer.y, depth = layer.depth))
for (row in layer.selections) calls.addAll(row.calls(selected[rowId++]))
}
resources[511] = DrawProtocol.displayList(calls)
DisplayListRenderer(resources).render(511, DisplayListRenderer.Target(screen, width, height), DisplayListRenderer.Target(output, width, height))
return calls
}
fun preview(screenGray: ByteArray, width: Int, height: Int, rightLens: Boolean = false): ByteArray {
val screen = BmpUtil.pack4bppFromGray8(screenGray, width, height)
val output = ByteArray(screen.size); val resources = HashMap<Int, ByteArray>()
val surfaces = IntArray(layers.size) { id ->
val layer = layers[id]; resources[id] = DrawProtocol.rawImage(layer.width, layer.height, layer.packed); id
}
val rows = IntArray(allSelections.size) { id -> resources[id + layers.size] = allSelections[id].resource.bytes; id + layers.size }
resources[511] = DrawProtocol.displayList(calls(width, height, surfaces, rows))
DisplayListRenderer(resources, rightLens = rightLens).render(511, DisplayListRenderer.Target(screen, width, height), DisplayListRenderer.Target(output, width, height))
val target = DisplayListRenderer.Target(output, width, height)
return ByteArray(width * height) { (target.get(it % width, it / width) * 16).toByte() }
}
@@ -23,17 +33,20 @@ class ShellScene(val layers: List<Layer>) {
val count = reader.getShort().toInt() and 65535; require(count <= 64)
val layers = ArrayList<Layer>()
repeat(count) {
require(reader.remaining() >= 14)
require(reader.remaining() >= 16)
val key = reader.getShort().toInt() and 65535
val x = reader.getShort().toInt(); val y = reader.getShort().toInt()
val w = reader.getShort().toInt() and 65535; val h = reader.getShort().toInt() and 65535
val dim = reader.getShort().toInt() and 65535
val reserved = reader.getShort().toInt(); require(reserved == 0 && dim <= 256)
val selectionCount = reader.getShort().toInt() and 65535; require(selectionCount <= 64 && dim <= 256)
val depth = reader.getShort().toInt(); require(depth in -128..127)
require(w in 1..640 && h in 1..480 && 5 + (w + 1) / 2 * h <= 65536 && reader.remaining() >= w * h)
val gray = ByteArray(w * h); reader.get(gray)
layers.add(Layer(key, x, y, w, h, dim, BmpUtil.pack4bppFromGray8(gray, w, h)))
val selections = List(selectionCount) { MenuSelection.read(reader, reader.get().toInt()) }
layers.add(Layer(key, x, y, w, h, dim, BmpUtil.pack4bppFromGray8(gray, w, h), selections, depth))
}
require(reader.remaining() == 0)
require(layers.sumOf { it.selections.size } + layers.size < 511)
require(layers.map { it.key }.toSet().size == layers.size)
return ShellScene(layers)
}
@@ -50,6 +50,7 @@ class SurfaceCompositor {
var out: MutableList<ScreenDraw> = ArrayList()
while ((cursor.remaining() >= 1)) {
var kind: Int = (cursor.get() and 0xff)
if (kind in 3..5) { out.add(ScreenDraw.image(0, 0, 0).also { it.selection = MenuSelection.read(cursor, kind) }); continue }
if (((kind == ScreenDraw.KIND_GLYPH) && (cursor.remaining() >= 11))) {
var fontId: Int = (cursor.getShort().toInt() and 0xffff)
var encoding: Int = cursor.getInt()
@@ -106,6 +107,7 @@ class SurfaceCompositor {
* raster comes from ImageAtlas under imageId.
*/
class ScreenDraw {
@JvmField var selection: MenuSelection? = null
companion object {
const val KIND_GLYPH: Int = 0
@@ -609,6 +611,7 @@ class SurfaceCompositor {
var fingerprint: StringBuilder = StringBuilder()
fingerprint.append(screenWidth).append('x').append(screenHeight)
var draws: MutableList<ScreenDraw> = ArrayList()
val selections = ArrayList<MenuSelection>()
for (surface in ordered) {
if (!surface.visible || (shellScene != null && surface.id == "shell")) {
continue
@@ -616,6 +619,8 @@ class SurfaceCompositor {
blendLocked(gray, surface)
var dim: Int = dimForLocked(surface)
for (draw in surface.draws) {
val selected = draw.selection
if (selected != null) { selections.add(selected.translated(surface.x, surface.y)); continue }
if (((dim < 256) && (draw.kind == ScreenDraw.KIND_IMAGE))) {
continue
}
@@ -656,8 +661,8 @@ class SurfaceCompositor {
fingerprint.append(":dim").append(dim)
}
}
val scene = if (surfaces.values.any { it.visible && it.zOrder > 1 }) ShellScene.EMPTY else shellScene ?: ShellScene.EMPTY
val preview = if (shellScene != null) scene.preview(gray, screenWidth, screenHeight) else gray
val scene = if (surfaces.values.any { it.visible && it.zOrder > 1 }) ShellScene.EMPTY else ShellScene(shellScene?.layers ?: emptyList(), selections)
val preview = if (shellScene != null || selections.isNotEmpty()) scene.preview(gray, screenWidth, screenHeight) else gray
return Composite(preview, screenWidth, screenHeight, fingerprint.append("|shell:").append(scene.fingerprint).toString(),
nextCompositeSeq++, draws.toTypedArray()).also { it.screenGray = gray; it.shellScene = scene }
}
+1 -1
View File
@@ -156,7 +156,7 @@ test('the background registers once and uses a nine-byte image reference on late
return 1;
} } } } },
});
const { prepareFrameDraws } = load('app/graphics/glyph-wire.ts', { '../native/texture-atlas': atlas });
const { prepareFrameDraws } = load('app/graphics/glyph-wire.ts', { '../native/texture-atlas': atlas, './presentation-wire': load('app/graphics/presentation-wire.ts') });
const background = compass.createCompassBackground(576, 260, 256, 193.25, 98, 140, 1);
for (const heading of [0, 1, 2, 45, 90]) {
const image = background.clone();
@@ -34,7 +34,86 @@ class DisplayListTest {
2 to DrawProtocol.displayList(listOf(DrawProtocol.call(7,DrawProtocol.word(1)))))
assertFails { DisplayListRenderer(cyclic).render(1,target,target) }
}
private class Glasses {
@Test fun roundedRectsAndNestedOddNegativeDepthMatchFirmwareOnBothLenses() {
val resources = mapOf(
40 to hex("0404000200f00f0ff0"),
41 to hex("0202000f00080202010001000c0008000300040a0a000402022800050004001f"),
42 to hex("02010005000702fd2900"))
val screen = hex("012345601234560112345601234560122345601234560123345601234560123445601234560123455601234f60123456601234560123456001234560123456011234560123456012234560123456012334560123456012344560123456012345")
val expected = listOf("01234560123456011aaaaaaaaaa56012aa45644444aa0123a4564444456a1234a564f44f564a2345a6444fff644a3456a4444456444a4560aa44456444aa56011aaaaaaaaaa56012234560123456012334560123456012344560123456012345", "012345601234560112aaaaaaaaaa60122aa56444445aa1233a5644444564a2344a644f44f644a3455a4444ff6444a4566a4444564444a5600aa44564444aa60112aaaaaaaaaa6012234560123456012334560123456012344560123456012345")
for (right in listOf(false, true)) {
val output = ByteArray(screen.size)
DisplayListRenderer(resources, rightLens = right).render(42, DisplayListRenderer.Target(screen,16,12), DisplayListRenderer.Target(output,16,12))
assertContentEquals(hex(expected[if(right) 1 else 0]), output)
}
for (depth in -128..127) {
assertEquals(kotlin.math.floor(depth / 2.0).toInt(), DrawProtocol.depthOffset(depth, false))
assertEquals(-kotlin.math.floor((depth + 1) / 2.0).toInt(), DrawProtocol.depthOffset(depth, true))
}
}
@Test fun roundedFillPreservesBrighterTextAndDepthClipsWithoutNibbleDamage() {
val pixels = ByteArray(32) { 0x11 }; pixels[13] = 0xf1.toByte()
val target = DisplayListRenderer.Target(pixels,8,8)
val fill = DrawProtocol.roundedRect(-1,0,8,8,2,6,16,2)
DisplayListRenderer(emptyMap()).execute(DrawProtocol.sequence(listOf(fill)),target)
assertEquals(15,target.get(2,3)); assertEquals(6,target.get(3,3)); assertEquals(1,target.get(0,0))
val bbox = DrawProtocol.call(1,hex("00000002010f10"),depth=-1)
DisplayListRenderer(emptyMap()).execute(DrawProtocol.sequence(listOf(bbox)),target)
assertEquals(15,target.get(0,0));assertEquals(1,target.get(7,0))
val before=pixels.copyOf()
assertFails { DisplayListRenderer(emptyMap()).execute(DrawProtocol.sequence(listOf(byteArrayOf(8,2))),target) }
assertContentEquals(before,pixels)
}
@Test fun selectedMenuResourcesStayOutOfScreenAndReplayAtDepthTwo() {
val planner=ScenePlanner(ResourceCacheState()); val left=Glasses(); val right=Glasses(true)
val app=ByteArray(640*480/2) { 0x11 }
fun row(x:Int) = MenuSelection(x,8,8,4,1,4,9,2,hex("00ff0000000000000000000000000000"))
val scene=ShellScene(emptyList(),listOf(row(10)))
val first=planner.plan(app,640,480,null,scene,1);left.apply(first.commands);right.apply(first.commands)
assertContentEquals(app,left.screen);assertContentEquals(app,right.screen)
val l=DisplayListRenderer.Target(left.composition,640,480);val r=DisplayListRenderer.Target(right.composition,640,480)
assertEquals(15,l.get(13,8));assertEquals(15,r.get(11,8));assertEquals(1,l.get(9,8))
val moved=planner.plan(app,640,480,null,ShellScene(emptyList(),listOf(row(20))),1)
assertFalse(moved.commands.any { it[0].toInt()==26 || it[0].toInt()==29 })
left.apply(moved.commands);assertContentEquals(app,left.screen)
left.apply(planner.plan(app,640,480,null,ShellScene.EMPTY,1).commands)
assertContentEquals(app,left.composition)
}
@Test fun contextMenusAndSidebarDepthReplayOnBothLensesWithoutBakedCopies() {
fun record(kind: Int, x: Int, y: Int, w: Int, h: Int, depth: Int, gray: ByteArray): MenuSelection {
val bytes = DrawProtocol.word(x) + DrawProtocol.word(y) + DrawProtocol.word(w) + DrawProtocol.word(h) +
DrawProtocol.word(0) + byteArrayOf(16, 48, depth.toByte()) + DrawProtocol.word(0) + gray
return MenuSelection.read(ArrayByteReader(bytes), kind)
}
val menu = record(5, 10, 10, 8, 8, 4, ByteArray(64) { if (it == 0) 0 else 1 })
val selected = record(3, 12, 12, 4, 2, 6, ByteArray(8) { -1 })
val icon = record(4, 30, 10, 2, 2, -2, ByteArray(4) { -1 })
val app = ByteArray(640 * 480 / 2) { 0x66 }
val planner = ScenePlanner(ResourceCacheState())
val scene = ShellScene(emptyList(), listOf(menu, selected, icon))
val plan = planner.plan(app, 640, 480, null, scene, 1)
for (right in listOf(false, true)) {
val glasses = Glasses(right); glasses.apply(plan.commands)
assertContentEquals(app, glasses.screen)
val output = DisplayListRenderer.Target(glasses.composition,640,480)
val shift = if (right) -2 else 2
assertEquals(6, output.get(10 + shift,10)) // transparent corner
assertEquals(0, output.get(11 + shift,10)) // opaque black stays opaque
assertEquals(15, output.get(12 + (if (right) -3 else 3),12))
assertEquals(15, output.get(30 + (if (right) 1 else -1),10))
assertEquals(6, output.get(if (right) 30 else 31,10)) // no unshifted icon
val preview = scene.preview(ByteArray(640*480) { 96 },640,480,right)
assertContentEquals(glasses.composition, BmpUtil.pack4bppFromGray8(preview,640,480))
}
// The shell uses an independently owned surface with its own depth.
val shell = ShellScene(listOf(ShellScene.Layer(1,10,10,8,8,256,ByteArray(32),listOf(selected),4)))
val left = shell.preview(ByteArray(640*480) { 96 },640,480)
val right = shell.preview(ByteArray(640*480) { 96 },640,480,true)
assertEquals(0,left[10*640+12].toInt()); assertEquals(96,left[10*640+10].toInt())
assertEquals(0,right[10*640+8].toInt()); assertEquals(96,right[10*640+16].toInt())
}
private class Glasses(val right: Boolean = false) {
val resources=mutableMapOf<Int,ByteArray>(); val screen=ByteArray(640*480/2);val composition=ByteArray(screen.size)
var root=65535
fun apply(commands: List<ByteArray>) {
@@ -46,9 +125,9 @@ class DisplayListTest {
} }
22 -> repeat(DrawProtocol.u16(b,1)) { resources.remove(DrawProtocol.u16(b,3+it*2)) }
29 -> repeat(DrawProtocol.u16(b,1)) { val p=3+it*6;resources.getOrPut(DrawProtocol.u16(b,p)) { DrawProtocol.rawImage(DrawProtocol.u16(b,p+2),DrawProtocol.u16(b,p+4)) } }
26 -> DisplayListRenderer(resources).execute(b.copyOfRange(1,b.size),DisplayListRenderer.Target(screen,640,480))
26 -> DisplayListRenderer(resources, rightLens = right).execute(b.copyOfRange(1,b.size),DisplayListRenderer.Target(screen,640,480))
27 -> root=DrawProtocol.u16(b,1)
28 -> DisplayListRenderer(resources).render(root,DisplayListRenderer.Target(screen,640,480),DisplayListRenderer.Target(composition,640,480))
28 -> DisplayListRenderer(resources, rightLens = right).render(root,DisplayListRenderer.Target(screen,640,480),DisplayListRenderer.Target(composition,640,480))
else -> error("legacy command ${b[0]}")
}
}
+110
View File
@@ -0,0 +1,110 @@
const test=require('node:test');
const assert=require('node:assert/strict');
const fs=require('node:fs');
const vm=require('node:vm');
const ts=require('typescript');
const graphics=require('../.test-build/app/graphics/image.js');
const planes=require('../.test-build/app/graphics/plane.js');
const wire=require('../.test-build/app/graphics/presentation-wire.js');
const {encodeShellScene}=require('../.test-build/app/graphics/shell-scene.js');
const {SurfaceCompositor}=require('../.test-build/app/graphics/surface-compositor.js');
function load(file,modules) {
const context={exports:{},require:name=>{assert.ok(name in modules, name);return modules[name];}};
vm.runInNewContext(ts.transpileModule(fs.readFileSync(file,'utf8'),{compilerOptions:{module:ts.ModuleKind.CommonJS,target:ts.ScriptTarget.ES2020}}).outputText,context);
return context.exports;
}
const font={lineHeight:12,ascent:10,descent:2,measureText:text=>text.length*4,
drawText:(image,x,y,text,value)=>{for(let i=0;i<text.length;i++) image.fillRect(x+i*4,y+2,2,6,value);}};
const {MenuLayer}=load('app/ui/menu.ts',{
'../graphics/image':graphics,'../graphics/textwrap':{},'../graphics/ui-fonts':{getDefaultSmallFont:()=>font},
'../util/numeric-util':{clamp:(n,a,b)=>Math.max(a,Math.min(b,n))},'./gestures':{},
'./metrics':require('../.test-build/app/ui/metrics.js'),
});
const {prepareFrameDraws}=load('app/graphics/glyph-wire.ts',{'./presentation-wire':wire,'../native/texture-atlas':{textureAtlasAvailable:()=>false}});
function menu() {
const layer=new MenuLayer(null,[{label:'FIRST',onSelect(){}},{label:'SECOND',onSelect(){}}],{x:0,y:0,width:80,minHeight:70,maxHeight:80,squareCorners:true});
const context={stack:{getBaseSize:()=>({width:80,height:80}),isFocused:()=>true}};
return {layer,paint:()=>layer.paint(context,()=>new graphics.GrayImage(80,80)),context};
}
test('menu retains the selected text and rounded highlight at depth +2',async()=>{
const m=menu(),image=m.paint(),row=image.draws.find(d=>d.presentation);
assert.equal(row.presentation.depth,2);assert.equal(row.presentation.radius,8);
assert.ok(row.source.pixels.some(v=>v===255));assert.ok(!image.withDrawsBaked(false).pixels.some(v=>v===255));
const flat=planes.flattenPlanesWithDraws([{image,x:0,y:0}]);
const records=wire.presentationRecords(prepareFrameDraws(flat.draws));assert.equal(records.length,1);
const c=new SurfaceCompositor(80,80);c.configureSurface('app',{x:0,y:0,width:80,height:80,zOrder:0,transparency:'opaque'});
c.submitSurfaceFrame('app',flat.image.pixels,{x:0,y:0,width:80,height:80},prepareFrameDraws(flat.draws));
const screen=flat.image.pixels.slice(),preview=c.composite();
assert.ok(preview.some(v=>v===240));assert.deepEqual(flat.image.pixels,screen);
await m.layer.handleInput({type:'scroll-down'},m.context);
const next=m.paint().draws.find(d=>d.presentation);assert.ok(next.y>row.y);assert.equal(next.presentation.depth,2);
});
test('shell menu selection survives serialization and is not baked into its surface',()=>{
const image=menu().paint(),bytes=encodeShellScene([{image,x:0,y:0,shellKey:7}]);
assert.equal(new DataView(bytes.buffer).getUint16(14,true),1);
const c=new SurfaceCompositor(80,80);c.setShellScene(bytes);assert.ok(c.composite().some(v=>v===240));
});
test('later opaque planes occlude a replayed selection without erasing its visible part',()=>{
const image=menu().paint(),row=image.draws.find(d=>d.presentation),cover=new graphics.GrayImage(10,8,1);
const flat=planes.flattenPlanesWithDraws([{image,x:0,y:0},{image:cover,x:row.x+10,y:row.y+2}]);
const records=wire.presentationRecords(prepareFrameDraws(flat.draws));assert.ok(records[0].occlusions.length);
const c=new SurfaceCompositor(80,80);c.configureSurface('app',{x:0,y:0,width:80,height:80,zOrder:0,transparency:'opaque'});
c.submitSurfaceFrame('app',flat.image.pixels,{x:0,y:0,width:80,height:80},prepareFrameDraws(flat.draws));
const preview=c.composite();
for(let y=row.y+2;y<row.y+10;y++) for(let x=row.x+10;x<row.x+20;x++) assert.equal(preview[y*80+x],0);
assert.ok(preview.some(v=>v===240));
});
const {LayerStack,noopLayerActions}=load('app/ui/layers.ts',{
'../graphics/image':graphics,'../graphics/plane':planes,'../native/frame-timings':{spanCurrent:(_name,fn)=>fn()},'./gestures':{},
});
test('context menu surface uses +4 and selected row +6 without changing the app screen',()=>{
const base=new graphics.GrayImage(100,90,96);
const stack=new LayerStack({paint:()=>base},noopLayerActions,{width:100,height:90});
stack.push(new MenuLayer(null,[{label:'FIRST',onSelect(){}}],{x:10,y:8,width:80,minHeight:70,maxHeight:70,depth:4}));
const frame=planes.flattenPlanesWithDraws(stack.paint());
assert.deepEqual(frame.image.pixels,base.pixels);
const records=wire.presentationRecords(prepareFrameDraws(frame.draws));
assert.deepEqual(records.map(r=>r.depth),[4,6]);assert.equal(records[0].mode,'masked-image');
const c=new SurfaceCompositor(100,90);c.configureSurface('app',{x:0,y:0,width:100,height:90,zOrder:0,transparency:'opaque'});
c.submitSurfaceFrame('app',frame.image.pixels,{x:0,y:0,width:100,height:90},prepareFrameDraws(frame.draws));
const preview=c.composite();
assert.equal(preview[45*100+10],96); // old left edge has no baked menu
assert.equal(preview[45*100+13],0); // shifted opaque black interior
assert.equal(preview[8*100+12],96); // transparent rounded corner
assert.ok(preview.some(v=>v===240));
stack.pop();const closed=planes.flattenPlanesWithDraws(stack.paint());
c.submitSurfaceFrame('app',closed.image.pixels,{x:0,y:0,width:100,height:90},prepareFrameDraws(closed.draws));
assert.deepEqual(c.composite(),base.pixels);
});
test('system menu bridge shifts its surface +4 and selected row +6',()=>{
const image=menu().paint(),bytes=encodeShellScene([{image,x:8,y:0,shellKey:7,depth:4}]);
const view=new DataView(bytes.buffer),w=view.getUint16(8,true),h=view.getUint16(10,true);
assert.equal(view.getInt16(16,true),4);
assert.equal(wire.readPresentation(bytes,18+w*h).selection.depth,6);
const c=new SurfaceCompositor(100,80);c.setShellScene(bytes);const preview=c.composite();
assert.equal(preview[40*100+8],0);assert.equal(preview[40*100+10],80);
});
test('unselected sidebar icons retain -2 depth through shell cropping, including attention badges',()=>{
const shellScene=require('../.test-build/app/graphics/shell-scene.js');
const {ShellChromeLayer}=load('app/ui/shell/chrome-layer.ts',{
'../../graphics/shell-scene':shellScene,'../../graphics/image':graphics,
'../../graphics/ui-fonts':{getDefaultSmallFont:()=>font,getDefaultMediumFont:()=>font},
'../../graphics/textwrap':{},'./ambient-cards':{},'../../graphics/battery':{},
'../../native/notification-icons':{},'../../native/phone-battery':{},'../../util/render-freshness':{},
'../../graphics/icons':{},'../dashboard-settings':{},'../clock-format':{},'../../graphics/bdffont':{},
'../layers':{LayerStack},'../menu':{scrollToKeepSelectionVisible:()=>0},'../metrics':{},
'./geometry':{MIN_WINDOW_HEIGHT:280,minWindowTop:()=>0,windowTop:()=>0,SHELL_OPAQUE_BLACK:1,SIDEBAR_WIDTH:64,TOP_BAR_HEIGHT:24},
});
const state={selectedIndex:0,focus:'sidebar',windows:[0,1,2].map(n=>({attention:n===1,drawIcon:(image,x,y)=>image.fillRect(x,y,4,4,240)}))};
const chrome=new ShellChromeLayer(()=>state),image=new graphics.GrayImage(640,480);
chrome.drawSidebar(image,state);
assert.deepEqual(Array.from(image.draws.filter(d=>d.presentation),d=>d.presentation.depth),[-2,-2]);
const crop=shellScene.shellCrop(image,0,0,64,280,1),bytes=encodeShellScene([crop]);
const c=new SurfaceCompositor(640,480);c.setShellScene(bytes);const preview=c.composite();
assert.equal(preview[34*640+30],240); // selected icon stays at its original x
assert.equal(preview[74*640+29],240); // unselected icon moves left by one
assert.equal(preview[74*640+33],0); // no baked copy at the original right edge
state.selectedIndex=1;const next=new graphics.GrayImage(640,480);chrome.drawSidebar(next,state);
assert.equal(next.draws.filter(d=>d.presentation).length,2);
});
+4
View File
@@ -142,6 +142,10 @@ test('Music settings keeps toggles and selection when a new app arrives and supp
const font = BdfFont.parse(source('app/fonts/terminus/ter-u20n.bdf'));
class RecordingImage extends graphics.GrayImage {
texts = [];
drawMenuSelection(source, x, y, ...args) {
this.texts.push(...source.texts.map(t => ({ ...t, x: t.x + x, y: t.y + y })));
super.drawMenuSelection(source, x, y, ...args);
}
drawText(font, x, y, text, value) { this.texts.push({ x, y, text }); super.drawText(font, x, y, text, value); }
}
const deps = {
+4
View File
@@ -58,6 +58,10 @@ function ui(fontSize = 12) {
const font = BdfFont.parse(source(`app/fonts/terminus/ter-u${fontSize}n.bdf`));
class RecordingImage extends graphics.GrayImage {
texts = [];
drawMenuSelection(source, x, y, ...args) {
this.texts.push(...source.texts.map(t => ({ ...t, x: t.x + x, y: t.y + y })));
super.drawMenuSelection(source, x, y, ...args);
}
drawText(font, x, y, text, value) {
this.texts.push({ x, y, text });
super.drawText(font, x, y, text, value);
+3
View File
@@ -25,6 +25,9 @@
"../app/g2/flash-prompt-protocol.ts",
"../app/graphics/surface-compositor.ts",
"../app/graphics/image.ts",
"../app/graphics/plane.ts",
"../app/graphics/shell-scene.ts",
"../app/ui/metrics.ts",
"../app/phone-ui/phone-gestures.ts",
"../app/g2/firmware-compat.ts",
"../app/g2/glasses-hardware-identity.ts",