Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
autozoom and renderer refactor (#547)
Brendan Allan4960426c3b55
diff --git a/Cargo.lock b/Cargo.lockindex 424c1a5b6..7d2dcc3b3 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -7264,9 +7264,9 @@ dependencies = [[[package]]name = "tao"-version = "0.32.8"+version = "0.33.0"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "63c8b1020610b9138dd7b1e06cf259ae91aa05c30f3bd0d6b42a03997b92dec1"+checksum = "1e59c1f38e657351a2e822eadf40d6a2ad4627b9c25557bc1180ec1b3295ef82"dependencies = ["bitflags 2.9.0","core-foundation 0.10.0",@@ -7295,8 +7295,8 @@ dependencies = ["tao-macros","unicode-segmentation","url",- "windows 0.60.0",- "windows-core 0.60.1",+ "windows 0.61.1",+ "windows-core 0.61.0","windows-version","x11-dl",]@@ -7343,9 +7343,9 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"[[package]]name = "tauri"-version = "2.4.0"+version = "2.5.1"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "511dd38065a5d3b36c33cdba4362b99a40a5103bebcd4aebb930717e7c8ba292"+checksum = "e7b0bc1aec81bda6bc455ea98fcaed26b3c98c1648c627ad6ff1c704e8bf8cbc"dependencies = ["anyhow","bytes",@@ -7368,6 +7368,7 @@ dependencies = ["objc2 0.6.0","objc2-app-kit 0.3.0","objc2-foundation 0.3.0",+ "objc2-ui-kit","percent-encoding","plist","raw-window-handle",@@ -7391,14 +7392,14 @@ dependencies = ["webkit2gtk","webview2-com","window-vibrancy",- "windows 0.60.0",+ "windows 0.61.1",][[package]]name = "tauri-build"-version = "2.1.0"+version = "2.2.0"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "7ffa8732a66f90903f5a585215f3cf1e87988d0359bc88c18a502efe7572c1de"+checksum = "d7a0350f0df1db385ca5c02888a83e0e66655c245b7443db8b78a70da7d7f8fc"dependencies = ["anyhow","cargo_toml",@@ -7418,9 +7419,9 @@ dependencies = [[[package]]name = "tauri-codegen"-version = "2.1.0"+version = "2.2.0"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "c266a247f14d63f40c6282c2653a8bac5cc3d482ca562a003a88513653ea817a"+checksum = "f93f035551bf7b11b3f51ad9bc231ebbe5e085565527991c16cf326aa38cdf47"dependencies = ["base64 0.22.1","brotli",@@ -7445,9 +7446,9 @@ dependencies = [[[package]]name = "tauri-macros"-version = "2.1.0"+version = "2.2.0"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "f47a1cf94b3bd6c4dc37dce1a43fc96120ff29a91757f0ab3cf713c7ad846e7c"+checksum = "8db4df25e2d9d45de0c4c910da61cd5500190da14ae4830749fee3466dddd112"dependencies = ["heck 0.5.0","proc-macro2",@@ -7802,29 +7803,31 @@ dependencies = [[[package]]name = "tauri-runtime"-version = "2.5.0"+version = "2.6.0"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "9e9c7bce5153f1ca7bc45eba37349b31ba50e975e28edc8b5766c5ec02b0b63a"+checksum = "00f004905d549854069e6774533d742b03cacfd6f03deb08940a8677586cbe39"dependencies = ["cookie","dpi","gtk","http","jni",+ "objc2 0.6.0",+ "objc2-ui-kit","raw-window-handle","serde","serde_json","tauri-utils","thiserror 2.0.6","url",- "windows 0.60.0",+ "windows 0.61.1",][[package]]name = "tauri-runtime-wry"-version = "2.5.0"+version = "2.6.0"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "087188020fd6facb8578fe9b38e81fa0fe5fb85744c73da51a299f94a530a1e3"+checksum = "f85d056f4d4b014fe874814034f3416d57114b617a493a4fe552580851a3f3a2"dependencies = ["gtk","http",@@ -7843,7 +7846,7 @@ dependencies = ["url","webkit2gtk","webview2-com",- "windows 0.60.0",+ "windows 0.61.1","wry",]@@ -7877,9 +7880,9 @@ dependencies = [[[package]]name = "tauri-utils"-version = "2.3.0"+version = "2.4.0"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "82dcced4014e59af9790cc22f5d271df3be09ecd6728ec68861642553c8d01b7"+checksum = "b2900399c239a471bcff7f15c4399eb1a8c4fe511ba2853e07c996d771a5e0a4"dependencies = ["anyhow","brotli",@@ -8917,16 +8920,16 @@ dependencies = [[[package]]name = "webview2-com"-version = "0.36.0"+version = "0.37.0"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "b0d606f600e5272b514dbb66539dd068211cc20155be8d3958201b4b5bd79ed3"+checksum = "b542b5cfbd9618c46c2784e4d41ba218c336ac70d44c55e47b251033e7d85601"dependencies = ["webview2-com-macros","webview2-com-sys",- "windows 0.60.0",- "windows-core 0.60.1",- "windows-implement 0.59.0",- "windows-interface 0.59.0",+ "windows 0.61.1",+ "windows-core 0.61.0",+ "windows-implement 0.60.0",+ "windows-interface 0.59.1",][[package]]@@ -8942,13 +8945,13 @@ dependencies = [[[package]]name = "webview2-com-sys"-version = "0.36.0"+version = "0.37.0"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "bfb27fccd3c27f68e9a6af1bcf48c2d82534b8675b83608a4d81446d095a17ac"+checksum = "8ae2d11c4a686e4409659d7891791254cf9286d3cfe0eef54df1523533d22295"dependencies = ["thiserror 2.0.6",- "windows 0.60.0",- "windows-core 0.60.1",+ "windows 0.61.1",+ "windows-core 0.61.0",][[package]]@@ -9204,11 +9207,24 @@ version = "0.60.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "ddf874e74c7a99773e62b1c671427abf01a425e77c3d3fb9fb1e4883ea934529"dependencies = [- "windows-collections",+ "windows-collections 0.1.1","windows-core 0.60.1",- "windows-future",+ "windows-future 0.1.1",+ "windows-link",+ "windows-numerics 0.1.1",+]++[[package]]+name = "windows"+version = "0.61.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c5ee8f3d025738cb02bad7868bbb5f8a6327501e870bf51f1b455b0a2454a419"+dependencies = [+ "windows-collections 0.2.0",+ "windows-core 0.61.0",+ "windows-future 0.2.0","windows-link",- "windows-numerics",+ "windows-numerics 0.2.0",][[package]]@@ -9234,6 +9250,15 @@ dependencies = ["windows-core 0.60.1",]+[[package]]+name = "windows-collections"+version = "0.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8"+dependencies = [+ "windows-core 0.61.0",+]+[[package]]name = "windows-core"version = "0.52.0"@@ -9285,8 +9310,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "810ce18ed2112484b0d4e15d022e5f598113e220c53e373fb31e67e21670c1ce"dependencies = ["windows-implement 0.59.0",- "windows-interface 0.59.0",- "windows-result 0.3.1",+ "windows-interface 0.59.1",+ "windows-result 0.3.2","windows-strings 0.3.1","windows-targets 0.53.0",]@@ -9298,12 +9323,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "ca21a92a9cae9bf4ccae5cf8368dce0837100ddf6e6d57936749e85f152f6247"dependencies = ["windows-implement 0.59.0",- "windows-interface 0.59.0",+ "windows-interface 0.59.1","windows-link",- "windows-result 0.3.1",+ "windows-result 0.3.2","windows-strings 0.3.1",]+[[package]]+name = "windows-core"+version = "0.61.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4763c1de310c86d75a878046489e2e5ba02c649d185f21c67d4cf8a56d098980"+dependencies = [+ "windows-implement 0.60.0",+ "windows-interface 0.59.1",+ "windows-link",+ "windows-result 0.3.2",+ "windows-strings 0.4.0",+]+[[package]]name = "windows-future"version = "0.1.1"@@ -9314,6 +9352,16 @@ dependencies = ["windows-link",]+[[package]]+name = "windows-future"+version = "0.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7a1d6bbefcb7b60acd19828e1bc965da6fcf18a7e39490c5f8be71e54a19ba32"+dependencies = [+ "windows-core 0.61.0",+ "windows-link",+]+[[package]]name = "windows-implement"version = "0.56.0"@@ -9347,6 +9395,17 @@ dependencies = ["syn 2.0.90",]+[[package]]+name = "windows-implement"+version = "0.60.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.90",+]+[[package]]name = "windows-interface"version = "0.56.0"@@ -9371,9 +9430,9 @@ dependencies = [[[package]]name = "windows-interface"-version = "0.59.0"+version = "0.59.1"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "cb26fd936d991781ea39e87c3a27285081e3c0da5ca0fcbc02d368cc6f52ff01"+checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8"dependencies = ["proc-macro2","quote",@@ -9382,9 +9441,9 @@ dependencies = [[[package]]name = "windows-link"-version = "0.1.0"+version = "0.1.1"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "6dccfd733ce2b1753b03b6d3c65edf020262ea35e20ccdf3e288043e6dd620e3"+checksum = "76840935b766e1b0a05c0066835fb9ec80071d4c09a16f6bd5f7e655e3c14c38"[[package]]name = "windows-numerics"@@ -9396,6 +9455,16 @@ dependencies = ["windows-link",]+[[package]]+name = "windows-numerics"+version = "0.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1"+dependencies = [+ "windows-core 0.61.0",+ "windows-link",+]+[[package]]name = "windows-registry"version = "0.2.0"@@ -9438,9 +9507,9 @@ dependencies = [[[package]]name = "windows-result"-version = "0.3.1"+version = "0.3.2"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "06374efe858fab7e4f881500e6e86ec8bc28f9462c47e5a9941a0142ad86b189"+checksum = "c64fd11a4fd95df68efcfee5f44a294fe71b8bc6a91993e2791938abcc712252"dependencies = ["windows-link",]@@ -9473,6 +9542,15 @@ dependencies = ["windows-link",]+[[package]]+name = "windows-strings"+version = "0.4.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7a2ba9642430ee452d5a7aa78d72907ebe8cfda358e8cb7918a2050581322f97"+dependencies = [+ "windows-link",+]+[[package]]name = "windows-sys"version = "0.45.0"@@ -9808,8 +9886,9 @@ dependencies = [[[package]]name = "wry"-version = "0.50.5"-source = "git+https://github.com/CapSoftware/wry?rev=293f510#293f510b4096444025110ab3b68722ddc5bc0b4d"+version = "0.51.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c886a0a9d2a94fd90cfa1d929629b79cfefb1546e2c7430c63a47f0664c0e4e2"dependencies = ["base64 0.22.1","block2 0.6.0",@@ -9843,8 +9922,8 @@ dependencies = ["webkit2gtk","webkit2gtk-sys","webview2-com",- "windows 0.60.0",- "windows-core 0.60.1",+ "windows 0.61.1",+ "windows-core 0.61.0","windows-version","x11-dl",]@@ -10200,3 +10279,8 @@ dependencies = ["syn 2.0.90","winnow 0.6.20",]++[[patch.unused]]+name = "wry"+version = "0.50.5"+source = "git+https://github.com/CapSoftware/wry?rev=293f510#293f510b4096444025110ab3b68722ddc5bc0b4d"diff --git a/Cargo.toml b/Cargo.tomlindex 02a370034..246e5f3ea 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -18,7 +18,7 @@ tokio = { version = "1.39.3", features = ["rt-multi-thread","time",] }-tauri = { version = "2.4.0", features = ["specta"] }+tauri = { version = "2.5.0", features = ["specta"] }specta = { version = "=2.0.0-rc.20", features = ["derive","serde_json",diff --git a/apps/desktop/package.json b/apps/desktop/package.jsonindex 7534fa8e8..8a598bec8 100644--- a/apps/desktop/package.json+++ b/apps/desktop/package.json@@ -36,7 +36,7 @@"@solidjs/router": "^0.14.2","@solidjs/start": "^1.1.3","@tanstack/solid-query": "^5.51.21",- "@tauri-apps/api": "^2.1.1",+ "@tauri-apps/api": "2.5.0","@tauri-apps/plugin-clipboard-manager": "^2.2.1","@tauri-apps/plugin-deep-link": "^2.2.0","@tauri-apps/plugin-dialog": "2.0.1",diff --git a/apps/desktop/src/routes/editor/ConfigSidebar.tsx b/apps/desktop/src/routes/editor/ConfigSidebar.tsxindex b24b245de..419717266 100644--- a/apps/desktop/src/routes/editor/ConfigSidebar.tsx+++ b/apps/desktop/src/routes/editor/ConfigSidebar.tsx@@ -1617,6 +1617,13 @@ function ZoomSegmentConfig(props: {projectHistory,} = useEditorContext();+ const states = {+ manual:+ props.segment.mode === "auto"+ ? { x: 0.5, y: 0.5 }+ : props.segment.mode.manual,+ };+return (<divdata-visible={editorState.timeline.selection?.type === "zoom"}@@ -1670,7 +1677,24 @@ function ZoomSegmentConfig(props: {/></Field><Field name="Zoom Mode" icon={<IconCapSettings />}>- <KTabs class="space-y-6">+ <KTabs+ class="space-y-6"+ onChange={(v) => {+ if (v === "auto") {+ setProject(+ "timeline",+ "zoomSegments",+ props.segmentIndex,+ "mode",+ "auto"+ );+ } else {+ setProject("timeline", "zoomSegments", props.segmentIndex, {+ mode: { manual: states.manual },+ });+ }+ }}+ ><KTabs.List class="flex flex-row items-center rounded-[0.5rem] relative border"><KTabs.Triggervalue="auto"diff --git a/apps/desktop/src/routes/editor/ExportDialog.tsx b/apps/desktop/src/routes/editor/ExportDialog.tsxindex 84b5dd6ce..f61f997fd 100644--- a/apps/desktop/src/routes/editor/ExportDialog.tsx+++ b/apps/desktop/src/routes/editor/ExportDialog.tsx@@ -2,23 +2,23 @@ import { Button } from "@cap/ui-solid";import { Select as KSelect } from "@kobalte/core/select";import { makePersisted } from "@solid-primitives/storage";import {- createMutation,- createQuery,- keepPreviousData+ createMutation,+ createQuery,+ keepPreviousData,} from "@tanstack/solid-query";import { save as saveDialog } from "@tauri-apps/plugin-dialog";import { cx } from "cva";import {- createEffect,- createRoot,- createSignal,- For,- JSX,- Match,- on,- Show,- Switch,- ValidComponent,+ createEffect,+ createRoot,+ createSignal,+ For,+ JSX,+ Match,+ on,+ Show,+ Switch,+ ValidComponent,} from "solid-js";import { createStore, produce, reconcile } from "solid-js/store";import toast from "solid-toast";@@ -28,20 +28,20 @@ import { authStore } from "~/store";import { trackEvent } from "~/utils/analytics";import { exportVideo } from "~/utils/export";import {- commands,- events,- ExportCompression,- FramesRendered,+ commands,+ events,+ ExportCompression,+ FramesRendered,} from "~/utils/tauri";import { RenderState, useEditorContext } from "./context";import { RESOLUTION_OPTIONS } from "./Header";import {- Dialog,- DialogContent,- MenuItem,- MenuItemList,- PopperContent,- topSlideAnimateClasses,+ Dialog,+ DialogContent,+ MenuItem,+ MenuItemList,+ PopperContent,+ topSlideAnimateClasses,} from "./ui";export const COMPRESSION_OPTIONS: Array<{@@ -96,7 +96,6 @@ export function ExportDialog() {refetchMeta,} = useEditorContext();-const [settings, setSettings] = makePersisted(createStore({format: "mp4" as "mp4" | "gif",@@ -158,9 +157,10 @@ export function ExportDialog() {if (exportState.type !== "idle") return;setExportState(reconcile({ action: "copy", type: "starting" }));- const outputPath = await exportWithSettings((progress) =>- setExportState({ type: "rendering", progress })- );+ const outputPath = await exportWithSettings((progress) => {+ console.log(progress);+ setExportState({ type: "rendering", progress });+ });setExportState({ type: "copying" });@@ -499,11 +499,7 @@ export function ExportDialog() {<KSelect.Value<(typeof FPS_OPTIONS)[number]> class="flex-1 text-sm text-left truncate tabular-nums text-[--gray-500]">- {(state) => (- <span>- {state.selectedOption()?.label}- </span>- )}+ {(state) => <span>{state.selectedOption()?.label}</span>}</KSelect.Value><KSelect.Icon<ValidComponent>as={(props) => (diff --git a/apps/desktop/src/utils/export.ts b/apps/desktop/src/utils/export.tsindex d8cb9cc5b..8bbcb06d1 100644--- a/apps/desktop/src/utils/export.ts+++ b/apps/desktop/src/utils/export.ts@@ -1,17 +1,14 @@import { Channel } from "@tauri-apps/api/core";-import {- commands,- ExportCompression,- ExportSettings,- FramesRendered,-} from "./tauri";+import { commands, ExportSettings, FramesRendered } from "./tauri";export async function exportVideo(projectPath: string,settings: ExportSettings,onProgress: (progress: FramesRendered) => void) {- const progress = new Channel<FramesRendered>();- progress.onmessage = onProgress;+ const progress = new Channel<FramesRendered>((e) => {+ console.log({ e });+ onProgress(e);+ });return await commands.exportVideo(projectPath, progress, settings);}diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex 6393be77d..e28b782b0 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -4,7 +4,7 @@ use cap_media::{feeds::RawCameraFrame, frame_ws::WSFrame};use cap_project::{BackgroundSource, CursorEvents, RecordingMeta, StudioRecordingMeta, XY};use cap_rendering::{decoder::DecodedFrame, DecodedSegmentFrames, FrameRenderer, ProjectRecordings, ProjectUniforms,- RenderVideoConstants,+ RenderVideoConstants, RendererLayers,};use tokio::{sync::{mpsc, oneshot},@@ -74,6 +74,8 @@ impl Renderer {let mut frame_renderer = FrameRenderer::new(&self.render_constants);+ let mut layers = RendererLayers::new(&self.render_constants.device);+loop {while let Some(msg) = self.rx.recv().await {match msg {@@ -96,7 +98,7 @@ impl Renderer {let output_size = uniforms.output_size;let frame = frame_renderer- .render(segment_frames, uniforms, &cursor)+ .render(segment_frames, uniforms, &cursor, &mut layers).await.unwrap();diff --git a/crates/editor/src/editor_instance.rs b/crates/editor/src/editor_instance.rsindex 501f8f6cb..0221879c3 100644--- a/crates/editor/src/editor_instance.rs+++ b/crates/editor/src/editor_instance.rs@@ -240,19 +240,17 @@ impl EditorInstance {.get_frames(segment_time as f32, !project.camera.hide).await{+ let uniforms = ProjectUniforms::new(+ &self.render_constants,+ &project,+ frame_number,+ fps,+ resolution_base,+ &segment.cursor,+ &segment_frames,+ );self.renderer- .render_frame(- segment_frames,- ProjectUniforms::new(- &self.render_constants,- &project,- frame_number,- fps,- resolution_base,- &segment.cursor,- ),- segment.cursor.clone(),- )+ .render_frame(segment_frames, uniforms, segment.cursor.clone()).await;}}diff --git a/crates/editor/src/playback.rs b/crates/editor/src/playback.rsindex 0de0bee18..676291e4c 100644--- a/crates/editor/src/playback.rs+++ b/crates/editor/src/playback.rs@@ -95,6 +95,7 @@ impl Playback {fps,resolution_base,&segment.cursor,+ &segment_frames,);self.rendererdiff --git a/crates/rendering/src/composite_frame.rs b/crates/rendering/src/composite_frame.rsindex 950a81315..81dff1bab 100644--- a/crates/rendering/src/composite_frame.rs+++ b/crates/rendering/src/composite_frame.rs@@ -143,16 +143,6 @@ impl CompositeVideoFramePipeline {wgpu::BindGroupLayoutEntry {binding: 2,visibility: wgpu::ShaderStages::FRAGMENT,- ty: wgpu::BindingType::Texture {- sample_type: wgpu::TextureSampleType::Float { filterable: true },- view_dimension: wgpu::TextureViewDimension::D2,- multisampled: false,- },- count: None,- },- wgpu::BindGroupLayoutEntry {- binding: 3,- visibility: wgpu::ShaderStages::FRAGMENT,ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),count: None,},@@ -165,7 +155,6 @@ impl CompositeVideoFramePipeline {device: &wgpu::Device,uniforms: &wgpu::Buffer,frame: &wgpu::TextureView,- intermediate: &wgpu::TextureView,) -> wgpu::BindGroup {let sampler = device.create_sampler(&(wgpu::SamplerDescriptor {@@ -193,10 +182,6 @@ impl CompositeVideoFramePipeline {},wgpu::BindGroupEntry {binding: 2,- resource: wgpu::BindingResource::TextureView(intermediate),- },- wgpu::BindGroupEntry {- binding: 3,resource: wgpu::BindingResource::Sampler(&sampler),},],diff --git a/crates/rendering/src/coord.rs b/crates/rendering/src/coord.rsindex 241caf44e..3999222af 100644--- a/crates/rendering/src/coord.rs+++ b/crates/rendering/src/coord.rs@@ -23,7 +23,7 @@ pub struct ZoomedFrameSpace;#[derive(Default, Clone, Copy, Debug)]pub struct TransformedDisplaySpace;-#[derive(Clone, Copy, Debug)]+#[derive(Clone, Copy, Debug, Default)]pub struct Coord<TSpace> {pub coord: XY<f64>,pub space: TSpace,diff --git a/crates/rendering/src/cursor_interpolation.rs b/crates/rendering/src/cursor_interpolation.rsnew file mode 100644index 000000000..681a2dcc9--- /dev/null+++ b/crates/rendering/src/cursor_interpolation.rs@@ -0,0 +1,170 @@+use cap_project::{CursorEvents, CursorMoveEvent, XY};++use crate::{+ spring_mass_damper::{SpringMassDamperSimulation, SpringMassDamperSimulationConfig},+ Coord, RawDisplayUVSpace,+};++#[derive(Debug, Clone)]+pub struct InterpolatedCursorPosition {+ pub position: Coord<RawDisplayUVSpace>,+ pub velocity: XY<f32>,+ pub cursor_id: String,+}++pub fn interpolate_cursor(+ cursor: &CursorEvents,+ time_secs: f32,+ smoothing: Option<SpringMassDamperSimulationConfig>,+) -> Option<InterpolatedCursorPosition> {+ let time_ms = (time_secs * 1000.0) as f64;++ if cursor.moves.is_empty() {+ return None;+ }++ if cursor.moves[0].time_ms > time_ms.into() {+ let event = &cursor.moves[0];++ return Some(InterpolatedCursorPosition {+ position: Coord::new(XY {+ x: event.x,+ y: event.y,+ }),+ velocity: XY::new(0.0, 0.0),+ cursor_id: event.cursor_id.clone(),+ });+ }++ if let Some(event) = cursor.moves.last() {+ if event.time_ms < time_ms.into() {+ return Some(InterpolatedCursorPosition {+ position: Coord::new(XY {+ x: event.x,+ y: event.y,+ }),+ velocity: XY::new(0.0, 0.0),+ cursor_id: event.cursor_id.clone(),+ });+ }+ }++ if let Some(smoothing_config) = smoothing {+ let events = get_smoothed_cursor_events(&cursor.moves, smoothing_config);+ interpolate_smoothed_position(&events, time_secs as f64, smoothing_config)+ } else {+ let (pos, cursor_id) = cursor.moves.windows(2).enumerate().find_map(|(i, chunk)| {+ if time_ms >= chunk[0].time_ms && time_ms < chunk[1].time_ms {+ let c = &chunk[0];+ Some((XY::new(c.x as f32, c.y as f32), c.cursor_id.clone()))+ } else {+ None+ }+ })?;++ Some(InterpolatedCursorPosition {+ position: Coord::new(XY {+ x: pos.x as f64,+ y: pos.y as f64,+ }),+ velocity: XY::new(0.0, 0.0),+ cursor_id,+ })+ }+}++fn get_smoothed_cursor_events(+ moves: &[CursorMoveEvent],+ smoothing_config: SpringMassDamperSimulationConfig,+) -> Vec<SmoothedCursorEvent> {+ let mut last_time = 0.0;++ let mut events = vec![];++ let mut sim = SpringMassDamperSimulation::new(smoothing_config);++ sim.set_position(XY::new(moves[0].x, moves[0].y).map(|v| v as f32));+ sim.set_velocity(XY::new(0.0, 0.0));++ if moves[0].time_ms > 0.0 {+ events.push(SmoothedCursorEvent {+ time: 0.0,+ target_position: sim.position,+ position: sim.position,+ velocity: sim.velocity,+ cursor_id: moves[0].cursor_id.clone(),+ })+ }++ for (i, m) in moves.iter().enumerate() {+ let target_position = moves+ .get(i + 1)+ .map(|e| XY::new(e.x, e.y).map(|v| v as f32))+ .unwrap_or(sim.target_position);+ sim.set_target_position(target_position);++ sim.run(m.time_ms as f32 - last_time);++ last_time = m.time_ms as f32;++ events.push(SmoothedCursorEvent {+ time: m.time_ms as f32,+ target_position,+ position: sim.position,+ velocity: sim.velocity,+ cursor_id: m.cursor_id.clone(),+ });+ }++ events+}++fn interpolate_smoothed_position(+ smoothed_events: &[SmoothedCursorEvent],+ query_time: f64,+ smoothing_config: SpringMassDamperSimulationConfig,+) -> Option<InterpolatedCursorPosition> {+ if smoothed_events.is_empty() {+ return None;+ }++ let mut sim = SpringMassDamperSimulation::new(smoothing_config);++ let query_time_ms = (query_time * 1000.0) as f32;++ let cursor_id = match smoothed_events+ .windows(2)+ .find(|chunk| chunk[0].time <= query_time_ms && query_time_ms < chunk[1].time)+ {+ Some(c) => {+ sim.set_position(c[0].position);+ sim.set_velocity(c[0].velocity);+ sim.set_target_position(c[0].target_position);+ sim.run(query_time_ms - c[0].time);+ c[0].cursor_id.clone()+ }+ None => {+ let e = smoothed_events.last().unwrap();+ sim.set_position(e.position);+ sim.set_velocity(e.velocity);+ sim.set_target_position(e.target_position);+ sim.run(query_time_ms - e.time);+ e.cursor_id.clone()+ }+ };++ Some(InterpolatedCursorPosition {+ position: Coord::new(sim.position.map(|v| v as f64)),+ velocity: sim.velocity,+ cursor_id,+ })+}++#[derive(Debug)]+struct SmoothedCursorEvent {+ time: f32,+ target_position: XY<f32>,+ position: XY<f32>,+ velocity: XY<f32>,+ cursor_id: String,+}diff --git a/crates/rendering/src/frame_pipeline.rs b/crates/rendering/src/frame_pipeline.rsindex 72da7f64e..ae224416a 100644--- a/crates/rendering/src/frame_pipeline.rs+++ b/crates/rendering/src/frame_pipeline.rs@@ -1,82 +1,45 @@-use std::time::Instant;-+use cap_project::XY;use futures_intrusive::channel::shared::oneshot_channel;-use wgpu::{hal::Device, COPY_BYTES_PER_ROW_ALIGNMENT};--use crate::{get_either, ProjectUniforms, RenderVideoConstants, RenderingError};+use wgpu::COPY_BYTES_PER_ROW_ALIGNMENT;-pub struct FramePipeline<'a, 'b> {- pub state: &'a mut FramePipelineState<'b>,- pub encoder: &'a mut FramePipelineEncoder,-}+use crate::{ProjectUniforms, RenderSession, RenderVideoConstants, RenderingError};pub struct FramePipelineState<'a> {pub constants: &'a RenderVideoConstants,pub uniforms: &'a ProjectUniforms,- pub textures: &'a (wgpu::Texture, wgpu::Texture),- pub texture_views: (wgpu::TextureView, wgpu::TextureView),- output_is_left: bool,+ pub texture: &'a wgpu::Texture,+ pub texture_view: wgpu::TextureView,}impl<'a> FramePipelineState<'a> {pub fn new(constants: &'a RenderVideoConstants,uniforms: &'a ProjectUniforms,- textures: &'a (wgpu::Texture, wgpu::Texture),+ texture: &'a wgpu::Texture,) -> Self {- let texture_views = (- textures- .0- .create_view(&wgpu::TextureViewDescriptor::default()),- textures- .1- .create_view(&wgpu::TextureViewDescriptor::default()),- );+ let texture_view = texture.create_view(&wgpu::TextureViewDescriptor::default());Self {constants,uniforms,- textures,- texture_views,- output_is_left: true,+ texture,+ texture_view,}}-- pub fn is_left(&self) -> bool {- self.output_is_left- }-- pub fn get_current_texture_view(&self) -> &wgpu::TextureView {- get_either(- (&self.texture_views.0, &self.texture_views.1),- self.output_is_left,- )- }-- pub fn get_other_texture_view(&self) -> &wgpu::TextureView {- get_either(- (&self.texture_views.0, &self.texture_views.1),- !self.output_is_left,- )- }-- pub fn get_current_texture(&self) -> &wgpu::Texture {- get_either((&self.textures.0, &self.textures.1), self.output_is_left)- }-- pub fn get_other_texture(&self) -> &wgpu::Texture {- get_either((&self.textures.0, &self.textures.1), !self.output_is_left)- }-- pub fn switch_output(&mut self) {- self.output_is_left = !self.output_is_left;- }}pub struct FramePipelineEncoder {pub encoder: wgpu::CommandEncoder,}+#[derive(Clone)]+pub struct RenderedFrame {+ pub data: Vec<u8>,+ pub width: u32,+ pub height: u32,+ pub padded_bytes_per_row: u32,+}+impl FramePipelineEncoder {pub fn new(state: &FramePipelineState) -> Self {Self {@@ -87,113 +50,92 @@ impl FramePipelineEncoder {),}}- pub fn do_render_pass(- &mut self,- output_view: &wgpu::TextureView,- render_pipeline: &wgpu::RenderPipeline,- bind_group: wgpu::BindGroup,- load_op: wgpu::LoadOp<wgpu::Color>,- ) {- let mut render_pass = self.encoder.begin_render_pass(&wgpu::RenderPassDescriptor {- label: Some("Render Pass"),- color_attachments: &[Some(wgpu::RenderPassColorAttachment {- view: output_view,- resolve_target: None,- ops: wgpu::Operations {- load: load_op,- store: wgpu::StoreOp::Store,- },- })],- depth_stencil_attachment: None,- timestamp_writes: None,- occlusion_query_set: None,- });-- render_pass.set_pipeline(render_pipeline);- render_pass.set_bind_group(0, &bind_group, &[]);- render_pass.draw(0..4, 0..1);- }+}- pub fn padded_bytes_per_row(&self, state: &FramePipelineState<'_>) -> u32 {- // Calculate the aligned bytes per row- let align = COPY_BYTES_PER_ROW_ALIGNMENT;- let unpadded_bytes_per_row = state.uniforms.output_size.0 * 4;- let padding = (align - (unpadded_bytes_per_row % align)) % align;- let padded_bytes_per_row = unpadded_bytes_per_row + padding;+pub fn padded_bytes_per_row(output_size: (u32, u32)) -> u32 {+ // Calculate the aligned bytes per row+ let align = COPY_BYTES_PER_ROW_ALIGNMENT;+ let unpadded_bytes_per_row = output_size.0 * 4;+ let padding = (align - (unpadded_bytes_per_row % align)) % align;+ let padded_bytes_per_row = unpadded_bytes_per_row + padding;- // Ensure the padded_bytes_per_row is a multiple of 4 (32 bits)- (padded_bytes_per_row + 3) & !3- }+ // Ensure the padded_bytes_per_row is a multiple of 4 (32 bits)+ (padded_bytes_per_row + 3) & !3+}- pub async fn copy_output(- self,- state: FramePipelineState<'_>,- ) -> Result<Vec<u8>, RenderingError> {- let padded_bytes_per_row = self.padded_bytes_per_row(&state);- let constants = &state.constants;-- constants- .queue- .submit(std::iter::once(self.encoder.finish()));-- let output_texture_size = wgpu::Extent3d {- width: state.uniforms.output_size.0,- height: state.uniforms.output_size.1,- depth_or_array_layers: 1,- };-- let output_buffer_size = (padded_bytes_per_row * state.uniforms.output_size.1) as u64;-- let output_buffer = constants.device.create_buffer(&wgpu::BufferDescriptor {- size: output_buffer_size,- usage: wgpu::BufferUsages::COPY_DST | wgpu::BufferUsages::MAP_READ,- label: Some("Output Buffer"),- mapped_at_creation: false,- });-- let mut encoder = constants.device.create_command_encoder(- &(wgpu::CommandEncoderDescriptor {- label: Some("Copy Encoder"),- }),- );-- encoder.copy_texture_to_buffer(- wgpu::ImageCopyTexture {- texture: state.get_current_texture(),- mip_level: 0,- origin: wgpu::Origin3d::ZERO,- aspect: wgpu::TextureAspect::All,- },- wgpu::ImageCopyBuffer {- buffer: &output_buffer,- layout: wgpu::ImageDataLayout {- offset: 0,- bytes_per_row: Some(padded_bytes_per_row),- rows_per_image: Some(state.uniforms.output_size.1),- },+pub async fn finish_encoder(+ session: &mut RenderSession,+ device: &wgpu::Device,+ queue: &wgpu::Queue,+ uniforms: &ProjectUniforms,+ encoder: wgpu::CommandEncoder,+) -> Result<RenderedFrame, RenderingError> {+ let padded_bytes_per_row = padded_bytes_per_row(uniforms.output_size);++ queue.submit(std::iter::once(encoder.finish()));++ let output_texture_size = wgpu::Extent3d {+ width: uniforms.output_size.0,+ height: uniforms.output_size.1,+ depth_or_array_layers: 1,+ };++ let output_buffer_size = (padded_bytes_per_row * uniforms.output_size.1) as u64;++ let output_buffer = device.create_buffer(&wgpu::BufferDescriptor {+ size: output_buffer_size,+ usage: wgpu::BufferUsages::COPY_DST | wgpu::BufferUsages::MAP_READ,+ label: Some("Output Buffer"),+ mapped_at_creation: false,+ });++ let mut encoder = device.create_command_encoder(+ &(wgpu::CommandEncoderDescriptor {+ label: Some("Copy Encoder"),+ }),+ );++ encoder.copy_texture_to_buffer(+ wgpu::ImageCopyTexture {+ texture: session.current_texture(),+ mip_level: 0,+ origin: wgpu::Origin3d::ZERO,+ aspect: wgpu::TextureAspect::All,+ },+ wgpu::ImageCopyBuffer {+ buffer: &output_buffer,+ layout: wgpu::ImageDataLayout {+ offset: 0,+ bytes_per_row: Some(padded_bytes_per_row),+ rows_per_image: Some(uniforms.output_size.1),},- output_texture_size,- );-- constants.queue.submit(std::iter::once(encoder.finish()));-- let buffer_slice = output_buffer.slice(..);- let (tx, rx) = oneshot_channel();- buffer_slice.map_async(wgpu::MapMode::Read, move |result| {- tx.send(result).ok();- });- constants.device.poll(wgpu::Maintain::Wait);-- rx.receive()- .await- .ok_or(RenderingError::BufferMapWaitingFailed)??;-- let data = buffer_slice.get_mapped_range();- let data_vec = data.to_vec();-- drop(data);- output_buffer.unmap();-- Ok(data_vec)- }+ },+ output_texture_size,+ );++ queue.submit(std::iter::once(encoder.finish()));++ let buffer_slice = output_buffer.slice(..);+ let (tx, rx) = oneshot_channel();+ buffer_slice.map_async(wgpu::MapMode::Read, move |result| {+ tx.send(result).ok();+ });+ device.poll(wgpu::Maintain::Wait);++ rx.receive()+ .await+ .ok_or(RenderingError::BufferMapWaitingFailed)??;++ let data = buffer_slice.get_mapped_range();+ let data_vec = data.to_vec();++ drop(data);+ output_buffer.unmap();++ Ok(RenderedFrame {+ data: data_vec,+ padded_bytes_per_row,+ width: uniforms.output_size.0,+ height: uniforms.output_size.1,+ })}diff --git a/crates/rendering/src/layers/background.rs b/crates/rendering/src/layers/background.rsindex 96e99e71f..f200f1a18 100644--- a/crates/rendering/src/layers/background.rs+++ b/crates/rendering/src/layers/background.rs@@ -8,20 +8,28 @@ use specta::Type;use wgpu::{include_wgsl, util::DeviceExt};use crate::{- create_shader_render_pipeline, frame_pipeline::FramePipeline, srgb_to_linear, RenderingError,+ create_shader_render_pipeline, srgb_to_linear, ProjectUniforms, RenderVideoConstants,+ RenderingError,};+#[derive(PartialEq, Debug, Clone, Copy, Serialize, Deserialize, Type)]+struct Gradient {+ start: [f32; 4],+ end: [f32; 4],+ angle: f32,+}++#[derive(PartialEq)]+enum ColorOrGradient {+ Color([f32; 4]),+ Gradient(Gradient),+}+#[derive(Debug, Clone, Serialize, Deserialize, Type)]pub enum Background {Color([f32; 4]),- Gradient {- start: [f32; 4],- end: [f32; 4],- angle: f32,- },- Image {- path: String,- },+ Gradient(Gradient),+ Image { path: String },}impl From<BackgroundSource> for Background {@@ -33,7 +41,7 @@ impl From<BackgroundSource> for Background {srgb_to_linear(value[2]),1.0,]),- BackgroundSource::Gradient { from, to, angle } => Background::Gradient {+ BackgroundSource::Gradient { from, to, angle } => Background::Gradient(Gradient {start: [srgb_to_linear(from[0]),srgb_to_linear(from[1]),@@ -47,7 +55,7 @@ impl From<BackgroundSource> for Background {1.0,],angle: angle as f32,- },+ }),BackgroundSource::Image { path } | BackgroundSource::Wallpaper { path } => {if let Some(path) = path {if !path.is_empty() {@@ -67,178 +75,195 @@ impl From<BackgroundSource> for Background {}}-pub struct BackgroundLayer;+pub enum Inner {+ Image {+ path: String,+ bind_group: wgpu::BindGroup,+ },+ ColorOrGradient {+ value: ColorOrGradient,+ buffer: wgpu::Buffer,+ bind_group: wgpu::BindGroup,+ },+}++pub struct BackgroundLayer {+ inner: Option<Inner>,+ image_pipeline: ImageBackgroundPipeline,+ color_pipeline: GradientOrColorPipeline,+}impl BackgroundLayer {- pub async fn render<'a, 'b>(- pipeline: &mut FramePipeline<'a, 'b>,+ pub fn new(device: &wgpu::Device) -> Self {+ Self {+ inner: None,+ image_pipeline: ImageBackgroundPipeline::new(device),+ color_pipeline: GradientOrColorPipeline::new(device),+ }+ }++ pub async fn prepare(+ &mut self,+ constants: &RenderVideoConstants,+ uniforms: &ProjectUniforms,background: Background,) -> Result<(), RenderingError> {- let constants = pipeline.state.constants;- let uniforms = pipeline.state.uniforms;+ let device = &constants.device;+ let queue = &constants.queue;- pipeline.state.switch_output();-- // First, handle the backgroundmatch background {Background::Image { path } => {- let mut textures = constants.background_textures.write().await;- let texture = match textures.entry(path.clone()) {- std::collections::hash_map::Entry::Occupied(e) => e.into_mut(),- std::collections::hash_map::Entry::Vacant(e) => {- let img = image::open(&path)- .map_err(|e| RenderingError::ImageLoadError(e.to_string()))?;- let rgba = img.to_rgba8();- let dimensions = img.dimensions();-- let texture = constants.device.create_texture(&wgpu::TextureDescriptor {- label: Some("Background Image Texture"),- size: wgpu::Extent3d {- width: dimensions.0,- height: dimensions.1,- depth_or_array_layers: 1,- },- mip_level_count: 1,- sample_count: 1,- dimension: wgpu::TextureDimension::D2,- format: wgpu::TextureFormat::Rgba8UnormSrgb,- usage: wgpu::TextureUsages::TEXTURE_BINDING- | wgpu::TextureUsages::COPY_DST,- view_formats: &[],+ match &self.inner {+ Some(Inner::Image {+ path: current_path, ..+ }) if current_path == &path => {}+ _ => {+ let mut textures = constants.background_textures.write().await;+ let texture = match textures.entry(path.clone()) {+ std::collections::hash_map::Entry::Occupied(e) => e.into_mut(),+ std::collections::hash_map::Entry::Vacant(e) => {+ let img = image::open(&path)+ .map_err(|e| RenderingError::ImageLoadError(e.to_string()))?;+ let rgba = img.to_rgba8();+ let dimensions = img.dimensions();++ let texture = device.create_texture(&wgpu::TextureDescriptor {+ label: Some("Background Image Texture"),+ size: wgpu::Extent3d {+ width: dimensions.0,+ height: dimensions.1,+ depth_or_array_layers: 1,+ },+ mip_level_count: 1,+ sample_count: 1,+ dimension: wgpu::TextureDimension::D2,+ format: wgpu::TextureFormat::Rgba8UnormSrgb,+ usage: wgpu::TextureUsages::TEXTURE_BINDING+ | wgpu::TextureUsages::COPY_DST,+ view_formats: &[],+ });++ queue.write_texture(+ wgpu::ImageCopyTexture {+ texture: &texture,+ mip_level: 0,+ origin: wgpu::Origin3d::ZERO,+ aspect: wgpu::TextureAspect::All,+ },+ &rgba,+ wgpu::ImageDataLayout {+ offset: 0,+ bytes_per_row: Some(4 * dimensions.0),+ rows_per_image: Some(dimensions.1),+ },+ wgpu::Extent3d {+ width: dimensions.0,+ height: dimensions.1,+ depth_or_array_layers: 1,+ },+ );++ e.insert(texture)+ }+ };++ let output_ar =+ uniforms.output_size.1 as f32 / uniforms.output_size.0 as f32;+ let image_ar = texture.height() as f32 / texture.width() as f32;++ let y_height = if output_ar < image_ar {+ ((image_ar - output_ar) / 2.0) / image_ar+ } else {+ 0.0+ };++ let x_width = if output_ar > image_ar {+ let output_ar = 1.0 / output_ar;+ let image_ar = 1.0 / image_ar;++ ((image_ar - output_ar) / 2.0) / image_ar+ } else {+ 0.0+ };++ let image_uniforms = ImageBackgroundUniforms {+ output_size: [+ uniforms.output_size.0 as f32,+ uniforms.output_size.1 as f32,+ ],+ padding: 0.0,+ x_width,+ y_height,+ _padding: 0.0,+ };++ let uniform_buffer =+ device.create_buffer_init(&wgpu::util::BufferInitDescriptor {+ label: Some("Image Background Uniforms"),+ contents: bytemuck::cast_slice(&[image_uniforms]),+ usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,+ });++ let texture_view =+ texture.create_view(&wgpu::TextureViewDescriptor::default());++ self.inner = Some(Inner::Image {+ path,+ bind_group: self.image_pipeline.bind_group(+ &device,+ &uniform_buffer,+ &texture_view,+ ),});-- constants.queue.write_texture(- wgpu::ImageCopyTexture {- texture: &texture,- mip_level: 0,- origin: wgpu::Origin3d::ZERO,- aspect: wgpu::TextureAspect::All,- },- &rgba,- wgpu::ImageDataLayout {- offset: 0,- bytes_per_row: Some(4 * dimensions.0),- rows_per_image: Some(dimensions.1),- },- wgpu::Extent3d {- width: dimensions.0,- height: dimensions.1,- depth_or_array_layers: 1,- },- );-- e.insert(texture)}};-- let output_ar = uniforms.output_size.1 as f32 / uniforms.output_size.0 as f32;- let image_ar = texture.height() as f32 / texture.width() as f32;-- let y_height = if output_ar < image_ar {- ((image_ar - output_ar) / 2.0) / image_ar- } else {- 0.0- };-- let x_width = if output_ar > image_ar {- let output_ar = 1.0 / output_ar;- let image_ar = 1.0 / image_ar;-- ((image_ar - output_ar) / 2.0) / image_ar- } else {- 0.0- };-- let image_uniforms = ImageBackgroundUniforms {- output_size: [uniforms.output_size.0 as f32, uniforms.output_size.1 as f32],- padding: 0.0,- x_width,- y_height,- _padding: 0.0,- };-- let uniform_buffer =- constants- .device- .create_buffer_init(&wgpu::util::BufferInitDescriptor {- label: Some("Image Background Uniforms"),- contents: bytemuck::cast_slice(&[image_uniforms]),- usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,- });-- let texture_view = texture.create_view(&wgpu::TextureViewDescriptor::default());- let bind_group = constants.image_background_pipeline.bind_group(- &constants.device,- &uniform_buffer,- &texture_view,- );-- pipeline.encoder.do_render_pass(- pipeline.state.get_current_texture_view(),- &constants.image_background_pipeline.render_pipeline,- bind_group,- wgpu::LoadOp::Clear(wgpu::Color::BLACK),- );- }- _ => {- let bind_group = constants.gradient_or_color_pipeline.bind_group(- &constants.device,- &GradientOrColorUniforms::from(background).to_buffer(&constants.device),- );-- pipeline.encoder.do_render_pass(- pipeline.state.get_current_texture_view(),- &constants.gradient_or_color_pipeline.render_pipeline,- bind_group,- wgpu::LoadOp::Clear(wgpu::Color::BLACK),- );}- }-- if uniforms.project.background.blur > 0.0 {- pipeline.state.switch_output();-- let blur_strength = uniforms.project.background.blur as f32 / 100.0;- let blur_uniform = BackgroundBlurUniforms {- output_size: [uniforms.output_size.0 as f32, uniforms.output_size.1 as f32],- blur_strength,- _padding: 0.0,- };- let blur_buffer =- constants- .device- .create_buffer_init(&wgpu::util::BufferInitDescriptor {- label: Some("BackgroundBlur Uniform Buffer"),- contents: bytemuck::cast_slice(&[blur_uniform]),- usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,+ Background::Color(color) => match &self.inner {+ Some(Inner::ColorOrGradient {+ value: ColorOrGradient::Color(current_color),+ ..+ }) if &color == current_color => {}+ _ => {+ let buffer = GradientOrColorUniforms::from(background).to_buffer(device);+ self.inner = Some(Inner::ColorOrGradient {+ value: ColorOrGradient::Color(color),+ bind_group: self.color_pipeline.bind_group(device, &buffer),+ buffer,});- let sampler = constants.device.create_sampler(&wgpu::SamplerDescriptor {- address_mode_u: wgpu::AddressMode::ClampToEdge,- address_mode_v: wgpu::AddressMode::ClampToEdge,- address_mode_w: wgpu::AddressMode::ClampToEdge,- mag_filter: wgpu::FilterMode::Linear,- min_filter: wgpu::FilterMode::Linear,- mipmap_filter: wgpu::FilterMode::Nearest,- ..Default::default()- });-- let blur_bind_group = constants.background_blur_pipeline.bind_group(- &constants.device,- &blur_buffer,- pipeline.state.get_other_texture_view(),- &sampler,- );-- pipeline.encoder.do_render_pass(- pipeline.state.get_current_texture_view(),- &constants.background_blur_pipeline.render_pipeline,- blur_bind_group,- wgpu::LoadOp::Clear(wgpu::Color::BLACK),- );+ }+ },+ Background::Gradient(gradient) => match &self.inner {+ Some(Inner::ColorOrGradient {+ value: ColorOrGradient::Gradient(current_gradient),+ ..+ }) if &gradient == current_gradient => {}+ _ => {+ let buffer = GradientOrColorUniforms::from(background).to_buffer(device);+ self.inner = Some(Inner::ColorOrGradient {+ value: ColorOrGradient::Gradient(gradient),+ bind_group: self.color_pipeline.bind_group(device, &buffer),+ buffer,+ });+ }+ },}Ok(())}++ pub fn render(&self, pass: &mut wgpu::RenderPass<'_>) {+ if let Some(Inner::Image { bind_group, .. }) = &self.inner {+ pass.set_pipeline(&self.image_pipeline.render_pipeline);+ pass.set_bind_group(0, bind_group, &[]);+ } else if let Some(Inner::ColorOrGradient { bind_group, .. }) = &self.inner {+ pass.set_pipeline(&self.color_pipeline.render_pipeline);+ pass.set_bind_group(0, bind_group, &[]);+ } else {+ return;+ }++ pass.draw(0..4, 0..1);+ }}pub struct ImageBackgroundPipeline {@@ -419,7 +444,7 @@ impl From<Background> for GradientOrColorUniforms {angle: 0.0,_padding: [0.0; 3],},- Background::Gradient { start, end, angle } => Self {+ Background::Gradient(Gradient { start, end, angle }) => Self {start,end,angle,@@ -449,7 +474,7 @@ impl GradientOrColorPipeline {fn bind_group_layout(device: &wgpu::Device) -> wgpu::BindGroupLayout {device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {- label: Some("composite-video-frame.wgsl Bind Group Layout"),+ label: Some("gradient-or-color.wgsl Bind Group Layout"),entries: &[wgpu::BindGroupLayoutEntry {binding: 0,visibility: wgpu::ShaderStages::VERTEX_FRAGMENT,@@ -476,136 +501,3 @@ impl GradientOrColorPipeline {bind_group}}--#[repr(C)]-#[derive(Debug, Clone, Copy, Pod, Zeroable)]-pub struct BackgroundBlurUniforms {- output_size: [f32; 2],- blur_strength: f32,- _padding: f32,-}--pub struct BackgroundBlurPipeline {- pub bind_group_layout: wgpu::BindGroupLayout,- pub render_pipeline: wgpu::RenderPipeline,-}--impl BackgroundBlurPipeline {- pub fn new(device: &wgpu::Device) -> Self {- let bind_group_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {- label: Some("background-blur Bind Group Layout"),- entries: &[- wgpu::BindGroupLayoutEntry {- binding: 0,- visibility: wgpu::ShaderStages::VERTEX_FRAGMENT,- ty: wgpu::BindingType::Buffer {- ty: wgpu::BufferBindingType::Uniform,- has_dynamic_offset: false,- min_binding_size: None,- },- count: None,- },- wgpu::BindGroupLayoutEntry {- binding: 1,- visibility: wgpu::ShaderStages::FRAGMENT,- ty: wgpu::BindingType::Texture {- sample_type: wgpu::TextureSampleType::Float { filterable: true },- view_dimension: wgpu::TextureViewDimension::D2,- multisampled: false,- },- count: None,- },- wgpu::BindGroupLayoutEntry {- binding: 2,- visibility: wgpu::ShaderStages::FRAGMENT,- ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),- count: None,- },- ],- });- let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {- label: Some("Background Blur Shader"),- source: wgpu::ShaderSource::Wgsl(- include_str!("../shaders/background-blur.wgsl").into(),- ),- });- let empty_constants: HashMap<String, f64> = HashMap::new();- let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {- label: Some("Background Blur Pipeline Layout"),- bind_group_layouts: &[&bind_group_layout],- push_constant_ranges: &[],- });- let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {- label: Some("Background Blur Pipeline"),- layout: Some(&pipeline_layout),- vertex: wgpu::VertexState {- module: &shader,- entry_point: "vs_main",- buffers: &[],- compilation_options: wgpu::PipelineCompilationOptions {- constants: &empty_constants,- zero_initialize_workgroup_memory: false,- vertex_pulling_transform: false,- },- },- fragment: Some(wgpu::FragmentState {- module: &shader,- entry_point: "fs_main",- targets: &[Some(wgpu::ColorTargetState {- format: wgpu::TextureFormat::Rgba8UnormSrgb,- blend: Some(wgpu::BlendState::REPLACE),- write_mask: wgpu::ColorWrites::ALL,- })],- compilation_options: wgpu::PipelineCompilationOptions {- constants: &empty_constants,- zero_initialize_workgroup_memory: false,- vertex_pulling_transform: false,- },- }),- primitive: wgpu::PrimitiveState {- topology: wgpu::PrimitiveTopology::TriangleList,- strip_index_format: None,- front_face: wgpu::FrontFace::Ccw,- cull_mode: Some(wgpu::Face::Back),- polygon_mode: wgpu::PolygonMode::Fill,- unclipped_depth: false,- conservative: false,- },- depth_stencil: None,- multisample: wgpu::MultisampleState::default(),- multiview: None,- cache: None,- });- Self {- bind_group_layout,- render_pipeline,- }- }-- pub fn bind_group(- &self,- device: &wgpu::Device,- uniform_buffer: &wgpu::Buffer,- texture_view: &wgpu::TextureView,- sampler: &wgpu::Sampler,- ) -> wgpu::BindGroup {- device.create_bind_group(&wgpu::BindGroupDescriptor {- label: Some("BackgroundBlur Bind Group"),- layout: &self.bind_group_layout,- entries: &[- wgpu::BindGroupEntry {- binding: 0,- resource: uniform_buffer.as_entire_binding(),- },- wgpu::BindGroupEntry {- binding: 1,- resource: wgpu::BindingResource::TextureView(texture_view),- },- wgpu::BindGroupEntry {- binding: 2,- resource: wgpu::BindingResource::Sampler(sampler),- },- ],- })- }-}diff --git a/crates/rendering/src/layers/blur.rs b/crates/rendering/src/layers/blur.rsnew file mode 100644index 000000000..f4b7f356b--- /dev/null+++ b/crates/rendering/src/layers/blur.rs@@ -0,0 +1,209 @@+use std::collections::HashMap;++use bytemuck::{Pod, Zeroable};+use wgpu::util::DeviceExt;++use crate::ProjectUniforms;++pub struct BlurLayer {+ pub blur_amount: f64,+ sampler: wgpu::Sampler,+ uniforms_buffer: wgpu::Buffer,+ pipeline: BlurPipeline,+}++impl BlurLayer {+ pub fn new(device: &wgpu::Device) -> Self {+ Self {+ blur_amount: 0.0,+ sampler: device.create_sampler(&wgpu::SamplerDescriptor {+ address_mode_u: wgpu::AddressMode::ClampToEdge,+ address_mode_v: wgpu::AddressMode::ClampToEdge,+ address_mode_w: wgpu::AddressMode::ClampToEdge,+ mag_filter: wgpu::FilterMode::Linear,+ min_filter: wgpu::FilterMode::Linear,+ mipmap_filter: wgpu::FilterMode::Nearest,+ ..Default::default()+ }),+ uniforms_buffer: device.create_buffer_init(&wgpu::util::BufferInitDescriptor {+ label: Some("BackgroundBlur Uniform Buffer"),+ contents: bytemuck::cast_slice(&[BlurUniforms::default()]),+ usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,+ }),+ pipeline: BlurPipeline::new(device),+ }+ }++ pub fn prepare(&mut self, queue: &wgpu::Queue, uniforms: &ProjectUniforms) {+ self.blur_amount = uniforms.project.background.blur;+ if self.blur_amount <= 0.0 {+ return;+ }++ let blur_strength = uniforms.project.background.blur as f32 / 100.0;+ let blur_uniform = BlurUniforms {+ output_size: [uniforms.output_size.0 as f32, uniforms.output_size.1 as f32],+ blur_strength,+ _padding: 0.0,+ };++ queue.write_buffer(+ &self.uniforms_buffer,+ 0,+ bytemuck::cast_slice(&[blur_uniform]),+ );+ }++ pub fn render(+ &self,+ pass: &mut wgpu::RenderPass<'_>,+ device: &wgpu::Device,+ source_texture: &wgpu::TextureView,+ ) {+ pass.set_pipeline(&self.pipeline.render_pipeline);+ pass.set_bind_group(+ 0,+ &self.pipeline.bind_group(+ &device,+ &self.uniforms_buffer,+ &source_texture,+ &self.sampler,+ ),+ &[],+ );+ pass.draw(0..4, 0..1);+ }+}++#[repr(C)]+#[derive(Debug, Clone, Copy, Pod, Zeroable, Default)]+pub struct BlurUniforms {+ output_size: [f32; 2],+ blur_strength: f32,+ _padding: f32,+}++pub struct BlurPipeline {+ pub bind_group_layout: wgpu::BindGroupLayout,+ pub render_pipeline: wgpu::RenderPipeline,+}++impl BlurPipeline {+ pub fn new(device: &wgpu::Device) -> Self {+ let bind_group_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {+ label: Some("background-blur Bind Group Layout"),+ entries: &[+ wgpu::BindGroupLayoutEntry {+ binding: 0,+ visibility: wgpu::ShaderStages::VERTEX_FRAGMENT,+ ty: wgpu::BindingType::Buffer {+ ty: wgpu::BufferBindingType::Uniform,+ has_dynamic_offset: false,+ min_binding_size: None,+ },+ count: None,+ },+ wgpu::BindGroupLayoutEntry {+ binding: 1,+ visibility: wgpu::ShaderStages::FRAGMENT,+ ty: wgpu::BindingType::Texture {+ sample_type: wgpu::TextureSampleType::Float { filterable: true },+ view_dimension: wgpu::TextureViewDimension::D2,+ multisampled: false,+ },+ count: None,+ },+ wgpu::BindGroupLayoutEntry {+ binding: 2,+ visibility: wgpu::ShaderStages::FRAGMENT,+ ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),+ count: None,+ },+ ],+ });+ let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {+ label: Some("Background Blur Shader"),+ source: wgpu::ShaderSource::Wgsl(+ include_str!("../shaders/background-blur.wgsl").into(),+ ),+ });+ let empty_constants: HashMap<String, f64> = HashMap::new();+ let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {+ label: Some("Background Blur Pipeline Layout"),+ bind_group_layouts: &[&bind_group_layout],+ push_constant_ranges: &[],+ });+ let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {+ label: Some("Background Blur Pipeline"),+ layout: Some(&pipeline_layout),+ vertex: wgpu::VertexState {+ module: &shader,+ entry_point: "vs_main",+ buffers: &[],+ compilation_options: wgpu::PipelineCompilationOptions {+ constants: &empty_constants,+ zero_initialize_workgroup_memory: false,+ vertex_pulling_transform: false,+ },+ },+ fragment: Some(wgpu::FragmentState {+ module: &shader,+ entry_point: "fs_main",+ targets: &[Some(wgpu::ColorTargetState {+ format: wgpu::TextureFormat::Rgba8UnormSrgb,+ blend: Some(wgpu::BlendState::REPLACE),+ write_mask: wgpu::ColorWrites::ALL,+ })],+ compilation_options: wgpu::PipelineCompilationOptions {+ constants: &empty_constants,+ zero_initialize_workgroup_memory: false,+ vertex_pulling_transform: false,+ },+ }),+ primitive: wgpu::PrimitiveState {+ topology: wgpu::PrimitiveTopology::TriangleList,+ strip_index_format: None,+ front_face: wgpu::FrontFace::Ccw,+ cull_mode: Some(wgpu::Face::Back),+ polygon_mode: wgpu::PolygonMode::Fill,+ unclipped_depth: false,+ conservative: false,+ },+ depth_stencil: None,+ multisample: wgpu::MultisampleState::default(),+ multiview: None,+ cache: None,+ });+ Self {+ bind_group_layout,+ render_pipeline,+ }+ }++ pub fn bind_group(+ &self,+ device: &wgpu::Device,+ uniform_buffer: &wgpu::Buffer,+ texture_view: &wgpu::TextureView,+ sampler: &wgpu::Sampler,+ ) -> wgpu::BindGroup {+ device.create_bind_group(&wgpu::BindGroupDescriptor {+ label: Some("BackgroundBlur Bind Group"),+ layout: &self.bind_group_layout,+ entries: &[+ wgpu::BindGroupEntry {+ binding: 0,+ resource: uniform_buffer.as_entire_binding(),+ },+ wgpu::BindGroupEntry {+ binding: 1,+ resource: wgpu::BindingResource::TextureView(texture_view),+ },+ wgpu::BindGroupEntry {+ binding: 2,+ resource: wgpu::BindingResource::Sampler(sampler),+ },+ ],+ })+ }+}diff --git a/crates/rendering/src/layers/camera.rs b/crates/rendering/src/layers/camera.rsindex cd077dbef..dd9a7cd68 100644--- a/crates/rendering/src/layers/camera.rs+++ b/crates/rendering/src/layers/camera.rs@@ -1,20 +1,43 @@use cap_project::XY;+use wgpu::util::DeviceExt;-use crate::{frame_pipeline::FramePipeline, CompositeVideoFrameUniforms, DecodedFrame};+use crate::{+ composite_frame::CompositeVideoFramePipeline, CompositeVideoFrameUniforms, DecodedFrame,+};-pub struct CameraLayer;+pub struct CameraLayer {+ uniforms_buffer: wgpu::Buffer,+ bind_group: Option<wgpu::BindGroup>,+ pipeline: CompositeVideoFramePipeline,+}impl CameraLayer {- pub fn render(- pipeline: &mut FramePipeline,+ pub fn new(device: &wgpu::Device) -> Self {+ Self {+ uniforms_buffer: device.create_buffer_init(+ &(wgpu::util::BufferInitDescriptor {+ label: Some("CameraLayer Uniforms Buffer"),+ contents: bytemuck::cast_slice(&[CompositeVideoFrameUniforms::default()]),+ usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,+ }),+ ),+ bind_group: None,+ pipeline: CompositeVideoFramePipeline::new(device),+ }+ }++ pub fn prepare(+ &mut self,+ device: &wgpu::Device,+ queue: &wgpu::Queue,+ uniforms: CompositeVideoFrameUniforms,camera_size: XY<u32>,camera_frame: &DecodedFrame,- uniforms: &CompositeVideoFrameUniforms,(texture, texture_view): (&wgpu::Texture, &wgpu::TextureView),) {- let constants = pipeline.state.constants;+ queue.write_buffer(&self.uniforms_buffer, 0, bytemuck::cast_slice(&[uniforms]));- constants.queue.write_texture(+ queue.write_texture(wgpu::ImageCopyTexture {texture: &texture,mip_level: 0,@@ -34,18 +57,18 @@ impl CameraLayer {},);- pipeline.state.switch_output();+ self.bind_group = Some(self.pipeline.bind_group(+ &device,+ &self.uniforms_buffer,+ &texture_view,+ ))+ }- pipeline.encoder.do_render_pass(- pipeline.state.get_current_texture_view(),- &constants.composite_video_frame_pipeline.render_pipeline,- constants.composite_video_frame_pipeline.bind_group(- &constants.device,- &uniforms.to_buffer(&constants.device),- &texture_view,- pipeline.state.get_other_texture_view(),- ),- wgpu::LoadOp::Load,- );+ pub fn render(&self, pass: &mut wgpu::RenderPass<'_>) {+ if let Some(bind_group) = &self.bind_group {+ pass.set_pipeline(&self.pipeline.render_pipeline);+ pass.set_bind_group(0, bind_group, &[]);+ pass.draw(0..4, 0..1);+ }}}diff --git a/crates/rendering/src/layers/cursor.rs b/crates/rendering/src/layers/cursor.rsindex 88d3e2f02..e228b54df 100644--- a/crates/rendering/src/layers/cursor.rs+++ b/crates/rendering/src/layers/cursor.rs@@ -2,13 +2,11 @@ use std::collections::HashMap;use bytemuck::{Pod, Zeroable};use cap_project::*;-use wgpu::{include_wgsl, util::DeviceExt, FilterMode};+use wgpu::{include_wgsl, util::DeviceExt, BindGroup, FilterMode};use crate::{- frame_pipeline::{FramePipeline, FramePipelineState},- spring_mass_damper::{SpringMassDamperSimulation, SpringMassDamperSimulationConfig},- zoom::InterpolatedZoom,- Coord, DecodedSegmentFrames, ProjectUniforms, RawDisplayUVSpace, STANDARD_CURSOR_HEIGHT,+ zoom::InterpolatedZoom, DecodedSegmentFrames, ProjectUniforms, RenderVideoConstants,+ STANDARD_CURSOR_HEIGHT,};const CURSOR_CLICK_DURATION: f64 = 0.25;@@ -16,14 +14,19 @@ const CURSOR_CLICK_DURATION_MS: f64 = CURSOR_CLICK_DURATION * 1000.0;const CLICK_SHRINK_SIZE: f32 = 0.7;pub struct CursorLayer {+ statics: Statics,+ bind_group: Option<BindGroup>,+}++struct Statics {uniform_buffer: wgpu::Buffer,texture_sampler: wgpu::Sampler,bind_group_layout: wgpu::BindGroupLayout,render_pipeline: wgpu::RenderPipeline,}-impl CursorLayer {- pub fn new(device: &wgpu::Device) -> Self {+impl Statics {+ fn new(device: &wgpu::Device) -> Self {let bind_group_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {label: Some("Cursor Pipeline Layout"),entries: &[@@ -137,31 +140,61 @@ impl CursorLayer {}}- pub fn render(+ fn create_bind_group(&self,- pipeline: &mut FramePipeline,+ device: &wgpu::Device,+ cursor_texture: &wgpu::Texture,+ ) -> wgpu::BindGroup {+ device.create_bind_group(&wgpu::BindGroupDescriptor {+ layout: &self.bind_group_layout,+ entries: &[+ wgpu::BindGroupEntry {+ binding: 0,+ resource: self.uniform_buffer.as_entire_binding(),+ },+ wgpu::BindGroupEntry {+ binding: 1,+ resource: wgpu::BindingResource::TextureView(+ &cursor_texture.create_view(&wgpu::TextureViewDescriptor::default()),+ ),+ },+ wgpu::BindGroupEntry {+ binding: 2,+ resource: wgpu::BindingResource::Sampler(&self.texture_sampler),+ },+ ],+ label: Some("Cursor Bind Group"),+ })+ }+}++impl CursorLayer {+ pub fn new(device: &wgpu::Device) -> Self {+ let statics = Statics::new(device);++ Self {+ statics,+ bind_group: None,+ }+ }++ pub fn prepare(+ &mut self,segment_frames: &DecodedSegmentFrames,resolution_base: XY<u32>,cursor: &CursorEvents,zoom: &InterpolatedZoom,+ uniforms: &ProjectUniforms,+ constants: &RenderVideoConstants,) {- let FramePipelineState {- uniforms,- constants,- ..- } = &pipeline.state;+ if uniforms.project.cursor.hide {+ self.bind_group = None;+ return;+ }+let time_s = segment_frames.recording_time;- let cursor_settings = &uniforms.project.cursor;- let Some(interpolated_cursor) = interpolate_cursor(- cursor,- time_s,- (!cursor_settings.raw).then(|| SpringMassDamperSimulationConfig {- tension: cursor_settings.tension,- mass: cursor_settings.mass,- friction: cursor_settings.friction,- }),- ) else {+ let Some(interpolated_cursor) = &uniforms.interpolated_cursor else {return;};@@ -173,9 +206,11 @@ impl CursorLayer {let speed = (velocity[0] * velocity[0] + velocity[1] * velocity[1]).sqrt();let motion_blur_amount = (speed * 0.3).min(1.0) * 0.0; // uniforms.project.cursor.motion_blur;- let last_move_event = find_cursor_move(&cursor, time_s);- let Some(cursor_texture) = constants.cursor_textures.get(&last_move_event.cursor_id) else {+ let Some(cursor_texture) = constants+ .cursor_textures+ .get(&interpolated_cursor.cursor_id)+ else {return;};@@ -229,42 +264,25 @@ impl CursorLayer {_alignment: [0.0; 3],};- constants- .queue- .write_buffer(&self.uniform_buffer, 0, bytemuck::cast_slice(&[uniforms]));-- let cursor_bind_group = constants- .device- .create_bind_group(&wgpu::BindGroupDescriptor {- layout: &self.bind_group_layout,- entries: &[- wgpu::BindGroupEntry {- binding: 0,- resource: self.uniform_buffer.as_entire_binding(),- },- wgpu::BindGroupEntry {- binding: 1,- resource: wgpu::BindingResource::TextureView(- &cursor_texture- .inner- .create_view(&wgpu::TextureViewDescriptor::default()),- ),- },- wgpu::BindGroupEntry {- binding: 2,- resource: wgpu::BindingResource::Sampler(&self.texture_sampler),- },- ],- label: Some("Cursor Bind Group"),- });-- pipeline.encoder.do_render_pass(- pipeline.state.get_current_texture_view(),- &self.render_pipeline,- cursor_bind_group,- wgpu::LoadOp::Load,+ constants.queue.write_buffer(+ &self.statics.uniform_buffer,+ 0,+ bytemuck::cast_slice(&[uniforms]),+ );++ self.bind_group = Some(+ self.statics+ .create_bind_group(&constants.device, &cursor_texture.inner),);}++ pub fn render(&self, pass: &mut wgpu::RenderPass<'_>) {+ if let Some(bind_group) = &self.bind_group {+ pass.set_pipeline(&self.statics.render_pipeline);+ pass.set_bind_group(0, bind_group, &[]);+ pass.draw(0..4, 0..1);+ }+ }}#[repr(C, align(16))]@@ -299,159 +317,6 @@ pub fn find_cursor_move(cursor: &CursorEvents, time: f32) -> &CursorMoveEvent {event}-struct InterpolatedCursorPosition {- position: Coord<RawDisplayUVSpace>,- velocity: XY<f32>,-}--fn interpolate_cursor(- cursor: &CursorEvents,- time_secs: f32,- smoothing: Option<SpringMassDamperSimulationConfig>,-) -> Option<InterpolatedCursorPosition> {- let time_ms = (time_secs * 1000.0) as f64;-- if cursor.moves.is_empty() {- return None;- }-- if cursor.moves[0].time_ms > time_ms.into() {- let event = &cursor.moves[0];-- return Some(InterpolatedCursorPosition {- position: Coord::new(XY {- x: event.x,- y: event.y,- }),- velocity: XY::new(0.0, 0.0),- });- }-- if let Some(event) = cursor.moves.last() {- if event.time_ms < time_ms.into() {- return Some(InterpolatedCursorPosition {- position: Coord::new(XY {- x: event.x,- y: event.y,- }),- velocity: XY::new(0.0, 0.0),- });- }- }-- if let Some(smoothing_config) = smoothing {- let events = get_smoothed_cursor_events(&cursor.moves, smoothing_config);- interpolate_smoothed_position(&events, time_secs as f64, smoothing_config)- } else {- let pos = cursor.moves.windows(2).enumerate().find_map(|(i, chunk)| {- if time_ms >= chunk[0].time_ms && time_ms < chunk[1].time_ms {- let c = &chunk[0];- Some(XY::new(c.x as f32, c.y as f32))- } else {- None- }- })?;-- Some(InterpolatedCursorPosition {- position: Coord::new(XY {- x: pos.x as f64,- y: pos.y as f64,- }),- velocity: XY::new(0.0, 0.0),- })- }-}--fn interpolate_smoothed_position(- smoothed_events: &[SmoothedCursorEvent],- query_time: f64,- smoothing_config: SpringMassDamperSimulationConfig,-) -> Option<InterpolatedCursorPosition> {- if smoothed_events.is_empty() {- return None;- }-- let mut sim = SpringMassDamperSimulation::new(smoothing_config);-- let query_time_ms = (query_time * 1000.0) as f32;-- match smoothed_events- .windows(2)- .find(|chunk| chunk[0].time <= query_time_ms && query_time_ms < chunk[1].time)- {- Some(c) => {- sim.set_position(c[0].position);- sim.set_velocity(c[0].velocity);- sim.set_target_position(c[0].target_position);- sim.run(query_time_ms - c[0].time);- }- None => {- let e = smoothed_events.last().unwrap();- sim.set_position(e.position);- sim.set_velocity(e.velocity);- sim.set_target_position(e.target_position);- sim.run(query_time_ms - e.time);- }- };-- Some(InterpolatedCursorPosition {- position: Coord::new(sim.position.map(|v| v as f64)),- velocity: sim.velocity,- })-}--#[derive(Debug)]-struct SmoothedCursorEvent {- time: f32,- target_position: XY<f32>,- position: XY<f32>,- velocity: XY<f32>,-}--fn get_smoothed_cursor_events(- moves: &[CursorMoveEvent],- smoothing_config: SpringMassDamperSimulationConfig,-) -> Vec<SmoothedCursorEvent> {- let mut last_time = 0.0;-- let mut events = vec![];-- let mut sim = SpringMassDamperSimulation::new(smoothing_config);-- sim.set_position(XY::new(moves[0].x, moves[0].y).map(|v| v as f32));- sim.set_velocity(XY::new(0.0, 0.0));-- if moves[0].time_ms > 0.0 {- events.push(SmoothedCursorEvent {- time: 0.0,- target_position: sim.position,- position: sim.position,- velocity: sim.velocity,- })- }-- for (i, m) in moves.iter().enumerate() {- let target_position = moves- .get(i + 1)- .map(|e| XY::new(e.x, e.y).map(|v| v as f32))- .unwrap_or(sim.target_position);- sim.set_target_position(target_position);-- sim.run(m.time_ms as f32 - last_time);-- last_time = m.time_ms as f32;-- events.push(SmoothedCursorEvent {- time: m.time_ms as f32,- target_position,- position: sim.position,- velocity: sim.velocity,- });- }-- events-}-fn get_click_t(clicks: &[CursorClickEvent], time_ms: f64) -> f32 {fn smoothstep(low: f32, high: f32, v: f32) -> f32 {let t = f32::clamp((v - low) / (high - low), 0.0, 1.0);diff --git a/crates/rendering/src/layers/display.rs b/crates/rendering/src/layers/display.rsindex 8b891ac1c..abb88350f 100644--- a/crates/rendering/src/layers/display.rs+++ b/crates/rendering/src/layers/display.rs@@ -1,18 +1,68 @@-use crate::{frame_pipeline::FramePipeline, DecodedSegmentFrames};+use cap_project::XY;++use crate::{+ composite_frame::{CompositeVideoFramePipeline, CompositeVideoFrameUniforms},+ DecodedSegmentFrames, ProjectUniforms,+};pub struct DisplayLayer {- // composite_resources: CompositeFrameResources,+ frame_texture: wgpu::Texture,+ frame_texture_view: wgpu::TextureView,+ uniforms_buffer: wgpu::Buffer,+ pipeline: CompositeVideoFramePipeline,+ bind_group: Option<wgpu::BindGroup>,}impl DisplayLayer {- pub fn render(pipeline: &mut FramePipeline, segment_frames: &DecodedSegmentFrames) {- let constants = pipeline.state.constants;- let uniforms = pipeline.state.uniforms;- let frame_size = pipeline.state.constants.options.screen_size;+ pub fn new(device: &wgpu::Device) -> Self {+ let frame_texture = Self::create_frame_texture(device, 1920, 1080);+ Self {+ frame_texture_view: frame_texture.create_view(&Default::default()),+ frame_texture,+ uniforms_buffer: CompositeVideoFrameUniforms::default().to_buffer(device),+ pipeline: CompositeVideoFramePipeline::new(device),+ bind_group: None,+ }+ }++ fn create_frame_texture(device: &wgpu::Device, width: u32, height: u32) -> wgpu::Texture {+ device.create_texture(+ &(wgpu::TextureDescriptor {+ size: wgpu::Extent3d {+ width,+ height,+ depth_or_array_layers: 1,+ },+ mip_level_count: 1,+ sample_count: 1,+ dimension: wgpu::TextureDimension::D2,+ format: wgpu::TextureFormat::Rgba8UnormSrgb,+ usage: wgpu::TextureUsages::TEXTURE_BINDING+ | wgpu::TextureUsages::RENDER_ATTACHMENT+ | wgpu::TextureUsages::COPY_DST,+ label: Some("Screen Frame texture"),+ view_formats: &[],+ }),+ )+ }- constants.queue.write_texture(+ pub fn prepare(+ &mut self,+ device: &wgpu::Device,+ queue: &wgpu::Queue,+ segment_frames: &DecodedSegmentFrames,+ frame_size: XY<u32>,+ uniforms: &ProjectUniforms,+ ) {+ if self.frame_texture.width() != frame_size.x || self.frame_texture.height() != frame_size.y+ {+ self.frame_texture = Self::create_frame_texture(device, frame_size.x, frame_size.y);+ self.frame_texture_view = self.frame_texture.create_view(&Default::default());+ }++ queue.write_texture(wgpu::ImageCopyTexture {- texture: &constants.screen_frame.0,+ texture: &self.frame_texture,mip_level: 0,origin: wgpu::Origin3d::ZERO,aspect: wgpu::TextureAspect::All,@@ -20,7 +70,7 @@ impl DisplayLayer {&segment_frames.screen_frame,wgpu::ImageDataLayout {offset: 0,- bytes_per_row: Some(constants.options.screen_size.x * 4),+ bytes_per_row: Some(frame_size.x * 4),rows_per_image: None,},wgpu::Extent3d {@@ -30,18 +80,24 @@ impl DisplayLayer {},);- pipeline.state.switch_output();-- pipeline.encoder.do_render_pass(- pipeline.state.get_current_texture_view(),- &constants.composite_video_frame_pipeline.render_pipeline,- constants.composite_video_frame_pipeline.bind_group(- &constants.device,- &uniforms.display.to_buffer(&constants.device),- &constants.screen_frame.1,- pipeline.state.get_other_texture_view(),- ),- wgpu::LoadOp::Load,+ queue.write_buffer(+ &self.uniforms_buffer,+ 0,+ bytemuck::cast_slice(&[uniforms.display]),);++ self.bind_group = Some(self.pipeline.bind_group(+ &device,+ &uniforms.display.to_buffer(&device),+ &self.frame_texture_view,+ ));+ }++ pub fn render(&self, pass: &mut wgpu::RenderPass<'_>) {+ if let Some(bind_group) = &self.bind_group {+ pass.set_pipeline(&self.pipeline.render_pipeline);+ pass.set_bind_group(0, bind_group, &[]);+ pass.draw(0..4, 0..1);+ }}}diff --git a/crates/rendering/src/layers/mod.rs b/crates/rendering/src/layers/mod.rsindex 8323af4f2..8605a463b 100644--- a/crates/rendering/src/layers/mod.rs+++ b/crates/rendering/src/layers/mod.rs@@ -1,9 +1,11 @@mod background;+mod blur;mod camera;mod cursor;mod display;pub use background::*;+pub use blur::*;pub use camera::*;pub use cursor::*;pub use display::*;diff --git a/crates/rendering/src/lib.rs b/crates/rendering/src/lib.rsindex 37ba564c3..8fe98a7b3 100644--- a/crates/rendering/src/lib.rs+++ b/crates/rendering/src/lib.rs@@ -1,27 +1,31 @@use anyhow::Result;use cap_project::{- AspectRatio, BackgroundSource, CameraXPosition, CameraYPosition, Crop, CursorEvents,- ProjectConfiguration, RecordingMeta, StudioRecordingMeta, XY,+ AspectRatio, CameraXPosition, CameraYPosition, Crop, CursorEvents, ProjectConfiguration,+ RecordingMeta, StudioRecordingMeta, XY,};use composite_frame::{CompositeVideoFramePipeline, CompositeVideoFrameUniforms};use core::f64;+use cursor_interpolation::{interpolate_cursor, InterpolatedCursorPosition};use decoder::{spawn_decoder, AsyncVideoDecoderHandle};-use frame_pipeline::{FramePipeline, FramePipelineEncoder, FramePipelineState};+use frame_pipeline::finish_encoder;use futures::future::OptionFuture;use futures::FutureExt;use layers::{- Background, BackgroundBlurPipeline, BackgroundLayer, CameraLayer, CursorLayer, DisplayLayer,+ Background, BackgroundLayer, BlurLayer, CameraLayer, CursorLayer, DisplayLayer,GradientOrColorPipeline, ImageBackgroundPipeline,};use specta::Type;+use spring_mass_damper::SpringMassDamperSimulationConfig;use std::{collections::HashMap, sync::Arc};use tokio::sync::mpsc;+use tracing::subscriber::DefaultGuard;use image::GenericImageView;use std::{path::PathBuf, time::Instant};mod composite_frame;mod coord;+mod cursor_interpolation;pub mod decoder;mod frame_pipeline;mod layers;@@ -31,6 +35,7 @@ mod zoom;pub use coord::*;pub use decoder::DecodedFrame;+pub use frame_pipeline::RenderedFrame;pub use project_recordings::{ProjectRecordings, SegmentRecordings, Video};use zoom::*;@@ -204,6 +209,8 @@ pub async fn render_video_to_channel(let mut frame_renderer = FrameRenderer::new(&constants);+ let mut layers = RendererLayers::new(&constants.device);+loop {if frame_number >= total_frames {break;@@ -235,10 +242,11 @@ pub async fn render_video_to_channel(fps,resolution_base,&segment.cursor,+ &segment_frames,);let frame = frame_renderer- .render(segment_frames, uniforms, &segment.cursor)+ .render(segment_frames, uniforms, &segment.cursor, &mut layers).await?;if frame.width == 0 || frame.height == 0 {@@ -314,15 +322,9 @@ pub struct RenderVideoConstants {pub queue: wgpu::Queue,pub device: wgpu::Device,pub options: RenderOptions,- composite_video_frame_pipeline: CompositeVideoFramePipeline,pub cursor_textures: HashMap<String, CursorTexture>,- gradient_or_color_pipeline: GradientOrColorPipeline,- image_background_pipeline: ImageBackgroundPipeline,- pub background_blur_pipeline: BackgroundBlurPipeline,background_textures: std::sync::Arc<tokio::sync::RwLock<HashMap<String, wgpu::Texture>>>,- screen_frame: (wgpu::Texture, wgpu::TextureView),camera_frame: Option<(wgpu::Texture, wgpu::TextureView)>,- cursor_layer: CursorLayer,}impl RenderVideoConstants {@@ -354,8 +356,6 @@ impl RenderVideoConstants {let image_background_pipeline = ImageBackgroundPipeline::new(&device);let background_textures = Arc::new(tokio::sync::RwLock::new(HashMap::new()));- let background_blur_pipeline = BackgroundBlurPipeline::new(&device);-let screen_frame = {let texture = device.create_texture(&(wgpu::TextureDescriptor {@@ -409,18 +409,12 @@ impl RenderVideoConstants {Ok(Self {_instance: instance,_adapter: adapter,- cursor_layer: CursorLayer::new(&device),device,queue,options,- composite_video_frame_pipeline,- gradient_or_color_pipeline,cursor_textures,- image_background_pipeline,background_textures,- screen_frame,camera_frame,- background_blur_pipeline,})}@@ -521,6 +515,7 @@ pub struct ProjectUniforms {pub cursor_size: f32,display: CompositeVideoFrameUniforms,camera: Option<CompositeVideoFrameUniforms>,+ interpolated_cursor: Option<InterpolatedCursorPosition>,pub project: ProjectConfiguration,pub zoom: InterpolatedZoom,pub resolution_base: XY<u32>,@@ -691,46 +686,50 @@ impl ProjectUniforms {fps: u32,resolution_base: XY<u32>,cursor_events: &CursorEvents,+ segment_frames: &DecodedSegmentFrames,) -> Self {let options = &constants.options;let output_size = Self::get_output_size(options, project, resolution_base);let frame_time = frame_number as f32 / fps as f32;- // let zoom_keyframes = ZoomKeyframes::new(project);- // let current_zoom = zoom_keyframes.interpolate(time as f64);- // let prev_zoom = zoom_keyframes.interpolate((time - 1.0 / 30.0) as f64);-let velocity = [0.0, 0.0];- // if current_zoom.amount != prev_zoom.amount {- // let scale_change = (current_zoom.amount - prev_zoom.amount) as f32;- // // Reduce the velocity scale from 0.05 to 0.02- // [- // (scale_change * output_size.0 as f32) * 0.02, // Reduced from 0.05- // (scale_change * output_size.1 as f32) * 0.02,- // ]- // } else {- // [0.0, 0.0]- // };let motion_blur_amount = 0.0;- // if current_zoom.amount != prev_zoom.amount {- // project.motion_blur.unwrap_or(0.2) // Reduced from 0.5 to 0.2- // } else {- // 0.0- // };let crop = Self::get_crop(options, project);- let segment_cursor = SegmentsCursor::new(- frame_time as f64,- project- .timeline- .as_ref()- .map(|t| t.zoom_segments.as_slice())- .unwrap_or(&[]),+ let interpolated_cursor = interpolate_cursor(+ cursor_events,+ segment_frames.recording_time,+ (!project.cursor.raw).then(|| SpringMassDamperSimulationConfig {+ tension: project.cursor.tension,+ mass: project.cursor.mass,+ friction: project.cursor.friction,+ }),);- let zoom = InterpolatedZoom::new(segment_cursor, Some(cursor_events));+ let zoom = InterpolatedZoom::new(+ SegmentsCursor::new(+ frame_time as f64,+ project+ .timeline+ .as_ref()+ .map(|t| t.zoom_segments.as_slice())+ .unwrap_or(&[]),+ ),+ interpolate_cursor(+ cursor_events,+ (segment_frames.recording_time - 0.2).max(0.0),+ (!project.cursor.raw).then(|| SpringMassDamperSimulationConfig {+ tension: project.cursor.tension,+ mass: project.cursor.mass,+ friction: project.cursor.friction,+ }),+ )+ .as_ref()+ .map(|i| i.position)+ .unwrap_or_else(|| Coord::new(XY::new(0.5, 0.5))),+ );let display = {let output_size = XY::new(output_size.0 as f64, output_size.1 as f64);@@ -892,18 +891,11 @@ impl ProjectUniforms {camera,project: project.clone(),zoom,+ interpolated_cursor,}}}-#[derive(Clone)]-pub struct RenderedFrame {- pub data: Vec<u8>,- pub width: u32,- pub height: u32,- pub padded_bytes_per_row: u32,-}-pub struct DecodedSegmentFrames {pub screen_frame: DecodedFrame,pub camera_frame: Option<DecodedFrame>,@@ -913,47 +905,15 @@ pub struct DecodedSegmentFrames {pub struct FrameRenderer<'a> {constants: &'a RenderVideoConstants,- output_texture_desc: Option<wgpu::TextureDescriptor<'static>>,- output_textures: Option<(wgpu::Texture, wgpu::Texture)>,+ session: Option<RenderSession>,}impl<'a> FrameRenderer<'a> {pub fn new(constants: &'a RenderVideoConstants) -> Self {Self {constants,- output_texture_desc: None,- output_textures: None,- }- }-- fn update_output_textures(&mut self, width: u32, height: u32) {- if let Some(desc) = &self.output_texture_desc {- if desc.size.width == width && desc.size.height == height {- return;- }+ session: None,}-- let output_texture_desc = self.output_texture_desc.insert(wgpu::TextureDescriptor {- size: wgpu::Extent3d {- width,- height,- depth_or_array_layers: 1,- },- mip_level_count: 1,- sample_count: 1,- dimension: wgpu::TextureDimension::D2,- format: wgpu::TextureFormat::Rgba8UnormSrgb,- usage: wgpu::TextureUsages::TEXTURE_BINDING- | wgpu::TextureUsages::RENDER_ATTACHMENT- | wgpu::TextureUsages::COPY_SRC,- label: Some("Intermediate Texture"),- view_formats: &[],- });-- self.output_textures = Some((- self.constants.device.create_texture(output_texture_desc),- self.constants.device.create_texture(output_texture_desc),- ));}pub async fn render(@@ -961,53 +921,88 @@ impl<'a> FrameRenderer<'a> {segment_frames: DecodedSegmentFrames,uniforms: ProjectUniforms,cursor: &CursorEvents,+ layers: &mut RendererLayers,) -> Result<RenderedFrame, RenderingError> {- self.update_output_textures(uniforms.output_size.0, uniforms.output_size.1);+ let session = self.session.get_or_insert_with(|| {+ RenderSession::new(+ &self.constants.device,+ uniforms.output_size.0,+ uniforms.output_size.1,+ )+ });++ session.update_texture_size(+ &self.constants.device,+ uniforms.output_size.0,+ uniforms.output_size.1,+ );produce_frame(&self.constants,segment_frames,uniforms,- self.output_textures.as_ref().unwrap(),cursor,+ layers,+ session,).await}}-// TODO: reuse as many resources as possible-// https://github.com/gfx-rs/wgpu/wiki/Encapsulating-Graphics-Work-async fn produce_frame(- constants: &RenderVideoConstants,- segment_frames: DecodedSegmentFrames,- uniforms: ProjectUniforms,- textures: &(wgpu::Texture, wgpu::Texture),- cursor: &CursorEvents,-) -> Result<RenderedFrame, RenderingError> {- let background = Background::from(uniforms.project.background.source.clone());+pub struct RendererLayers {+ background: BackgroundLayer,+ background_blur: BlurLayer,+ display: DisplayLayer,+ cursor: CursorLayer,+ camera: CameraLayer,+}- let mut state = FramePipelineState::new(constants, &uniforms, textures);- let mut encoder = FramePipelineEncoder::new(&state);+impl RendererLayers {+ pub fn new(device: &wgpu::Device) -> Self {+ Self {+ background: BackgroundLayer::new(device),+ background_blur: BlurLayer::new(device),+ display: DisplayLayer::new(device),+ cursor: CursorLayer::new(device),+ camera: CameraLayer::new(device),+ }+ }- {- let mut pipeline = FramePipeline {- state: &mut state,- encoder: &mut encoder,- };+ pub async fn prepare(+ &mut self,+ constants: &RenderVideoConstants,+ uniforms: &ProjectUniforms,+ segment_frames: &DecodedSegmentFrames,+ cursor: &CursorEvents,+ ) -> Result<(), RenderingError> {+ self.background+ .prepare(+ &constants,+ uniforms,+ Background::from(uniforms.project.background.source.clone()),+ )+ .await?;- BackgroundLayer::render(&mut pipeline, background).await?;+ if uniforms.project.background.blur > 0.0 {+ self.background_blur.prepare(&constants.queue, uniforms);+ }- DisplayLayer::render(&mut pipeline, &segment_frames);+ self.display.prepare(+ &constants.device,+ &constants.queue,+ segment_frames,+ constants.options.screen_size,+ &uniforms,+ );- if !uniforms.project.cursor.hide {- constants.cursor_layer.render(- &mut pipeline,- &segment_frames,- uniforms.resolution_base,- &cursor,- &uniforms.zoom,- );- }+ self.cursor.prepare(+ segment_frames,+ uniforms.resolution_base,+ cursor,+ &uniforms.zoom,+ uniforms,+ constants,+ );if let (Some(camera_size),@@ -1020,25 +1015,202 @@ async fn produce_frame(&uniforms.camera,&constants.camera_frame,) {- CameraLayer::render(- &mut pipeline,+ self.camera.prepare(+ &constants.device,+ &constants.queue,+ *uniforms,camera_size,camera_frame,- uniforms,(texture, texture_view),);}++ Ok(())}- let padded_bytes_per_row = encoder.padded_bytes_per_row(&state);- let image_data = encoder.copy_output(state).await?;+ pub fn render(+ &self,+ device: &wgpu::Device,+ encoder: &mut wgpu::CommandEncoder,+ session: &mut RenderSession,+ ) {+ macro_rules! render_pass {+ ($view:expr, $load:expr) => {+ encoder.begin_render_pass(&wgpu::RenderPassDescriptor {+ label: Some("Render Pass"),+ color_attachments: &[Some(wgpu::RenderPassColorAttachment {+ view: $view,+ resolve_target: None,+ ops: wgpu::Operations {+ load: $load,+ store: wgpu::StoreOp::Store,+ },+ })],+ depth_stencil_attachment: None,+ timestamp_writes: None,+ occlusion_query_set: None,+ })+ };+ }- Ok(RenderedFrame {- data: image_data,- padded_bytes_per_row,- width: uniforms.output_size.0,- height: uniforms.output_size.1,- })+ {+ let mut pass = render_pass!(+ session.current_texture_view(),+ wgpu::LoadOp::Clear(wgpu::Color::BLACK)+ );+ self.background.render(&mut pass);+ }++ if self.background_blur.blur_amount > 0.0 {+ let mut pass = render_pass!(session.other_texture_view(), wgpu::LoadOp::Load);+ self.background_blur+ .render(&mut pass, device, session.current_texture_view());++ session.swap_textures();+ }++ {+ let mut pass = render_pass!(session.current_texture_view(), wgpu::LoadOp::Load);+ self.display.render(&mut pass);+ }++ {+ let mut pass = render_pass!(session.current_texture_view(), wgpu::LoadOp::Load);+ self.cursor.render(&mut pass);+ }++ {+ let mut pass = render_pass!(session.current_texture_view(), wgpu::LoadOp::Load);+ self.camera.render(&mut pass);+ }+ }+}++pub struct RenderSession {+ textures: (wgpu::Texture, wgpu::Texture),+ texture_views: (wgpu::TextureView, wgpu::TextureView),+ current_is_left: bool,+}++impl RenderSession {+ pub fn new(device: &wgpu::Device, width: u32, height: u32) -> Self {+ let make_texture = || {+ device.create_texture(&wgpu::TextureDescriptor {+ size: wgpu::Extent3d {+ width,+ height,+ depth_or_array_layers: 1,+ },+ mip_level_count: 1,+ sample_count: 1,+ dimension: wgpu::TextureDimension::D2,+ format: wgpu::TextureFormat::Rgba8UnormSrgb,+ usage: wgpu::TextureUsages::TEXTURE_BINDING+ | wgpu::TextureUsages::RENDER_ATTACHMENT+ | wgpu::TextureUsages::COPY_SRC,+ label: Some("Intermediate Texture"),+ view_formats: &[],+ })+ };++ let textures = (make_texture(), make_texture());++ Self {+ current_is_left: true,+ texture_views: (+ textures.0.create_view(&Default::default()),+ textures.1.create_view(&Default::default()),+ ),+ textures,+ }+ }++ pub fn update_texture_size(&mut self, device: &wgpu::Device, width: u32, height: u32) {+ let make_texture = || {+ device.create_texture(&wgpu::TextureDescriptor {+ size: wgpu::Extent3d {+ width,+ height,+ depth_or_array_layers: 1,+ },+ mip_level_count: 1,+ sample_count: 1,+ dimension: wgpu::TextureDimension::D2,+ format: wgpu::TextureFormat::Rgba8UnormSrgb,+ usage: wgpu::TextureUsages::TEXTURE_BINDING+ | wgpu::TextureUsages::RENDER_ATTACHMENT+ | wgpu::TextureUsages::COPY_SRC,+ label: Some("Intermediate Texture"),+ view_formats: &[],+ })+ };++ self.textures = (make_texture(), make_texture());+ self.texture_views = (+ self.textures.0.create_view(&Default::default()),+ self.textures.1.create_view(&Default::default()),+ );+ }++ pub fn current_texture(&self) -> &wgpu::Texture {+ if self.current_is_left {+ &self.textures.0+ } else {+ &self.textures.1+ }+ }++ pub fn current_texture_view(&self) -> &wgpu::TextureView {+ if self.current_is_left {+ &self.texture_views.0+ } else {+ &self.texture_views.1+ }+ }++ pub fn other_texture_view(&self) -> &wgpu::TextureView {+ if self.current_is_left {+ &self.texture_views.1+ } else {+ &self.texture_views.0+ }+ }++ pub fn swap_textures(&mut self) {+ self.current_is_left = !self.current_is_left;+ }+}++// TODO: reuse as many resources as possible+// https://github.com/gfx-rs/wgpu/wiki/Encapsulating-Graphics-Work+async fn produce_frame(+ constants: &RenderVideoConstants,+ segment_frames: DecodedSegmentFrames,+ uniforms: ProjectUniforms,+ cursor: &CursorEvents,+ layers: &mut RendererLayers,+ session: &mut RenderSession,+) -> Result<RenderedFrame, RenderingError> {+ layers+ .prepare(constants, &uniforms, &segment_frames, cursor)+ .await?;++ let mut encoder = constants.device.create_command_encoder(+ &(wgpu::CommandEncoderDescriptor {+ label: Some("Render Encoder"),+ }),+ );++ layers.render(&constants.device, &mut encoder, session);++ Ok(finish_encoder(+ session,+ &constants.device,+ &constants.queue,+ &uniforms,+ encoder,+ )+ .await?)}pub fn create_shader_render_pipeline(@@ -1074,7 +1246,7 @@ pub fn create_shader_render_pipeline(entry_point: "fs_main",targets: &[Some(wgpu::ColorTargetState {format: wgpu::TextureFormat::Rgba8UnormSrgb,- blend: Some(wgpu::BlendState::REPLACE),+ blend: Some(wgpu::BlendState::ALPHA_BLENDING),write_mask: wgpu::ColorWrites::ALL,})],compilation_options: wgpu::PipelineCompilationOptions {diff --git a/crates/rendering/src/shaders/composite-video-frame.wgsl b/crates/rendering/src/shaders/composite-video-frame.wgslindex d431ec203..2f76e3c12 100644--- a/crates/rendering/src/shaders/composite-video-frame.wgsl+++ b/crates/rendering/src/shaders/composite-video-frame.wgsl@@ -17,8 +17,7 @@ struct Uniforms {@group(0) @binding(0) var<uniform> uniforms: Uniforms;@group(0) @binding(1) var frame_texture: texture_2d<f32>;-@group(0) @binding(2) var intermediate_texture: texture_2d<f32>;-@group(0) @binding(3) var frame_sampler: sampler;+@group(0) @binding(2) var frame_sampler: sampler;struct VertexOutput {@builtin(position) position: vec4<f32>,@@ -54,17 +53,17 @@ fn fs_main(@builtin(position) frag_coord: vec4<f32>) -> @location(0) vec4<f32> {// Advanced shadow calculationlet min_frame_size = min(size.x, size.y);let shadow_enabled = uniforms.shadow > 0.0;-+// Get shadow parameters, either from advanced settings or fallback to basic shadowlet shadow_strength = uniforms.shadow / 100.0;-+// Use shadow_strength as a multiplier for all advanced settingslet shadow_size = select(shadow_strength * min_frame_size,shadow_strength * (uniforms.shadow_size / 100.0) * min_frame_size,shadow_enabled);-+let shadow_opacity = select(shadow_strength * 0.18,shadow_strength * (uniforms.shadow_opacity / 100.0),@@ -79,7 +78,7 @@ fn fs_main(@builtin(position) frag_coord: vec4<f32>) -> @location(0) vec4<f32> {// Calculate shadow with no offsetlet shadow_dist = sdf_rounded_rect(p - center, size, uniforms.rounding_px);-+// Apply blur and size to shadowlet shadow_strength_final = smoothstep(shadow_size + shadow_blur, -shadow_blur, abs(shadow_dist));let shadow_color = vec4<f32>(0.0, 0.0, 0.0, shadow_strength_final * shadow_opacity);@@ -88,14 +87,11 @@ fn fs_main(@builtin(position) frag_coord: vec4<f32>) -> @location(0) vec4<f32> {let target_uv = (p - uniforms.target_bounds.xy) / uniforms.target_size;let crop_bounds_uv = vec4<f32>(uniforms.crop_bounds.xy / uniforms.frame_size, uniforms.crop_bounds.zw / uniforms.frame_size);- let bg_color = textureSample(intermediate_texture, frame_sampler, uv);-+ let bg_color = vec4<f32>(0.0);+// If outside the target area, just blend shadow with intermediateif target_uv.x < 0.0 || target_uv.x > 1.0 || target_uv.y < 0.0 || target_uv.y > 1.0 {- return vec4<f32>(- mix(bg_color.rgb, vec3<f32>(0.0), shadow_color.a),- 1.0- );+ return shadow_color;}var base_color = sample_texture(target_uv, crop_bounds_uv);@@ -105,11 +101,7 @@ fn fs_main(@builtin(position) frag_coord: vec4<f32>) -> @location(0) vec4<f32> {if blur_amount < 0.01 {// First blend shadow with intermediate, then blend result with base color- let with_shadow = vec4<f32>(- mix(bg_color.rgb, vec3<f32>(0.0), shadow_color.a),- 1.0- );- return mix(with_shadow, base_color, base_color.a);+ return mix(shadow_color, base_color, base_color.a);}let center_uv = vec2<f32>(0.5, 0.5);@@ -155,7 +147,7 @@ fn fs_main(@builtin(position) frag_coord: vec4<f32>) -> @location(0) vec4<f32> {let final_color = accum / weight_sum;let blurred = vec4(final_color.rgb, base_color.a);- return mix(mix(bg_color, shadow_color, shadow_color.a), blurred, blurred.a);+ return mix(shadow_color, blurred, blurred.a);}fn sample_texture(uv: vec2<f32>, crop_bounds_uv: vec4<f32>) -> vec4<f32> {@@ -182,7 +174,8 @@ fn apply_rounded_corners(current_color: vec4<f32>, target_uv: vec2<f32>) -> vec4let distance_blur = 1.0;if target_rounding_coord.x >= 0.0 && target_rounding_coord.y >= 0.0 && distance >= -distance_blur/2.0 {- return mix(current_color, vec4<f32>(0.0), min(distance / distance_blur + 0.5, 1.0));+ return vec4<f32>(0.0);+ // return mix(current_color, vec4<f32>(0.0), min(distance / distance_blur + 0.5, 1.0));}return current_color;diff --git a/crates/rendering/src/zoom.rs b/crates/rendering/src/zoom.rsindex 245cd4f1d..e3f1f6445 100644--- a/crates/rendering/src/zoom.rs+++ b/crates/rendering/src/zoom.rs@@ -1,5 +1,7 @@use cap_project::{cursor::CursorEvents, ZoomSegment, XY};+use crate::{Coord, RawDisplayUVSpace};+pub const ZOOM_DURATION: f64 = 1.0;// Added constant for cursor smoothingpub const CURSOR_SMOOTHING_WINDOW: f64 = 0.15; // 150ms window for smoothing@@ -52,76 +54,12 @@ pub struct SegmentBounds {}impl SegmentBounds {- // Add current_time parameter to from_segment- fn from_segment(- segment: &ZoomSegment,- current_time: f64,- cursor_events: Option<&CursorEvents>,- ) -> Self {- println!(- "Zoom mode: {:?}, segment time: {}, current time: {}",- segment.mode, segment.start, current_time- );-- // Add detailed debug info about cursor_events- if let Some(events) = cursor_events {- println!(- "Cursor events available: {} move events",- events.moves.len()- );- // Print first 3 move events to check timestamps- if !events.moves.is_empty() {- for i in 0..std::cmp::min(3, events.moves.len()) {- println!(- "Sample move event {}: time={}, pos=({}, {})",- i, events.moves[i].time_ms, events.moves[i].x, events.moves[i].y- );- }- // Print last event- if events.moves.len() > 3 {- let last = &events.moves[events.moves.len() - 1];- println!(- "Last move event: time={}, pos=({}, {})",- last.time_ms, last.x, last.y- );- }- }- } else {- println!("No cursor events provided");- }-+ fn from_segment(segment: &ZoomSegment, interpolated_cursor: Coord<RawDisplayUVSpace>) -> Self {let position = match segment.mode {- cap_project::ZoomMode::Auto => {- // Use current_time instead of segment.start to get continuously changing cursor positions- if let Some(events) = cursor_events {- println!("Looking for cursor position at time: {}", current_time);-- // Get smoothed cursor position instead of exact position- if let Some(pos) =- get_smoothed_cursor_position(events, current_time, CURSOR_SMOOTHING_WINDOW)- {- println!("Found smoothed cursor position: ({}, {})", pos.0, pos.1);- pos- } else {- println!(- "No cursor position found at time: {}, defaulting to center",- current_time- );- (0.5, 0.5) // Fall back to center if no cursor data available- }- } else {- println!("No cursor events provided, defaulting to center");- (0.5, 0.5) // Fall back to center if no cursor events provided- }- }+ cap_project::ZoomMode::Auto => (interpolated_cursor.x, interpolated_cursor.y),cap_project::ZoomMode::Manual { x, y } => (x as f64, y as f64),};- println!("Final position: ({}, {})", position.0, position.1);-- // Fix: Instead of defaulting to (0.0, 0.0), use (0.5, 0.5) as center- // The rest of the function remains the same-let scaled_center = [position.0 * segment.amount, position.1 * segment.amount];let center_diff = [scaled_center[0] - position.0, scaled_center[1] - position.1];@@ -146,104 +84,6 @@ impl SegmentBounds {}}-// New helper function to get smoothed cursor position-fn get_smoothed_cursor_position(- events: &CursorEvents,- time: f64,- window: f64,-) -> Option<(f64, f64)> {- // First try to get the exact position at the current time- if let Some(pos) = events.cursor_position_at(time) {- // Try to find positions within the smoothing window- let start_time = time - window / 2.0;- let end_time = time + window / 2.0;-- // Collect cursor positions within the time window- let mut positions = Vec::new();- let mut total_weight = 0.0;- let mut weighted_x = 0.0;- let mut weighted_y = 0.0;-- // Find positions in the time window- for event in &events.moves {- let event_time = event.time_ms / 1000.0; // Convert to seconds-- if event_time >= start_time && event_time <= end_time {- // Calculate weight based on time proximity (closer to current time = higher weight)- let time_diff = (time - event_time).abs();- let weight = 1.0 - (time_diff / (window / 2.0)).min(1.0);-- positions.push((event.x, event.y, weight));- total_weight += weight;- weighted_x += event.x * weight;- weighted_y += event.y * weight;- }- }-- // If we found positions in the window, return weighted average- if !positions.is_empty() && total_weight > 0.0 {- return Some((weighted_x / total_weight, weighted_y / total_weight));- }-- // If no positions in window, use the exact position- return Some((pos.x, pos.y));- }-- // Try to interpolate between closest positions if exact position not found- let mut before = None;- let mut after = None;-- for event in &events.moves {- let event_time = event.time_ms / 1000.0;-- if event_time <= time {- // Find the closest event before the target time- if let Some((prev_time, _, _)) = before {- if event_time > prev_time {- before = Some((event_time, event.x, event.y));- }- } else {- before = Some((event_time, event.x, event.y));- }- } else {- // Find the closest event after the target time- if let Some((next_time, _, _)) = after {- if event_time < next_time {- after = Some((event_time, event.x, event.y));- }- } else {- after = Some((event_time, event.x, event.y));- }- }- }-- match (before, after) {- // Interpolate between two points- (Some((t1, x1, y1)), Some((t2, x2, y2))) => {- // Calculate interpolation factor- let t_diff = t2 - t1;- if t_diff > 0.0 {- let factor = (time - t1) / t_diff;-- // Linearly interpolate between the two positions- let x = x1 + (x2 - x1) * factor;- let y = y1 + (y2 - y1) * factor;-- Some((x, y))- } else {- // If timestamps are identical, just use one of the positions- Some((x1, y1))- }- }- // If we only have a position before the time- (Some((_, x, y)), None) => Some((x, y)),- // If we only have a position after the time- (None, Some((_, x, y))) => Some((x, y)),- // No positions at all- (None, None) => None,- }-}-#[derive(Debug, Clone, Copy)]pub struct InterpolatedZoom {// the ratio of current zoom to the maximum amount for the current segment@@ -252,11 +92,11 @@ pub struct InterpolatedZoom {}impl InterpolatedZoom {- pub fn new(cursor: SegmentsCursor, cursor_events: Option<&CursorEvents>) -> Self {+ pub fn new(cursor: SegmentsCursor, interpolated_cursor: Coord<RawDisplayUVSpace>) -> Self {let ease_in = bezier_easing::bezier_easing(0.1, 0.0, 0.3, 1.0).unwrap();let ease_out = bezier_easing::bezier_easing(0.5, 0.0, 0.5, 1.0).unwrap();- Self::new_with_easing(cursor, cursor_events, ease_in, ease_out)+ Self::new_with_easing(cursor, interpolated_cursor, ease_in, ease_out)}// the multiplier applied to the display width/height@@ -266,7 +106,7 @@ impl InterpolatedZoom {pub(self) fn new_with_easing(cursor: SegmentsCursor,- cursor_events: Option<&CursorEvents>,+ interpolated_cursor: Coord<RawDisplayUVSpace>,ease_in: impl Fn(f32) -> f32,ease_out: impl Fn(f32) -> f32,) -> InterpolatedZoom {@@ -281,7 +121,7 @@ impl InterpolatedZoom {t: 1.0 - zoom_t,bounds: {let prev_segment_bounds =- SegmentBounds::from_segment(prev_segment, cursor.time, cursor_events);+ SegmentBounds::from_segment(prev_segment, interpolated_cursor);SegmentBounds::new(prev_segment_bounds.top_left * (1.0 - zoom_t)@@ -300,7 +140,7 @@ impl InterpolatedZoom {t,bounds: {let segment_bounds =- SegmentBounds::from_segment(segment, cursor.time, cursor_events);+ SegmentBounds::from_segment(segment, interpolated_cursor);SegmentBounds::new(default.top_left * (1.0 - t) + segment_bounds.top_left * t,@@ -311,9 +151,8 @@ impl InterpolatedZoom {}(Some(prev_segment), Some(segment)) => {let prev_segment_bounds =- SegmentBounds::from_segment(prev_segment, cursor.time, cursor_events);- let segment_bounds =- SegmentBounds::from_segment(segment, cursor.time, cursor_events);+ SegmentBounds::from_segment(prev_segment, interpolated_cursor);+ let segment_bounds = SegmentBounds::from_segment(segment, interpolated_cursor);let zoom_t =ease_in(t_clamp((cursor.time - segment.start) / ZOOM_DURATION) as f32) as f64;@@ -337,7 +176,7 @@ impl InterpolatedZoom {let min = InterpolatedZoom::new_with_easing(SegmentsCursor::new(segment.start, cursor.segments),- cursor_events,+ interpolated_cursor,ease_in,ease_out,);@@ -408,7 +247,8 @@ mod test {}fn test_interp((time, segments): (f64, &[ZoomSegment]), expected: InterpolatedZoom) {- let actual = InterpolatedZoom::new_with_easing(c(time, segments), None, |t| t, |t| t);+ let actual =+ InterpolatedZoom::new_with_easing(c(time, segments), Default::default(), |t| t, |t| t);assert_f64_near!(actual.t, expected.t, "t");diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex ea2c93bd1..f693b71fd 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -100,12 +100,12 @@ importers:version: 0.14.10([email protected])'@solidjs/start':specifier: ^1.1.3- version: 1.1.3(@testing-library/[email protected])(@types/[email protected])([email protected])([email protected])([email protected])([email protected](@planetscale/[email protected])(@types/[email protected])([email protected]([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected]))([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))([email protected])+ version: 1.1.3(@testing-library/[email protected])(@types/[email protected])([email protected])([email protected])([email protected])([email protected](@planetscale/[email protected])(@types/[email protected])([email protected]([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected]))([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))([email protected])'@tanstack/solid-query':specifier: ^5.51.21version: 5.75.4([email protected])'@tauri-apps/api':- specifier: ^2.1.1+ specifier: 2.5.0version: 2.5.0'@tauri-apps/plugin-clipboard-manager':specifier: ^2.2.1@@ -187,7 +187,7 @@ importers:version: 9.0.1vinxi:specifier: ^0.5.6- version: 0.5.6(@planetscale/[email protected])(@types/[email protected])([email protected]([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected]))([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])+ version: 0.5.6(@planetscale/[email protected])(@types/[email protected])([email protected]([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected]))([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])webcodecs:specifier: ^0.1.0version: 0.1.0@@ -218,10 +218,10 @@ importers:version: 5.8.3vite:specifier: ^6.3.5vite-tsconfig-paths:specifier: ^5.0.1- version: 5.1.4([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected]))+ version: 5.1.4([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected]))apps/discord-bot:dependencies:@@ -304,16 +304,16 @@ importers:version: 1.0.0-beta.7(@storybook/[email protected]([email protected]([email protected])))([email protected])([email protected]([email protected]))storybook-solidjs-vite:specifier: ^1.0.0-beta.2- version: 1.0.0-beta.7(@storybook/[email protected]([email protected]([email protected])))([email protected])([email protected]([email protected]))([email protected](@testing-library/[email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))+ version: 1.0.0-beta.7(@storybook/[email protected]([email protected]([email protected])))([email protected])([email protected]([email protected]))([email protected](@testing-library/[email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))typescript:specifier: ^5.7.2version: 5.8.3vite:specifier: ^6.3.5vite-plugin-solid:specifier: ^2.10.2- version: 2.11.6(@testing-library/[email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected]))+ version: 2.11.6(@testing-library/[email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected]))apps/tasks:dependencies:@@ -697,13 +697,13 @@ importers:dependencies:'@vitejs/plugin-react':specifier: ^4.0.3- version: 4.4.1([email protected](@types/[email protected])([email protected])([email protected])([email protected]))+ version: 4.4.1([email protected](@types/[email protected])([email protected])([email protected])([email protected]))vite:specifier: ^6.3.5vite-tsconfig-paths:specifier: ^4.2.0- version: 4.3.2([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected]))+ version: 4.3.2([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected]))devDependencies:'@types/node':specifier: ^20.4.5@@ -900,7 +900,7 @@ importers:version: 19.1.3(@types/[email protected])'@vitejs/plugin-react':specifier: ^4.0.3- version: 4.4.1([email protected](@types/[email protected])([email protected])([email protected])([email protected]))+ version: 4.4.1([email protected](@types/[email protected])([email protected])([email protected])([email protected]))autoprefixer:specifier: ^10.4.16version: 10.4.21([email protected])@@ -942,10 +942,10 @@ importers:version: 5.8.3vite:specifier: ^6.3.5vite-tsconfig-paths:specifier: ^4.2.1- version: 4.3.2([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected]))+ version: 4.3.2([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected]))packages/ui-solid:dependencies:@@ -994,7 +994,7 @@ importers:version: 0.18.6([email protected])unplugin-fonts:specifier: ^1.1.1- version: 1.3.1([email protected](@types/[email protected])([email protected])([email protected])([email protected]))+ version: 1.3.1([email protected](@types/[email protected])([email protected])([email protected])([email protected]))unplugin-icons:specifier: ^0.19.2version: 0.19.3@@ -5014,10 +5014,10 @@ packages:react-dom:optional: true- '@storybook/[email protected]':- resolution: {integrity: sha512-jaa6KaKjmmOxozotDieuH7Qcc5KyIBQhwMHoh9YSinqmAoHdLKQSrPEEpluEjwoMW+BDPRVYLAMWiXmemuDTRg==}+ '@storybook/[email protected]':+ resolution: {integrity: sha512-z0VUmeKDPv5dhP2XUu6ruJMCZFF6YW4Vn2riIz7s462ezjMaMPrA+mNOfpgXIWQbj/WJrprR1TjlNXjS/4q6gA==}peerDependencies:- storybook: ^9.0.0-beta.11+ storybook: ^9.0.0-rc.0vite: ^5.0.0 || ^6.0.0'@storybook/[email protected]':@@ -5033,10 +5033,10 @@ packages:peerDependencies:storybook: ^8.6.12- '@storybook/[email protected]':- resolution: {integrity: sha512-nkx1/8KnJ/SPrZtVc0tlJJwDZA9B7CAx2vNNKK36cdcOxq5sHzu9ahfQs7RiY12W3nHiAoAuYAlHITTY15ujsQ==}+ '@storybook/[email protected]':+ resolution: {integrity: sha512-6bGUD69+qWjG4OFYh6+ibA+ehGBAo4fvNAyGjMiUZyiUIg1Fb2X34G/PKYFoYsBQay0MOpcjan9SwiZquYnO4A==}peerDependencies:- storybook: ^9.0.0-beta.11+ storybook: ^9.0.0-rc.0'@storybook/[email protected]':resolution: {integrity: sha512-bOmTNJE4FM6+3/1hPQVgha8cLxX2Nyi/4Z+tYq0pCDEyQqGRTD2KXre9XsSCnziRaGxiW80OrKkmqWY8Otuu4A==}@@ -13032,6 +13032,11 @@ packages:engines: {node: '>= 14'}hasBin: true+ resolution: {integrity: sha512-4lLa/EcQCB0cJkyts+FpIRx5G/llPxfP6VQU5KByHEhLxY3IJCH0f0Hy1MHI8sClTvsIb8qwRJ6R/ZdlDJ/leQ==}+ engines: {node: '>= 14.6'}+ hasBin: true+resolution: {integrity: sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==}engines: {node: '>=6'}@@ -14081,7 +14086,7 @@ snapshots:micromatch: 4.0.8ts-pattern: 5.7.0unified: 11.0.5- yaml: 2.7.1+ yaml: 2.8.0zod: 3.24.4transitivePeerDependencies:- '@effect-ts/otel-node'@@ -17664,11 +17669,11 @@ snapshots:dependencies:solid-js: 1.9.6- '@solidjs/[email protected](@testing-library/[email protected])(@types/[email protected])([email protected])([email protected])([email protected])([email protected](@planetscale/[email protected])(@types/[email protected])([email protected]([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected]))([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))([email protected])':+ '@solidjs/[email protected](@testing-library/[email protected])(@types/[email protected])([email protected])([email protected])([email protected])([email protected](@planetscale/[email protected])(@types/[email protected])([email protected]([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected]))([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))([email protected])':dependencies:- '@tanstack/server-functions-plugin': 1.119.2(@types/[email protected])([email protected])([email protected])([email protected])- '@vinxi/plugin-directives': 0.5.1([email protected](@planetscale/[email protected])(@types/[email protected])([email protected]([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected]))([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))- '@vinxi/server-components': 0.5.1([email protected](@planetscale/[email protected])(@types/[email protected])([email protected]([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected]))([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))+ '@tanstack/server-functions-plugin': 1.119.2(@types/[email protected])([email protected])([email protected])([email protected])+ '@vinxi/plugin-directives': 0.5.1([email protected](@planetscale/[email protected])(@types/[email protected])([email protected]([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected]))([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))+ '@vinxi/server-components': 0.5.1([email protected](@planetscale/[email protected])(@types/[email protected])([email protected]([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected]))([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))defu: 6.1.4error-stack-parser: 2.1.4html-to-image: 1.11.13@@ -17679,8 +17684,8 @@ snapshots:source-map-js: 1.2.1terracotta: 1.0.6([email protected])tinyglobby: 0.2.13- vinxi: 0.5.6(@planetscale/[email protected])(@types/[email protected])([email protected]([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected]))([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])- vite-plugin-solid: 2.11.6(@testing-library/[email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected]))+ vinxi: 0.5.6(@planetscale/[email protected])(@types/[email protected])([email protected]([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected]))([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])+ vite-plugin-solid: 2.11.6(@testing-library/[email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected]))transitivePeerDependencies:- '@testing-library/jest-dom'- '@types/node'@@ -17807,13 +17812,12 @@ snapshots:react: 18.3.1react-dom: 18.3.1([email protected])- '@storybook/[email protected]([email protected]([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))':+ '@storybook/[email protected]([email protected]([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))':dependencies:- '@storybook/csf-plugin': 9.0.0-beta.11([email protected]([email protected]))- browser-assert: 1.2.1+ '@storybook/csf-plugin': 9.0.0-rc.0([email protected]([email protected]))storybook: 8.6.12([email protected])ts-dedent: 2.2.0dependencies:@@ -17841,7 +17845,7 @@ snapshots:storybook: 8.6.12([email protected])unplugin: 1.16.1dependencies:storybook: 8.6.12([email protected])unplugin: 1.16.1@@ -17949,7 +17953,7 @@ snapshots:postcss-selector-parser: 6.0.10- '@tanstack/[email protected](@types/[email protected])([email protected])([email protected])([email protected])':+ '@tanstack/[email protected](@types/[email protected])([email protected])([email protected])([email protected])':dependencies:'@babel/code-frame': 7.26.2'@babel/core': 7.27.1@@ -17962,7 +17966,7 @@ snapshots:babel-dead-code-elimination: 1.0.10dedent: 1.6.0tiny-invariant: 1.3.3transitivePeerDependencies:- '@types/node'- babel-plugin-macros@@ -18005,7 +18009,7 @@ snapshots:ansis: 3.17.0diff: 7.0.0- '@tanstack/[email protected](@types/[email protected])([email protected])([email protected])([email protected])':+ '@tanstack/[email protected](@types/[email protected])([email protected])([email protected])([email protected])':dependencies:'@babel/code-frame': 7.26.2'@babel/core': 7.27.1@@ -18014,7 +18018,7 @@ snapshots:'@babel/template': 7.27.2'@babel/traverse': 7.27.1'@babel/types': 7.27.1- '@tanstack/directive-functions-plugin': 1.119.2(@types/[email protected])([email protected])([email protected])([email protected])+ '@tanstack/directive-functions-plugin': 1.119.2(@types/[email protected])([email protected])([email protected])([email protected])babel-dead-code-elimination: 1.0.10dedent: 1.6.0tiny-invariant: 1.3.3@@ -18565,7 +18569,7 @@ snapshots:'@types/[email protected]':dependencies:- '@types/node': 22.15.17+ '@types/node': 20.17.43optional: true'@typescript-eslint/[email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])':@@ -18864,7 +18868,7 @@ snapshots:consola: 3.4.2defu: 6.1.4get-port-please: 3.1.2- h3: 1.15.2+ h3: 1.15.3http-shutdown: 1.2.2jiti: 1.21.7mlly: 1.7.4@@ -18875,7 +18879,7 @@ snapshots:untun: 0.1.3uqr: 0.1.2- '@vinxi/[email protected]([email protected](@planetscale/[email protected])(@types/[email protected])([email protected]([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected]))([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))':+ '@vinxi/[email protected]([email protected](@planetscale/[email protected])(@types/[email protected])([email protected]([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected]))([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))':dependencies:'@babel/parser': 7.27.2acorn: 8.14.1@@ -18886,27 +18890,27 @@ snapshots:magicast: 0.2.11recast: 0.23.11tslib: 2.8.1- vinxi: 0.5.6(@planetscale/[email protected])(@types/[email protected])([email protected]([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected]))([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])+ vinxi: 0.5.6(@planetscale/[email protected])(@types/[email protected])([email protected]([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected]))([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])- '@vinxi/[email protected]([email protected](@planetscale/[email protected])(@types/[email protected])([email protected]([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected]))([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))':+ '@vinxi/[email protected]([email protected](@planetscale/[email protected])(@types/[email protected])([email protected]([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected]))([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))':dependencies:- '@vinxi/plugin-directives': 0.5.1([email protected](@planetscale/[email protected])(@types/[email protected])([email protected]([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected]))([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))+ '@vinxi/plugin-directives': 0.5.1([email protected](@planetscale/[email protected])(@types/[email protected])([email protected]([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected]))([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))acorn: 8.14.1acorn-loose: 8.5.0acorn-typescript: 1.4.13([email protected])astring: 1.9.0magicast: 0.2.11recast: 0.23.11- vinxi: 0.5.6(@planetscale/[email protected])(@types/[email protected])([email protected]([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected]))([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])+ vinxi: 0.5.6(@planetscale/[email protected])(@types/[email protected])([email protected]([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected]))([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])- '@vitejs/[email protected]([email protected](@types/[email protected])([email protected])([email protected])([email protected]))':+ '@vitejs/[email protected]([email protected](@types/[email protected])([email protected])([email protected])([email protected]))':dependencies:'@babel/core': 7.27.1'@babel/plugin-transform-react-jsx-self': 7.27.1(@babel/[email protected])'@babel/plugin-transform-react-jsx-source': 7.27.1(@babel/[email protected])'@types/babel__core': 7.20.5react-refresh: 0.17.0transitivePeerDependencies:- supports-color@@ -26216,16 +26220,16 @@ snapshots:- [email protected](@storybook/[email protected]([email protected]([email protected])))([email protected])([email protected]([email protected]))([email protected](@testing-library/[email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])))([email protected](@types/[email protected])([email protected])([email protected])([email protected])):+ [email protected](@storybook/[email protected]([email protected]([email protected])))([email protected])([email protected]([email protected]))([email protected](@testing-library/[email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])))([email protected](@types/[email protected])([email protected])([email protected])([email protected])):dependencies:- '@storybook/builder-vite': 9.0.0-beta.11([email protected]([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))+ '@storybook/builder-vite': 9.0.0-rc.0([email protected]([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))'@storybook/types': 9.0.0-alpha.1([email protected]([email protected]))magic-string: 0.30.17solid-js: 1.9.6storybook: 8.6.12([email protected])storybook-solidjs: 1.0.0-beta.7(@storybook/[email protected]([email protected]([email protected])))([email protected])([email protected]([email protected]))- vite-plugin-solid: 2.11.6(@testing-library/[email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected]))+ vite-plugin-solid: 2.11.6(@testing-library/[email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected]))transitivePeerDependencies:- '@storybook/test'@@ -27106,11 +27110,11 @@ snapshots:transitivePeerDependencies:- rollup- [email protected]([email protected](@types/[email protected])([email protected])([email protected])([email protected])):+ [email protected]([email protected](@types/[email protected])([email protected])([email protected])([email protected])):dependencies:fast-glob: 3.3.3unplugin: 2.0.0-beta.1dependencies:@@ -27172,7 +27176,7 @@ snapshots:anymatch: 3.1.3chokidar: 4.0.3destr: 2.0.5- h3: 1.15.2+ h3: 1.15.3lru-cache: 10.4.3node-fetch-native: 1.6.6ofetch: 1.4.1@@ -27355,7 +27359,7 @@ snapshots:dependencies:global: 4.4.0- [email protected](@planetscale/[email protected])(@types/[email protected])([email protected]([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected]))([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected]):+ [email protected](@planetscale/[email protected])(@types/[email protected])([email protected]([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected]))([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected]):dependencies:'@babel/core': 7.27.1'@babel/plugin-syntax-jsx': 7.27.1(@babel/[email protected])@@ -27389,7 +27393,7 @@ snapshots:unctx: 2.4.1unenv: 1.10.0unstorage: 1.16.0(@planetscale/[email protected])([email protected]([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected]))([email protected]))([email protected])zod: 3.24.4transitivePeerDependencies:- '@azure/app-configuration'@@ -27451,7 +27455,7 @@ snapshots:- supports-color- terser- [email protected](@testing-library/[email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])):+ [email protected](@testing-library/[email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])):dependencies:'@babel/core': 7.27.1'@types/babel__core': 7.20.5@@ -27459,31 +27463,31 @@ snapshots:merge-anything: 5.1.7solid-js: 1.9.6solid-refresh: 0.6.3([email protected])- vitefu: 1.0.6([email protected](@types/[email protected])([email protected])([email protected])([email protected]))+ vitefu: 1.0.6([email protected](@types/[email protected])([email protected])([email protected])([email protected]))optionalDependencies:'@testing-library/jest-dom': 6.5.0transitivePeerDependencies:- supports-color- [email protected]([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])):+ [email protected]([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])):dependencies:debug: 4.4.0([email protected])globrex: 0.1.2tsconfck: 3.1.5([email protected])optionalDependencies:transitivePeerDependencies:- supports-color- typescript- [email protected]([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])):+ [email protected]([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])):dependencies:debug: 4.4.0([email protected])globrex: 0.1.2tsconfck: 3.1.5([email protected])optionalDependencies:transitivePeerDependencies:- supports-color- typescript@@ -27498,7 +27502,7 @@ snapshots:fsevents: 2.3.3terser: 5.39.0- [email protected](@types/[email protected])([email protected])([email protected])([email protected]):+ [email protected](@types/[email protected])([email protected])([email protected])([email protected]):dependencies:esbuild: 0.24.2postcss: 8.5.3@@ -27508,9 +27512,9 @@ snapshots:fsevents: 2.3.3jiti: 2.4.2terser: 5.39.0- yaml: 2.7.1+ yaml: 2.8.0- [email protected](@types/[email protected])([email protected])([email protected])([email protected]):+ [email protected](@types/[email protected])([email protected])([email protected])([email protected]):dependencies:esbuild: 0.25.4fdir: 6.4.4([email protected])@@ -27523,9 +27527,9 @@ snapshots:fsevents: 2.3.3jiti: 2.4.2terser: 5.39.0- yaml: 2.7.1+ yaml: 2.8.0- [email protected](@types/[email protected])([email protected])([email protected])([email protected]):+ [email protected](@types/[email protected])([email protected])([email protected])([email protected]):dependencies:esbuild: 0.25.4fdir: 6.4.4([email protected])@@ -27538,11 +27542,11 @@ snapshots:fsevents: 2.3.3jiti: 2.4.2terser: 5.39.0- yaml: 2.7.1+ yaml: 2.8.0- [email protected]([email protected](@types/[email protected])([email protected])([email protected])([email protected])):+ [email protected]([email protected](@types/[email protected])([email protected])([email protected])([email protected])):optionalDependencies:dependencies:@@ -27813,6 +27817,8 @@ snapshots:+ [email protected]: {}+dependencies:camelcase: 5.3.1