Add Glanceboard depth setting

This commit is contained in:
James Babcock committed 2026-09-24 02:26:20 -07:00
1 parent 71c1971992
commit 915f155819
29 files changed
+262 -50

No files matched your search

@@ -291,6 +291,8 @@ class FaceclawBleCommunicator(context: Context, rightAddress: String?, leftAddre
fun setSurfaceVisible(id: String, visible: Boolean) = core.setSurfaceVisible(id, visible)
fun setSurfaceDepth(id: String, depth: Int) = core.setSurfaceDepth(id, depth)
fun setScreenBlanked(blanked: Boolean) = core.setScreenBlanked(blanked)
fun configureSurface(id: String?, x: Int, y: Int, width: Int, height: Int, zOrder: Int, transparency: Int) =
@@ -87,6 +87,10 @@ class FaceclawPreviewCompositor(context: Context) {
compositor.setSurfaceVisible(id, visible)
}
fun setSurfaceDepth(id: String, depth: Int) {
compositor.setSurfaceDepth(id, depth)
}
/** Blank (screen off) or unblank the output; retained surface state survives. */
fun setScreenBlanked(blanked: Boolean) {
compositor.setBlanked(blanked)
+1
View File
@@ -7,6 +7,7 @@
* Add tokens and faceclaw-input script, which allows using a CLI utility as an input device for the glasses
* Navigate app: Add map-without-destination mode
* Nightscout app: Glanceboard widget still shows out-of-bounds values when out of space
* Glanceboard: Add distance setting
### iOS port:
+2
View File
@@ -54,6 +54,8 @@ export type GlanceboardProvider = {
showOnLongPress: () => boolean;
/** Whether the head-tilt wake goes to the board rather than the regular UI. */
showOnHeadTilt: () => boolean;
/** Stereo depth (firmware units; positive is nearer) while the board covers the screen. */
depth: () => number;
/** A fresh board; requestRender asks the host to repaint it. */
createBoard: (requestRender: () => void) => GlanceBoardInstance;
};
+3 -1
View File
@@ -13,6 +13,7 @@ import { GlanceBoard } from "./board";
import {
clearConflictingSlots,
glanceboardEnabledSetting,
glanceDepthSetting,
glanceLayout,
glanceLayoutSetting,
glanceShowLinesSetting,
@@ -297,7 +298,7 @@ function openSlotPicker(ctx: LayerContext, slotIndex: number): void {
openModalMenu(ctx, setting.label, items, Math.max(0, setting.values.indexOf(current)));
}
/** Settings: layout, sleep gestures, duration, and slot lines. */
/** Settings: layout, sleep gestures, duration, slot lines, and stereo depth. */
function openGlanceSettings(ctx: LayerContext): void {
const items: MenuItem[] = [
enumSettingMenuItem(glanceLayoutSetting),
@@ -305,6 +306,7 @@ function openGlanceSettings(ctx: LayerContext): void {
toggleSettingMenuItem(glanceShowOnLongPressSetting),
toggleSettingMenuItem(glanceShowOnHeadTiltSetting),
toggleSettingMenuItem(glanceShowLinesSetting),
enumSettingMenuItem(glanceDepthSetting),
];
ctx.stack.push(new MenuLayer("Glanceboard settings", items, pageMenuLayout(ctx.stack.getBaseSize().width)));
}
@@ -103,6 +103,31 @@ export const glanceShowOnHeadTiltSetting = new ConfigSettingBoolean({
description: "Tilting your head up while asleep shows the Glanceboard instead of waking the regular UI.",
});
const DEPTH_VALUES = ["-64", "-48", "-32", "-16", "0", "16", "32", "48", "64"] as const;
export type GlanceDepth = (typeof DEPTH_VALUES)[number];
/**
* Stereo depth of the board, in the firmware's depth units: the lenses shift
* it by half this many pixels each, in opposite directions.
*/
export const glanceDepthSetting = new ConfigSettingEnum<GlanceDepth>({
id: "glanceboard-depth",
label: "Depth",
storageKey: "glanceboard.depth",
defaultValue: "0",
values: DEPTH_VALUES,
formatValue: (value) => {
const depth = Number(value);
return depth === 0 ? "0" : depth > 0 ? `+${depth} (nearer)` : `${depth} (farther)`;
},
description:
"Moves the Glanceboard nearer (positive) or farther away (negative) by shifting it in opposite directions on the two lenses.",
});
export function glanceDepth(): number {
return Number(glanceDepthSetting.get());
}
/** Hairlines between the board's slots. */
export const glanceShowLinesSetting = new ConfigSettingBoolean({
id: "glanceboard-show-lines",
+2
View File
@@ -3,6 +3,7 @@ import { GlanceBoard } from "./board";
import { createGlanceboardAppWindow, GLANCEBOARD_SURFACE_ID, GLANCEBOARD_WINDOW_ID } from "./glanceboard-app";
import {
glanceboardEnabledSetting,
glanceDepth,
glanceLayout,
glanceShowOnHeadTiltSetting,
glanceShowOnLongPressSetting,
@@ -25,6 +26,7 @@ const glanceboardApp: AppDefinition = {
tapTimeoutMs: glanceTapTimeoutMs,
showOnLongPress: () => glanceShowOnLongPressSetting.get(),
showOnHeadTilt: () => glanceShowOnHeadTiltSetting.get(),
depth: glanceDepth,
createBoard: (requestRender) => new GlanceBoard(requestRender),
},
};
+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 = 27;
export const REQUIRED_FACECLAW_FIRMWARE_VERSION = 28;
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": "62ed330a71d6be45a4482e6007b00fc7f029a01d238f358f69ba992f83769590",
"outputSha256": "8dbb39ad4acaf430e889ff98fe698ccb54d55c19d90a4d7053ce0fb804adb11b",
"patches": [
{
"offset": 1045797,
"old": "38b584b0",
"new": "5cf31db9",
"new": "5cf35fb9",
"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": "fcf22cfe",
"new": "fcf26efe",
"desc": "cfw_ancs_event"
},
{
"offset": 1437951,
"old": "fef7e8fb",
"new": "fcf266fb",
"new": "fcf2a8fb",
"desc": "cfw_ancs_open"
},
{
"offset": 1437969,
"old": "fef7e7fb",
"new": "fcf27dfb",
"new": "fcf2bffb",
"desc": "cfw_ancs_close"
},
{
"offset": 1388387,
"old": "39694d00",
"new": "41547d00",
"new": "c5547d00",
"desc": "connection-bound ANCS EUS write callback"
},
{
"offset": 971497,
"old": "fff717f8",
"new": "6ef34dfa",
"new": "6ef38ffa",
"desc": "bl faceclaw_input_bridge_received (ring relay and ordered private transport before worker pool)"
},
{
"offset": 971845,
"old": "fef769ff",
"new": "6ef39ff9",
"new": "6ef3e1f9",
"desc": "bl faceclaw_input_bridge_received (ring relay and ordered private transport before worker pool)"
},
{
"offset": 979579,
"old": "fdf74ef8",
"new": "6cf384fa",
"new": "6cf3c6fa",
"desc": "bl faceclaw_input_bridge_received (ring relay and ordered private transport before worker pool)"
},
{
"offset": 1428895,
"old": "f8f76cfd",
"new": "fbf2c4fd",
"new": "fbf206fe",
"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": "29f354fc",
"new": "29f396fc",
"desc": "bl settings_send_wrapper (append caps field 100)"
},
{
"offset": 1246183,
"old": "f5f7e2f8",
"new": "29f330fe",
"new": "29f372fe",
"desc": "bl settings_decode_wrapper (Faceclaw lease field 101)"
},
{
"offset": 975219,
"old": "02f083fc",
"new": "6bf39cfe",
"new": "6bf3defe",
"desc": "bl faceclaw_display_start @ 0x467d68 (fail-open wake takeover)"
},
{
"offset": 975411,
"old": "02f023fc",
"new": "6bf300ff",
"new": "6bf342ff",
"desc": "bl faceclaw_display_start_headup @ 0x467e28 (fail-open wake takeover)"
},
{
"offset": 975103,
"old": "07f085fb",
"new": "6df356fa",
"new": "6df398fa",
"desc": "bl headup_gate (head-up sensor event -> EvenHub sys event 12 under lease)"
},
{
"offset": 830549,
"old": "19f03efb",
"new": "90f305fc",
"new": "90f347fc",
"desc": "bl gesture_ring_press_mode (observe ring touch-down, preserve stock dispatch)"
},
{
"offset": 830795,
"old": "1ff071ff",
"new": "90f3befb",
"new": "90f300fc",
"desc": "bl gesture_press (owned event 9 before stock menu gate)"
},
{
"offset": 830887,
"old": "1ff043ff",
"new": "90f3b8fb",
"new": "90f3fafb",
"desc": "bl gesture_short_long (Faceclaw lease gates event 11 vs stock Menu path)"
},
{
"offset": 831763,
"old": "1ff08dfd",
"new": "90f3eef9",
"new": "90f330fa",
"desc": "bl gesture_release (owned event 10 before stock menu gate)"
},
{
"offset": 1570209,
"old": "7fb50600",
"new": "daf2e5bf",
"new": "dbf227b8",
"desc": "even_ai_display_ctrl entry -> conditional Faceclaw lease trampoline"
},
{
"offset": 1051545,
"old": "f6f787f9",
"new": "54f3cdff",
"new": "55f30ff8",
"desc": "bl display_copy_hook @ 0x47a78e (640x480 direct framebuffer)"
},
{
"offset": 1051861,
"old": "f6f7e9f8",
"new": "54f32fff",
"new": "54f371ff",
"desc": "bl display_copy_hook @ 0x47a8ca (640x480 direct framebuffer)"
},
{
"offset": 1262237,
"old": "d9f7d0fd",
"new": "25f365fd",
"new": "25f3a7fd",
"desc": "bl faceclaw_send_wear_event @ 0x4ade92 (outside onboarding)"
},
{
"offset": 1262337,
"old": "d9f79efd",
"new": "25f333fd",
"new": "25f375fd",
"desc": "bl faceclaw_send_wear_event @ 0x4adef6 (outside onboarding)"
},
{
"offset": 1309405,
"old": "67f02dff",
"new": "19f33dfe",
"new": "19f37ffe",
"desc": "bl compass_decode_capture (sample-matched GAF diagnostics)"
},
{
"offset": 1307865,
"old": "fff7c9fb",
"new": "1af3bbf9",
"new": "1af3fdf9",
"desc": "bl compass_report_event (stock UI + heading with diagnostics over BLE)"
},
{
"offset": 1300937,
"old": "00210170",
"new": "1bf3a1fe",
"new": "1bf3e3fe",
"desc": "bl compass_preserve_accuracy (retain magnetic calibration under Faceclaw framebuffer lease)"
},
{
"offset": 4537963,
"old": "",
"new": "b0b581ea00039b0701d0034637e0c2b110f0030315d000f1010ca2f1010e0023cc5c9e45c45403f1010404d0634413f003032346f4d121440319121b102a14d302e00346102a10d3d1f800c0d1f804e0cc688d68103adc609d60c3f804e043f810cb0f2a01f11001eed8042a07d300bf51f8045b043a032a43f8045bf8d8002a08bfb0bd0139013b11f8015f013a03f8015ff9d1b0bd00bf884218bf002a00d1704710b50b1a38bf431a934207d288420ad281ea00039b0726d0034669e0fff79fffbde81040704781ea000300eb020c9b0701eb020e42d15fea8c732bd0a0f1010c00bf8b1813f801ec8418531e04f801ec04d0624412f003021a46f2d101eb030e00eb030c17e0830736d0a2f1010c00f1010e002300bfcc5c9c45c45403f1010404d0734413f003032346f4d1121b2144031922e01346042b0ed3aef10402acf1040152f80449043b032b41f80449f8d802f1040e01f1040c1a4653b1aef10101acf1010300bf11f80149013a03f80149f9d1bde8104070470346042a06d351f8044b043a032a43f8044bf8d8002af0d00139013b00bf11f8014f013a03f8014ff9d1e6e700bf2de9f04fc5b04ff64c484ef66c6b4ff29c591446cff6ff78ccf2ff0bc2f229094ff6ff75002701260d93cde90e0106e048f2a351c0f24501bff32f8f8847d9f800a0bff35f8fd9f800000321cff680710140b1f1005fbff35f8f02d10168594544d04ff46d7006f04bfc002800f01a81414600bf42180c3182f8b47382f8b57382f8b67382f8b77382f8b87382f8b97382f8ba7382f8bb7382f8bc7382f8bd7382f8be7382f8bf73e4d1c0f800b086728583c583058445848584c584058545858585c585058645868586c5860587458759e8001f5145abd1bff35f8f49e8000121b159e8001f5145f8d0a1e70f99012641ea04410024c0f8701206e048f2a351c0f24501bff32f8f8847d9f80070bff35f8fd9f800000321cff680710140b1f1005fbff35f8f02d10168594544d04ff46d7006f0e5fb002800f0b480414600bf42180c3182f8b44382f8b54382f8b64382f8b74382f8b84382f8b94382f8ba4382f8bb4382f8bc4382f8bd4382f8be4382f8bf43e4d1c0f800b086728583c583058445848584c584058545858585c585058645868586c5860587458759e8001fb942abd1bff35f8f49e8000121b159e8001fb942f8d0a1e7d0f874a242f6f766c0f24406baf1000fbff35f8f4ad006f19a0250464ff0ff314ff0ff379047002840f023810f9800285fd00e980778a7f11700022859d80f980c2840f00c810e9e7078b178084300f00681f0780138022800f20181b279f379747a42ea0322337a307942ea0342717942ea0463b27af67a192f42ea062200f06f83172f40f08483002a40f0e880fe2800f07485812800f06685002840f07b8551ea030040f0db8000f0fabe04460020b047d8b104f51d7151e800afbaf1000f0bd1bff35f8f00bf41e80002002a7bd051e800afbaf1000ff6d00021bff32f8f0029bff35f8f6bd0824694e74ff0ff37bfe047f6df40c0f24f008047002701261197adf8487006e048f2a351c0f24501bff32f8f8847d9f80040bff35f8fd9f800000321cff680710140b1f1005fbff35f8f02d10168594549d04ff46d7006f003fb002842d0414642180c3182f8b47382f8b57382f8b67382f8b77382f8b87382f8b97382f8ba7382f8bb7382f8bc7382f8bd7382f8be7382f8bf73e4d1c0f800b086728583c583058445848584c584058545858585c585058645868586c5860587458759e8001fa142add1bff35f8f49e8000159b159e8001fa142f8d0a3e706f5a971884726e7012189e700200e9999b10f9a8ab1097801f07f02b2f10b0418bf0124b2f11c0618bf01268a2924dc0b2926d01c2924d03fe00d9010a804f0c7f84ff0ff3701269df84900002810a818bf4ff0ff3704f08bf9054646b99df8480028b94af21f30c0f247004c3080470d98002818bfc56013e09c2901d08b291bd160b14af21f31c0f247010746884797f8641119b997f80413384669b14ff0ff3742f6f760c0f2440000f5807150468847384645b0bde8f08f0d9010a8264004f086f80e98007800f07f041d2c00f07e0018bf1a2811d1d9f800100322cff680720a40b2f1005fbff35f8f0ad10a685a4504bf002281f8812303e0a4f115010129e9d90f2c0adc092c00f3cc80052c00f07882072c40f0f282002769e0142c00f37781102c00f07582112c40f0e7820f98022840f00b840e990878112840f006844878002840f0028445f64d50c0f24600804701284ff000077ff475af40f20830c0f210003590ff208df8d00044f25220c0f20100339040f2c960c0f248003446cde93677804798b148f27e30c2f2070000880122c1b264298df8cf2008d80721b0f5807f38bf03218df8cf108df8d00040f2d260adf8d800052035ae8df8da00f01d33a90522fff78afc4ff22507c0f247070120092132460c23b8470746264631e748f2a351c0f24501bff32f8f8847d9f80040bff35f8fd9f800000321cff680710140b1f1005fbff35f8f03d10168594500f04e844ff46d7006f0b4f9002800f04684414642180c3182f8b47382f8b57382f8b67382f8b77382f8b87382f8b97382f8ba7382f8bb7382f8bc7382f8bd7382f8be7382f8bf73e4d10121c0f800b081728583c583058445848584c584058545858585c585058645868586c5860587458759e8001fa142aad1bff35f8f49e80001002900f00c8459e8001fa142f6d09ee70a2c00f0b9810b2c40f02682d9f800500320cff680702840b0f1005fbff35f8f41f059802868002758457ff4baaed5f870030c9642f68d46c0f244060028a5f8807318bfb0470021a5f8b013c5f8ac13c5f8681185f8661185f86411d5f86c01c5f8601185f86511c5f86c11c5f80013a5f86c1320b148f2a351c0f245018847d5f87802002818bf04f02df90024c5f87842d5f8680320b148f2a351c0f245018847c5f86843a5f86c43286ca5f8444040b1b047286c06f166018847002804bf002028644bf63940c0f251008047d9f800400320cff680702040b0f1005fbff35f8f2ad12068584527d194f877010027c4f8807188b149f25962c0f25902002044f2436184f8777190474ef6e378c0f25a08c04708f1bc008047d4f8840184f8707150b1b047d4f8840106f166018847002804bf0020c4f88401d9f800000321cff680710140b1f1005fbff35f8f40f00a860168594540f0068690f8a811002900f0fb8506f0c9fb00f0fdbd152c00f06b81162c40f070810f9801380228c0f093820e994ff0ff374878897840ea0120b0f5007f3ff605ae03210f9a01eb400191427ff4fead002700288df8d4708df8d5708df8d6708df8d7708df8d8708df8d9708df8da708df8db708df8dc708df8dd708df8de708df8df708df8e0708df8e1708df8e2708df8e3708df8e4708df8e5708df8e6708Line truncated
"new": "b0b581ea00039b0701d0034637e0c2b110f0030315d000f1010ca2f1010e0023cc5c9e45c45403f1010404d0634413f003032346f4d121440319121b102a14d302e00346102a10d3d1f800c0d1f804e0cc688d68103adc609d60c3f804e043f810cb0f2a01f11001eed8042a07d300bf51f8045b043a032a43f8045bf8d8002a08bfb0bd0139013b11f8015f013a03f8015ff9d1b0bd00bf884218bf002a00d1704710b50b1a38bf431a934207d288420ad281ea00039b0726d0034669e0fff79fffbde81040704781ea000300eb020c9b0701eb020e42d15fea8c732bd0a0f1010c00bf8b1813f801ec8418531e04f801ec04d0624412f003021a46f2d101eb030e00eb030c17e0830736d0a2f1010c00f1010e002300bfcc5c9c45c45403f1010404d0734413f003032346f4d1121b2144031922e01346042b0ed3aef10402acf1040152f80449043b032b41f80449f8d802f1040e01f1040c1a4653b1aef10101acf1010300bf11f80149013a03f80149f9d1bde8104070470346042a06d351f8044b043a032a43f8044bf8d8002af0d00139013b00bf11f8014f013a03f8014ff9d1e6e700bf80b5002a18bf10f0030301d186460ce000f1010c864600bf013a0ef8011b04d01cf003030cf1010cf6d1102a11d35ffa81fc4ff001330cfb03fc00bf103acef80cc0cef808c0cef804c04ef810cb0f2af4d8042a0bd35ffa81fc4ff001330cfb03fc00bf043a032a4ef804cbfad8002a08bf80bdaef10103013a03f8011ffbd180bd00bf2de9f04fc5b04ff64c484ef66c6b4ff29c591446cff6ff78ccf2ff0bc2f229094ff6ff75002701260d93cde90e0106e048f2a351c0f24501bff32f8f8847d9f800a0bff35f8fd9f800000321cff680710140b1f1005fbff35f8f02d10168594544d04ff46d7006f04bfc002800f01a81414600bf42180c3182f8b47382f8b57382f8b67382f8b77382f8b87382f8b97382f8ba7382f8bb7382f8bc7382f8bd7382f8be7382f8bf73e4d1c0f800b086728583c583058445848584c584058545858585c585058645868586c5860587458759e8001f5145abd1bff35f8f49e8000121b159e8001f5145f8d0a1e70f99012641ea04410024c0f8701206e048f2a351c0f24501bff32f8f8847d9f80070bff35f8fd9f800000321cff680710140b1f1005fbff35f8f02d10168594544d04ff46d7006f0e5fb002800f0b480414600bf42180c3182f8b44382f8b54382f8b64382f8b74382f8b84382f8b94382f8ba4382f8bb4382f8bc4382f8bd4382f8be4382f8bf43e4d1c0f800b086728583c583058445848584c584058545858585c585058645868586c5860587458759e8001fb942abd1bff35f8f49e8000121b159e8001fb942f8d0a1e7d0f874a242f6f766c0f24406baf1000fbff35f8f4ad006f19a0250464ff0ff314ff0ff379047002840f023810f9800285fd00e980778a7f11700022859d80f980c2840f00c810e9e7078b178084300f00681f0780138022800f20181b279f379747a42ea0322337a307942ea0342717942ea0463b27af67a192f42ea062200f06f83172f40f08483002a40f0e880fe2800f07485812800f06685002840f07b8551ea030040f0db8000f0fabe04460020b047d8b104f51d7151e800afbaf1000f0bd1bff35f8f00bf41e80002002a7bd051e800afbaf1000ff6d00021bff32f8f0029bff35f8f6bd0824694e74ff0ff37bfe047f6df40c0f24f008047002701261197adf8487006e048f2a351c0f24501bff32f8f8847d9f80040bff35f8fd9f800000321cff680710140b1f1005fbff35f8f02d10168594549d04ff46d7006f003fb002842d0414642180c3182f8b47382f8b57382f8b67382f8b77382f8b87382f8b97382f8ba7382f8bb7382f8bc7382f8bd7382f8be7382f8bf73e4d1c0f800b086728583c583058445848584c584058545858585c585058645868586c5860587458759e8001fa142add1bff35f8f49e8000159b159e8001fa142f8d0a3e706f5a971884726e7012189e700200e9999b10f9a8ab1097801f07f02b2f10b0418bf0124b2f11c0618bf01268a2924dc0b2926d01c2924d03fe00d9010a804f0c7f84ff0ff3701269df84900002810a818bf4ff0ff3704f08bf9054646b99df8480028b94af21f30c0f247004c3080470d98002818bfc56013e09c2901d08b291bd160b14af21f31c0f247010746884797f8641119b997f80413384669b14ff0ff3742f6f760c0f2440000f5807150468847384645b0bde8f08f0d9010a8264004f086f80e98007800f07f041d2c00f07e0018bf1a2811d1d9f800100322cff680720a40b2f1005fbff35f8f0ad10a685a4504bf002281f8812303e0a4f115010129e9d90f2c0adc092c00f3cc80052c00f07882072c40f0f282002769e0142c00f37781102c00f07582112c40f0e7820f98022840f00b840e990878112840f006844878002840f0028445f64d50c0f24600804701284ff000077ff475af40f20830c0f210003590ff208df8d00044f25220c0f20100339040f2c960c0f248003446cde93677804798b148f27e30c2f2070000880122c1b264298df8cf2008d80721b0f5807f38bf03218df8cf108df8d00040f2d260adf8d800052035ae8df8da00f01d33a90522fff748fc4ff22507c0f247070120092132460c23b8470746264631e748f2a351c0f24501bff32f8f8847d9f80040bff35f8fd9f800000321cff680710140b1f1005fbff35f8f03d10168594500f04e844ff46d7006f0b4f9002800f04684414642180c3182f8b47382f8b57382f8b67382f8b77382f8b87382f8b97382f8ba7382f8bb7382f8bc7382f8bd7382f8be7382f8bf73e4d10121c0f800b081728583c583058445848584c584058545858585c585058645868586c5860587458759e8001fa142aad1bff35f8f49e80001002900f00c8459e8001fa142f6d09ee70a2c00f0b9810b2c40f02682d9f800500320cff680702840b0f1005fbff35f8f41f059802868002758457ff4baaed5f870030c9642f68d46c0f244060028a5f8807318bfb0470021a5f8b013c5f8ac13c5f8681185f8661185f86411d5f86c01c5f8601185f86511c5f86c11c5f80013a5f86c1320b148f2a351c0f245018847d5f87802002818bf04f02df90024c5f87842d5f8680320b148f2a351c0f245018847c5f86843a5f86c43286ca5f8444040b1b047286c06f166018847002804bf002028644bf63940c0f251008047d9f800400320cff680702040b0f1005fbff35f8f2ad12068584527d194f877010027c4f8807188b149f25962c0f25902002044f2436184f8777190474ef6e378c0f25a08c04708f1bc008047d4f8840184f8707150b1b047d4f8840106f166018847002804bf0020c4f88401d9f800000321cff680710140b1f1005fbff35f8f40f00a860168594540f0068690f8a811002900f0fb8506f0c9fb00f0fdbd152c00f06b811Line truncated
"desc": "append injected blobs to main-app payload"
},
{
"offset": 779123,
"old": "805a3900",
"new": "e84d3a00",
"new": "5c4f3a00",
"desc": "main-app subheader payload size (ps)"
},
{
"offset": 152,
"old": "005b3900",
"new": "684e3a00",
"new": "dc4f3a00",
"desc": "main-app TOC entry size (ps + 128)"
},
{
"offset": 779243,
"old": "805a3904",
"new": "e84d3a04",
"new": "5c4f3a04",
"desc": "main-app preamble length (low 24 bits)"
},
{
"offset": 779247,
"old": "effdbcea",
"new": "e5d1780a",
"new": "56bcf2ba",
"desc": "[5] ota/s200_firmware_ota.bin preamble crc32"
},
{
"offset": 156,
"old": "c0c6322a",
"new": "e2593a34",
"new": "8dff7648",
"desc": "[5] ota/s200_firmware_ota.bin component crc32c (TOC)"
},
{
"offset": 779127,
"old": "c0c6322a",
"new": "e2593a34",
"new": "8dff7648",
"desc": "[5] ota/s200_firmware_ota.bin component crc32c (subheader)"
}
]
+10 -1
View File
@@ -23,7 +23,7 @@ export const GLANCE_SURFACE_Z_ORDER = 900;
/** Surface operations needed by the board, shared by Android and iOS. */
export type GlanceDisplay = Pick<DisplayTarget,
"configureSurface" | "setSurfaceVisible" | "setScreenBlanked" | "submitSurfaceFrame">;
"configureSurface" | "setSurfaceVisible" | "setSurfaceDepth" | "setScreenBlanked" | "submitSurfaceFrame">;
export type GlanceHostOptions = {
getDisplay: () => GlanceDisplay | null;
@@ -52,6 +52,8 @@ export class GlanceHost {
private shown = false;
private hideTimer: ReturnType<typeof setTimeout> | null = null;
private configuredFor: GlanceDisplay | null = null;
/** Last depth given to the surface; null forces the next render to set it. */
private configuredDepth: number | null = null;
/** Serializes show/hide against each other and against in-flight renders. */
private queue: Promise<void> = Promise.resolve();
private rendering = false;
@@ -158,6 +160,7 @@ export class GlanceHost {
transparency: "opaque",
});
await display.setSurfaceVisible(GLANCE_SURFACE_ID, false);
this.configuredDepth = null;
this.configuredFor = display;
}
@@ -256,6 +259,12 @@ export class GlanceHost {
const { image, draws } = frameTimings.span(frameId, "flatten", () => flattenPlanesWithDraws(planes));
const buffer = frameTimings.span(frameId, "to8bpp", () => image.to8bppBuffer());
const preparedDraws = frameTimings.span(frameId, "prepareFrameDraws", () => prepareFrameDraws(draws));
// The glasses copy the screen shifted per lens while the board covers it.
const depth = this.options.getProvider()?.depth() ?? 0;
if (depth !== this.configuredDepth) {
await display.setSurfaceDepth(GLANCE_SURFACE_ID, depth);
this.configuredDepth = depth;
}
await frameTimings.spanAsync(frameId, "submit", () =>
display.submitSurfaceFrame(
GLANCE_SURFACE_ID,
+1
View File
@@ -86,6 +86,7 @@ export class IosPreviewController {
private readonly glanceDisplay: GlanceDisplay = {
configureSurface: async (id, options) => { await this.display?.configureSurface(id, options) },
setSurfaceVisible: async (id, visible) => { await this.display?.setSurfaceVisible(id, visible); this.schedulePreviewUpdate() },
setSurfaceDepth: async (id, depth) => { await this.display?.setSurfaceDepth(id, depth) },
setScreenBlanked: async blanked => { await this.display?.setScreenBlanked(blanked); this.schedulePreviewUpdate() },
submitSurfaceFrame: async (id, pixels, rect, fingerprint, paintMs, frameId, draws) => {
await this.display?.submitSurfaceFrame(id, pixels, rect, fingerprint, paintMs, frameId, draws); this.schedulePreviewUpdate()
+1
View File
@@ -18,6 +18,7 @@ export class SurfaceCompositor {
}
removeSurface(id: string): void { this.native.removeId(id); this.surfaces.delete(id) }
setSurfaceVisible(id: string, visible: boolean): void { this.native.visibleIdVisible(id, visible) }
setSurfaceDepth(id: string, depth: number): void { this.native.depthIdDepth(id, depth) }
setUnderlayDim(belowZOrder: number, factor: number): void {
if (!Number.isFinite(factor)) throw new Error('Invalid dim factor')
this.native.dimBelowFactor(belowZOrder, factor)
+2
View File
@@ -33,6 +33,8 @@ export class SurfaceCompositor {
const surface = this.surfaces.get(id)
if (surface) surface.visible = visible
}
/** Stereo depth only shifts the lenses; this local composite shows the unshifted screen. */
setSurfaceDepth(_id: string, _depth: number): void {}
setUnderlayDim(belowZOrder: number, factor: number): void {
if (!Number.isFinite(factor)) throw new Error('Invalid dim factor')
this.dimBelow = belowZOrder
+4
View File
@@ -524,6 +524,10 @@ export class FaceclawCommunicatorBridge {
await this.enqueueNativeCall(() => { this.communicator.setSurfaceVisibleIdVisible(id, Boolean(visible)); });
}
async setSurfaceDepth(id: string, depth: number): Promise<void> {
await this.enqueueNativeCall(() => { this.communicator.setSurfaceDepthIdDepth(id, Math.round(depth)); });
}
async setScreenBlanked(blanked: boolean): Promise<void> {
await this.enqueueNativeCall(() => { this.communicator.setScreenBlankedBlanked(Boolean(blanked)); });
}
+10
View File
@@ -550,6 +550,16 @@ export class FaceclawCommunicatorBridge {
});
}
/**
* Stereo depth for a surface, applied while it is the topmost visible
* surface and opaquely covers the screen; takes effect at its next frame.
*/
async setSurfaceDepth(id: string, depth: number): Promise<void> {
await this.enqueueJavaCall(() => {
this.communicator.setSurfaceDepth(id, Math.round(depth));
});
}
/**
* Blank (screen off) or unblank the composited output; retained surface
* state survives, so unblanking restores the screen without repaints.
+5
View File
@@ -14,6 +14,7 @@ export type DisplayTarget = Pick<
| "configureSurface"
| "removeSurface"
| "setSurfaceVisible"
| "setSurfaceDepth"
| "setUnderlayDim"
| "setScreenBlanked"
| "submitSurfaceFrame"
@@ -80,6 +81,10 @@ export class PreviewDisplayTarget implements DisplayTarget {
this.composited();
}
async setSurfaceDepth(id: string, depth: number): Promise<void> {
this.compositor.setSurfaceDepth(id, Math.round(depth));
}
async setUnderlayDim(belowZOrder: number, factor: number): Promise<void> {
this.compositor.setUnderlayDim(Math.round(belowZOrder), Math.max(0, Math.min(1, factor)));
this.composited();
+5
View File
@@ -19,6 +19,7 @@ export type DisplayTarget = Pick<
| "configureSurface"
| "removeSurface"
| "setSurfaceVisible"
| "setSurfaceDepth"
| "setUnderlayDim"
| "setScreenBlanked"
| "submitSurfaceFrame"
@@ -98,6 +99,10 @@ export class PreviewDisplayTarget implements DisplayTarget {
this.compositor.setSurfaceVisible(id, Boolean(visible));
}
async setSurfaceDepth(id: string, depth: number): Promise<void> {
this.compositor.setSurfaceDepth(id, Math.round(depth));
}
async submitShellScene(bytes: Uint8Array, paintMs = 0, frameId = 0): Promise<void> {
this.compositor.submitShellScene(new Uint8Array(bytes).buffer, paintMs, frameId);
}
@@ -9,3 +9,4 @@ const val DRAW_OP_TEXT = 5
const val DRAW_OP_REMAP_COLORS = 6
const val DRAW_OP_DISPLAY_LIST = 7
const val DRAW_OP_ROUNDED_RECT = 8
const val DRAW_OP_CLEAR = 9
@@ -1,6 +1,6 @@
package com.faceclaw.app
/** Revision 27 wire grammar, shared by scene planning and the local renderer. */
/** Revision 28 wire grammar, shared by scene planning and the local renderer. */
object DrawProtocol {
/** Mirrors g2flash/patches/zlib_glue.c. */
const val DRAW = CFW_MSG_DRAW_CALLS
@@ -107,6 +107,20 @@ object DrawProtocol {
writeS16(dy)
}
/** Fill the whole target, ignoring depth. */
fun clear(color: Int = 0, target: Int? = null): ByteArray {
require(color in 0..15)
return call(DRAW_OP_CLEAR, target) { writeU8(color) }
}
/**
* The copy that starts every root list: firmware presents only what the root
* draws. A shifted copy clears first so its uncovered edge is not stale.
*/
fun screenCopy(width: Int, height: Int, depth: Int = 0): List<ByteArray> =
if (depth == 0) listOf(rectCopy(SCREEN, 0, 0, width, height, 0, 0))
else listOf(clear(), rectCopy(SCREEN, 0, 0, width, height, 0, 0, depth = depth))
fun stockText(x: Int, y: Int, options: Int, text: ByteArray): ByteArray {
require(text.size <= 255)
return call(DRAW_OP_STOCK_FONT_STRING) {
@@ -930,6 +930,9 @@ class GlassesSessionCore(
* actually appear — otherwise a static window (e.g. the terminal hub) whose
* frame landed while briefly hidden would stay blank until its next repaint.
*/
/** Stereo depth for a full-screen surface; applies from its next frame. */
fun setSurfaceDepth(id: String, depth: Int) = compositor.setSurfaceDepth(id, depth)
fun setSurfaceVisible(id: String, visible: Boolean) {
// Its own frame: this recomposite is a real screen update with real
// latency, and without one it would show up in other frames' logs only
@@ -164,9 +164,11 @@ class DisplayListRenderer(
val frame = DrawEvaluation(elapsedMs)
val references = mutableSetOf<Int>()
for (apply in listOf(false, true)) {
if (apply) copyScreen(screen, composition)
// A root list composes the whole frame, including its screen copy.
if (root != DrawProtocol.SCREEN) {
executeList(root, composition, Walk(screen, apply, references, frame))
} else if (apply) {
copyScreen(screen, composition)
}
}
animationPending = frame.animationPending
@@ -226,6 +228,7 @@ class DisplayListRenderer(
DRAW_OP_TEXT -> drawText(reader, target, walk)
DRAW_OP_REMAP_COLORS -> remapColors(reader, target, walk)
DRAW_OP_ROUNDED_RECT -> drawRoundedRect(reader, target, walk)
DRAW_OP_CLEAR -> clear(reader, target, walk)
DRAW_OP_DISPLAY_LIST -> {
val id = reader.readU16()
reader.requireDone()
@@ -360,6 +363,13 @@ class DisplayListRenderer(
}
}
private fun clear(reader: DrawReader, target: Target, walk: Walk) {
val color = reader.readU8()
reader.requireDone()
require(color <= 15)
if (walk.apply) target.bytes.fill((color * 17).toByte(), target.offset, target.offset + target.stride * target.height)
}
private fun drawRoundedRect(reader: DrawReader, target: Target, walk: Walk) {
val x = ExtendedVarint.evaluate(reader, walk.frame)
val y = ExtendedVarint.evaluate(reader, walk.frame)
@@ -1,15 +1,16 @@
package com.faceclaw.app
/** Immutable shell snapshot. Keys identify writable surfaces across repaints, not their pixels. */
class ShellScene(val layers: List<Layer>, val selections: List<RetainedDrawing> = emptyList()) {
class ShellScene(val layers: List<Layer>, val selections: List<RetainedDrawing> = emptyList(), val screenDepth: Int = 0) {
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<RetainedDrawing> = emptyList(), val depth: Int = 0)
val allSelections = selections + layers.flatMap { it.selections }
val retainedResources = allSelections.flatMap { it.resources }
init { require(retainedResources.size + layers.size < 511) }
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 }
init { require(retainedResources.size + layers.size < 511 && screenDepth in -128..127) }
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 } + "|depth:$screenDepth"
fun calls(width: Int, height: Int, surfaces: IntArray, selected: IntArray): List<ByteArray> {
val calls = ArrayList<ByteArray>(); var rowId = 0
val now = drawAnimationTimeMs()
calls.addAll(DrawProtocol.screenCopy(width, height, screenDepth))
fun add(row: RetainedDrawing) {
calls.addAll(row.calls(selected.copyOfRange(rowId, rowId + row.resources.size), now))
rowId += row.resources.size
@@ -274,6 +274,9 @@ class SurfaceCompositor @JvmOverloads constructor(private val includePreviewInFr
@JvmField var visible: Boolean = true
/** Stereo depth; see setSurfaceDepth. */
@JvmField var depth: Int = 0
@JvmField var pixels: ByteArray = ByteArray(0)
@JvmField var fingerprint: String = ""
@@ -419,6 +422,27 @@ class SurfaceCompositor @JvmOverloads constructor(private val includePreviewInFr
}
}
/**
* Stereo depth (DrawProtocol.depthOffset) for a surface. It applies while the surface is the
* topmost visible one and opaquely covers the screen: the glasses then copy the whole screen
* into the frame shifted per lens. Takes effect when the next frame composites.
*/
fun setSurfaceDepth(id: String, depth: Int): Unit {
require(depth in -128..127) { "bad depth $depth for $id" }
lock.withLock {
val surface = surfaces.get(id) ?: throw IllegalArgumentException(("unknown surface " + id))
surface.depth = depth
}
}
/** The screen's stereo depth: see setSurfaceDepth. */
private fun screenDepthLocked(ordered: List<Surface>): Int {
val top = ordered.lastOrNull { it.visible } ?: return 0
val covers = top.transparency == TRANSPARENCY_OPAQUE && top.x <= 0 && top.y <= 0 &&
top.x + top.width >= screenWidth && top.y + top.height >= screenHeight
return if (covers) top.depth else 0
}
/**
* While blanked (screen off), composites are all-zero regardless of surface content; retained
* state is untouched, so unblanking restores the screen without asking sources to repaint.
@@ -681,7 +705,9 @@ class SurfaceCompositor @JvmOverloads constructor(private val includePreviewInFr
fingerprint.append(":dim").append(dim)
}
}
val scene = if (surfaces.values.any { it.visible && it.zOrder > 1 }) ShellScene.EMPTY else ShellScene(shellScene?.layers ?: emptyList(), selections)
val screenDepth = screenDepthLocked(ordered)
val scene = if (surfaces.values.any { it.visible && it.zOrder > 1 }) ShellScene(emptyList(), screenDepth = screenDepth)
else ShellScene(shellScene?.layers ?: emptyList(), selections, screenDepth)
val sceneKey = fingerprint.append("|shell:").append(scene.fingerprint).toString()
val preview = if (includePreview && (shellScene != null || selections.isNotEmpty())) {
previewScene(scene, gray, sceneKey)
@@ -223,6 +223,8 @@ class IosSurfaceCompositor(width: Int, height: Int) {
fun visible(id: String, visible: Boolean) = compositor.setSurfaceVisible(id, visible)
fun depth(id: String, depth: Int) = compositor.setSurfaceDepth(id, depth)
fun dim(below: Int, factor: Double) {
require(factor.isFinite())
compositor.setUnderlayDim(below, (factor.coerceIn(0.0, 1.0) * 256).toInt())
@@ -207,6 +207,8 @@ class IosGlassesSession internal constructor(
fun setSurfaceVisible(id: String, visible: Boolean) = core.setSurfaceVisible(id, visible)
fun setSurfaceDepth(id: String, depth: Int) = core.setSurfaceDepth(id, depth)
fun setScreenBlanked(blanked: Boolean) = core.setScreenBlanked(blanked)
fun configureSurface(id: String, x: Int, y: Int, width: Int, height: Int, zOrder: Int, transparency: Int) =
+14 -2
View File
@@ -27,7 +27,7 @@ function fixture() {
let now = 1000, nextTask = 0, screenOn = true, shellOptions;
const tasks = new Map(), sent = [], previews = [], received = [], errors = [];
const boardStats = { starts: 0, stops: 0, paints: 0 };
const settings = { lock: true, enabled: true, tap: true, hold: true, tilt: true, duration: 3000 };
const settings = { lock: true, enabled: true, tap: true, hold: true, tilt: true, duration: 3000, depth: 0 };
const clock = { Date: class extends Date { static now() { return now; } },
setTimeout: (fn, ms) => { tasks.set(++nextTask, { fn, at: now + ms }); return nextTask; },
clearTimeout: id => tasks.delete(id), setInterval: () => ++nextTask, clearInterval() {} };
@@ -63,6 +63,8 @@ function fixture() {
async configureSurface(id, options) { this.compositor.configureSurface(id, options); }
async removeSurface(id) { this.compositor.removeSurface(id); this.changed(); }
async setSurfaceVisible(id, visible) { this.compositor.setSurfaceVisible(id, visible); this.changed(); }
depths = [];
async setSurfaceDepth(id, depth) { this.depths.push([id, depth]); this.compositor.setSurfaceDepth(id, depth); }
async setUnderlayDim(below, factor) { this.compositor.setUnderlayDim(below, factor); this.changed(); }
async setScreenBlanked(blanked) { this.compositor.setScreenBlanked(blanked); this.changed(); }
async submitSurfaceFrame(id, pixels, rect, _fingerprint, _paintMs, _frameId, draws = null) { this.compositor.submitSurfaceFrame(id, pixels, rect, draws); this.changed(); }
@@ -96,7 +98,7 @@ function fixture() {
const provider = {
isEnabled: () => settings.enabled, showOnTap: () => settings.tap,
showOnLongPress: () => settings.hold, showOnHeadTilt: () => settings.tilt,
tapTimeoutMs: () => settings.duration,
tapTimeoutMs: () => settings.duration, depth: () => settings.depth,
createBoard: () => ({ start: () => boardStats.starts++, stop: () => boardStats.stops++,
paint: () => { boardStats.paints++; return new images.GrayImage(100, 80, 200); } }),
};
@@ -194,6 +196,16 @@ test('iOS sleep tap shows the shared board; repeated tap renews timeout and hide
assert.equal(f.boardStats.starts, 1); assert.equal(f.boardStats.stops, 1);
});
test('Glanceboard applies its depth setting to its surface only when it changes', async () => {
const f = fixture(); await f.connect(); f.shell.sleep(); await f.render();
f.settings.depth = 32; await f.hardware(0); assertBoard(f.sent.at(-1));
await f.advance(3100); await f.render(); assert.equal(f.controller.glance.isVisible(), false);
await f.hardware(0); assert.equal(f.controller.glance.isVisible(), true);
await f.advance(3100); await f.render();
f.settings.depth = 0; await f.hardware(0);
assert.deepEqual(f.controller.display.depths, [['glance', 32], ['glance', 0]]);
});
test('iOS holds and tap-then-holds last until release, including with phone backgrounded', async () => {
const f = fixture(); await f.connect(); f.shell.sleep(); f.controller.pause();
const previews = f.previews.length;
@@ -51,15 +51,43 @@ class DisplayListTest {
val calls = listOf(DrawProtocol.call(DRAW_OP_DISPLAY_LIST,DrawProtocol.word(20)), DrawProtocol.image(10,3,1),
DrawProtocol.call(DRAW_OP_TEXT,hex("0c00070003000f0141")), DrawProtocol.lut(8,4,128))
resources[21]=DrawProtocol.displayList(calls)
val screen=hex("123456789abcdef0123456789abcdef0"); val output=ByteArray(16)
// Like the C harness, seed composition with the screen: this list has no screen copy.
val screen=hex("123456789abcdef0123456789abcdef0"); val output=screen.copyOf()
val renderer=DisplayListRenderer(resources)
assertEquals(setOf(10,11,12,20,21),renderer.render(21,DisplayListRenderer.Target(screen,8,4),DisplayListRenderer.Target(output,8,4)))
// Shared with the C sanitizer harness: signed clipping, resource target override, font and LUT.
assertContentEquals(hex("71122334755061700112233445534477"),output)
val first=output.copyOf(); renderer.render(21,DisplayListRenderer.Target(screen,8,4),DisplayListRenderer.Target(output,8,4))
val first=output.copyOf(); screen.copyInto(output); renderer.render(21,DisplayListRenderer.Target(screen,8,4),DisplayListRenderer.Target(output,8,4))
assertContentEquals(first,output)
assertContentEquals(hex("123456789abcdef0123456789abcdef0"),screen)
}
@Test fun rootListsComposeTheScreenCopyAndClearBeforeDepthShifts() {
val screen = ByteArray(640 * 480 / 2) { (0x12 + it * 0x22).toByte() }
val sourceTarget = DisplayListRenderer.Target(screen, 640, 480)
// Without a copy, a root presents only what it draws.
val empty = mapOf(1 to DrawProtocol.displayList(emptyList()))
val composition = ByteArray(screen.size) { 0x55 }
DisplayListRenderer(empty).render(1, sourceTarget, DisplayListRenderer.Target(composition, 640, 480))
assertTrue(composition.all { it == 0x55.toByte() })
for (depth in listOf(-64, -17, 0, 1, 32)) for (right in listOf(false, true)) {
val resources = mapOf(1 to DrawProtocol.displayList(DrawProtocol.screenCopy(640, 480, depth)))
val output = ByteArray(screen.size) { -1 }
val target = DisplayListRenderer.Target(output, 640, 480)
DisplayListRenderer(resources, rightLens = right).render(1, sourceTarget, target)
val shift = DrawProtocol.depthOffset(depth, right)
for (y in listOf(0, 479)) for (x in 0 until 640) {
val sx = x - shift
assertEquals(if (sx in 0 until 640) sourceTarget.get(sx, y) else 0, target.get(x, y), "depth=$depth right=$right x=$x")
}
}
// Clear fills the whole resource target, padding included, and ignores depth.
val raw = DrawProtocol.rawImage(3, 2, hex("1234ab12"))
DisplayListRenderer(mapOf(5 to raw)).execute(DrawProtocol.sequence(listOf(DrawProtocol.clear(7, target = 5))),
DisplayListRenderer.Target(ByteArray(1), 1, 1))
assertContentEquals(DrawProtocol.rawImage(3, 2, hex("77777777")), raw)
val rejected = DrawProtocol.call(DRAW_OP_CLEAR, hex("10"))
assertFails { DisplayListRenderer(emptyMap()).execute(DrawProtocol.sequence(listOf(rejected)), DisplayListRenderer.Target(ByteArray(1), 1, 1)) }
}
@Test fun graphValidationPrecedesMutationAndCopyPreservesOverlap() {
val screen=hex("12345678"); val target=DisplayListRenderer.Target(screen,8,1)
val copy=DrawProtocol.call(DRAW_OP_RECT_COPY,hex("feff000000000600010002000000"))
@@ -80,7 +108,7 @@ class DisplayListTest {
val screen = hex("012345601234560112345601234560122345601234560123345601234560123445601234560123455601234f60123456601234560123456001234560123456011234560123456012234560123456012334560123456012344560123456012345")
val expected = listOf("01234560123456011aaaaaaaaaa56012aa45644444aa0123a4564444456a1234a564f44f564a2345a6444fff644a3456a4444456444a4560aa44456444aa56011aaaaaaaaaa56012234560123456012334560123456012344560123456012345", "012345601234560112aaaaaaaaaa60122aa56444445aa1233a5644444564a2344a644f44f644a3455a4444ff6444a4566a4444564444a5600aa44564444aa60112aaaaaaaaaa6012234560123456012334560123456012344560123456012345")
for (right in listOf(false, true)) {
val output = ByteArray(screen.size)
val output = screen.copyOf() // the shared vector's list has no screen copy
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)
}
@@ -189,6 +217,36 @@ class DisplayListTest {
assertTrue(reconnect.commands.any { it[0].toInt()==29 });glasses.apply(reconnect.commands)
assertContentEquals(newer,glasses.screen)
}
@Test fun fullScreenSurfaceDepthShiftsThePresentedScreenPerLens() {
val c = SurfaceCompositor()
c.configureScreen(640, 480)
c.configureSurface("app", 0, 0, 640, 480, 0, 0)
c.configureSurface("glance", 0, 0, 640, 480, 900, 0)
val board = ByteArray(640 * 480) { if (it % 640 in 100 until 110) 255.toByte() else 0 }
c.submitSurface("glance", ArrayByteReader(board), 0, 0, 640, 480, "board")
c.setSurfaceDepth("glance", 32)
assertEquals(32, c.composite().shellScene.screenDepth)
// Only the topmost visible surface counts, and only when it opaquely covers the screen.
c.configureSurface("partial", 0, 0, 10, 10, 950, 0)
assertEquals(0, c.composite().shellScene.screenDepth)
c.setSurfaceVisible("partial", false)
c.setSurfaceVisible("glance", false)
assertEquals(0, c.composite().shellScene.screenDepth)
c.setSurfaceVisible("glance", true)
val composite = c.composite()
val screen = BmpUtil.pack4bppFromGray8(composite.screenGray, 640, 480)
for (right in listOf(false, true)) {
val glasses = Glasses(right)
glasses.composition.fill(-1) // stale pixels from an earlier frame
glasses.apply(ScenePlanner(ResourceCacheState()).plan(screen, 640, 480, null, composite.shellScene, 1).commands)
assertContentEquals(screen, glasses.screen)
val output = DisplayListRenderer.Target(glasses.composition, 640, 480)
val shift = if (right) -16 else 16
assertEquals(15, output.get(100 + shift, 0)); assertEquals(0, output.get(99 + shift, 0))
assertEquals(15, output.get(109 + shift, 479)); assertEquals(0, output.get(110 + shift, 479))
assertEquals(0, output.get(if (right) 639 else 0, 240)) // cleared, not stale
}
}
@Test fun noisyFramesRemainBoundedAndResourceBudgetIs192KiB() {
val cache=ResourceCacheState();val planner=ScenePlanner(cache);val glasses=Glasses()
val app=ByteArray(640*480/2){(it*37).toByte()}
@@ -74,7 +74,7 @@ class DrawExpressionTest {
@Test fun playerSchedulesOnlyUnfinishedFramesAndCancelsStaleCallbacks() {
val call = DrawProtocol.roundedRect(DrawValue.Integer(0), DrawValue.animate(0, 4, 300), 2, 2, 0, 15)
val renderer = DisplayListRenderer(mapOf(1 to DrawProtocol.displayList(listOf(call))))
val renderer = DisplayListRenderer(mapOf(1 to DrawProtocol.displayList(DrawProtocol.screenCopy(4, 8) + call)))
val screen = DisplayListRenderer.Target(ByteArray(16), 4, 8)
val output = DisplayListRenderer.Target(ByteArray(16), 4, 8)
var now = 1000L
@@ -5,7 +5,7 @@ import kotlin.test.*
class DrawWireTest {
private fun hex(value: String) = value.chunked(2).map { it.toInt(16).toByte() }.toByteArray()
@Test fun encodersUseRevision27CoordinatesAndPreserveOtherWireBytes() {
@Test fun encodersUseRevision28CoordinatesAndPreserveOtherWireBytes() {
// Literal vectors pin the firmware grammar independently of the reader.
val calls = listOf(
DrawProtocol.image(0x1234, -32768, 32767, 0x1f, target = 511, depth = -128) to
@@ -20,12 +20,20 @@ class DrawWireTest {
DrawProtocol.lut(640, 480, 256) to "0600000000008002e0010123456789abcdef",
DrawProtocol.bbox(hex("ffffffffffffffff"), 4, 0, 0, 8, 2) to "010000000002010f10",
DrawProtocol.bbox(hex("0f"), 1, 1, 0, 1, 1) to "01000101000000010001001f",
DrawProtocol.clear(15, target = 511) to "0901ff010f",
)
for ((call, expected) in calls) assertContentEquals(hex(expected), call)
assertContentEquals(hex("0100050007027fff01"), DrawProtocol.sequence(listOf(calls[4].first)))
assertContentEquals(hex("1a0100050007027fff01"), DrawProtocol.message(listOf(calls[4].first)))
assertContentEquals(hex("020100050007027fff01"), DrawProtocol.displayList(listOf(calls[4].first)))
assertContentEquals(hex("1bffff"), DrawProtocol.root(DrawProtocol.SCREEN))
val flat = DrawProtocol.screenCopy(640, 352)
assertEquals(1, flat.size)
assertContentEquals(hex("0200ffff000000008002600100000000"), flat[0])
val shifted = DrawProtocol.screenCopy(640, 352, -32)
assertEquals(2, shifted.size)
assertContentEquals(hex("090000"), shifted[0])
assertContentEquals(hex("0202e0ffff000000008002600100000000"), shifted[1])
}
@Test fun optimizerFieldsAreReencodedAndOpaqueBytesArePreserved() {