Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
Merge commit '27910c6a408916f45c5bd6c393823a7684e1060e' into perf/windows-media-pipeline
Marcos Daniel Rivera Gonzalezbdcbcb033f44
diff --cc crates/recording/src/cursor.rsindex 6f099ee40,fb3ad69cc..1962fe3e1--- a/crates/recording/src/cursor.rs+++ b/crates/recording/src/cursor.rs@@@ -731,7 -703,74 +703,74 @@@ pub fn spawn_cursor_recorder}}+ fn cursor_id_for_image(+ data: CursorData,+ response: &mut CursorActorResponse,+ cursors_dir: &Path,+ writer: Option<&CursorFileWriter>,+ last_cursor_image: &mut Option<(Vec<u8>, String)>,+ ) -> String {+ use sha2::{Digest, Sha256};++ // Hashing a large macOS cursor TIFF costs milliseconds, and the image+ // rarely changes between ticks.+ if let Some((image, cursor_id)) = last_cursor_image+ && *image == data.image+ {+ return cursor_id.clone();+ }++ let hash_bytes = Sha256::digest(&data.image);+ let id = u64::from_le_bytes(+ hash_bytes[..8]+ .try_into()+ .expect("sha256 produces at least 8 bytes"),+ );++ let cursor_id = if let Some(existing_id) = response.cursors.get(&id) {+ existing_id.id.to_string()+ } else {+ let cursor_id = response.next_cursor_id.to_string();+ let file_name = format!("cursor_{cursor_id}.png");+ let cursor_path = cursors_dir.join(&file_name);++ if let Ok(image) = image::load_from_memory(&data.image) {+ let rgba_image = image.into_rgba8();++ let saved = match writer {+ Some(writer) => writer.save_image(cursor_path, rgba_image),+ None => save_cursor_image(&cursor_path, &rgba_image),+ };+ if saved {+ #[cfg(target_os = "macos")]+ let shape = cap_cursor_info::CursorShapeMacOS::from_hash(&hex::encode(hash_bytes))+ .map(Into::into);+ #[cfg(not(target_os = "macos"))]+ let shape = data.shape;+ response.cursors.insert(+ id,+ Cursor {+ file_name,+ id: response.next_cursor_id,+ hotspot: data.hotspot,+ shape,+ },+ );+ response.next_cursor_id += 1;+ }+ }++ cursor_id+ };++ *last_cursor_image = response+ .cursors+ .contains_key(&id)+ .then(|| (data.image, cursor_id.clone()));+ cursor_id+ }+-#[derive(Debug)]+#[derive(Debug, Clone)]struct CursorData {image: Vec<u8>,hotspot: XY<f64>,