sf-ui 0.1.2: fix the video flicker
All checks were successful
ci / test (push) Successful in 20m59s

Glass's video fade stepped down whenever it was already at its target, so
a fully shown video dipped every other frame. At 60 fps that was a 5 %
dip; on a slow GPU (Raspberry Pi 4, ~10 fps during playback) the video
went down to ~60 % every other frame and the backdrop flickered through.
The fade now clamps to its target, like the picture fades do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Tamas Csikel
2026-11-01 20:04:40 +01:00
parent 25fecb8dae
commit cb37d872ed
3 changed files with 10 additions and 7 deletions

View File

@@ -434,11 +434,14 @@ impl State {
keep
});
// Eases to the target and stays there. (It used to step down whenever
// it was already at the target: a fully shown video dipped every
// other frame, a visible flicker at a slow GPU's frame rate.)
let target = if self.video_on { 1.0 } else { 0.0 };
self.video_alpha = if target > self.video_alpha {
(self.video_alpha + dt / 0.3).min(1.0)
(self.video_alpha + dt / 0.3).min(target)
} else {
(self.video_alpha - dt / 0.3).max(0.0)
(self.video_alpha - dt / 0.3).max(target)
};
if !self.video_on && self.video_alpha <= 0.0 {
self.video = None;