Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

perf: speed up unannotated screenshot exports

cartesian-plane1339cb390a6c
diff --git a/apps/desktop-gpui/src/screenshot_export.rs b/apps/desktop-gpui/src/screenshot_export.rs
index 4720daddb..9f477aadc 100644
--- a/apps/desktop-gpui/src/screenshot_export.rs
+++ b/apps/desktop-gpui/src/screenshot_export.rs
@@ -132,12 +132,17 @@ pub fn export_bounds(scaled: &[Annotation], canvas: (u32, u32)) -> ExportBounds
pub fn composite(raw: &RawFrame, config: &ProjectConfiguration) -> Composited {
let width = raw.width.max(1);
let height = raw.height.max(1);
- if config.annotations.is_empty()
- && raw.rgba.len() == width as usize * height as usize * 4
- && pixels::is_opaque(&raw.rgba)
- {
+ if config.annotations.is_empty() && raw.rgba.len() == width as usize * height as usize * 4 {
+ let rgba = if has_no_visible_background(&config.background.source)
+ || pixels::is_opaque(&raw.rgba)
+ {
+ raw.rgba.clone()
+ } else {
+ pixels::flatten_onto_white(&raw.rgba)
+ };
+
return Composited {
- rgba: raw.rgba.clone(),
+ rgba,
width,
height,
};