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 {