Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1713,8 +1713,9 @@ For its first 3 seconds of dark the studio draws the capture's last picture
that was not dark in its place, on program and everywhere else but where its
background is removed, which shows the dark at once, so a moment
of black barely reaches viewers: the black shows until its picture is next
read, up to a quarter of a second, as each picture is drawn before it is
read, never held back for it. After that it shows the dark as it is, so a
read and that read comes back from the GPU, up to a quarter second, plus GPU
readback time, as each picture is drawn before it is read, never held back for
it. After that it shows the dark as it is, so a
stale picture never passes for live, and the capture's layer row, its
layer on the picture, and each scene pad showing it turn amber, and the
health dot counts it. The row's badge says what may have happened and offers
Expand Down
32 changes: 26 additions & 6 deletions rs/moq-studio/src/ui/dark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,16 @@ pub(super) fn counted(dark: usize, stalled: usize) -> Option<String> {
}

/// Whether the scene called `scene` draws a layer that `lost` its picture,
/// as `lost` says of a source: through the scenes it nests, and not one it
/// hides.
/// as `lost` says of a source: through the scenes it nests, and the masks
/// its layers read, and not one it hides.
pub(super) fn draws_lost(collection: &Collection, scene: &str, lost: impl Fn(&str) -> bool) -> bool {
collection
.drawn([Layer::scene(scene)])
.iter()
.any(|item| lost(&item.source))
collection.drawn([Layer::scene(scene)]).iter().any(|item| {
let masks = collection.filters(item).filter_map(|filter| match filter {
Filter::Mask { source, .. } => Some(source.as_str()),
_ => None,
});
std::iter::once(item.source.as_str()).chain(masks).any(&lost)
})
}

/// The amber badge in `rect`: a warning sign on amber.
Expand Down Expand Up @@ -426,12 +429,29 @@ mod tests {
});
collection.scenes.push(hidden);
collection.scenes[0].items.push(Item::new("inner", fill));
// A color cut to the camera's shape reads the camera's picture.
collection.sources.insert(
"red".into(),
Source::Color {
color: moq_scene::Rgba([255, 0, 0, 255]),
},
);
let mut masked = Scene::new("Masked");
masked.items.push(Item {
filters: vec![Filter::Mask {
source: "cam".into(),
mode: MaskMode::default(),
}],
..Item::new("red", fill)
});
collection.scenes.push(masked);
let outer = collection.scenes[0].name.clone();
collection.validate().unwrap();
let lost = |name: &str| name == "cam";
assert!(draws_lost(&collection, "Inner", lost));
assert!(draws_lost(&collection, &outer, lost), "through the scene it nests");
assert!(!draws_lost(&collection, "Hidden", lost), "not what it hides");
assert!(draws_lost(&collection, "Masked", lost), "through the mask it reads");
}

/// The health dot names what the layers lost, and counts them.
Expand Down