Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

perf(editor): composite camera effects with the newest mask during playback

Richie McIlroye9f647ae3c9b
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index 16f906b3e..682324934 100644
--- a/crates/editor/src/editor.rs
+++ b/crates/editor/src/editor.rs
@@ -214,6 +214,7 @@ impl Renderer {
layers
}
};
+ layers.set_realtime_camera_effects(true);
struct PendingFrame {
input: PendingRenderInput,
diff --git a/crates/rendering/src/lib.rs b/crates/rendering/src/lib.rs
index 7a613a5a8..5330a8429 100644
--- a/crates/rendering/src/lib.rs
+++ b/crates/rendering/src/lib.rs
@@ -7074,6 +7074,7 @@ pub struct RendererLayers {
camera_blur_processor: Option<cap_camera_effects::BlurProcessor>,
camera_blur_init_failed: bool,
camera_blur_unavailable: bool,
+ realtime_camera_effects: bool,
}
fn join_layer<T>(handle: std::thread::ScopedJoinHandle<'_, T>) -> T {
@@ -7196,6 +7197,7 @@ impl RendererLayers {
camera_blur_processor: None,
camera_blur_init_failed: false,
camera_blur_unavailable: false,
+ realtime_camera_effects: false,
}
});
layers_phase.finish("returned");
@@ -7209,11 +7211,22 @@ impl RendererLayers {
Ok(())
}
+ /// Editor playback: camera segmentation runs beside rendering and each
+ /// frame composites with the newest finished mask, refined against that
+ /// frame. Seeks still wait for an exact mask. Exports keep the default,
+ /// where every frame waits for its own mask.
+ pub fn set_realtime_camera_effects(&mut self, realtime: bool) {
+ self.realtime_camera_effects = realtime;
+ if let Some(processor) = &mut self.camera_blur_processor {
+ configure_camera_blur_processor(processor, realtime);
+ }
+ }
+
fn ensure_camera_blur_processor(&mut self, device: &wgpu::Device) {
if self.camera_blur_processor.is_none() && !self.camera_blur_init_failed {
match cap_camera_effects::BlurProcessor::new(device, wgpu::TextureFormat::Rgba8Unorm) {
Ok(mut processor) => {
- processor.set_frame_synchronous(true);
+ configure_camera_blur_processor(&mut processor, self.realtime_camera_effects);
self.camera_blur_processor = Some(processor);
}
Err(e) => {
@@ -8074,6 +8087,16 @@ async fn produce_transition_texture(
Ok(incoming_encoder)
}
+fn configure_camera_blur_processor(
+ processor: &mut cap_camera_effects::BlurProcessor,
+ realtime: bool,
+) {
+ processor.set_frame_synchronous(!realtime);
+ if realtime {
+ processor.set_inference_interval(std::time::Duration::ZERO);
+ }
+}
+
fn reset_camera_blur_for_dimensions(
processor: &mut cap_camera_effects::BlurProcessor,
dimensions: (u32, u32),