Face unlock: screen fill-light for low light; fix Quad-Bayer AE ramp
CI / test (push) Failing after 51s

- Boost the backlight to 90% while enrolling with the light on or while sign-in is scanning, then restore the previous level when that ends or the window closes.
- Add a Light: On/Off toggle (L key) to the Face window; the backdrop turns soft white while the light is on.
- Quad-Bayer AE: compute the low-light gain once and cap it by the highlight limit, so ramp-up and highlight back-off agree.
- Tests: backlight round-trip through the Face window, Quad-Bayer debayer color/low-light/dark-frame cases, and the AE ramp, back-off and restore order.
This commit is contained in:
nandi committed 2026-11-28 18:32:15 -08:00
1 parent c5b96e2c70
commit 40c5d6722c
8 files changed
+266 -12

No files matched your search

+48 -1
View File
@@ -17,14 +17,42 @@ pub(all) enum FaceHit {
DropSnap(Int)
ToggleFace(String)
UseCamera(String)
ToggleLight
Apply
Cancel
} derive(Eq)
///| Boost display backlight while the screen acts as a face fill-light, and restore it when done.
fn ChandraCompositor::sync_face_fill_light(self : ChandraCompositor) -> Unit {
let enroll_light = match self.shell.face.window {
Some(w) => !w.applying && !w.ended && w.fill_light
None => false
}
let auth_light = match self.auth {
Some(u) => u.view.face == Scanning
None => false
}
let want_boost = enroll_light || auth_light
if want_boost {
if self.face_saved_brightness < 0 {
let cur = @shell.read_backlight_percent()
if cur >= 0 && cur < 90 {
self.face_saved_brightness = cur
ignore(self.shell.set_brightness(90))
}
}
} else if self.face_saved_brightness >= 0 {
let prev = self.face_saved_brightness
self.face_saved_brightness = -1
ignore(self.shell.set_brightness(prev))
}
}
///| Follow the camera process and redraw when the window changed.
fn ChandraCompositor::face_window_tick(self : ChandraCompositor) -> Unit {
let f = self.shell.face
f.poll_window()
self.sync_face_fill_light()
if f.window_rev != self.face_rev {
self.face_rev = f.window_rev
self.damage.mark_full()
@@ -52,6 +80,7 @@ fn ChandraCompositor::face_window_activate(self : ChandraCompositor, h : FaceHit
DropSnap(i) => f.drop_snap(i)
ToggleFace(id) => f.toggle_remove(id)
UseCamera(path) => f.use_camera(path)
ToggleLight => f.toggle_fill_light()
Apply => f.apply()
Cancel => f.cancel_window()
}
@@ -79,6 +108,8 @@ fn ChandraCompositor::face_window_input(self : ChandraCompositor, ev : @nested.I
self.face_window_activate(Apply)
} else if code == key_space {
self.face_window_activate(Snap)
} else if code == key_l {
self.face_window_activate(ToggleLight)
}
}
true
@@ -106,8 +137,12 @@ fn ChandraCompositor::face_window_input(self : ChandraCompositor, ev : @nested.I
///|
let key_space : UInt = 57
///|
let key_l : UInt = 38
///| The window, when it is open.
fn ChandraCompositor::face_window_ops(self : ChandraCompositor) -> Array[@scene.DrawOp] {
self.sync_face_fill_light()
let ops : Array[@scene.DrawOp] = []
let f = self.shell.face
let win = match f.window {
@@ -136,7 +171,12 @@ fn ChandraCompositor::face_window_ops(self : ChandraCompositor) -> Array[@scene.
let rad = self.theme.radius + 2
let sw = self.output_w
let sh = self.output_h
ops.push(@scene.DrawOp::FillRect(@scene.Rect::new(0, 0, sw, sh), @scene.Rgba::new(0, 0, 0, 150), 0))
let backdrop = if win.fill_light && !win.ended {
@scene.Rgba::new(255, 250, 242, 245)
} else {
@scene.Rgba::new(0, 0, 0, 150)
}
ops.push(@scene.DrawOp::FillRect(@scene.Rect::new(0, 0, sw, sh), backdrop, 0))
let w = (sw - 32).min(560)
let pad = 24
let inner = w - pad * 2
@@ -145,6 +185,13 @@ fn ChandraCompositor::face_window_ops(self : ChandraCompositor) -> Array[@scene.
let hits : Array[(@scene.Rect, FaceHit)] = []
let mut y = pad
body.push(@scene.DrawOp::Text(pad, y + 7, "FACE UNLOCK", fs - 3, p.accent, @scene.TextAlign::Left, true))
if !win.ended {
let light_label = if win.fill_light { "Light: On" } else { "Light: Off" }
let light_w = @renderer.text_width("Light: Off", fs - 2, false, false) + 22
let lr = @scene.Rect::new(pad + inner - light_w, pad, light_w, 28)
auth_button(lr, light_label, false, false, hover == Some(ToggleLight), true, p, fs - 2, rad, body)
hits.push((lr, ToggleLight))
}
y = y + 18
body.push(@scene.DrawOp::Text(pad, y + (fs + 8) / 2, "Add or remove faces", fs + 3, p.foreground, @scene.TextAlign::Left, true))
y = y + fs + 10