Add an option to move the app switcher to the right or bottom, and adjust screen depth if bottom

This commit is contained in:
James Babcock committed 2026-10-01 02:40:13 -07:00
1 parent 46fded856a
commit 8f99779f98
21 files changed
+827 -286

No files matched your search

@@ -299,6 +299,48 @@ class DisplayListTest {
assertEquals(0, output.get(if (right) 639 else 0, 240)) // cleared, not stale
}
}
@Test fun addedDepthJoinsOrInsertsTheDepthField() {
val copy = DrawProtocol.rectCopy(DrawProtocol.SCREEN, 0, 0, 4, 4, 0, 0)
assertContentEquals(DrawProtocol.rectCopy(DrawProtocol.SCREEN, 0, 0, 4, 4, 0, 0, depth = 8), DrawProtocol.withAddedDepth(copy, 8))
val targeted = DrawProtocol.image(3, 1, 2, target = 5, depth = -2)
assertContentEquals(DrawProtocol.image(3, 1, 2, target = 5, depth = 6), DrawProtocol.withAddedDepth(targeted, 8))
assertSame(copy, DrawProtocol.withAddedDepth(copy, 0))
assertContentEquals(DrawProtocol.image(3, 1, 2, depth = 127), DrawProtocol.withAddedDepth(DrawProtocol.image(3, 1, 2, depth = 120), 16))
}
/** The bottom switcher's Depth setting: the shell scene's depth moves the screen, shell layers and selections together. */
@Test fun shellSceneDepthShiftsTheWholePresentationButNotDimming() {
val c = SurfaceCompositor()
c.configureScreen(640, 480)
c.configureSurface("app", 32, 0, 576, 480, 0, 0)
c.submitSurface("app", ArrayByteReader(ByteArray(576 * 480) { if (it % 576 in 100 until 110) 255.toByte() else 0 }),
0, 0, 576, 480, "stripe")
// One white 2x1 shell layer at (200, 10), dimming what is under it, at layer depth -2; scene depth 8.
val header = listOf(1, 1, 200, 10, 2, 1, 128, 0, -2).flatMap { listOf(it.toByte(), (it shr 8).toByte()) }.toByteArray()
c.setShellScene(ArrayByteReader(header + byteArrayOf(-1, -1) + DrawProtocol.word(8)))
val composite = c.composite()
assertEquals(8, composite.shellScene.screenDepth)
val calls = composite.shellScene.calls(640, 480, intArrayOf(1), IntArray(0))
assertTrue(calls.any { it.contentEquals(DrawProtocol.lut(640, 480, 128)) }) // the dim stays whole-screen
val screen = BmpUtil.pack4bppFromGray8(composite.screenGray, 640, 480)
for (right in listOf(false, true)) {
val glasses = Glasses(right)
glasses.apply(ScenePlanner(ResourceCacheState()).plan(screen, 640, 480, null, composite.shellScene, 1).commands)
val output = DisplayListRenderer.Target(glasses.composition, 640, 480)
// Screen: half of 8 per lens. Layer: depth -2 + 8, so one pixel less than the screen's shift on each lens.
val shift = if (right) -4 else 4
val layerShift = if (right) -3 else 3
assertEquals(0, output.get(131 + shift, 200)); assertTrue(output.get(132 + shift, 200) > 0)
assertTrue(output.get(141 + shift, 200) > 0); assertEquals(0, output.get(142 + shift, 200))
assertEquals(15, output.get(200 + layerShift, 10)); assertEquals(15, output.get(201 + layerShift, 10))
}
// The phone mirror shows the scene unshifted, so touches land where they look.
val preview = assertNotNull(c.previewComposite()).gray
assertEquals(0, preview[131].toInt() and 255); assertTrue((preview[132].toInt() and 255) > 0)
// A covering surface's own depth still wins over the scene's.
c.configureSurface("glance", 0, 0, 640, 480, 900, 0)
c.setSurfaceDepth("glance", -16)
assertEquals(-16, c.composite().shellScene.screenDepth)
}
@Test fun noisyFramesRemainBoundedAndResourceBudgetIs192KiB() {
val cache=ResourceCacheState();val planner=ScenePlanner(cache);val glasses=Glasses()
val app=ByteArray(640*480/2){(it*37).toByte()}
@@ -98,7 +98,7 @@ class FrameDisplayListTest {
// One opaque 1x1 shell layer, with one generic list after its pixels.
val layer = DrawProtocol.word(1) + DrawProtocol.word(1) + DrawProtocol.word(0) + DrawProtocol.word(0) +
DrawProtocol.word(1) + DrawProtocol.word(1) + DrawProtocol.word(256) + DrawProtocol.word(1) +
DrawProtocol.word(0) + byteArrayOf(32) + hex(multi)
DrawProtocol.word(0) + byteArrayOf(32) + hex(multi) + DrawProtocol.word(0)
val shell = ShellScene.decode(ArrayByteReader(layer))
assertEquals(2, shell.retainedResources.size)
assertEquals(240, shell.preview(ByteArray(64) { 32 }, 8, 8)[21].toInt() and 255)
@@ -43,7 +43,7 @@ class PreviewPackingTest {
compositor.configureSurface("app", 0, 0, 3, 2, 0, SurfaceCompositor.TRANSPARENCY_OPAQUE)
// One white 2x1 shell layer at (0,0), with no dimming or selection.
val header = listOf(1, 1, 0, 0, 2, 1, 256, 0, 0).flatMap { listOf(it.toByte(), (it shr 8).toByte()) }.toByteArray()
compositor.setShellScene(ArrayByteReader(header + byteArrayOf(-16, -16)))
compositor.setShellScene(ArrayByteReader(header + byteArrayOf(-16, -16) + DrawProtocol.word(0)))
val wire = compositor.applyAndComposite("app", ArrayByteReader(ByteArray(6) { 32 }), 0, 0, 3, 2, "first")
assertSame(wire.screenGray, wire.gray) // ShellScene.preview allocates its own pixels.
assertContentEquals(ByteArray(6) { 32 }, wire.screenGray)