Skip to content
Open
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
2 changes: 1 addition & 1 deletion apps/desktop-gpui/src/screenshot_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ async fn render_still(

let uniforms = ProjectUniforms::new(
constants,
config,
&Arc::new(config.clone()),
0,
30,
resolution_base,
Expand Down
2 changes: 2 additions & 0 deletions apps/desktop/src-tauri/src/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1950,6 +1950,7 @@ async fn generate_export_preview_inner(
.map(|segment| segment.display.duration)
.collect::<Vec<_>>(),
);
let project_config = Arc::new(project_config);

let render_constants = Arc::new(
RenderVideoConstants::new(
Expand Down Expand Up @@ -2546,6 +2547,7 @@ async fn generate_export_preview_fast_inner(
})
.await
.map_err(|error| format!("Failed to synchronize export preview timing: {error}"))?;
let project_config = Arc::new(project_config);
let transition_mapping = project_config.timeline.as_ref().and_then(|timeline| {
if timeline.transitions.is_empty() {
return None;
Expand Down
8 changes: 4 additions & 4 deletions apps/desktop/src-tauri/src/screenshot_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ impl ScreenshotEditorInstances {
);
let shutdown_token = render_shutdown_token;
let mut current_update = config_rx.borrow().clone();
let mut current_config = current_update.config.clone();
let mut current_config = std::sync::Arc::new(current_update.config.clone());
let mut current_revision = current_update.revision;
let mut first_frame_logged = false;

Expand Down Expand Up @@ -564,7 +564,7 @@ impl ScreenshotEditorInstances {
}
current_update = config_rx.borrow().clone();
current_revision = current_update.revision;
current_config = current_update.config.clone();
current_config = std::sync::Arc::new(current_update.config.clone());
}
_ = shutdown_token.cancelled() => {
break;
Expand Down Expand Up @@ -989,7 +989,7 @@ pub async fn prewarm_screenshot_renderer() {
Arc::new(cap_rendering::BackgroundTextureCache::default()),
);

let config = ProjectConfiguration::default();
let config = std::sync::Arc::new(ProjectConfiguration::default());
let mut frame_renderer = FrameRenderer::new(&constants);
let mut layers = RendererLayers::new_with_options(
&constants.device,
Expand Down Expand Up @@ -1637,7 +1637,7 @@ pub async fn render_screenshot_project_for_export(

pub async fn render_screenshot_png(instance: &ScreenshotEditorInstance) -> Result<Vec<u8>, String> {
let path = instance.path.clone();
let config = instance.config_tx.borrow().config.clone();
let config = std::sync::Arc::new(instance.config_tx.borrow().config.clone());
let width = instance.image_width;
let height = instance.image_height;

Expand Down
4 changes: 2 additions & 2 deletions crates/cap-test/src/suites/performance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ fn skipped_result(
}

struct FixtureContext {
project: ProjectConfiguration,
project: Arc<ProjectConfiguration>,
render_constants: Arc<RenderVideoConstants>,
segments: Vec<cap_editor::SegmentMedia>,
}
Expand Down Expand Up @@ -642,7 +642,7 @@ async fn load_fixture(recording_path: &Path) -> Result<FixtureContext> {
}

Ok(FixtureContext {
project,
project: Arc::new(project),
render_constants,
segments,
})
Expand Down
2 changes: 2 additions & 0 deletions crates/editor/examples/playback-pipeline-benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ async fn run_full_pipeline_benchmark(
recordings: &ProjectRecordingsMeta,
config: PipelineBenchmarkConfig,
) -> PipelineTimings {
let project = &Arc::new(project.clone());
let PipelineBenchmarkConfig {
fps,
frame_count,
Expand Down Expand Up @@ -617,6 +618,7 @@ async fn run_scrubbing_benchmark(
resolution_base: XY<u32>,
force_ffmpeg: bool,
) -> PipelineTimings {
let project = &Arc::new(project.clone());
let mut timings = PipelineTimings::default();

let render_constants = match RenderVideoConstants::new(
Expand Down
8 changes: 4 additions & 4 deletions crates/editor/src/playback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,7 @@ impl Playback {
.sort_by_key(|p| p.frame_number);

let playback_start_frame = frame_number;
let mut cached_project = self.project.borrow().clone();
let mut cached_project = Arc::new(self.project.borrow().clone());

let build_cursor_timelines =
|project: &ProjectConfiguration| -> Vec<Arc<PrecomputedCursorTimeline>> {
Expand Down Expand Up @@ -1387,7 +1387,7 @@ impl Playback {
drop(adopted.take());
preparing_audio_released.store(true, Ordering::Release);
let project = self.project.borrow().clone();
cached_project.audio = project.audio.clone();
Arc::make_mut(&mut cached_project).audio = project.audio.clone();
let ticket = self.audio_output.prepare_playback(PlaySpec {
segments: audio_segments.clone(),
music: self.music.clone(),
Expand Down Expand Up @@ -1460,7 +1460,7 @@ impl Playback {
|| clip_audio_changed(&cached_project, &next_project);
let cursor_changed = cursor_timeline_settings(&cached_project.cursor)
!= cursor_timeline_settings(&next_project.cursor);
cached_project = next_project;
cached_project = Arc::new(next_project);
if adopted.is_none()
&& audio_changed
&& let Some(generation) = audio_generation
Expand All @@ -1469,7 +1469,7 @@ impl Playback {
PlaySpec {
segments: audio_segments.clone(),
music: self.music.clone(),
project: cached_project.clone(),
project: (*cached_project).clone(),
duration_secs: duration,
start_playhead_secs: frame_number as f64 / fps_f64,
playhead_rx: audio_playhead_rx.clone(),
Expand Down
1 change: 1 addition & 0 deletions crates/editor/src/preparing_preview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ async fn run_preview(
segments,
cursor_assets,
} = input;
let project = Arc::new(project);
let metadata = recording_meta
.studio_meta()
.expect("Validated Studio metadata")
Expand Down
4 changes: 2 additions & 2 deletions crates/editor/src/preparing_preview/native_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ async fn ordinary_composed_frames(
let uniforms = match timeline {
Some(timeline) => ProjectUniforms::new_with_precomputed_cursor(
&constants,
&fixture.project,
&Arc::new(fixture.project.clone()),
frame_number,
30,
XY::new(320, 240),
Expand All @@ -394,7 +394,7 @@ async fn ordinary_composed_frames(
),
None => ProjectUniforms::new(
&constants,
&fixture.project,
&Arc::new(fixture.project.clone()),
frame_number,
30,
XY::new(320, 240),
Expand Down
4 changes: 2 additions & 2 deletions crates/editor/src/thumbnail.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{EditorInstance, editor::RendererTransitionInput};
use cap_project::{ProjectConfiguration, XY};
use cap_rendering::{ProjectUniforms, RenderedFrame, ZoomTransformTimeline};
use std::{io::Write, path::Path};
use std::{io::Write, path::Path, sync::Arc};

const THUMBNAIL_SIZE: XY<u32> = XY { x: 640, y: 640 };
const THUMBNAIL_FPS: u32 = 30;
Expand Down Expand Up @@ -53,6 +53,7 @@ impl EditorInstance {
let Some((project, signature)) = pending else {
return Ok(None);
};
let project = Arc::new(project);
let (source_time, segment) = project
.get_segment_time(0.0)
.ok_or("No first frame in the edited timeline")?;
Expand Down Expand Up @@ -165,7 +166,6 @@ fn save_thumbnail(
#[cfg(test)]
mod tests {
use super::*;
use std::sync::Arc;

fn project() -> (tempfile::TempDir, Vec<u8>) {
let root = tempfile::tempdir().unwrap();
Expand Down
5 changes: 2 additions & 3 deletions crates/export/src/preview.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::path::PathBuf;
use std::{path::PathBuf, sync::Arc};

use base64::{Engine, engine::general_purpose::STANDARD};
use cap_editor::EditorInstance;
Expand Down Expand Up @@ -220,6 +220,7 @@ async fn render_preview_frame(
segments,
total_duration,
} = source;
let project_config = &Arc::new(project_config.clone());
let transition_mapping = project_config.timeline.as_ref().and_then(|timeline| {
if timeline.transitions.is_empty() {
return None;
Expand Down Expand Up @@ -465,8 +466,6 @@ fn encode_preview_jpeg(frame: &RenderedFrame, quality: u8) -> Result<Vec<u8>, Ex

#[cfg(test)]
mod tests {
use std::sync::Arc;

use super::*;

fn frame(width: u32, height: u32, stride: usize, mut state: u64) -> RenderedFrame {
Expand Down
2 changes: 1 addition & 1 deletion crates/export/tests/real_recording_regression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ async fn export_sequence_render_matches_editor_reference_for_real_recording()
return Err("Recording is not a studio recording".into());
};

let project_config = recording_meta.project_config();
let project_config = Arc::new(recording_meta.project_config());
let recordings = Arc::new(
ProjectRecordingsMeta::new(&recording_meta.project_path, studio_meta)
.map_err(std::io::Error::other)?,
Expand Down
1 change: 1 addition & 0 deletions crates/rendering/examples/background-benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ async fn main() -> Result<()> {
};
project.background.source = case.source.clone();
project.background.padding = 20.0;
let project = Arc::new(project);
let duration = (args.frames + args.warmup) as f64 / 60.0;
let mut zoom =
ZoomTransformTimeline::from_project(&project, &cursor, duration, screen_size);
Expand Down
1 change: 1 addition & 0 deletions crates/rendering/examples/camera-texture-benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ async fn main() -> Result<()> {
}))?);
}
let zoom = ZoomTransformTimeline::from_project(&project, &cursor, 6.0, size);
let project = std::sync::Arc::new(project);
let mut renderer = FrameRenderer::new(&constants);
let mut frame_ms = Vec::new();
let mut frame_memory = Vec::new();
Expand Down
2 changes: 1 addition & 1 deletion crates/rendering/src/layers/animated_gradient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ mod tests {
}

fn test_uniforms(constants: &RenderVideoConstants, frame: u32) -> ProjectUniforms {
let project = ProjectConfiguration::default();
let project = std::sync::Arc::new(ProjectConfiguration::default());
let cursor = CursorEvents::default();
let frames = DecodedSegmentFrames {
screen_size: constants.options.screen_size,
Expand Down
2 changes: 1 addition & 1 deletion crates/rendering/src/layers/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ mod tests {
let zoom = ZoomTransformTimeline::from_project(project, &cursor, 6.0, size);
let uniforms = ProjectUniforms::new(
constants,
project,
&std::sync::Arc::new(project.clone()),
(frames.segment_time * 60.0).round() as u32,
60,
size,
Expand Down
Loading
Loading