remove unused deps and dead code

This commit is contained in:
Omar Saidahmed committed 2026-10-15 09:00:20 -04:00
1 parent df055f3dcb
commit 65ca7c1bbd
7 files changed
+6 -77

No files matched your search

Generated
-4
View File
@@ -4690,7 +4690,6 @@ dependencies = [
"photocraft-doc",
"photocraft-engine",
"photocraft-format",
"photocraft-geom",
"photocraft-io",
"rmcp",
"schemars",
@@ -4979,9 +4978,6 @@ name = "photocraft-testkit"
version = "0.9.0"
dependencies = [
"memory-stats",
"photocraft-color",
"photocraft-geom",
"photocraft-raster",
"serde_json",
]
+2 -66
View File
@@ -1,10 +1,8 @@
//! Native platform services: file dialogs (rfd), filesystem, codecs.
use photocraft_codecs::{ChannelLayout, EncodeOptions, Image, SampleType as CS};
use photocraft_color::{ColorMode, SampleType};
use photocraft_doc::{Document, Layer, Size};
use photocraft_codecs::{ChannelLayout, EncodeOptions, Image};
use photocraft_doc::Document;
use photocraft_format::RecoveryStore;
use photocraft_geom::Rect;
use photocraft_ui_egui::{FileDialogAnswer, FileDialogReply, FileDialogRequest, Recoverable, Services};
use std::cell::RefCell;
use std::future::Future;
@@ -515,68 +513,6 @@ fn platform_beep() {
}
}
/// Flat-image import via photocraft-codecs (kept for reference/tests; the app uses photocraft-io).
#[allow(dead_code)]
pub fn import_flat(name: &str, bytes: &[u8]) -> Result<Document, String> {
let img = photocraft_codecs::decode(bytes).map_err(|e| e.to_string())?;
let (w, h) = (img.width(), img.height());
let depth = match img.sample_type() {
CS::U8 => SampleType::U8,
CS::U16 => SampleType::U16,
_ => SampleType::F32,
};
let gray = matches!(img.layout(), ChannelLayout::Gray | ChannelLayout::GrayA);
let cmyk = matches!(img.layout(), ChannelLayout::Cmyk | ChannelLayout::CmykA);
let mode = if gray {
ColorMode::Grayscale
} else if cmyk {
ColorMode::Cmyk
} else {
ColorMode::Rgb
};
let target = match mode {
ColorMode::Grayscale => ChannelLayout::GrayA,
ColorMode::Cmyk => ChannelLayout::CmykA,
_ => ChannelLayout::Rgba,
};
let sample = match depth {
SampleType::U8 => CS::U8,
SampleType::U16 => CS::U16,
SampleType::F32 => CS::F32,
};
let conv = img.convert(target, sample);
let stem = std::path::Path::new(name).file_stem().map(|s| s.to_string_lossy().to_string()).unwrap_or(name.to_string());
let mut doc = Document::new(stem, Size::new(w, h), mode, depth);
doc.icc_profile = img.icc.clone().map(std::sync::Arc::new);
if let Some((x, _)) = img.meta.dpi {
doc.resolution_dpi = x;
}
let mut layer = Layer::raster("Background", doc.pixel_format());
let data = conv.to_normalized();
layer.surface_mut().ok_or("new raster layer has no pixels")?.write_region(Rect::from_xywh(0, 0, w, h), &data);
doc.layers.push(layer);
Ok(doc)
}
#[allow(dead_code)]
pub fn export_flat(doc: &Document, path: &str) -> Result<Vec<u8>, String> {
let format = photocraft_codecs::from_extension(path).ok_or_else(|| format!("unknown file type for {path}"))?;
let buf = photocraft_compose::flatten(doc);
let (w, h) = (buf.rect.width(), buf.rect.height());
let data: Vec<f32> = buf.px.iter().flat_map(|p| *p).collect();
let img = match doc.depth {
SampleType::U8 => Image::from_u8(w, h, ChannelLayout::Rgba, buf.to_rgba8().pixels),
SampleType::U16 => Image::from_u16(w, h, ChannelLayout::Rgba, &data.iter().map(|v| (v.clamp(0.0, 1.0) * 65535.0 + 0.5) as u16).collect::<Vec<_>>()),
SampleType::F32 => Image::from_f32(w, h, ChannelLayout::Rgba, &data),
}
.map_err(|e| e.to_string())?;
let img = match &doc.icc_profile {
Some(icc) if doc.mode == ColorMode::Rgb => img.with_icc(Some((**icc).clone())),
_ => img,
};
photocraft_codecs::encode(&img, format, &EncodeOptions::default()).map_err(|e| e.to_string())
}
#[cfg(test)]
mod tests {
use super::*;
@@ -1,5 +1,6 @@
use super::*;
use photocraft_color::Color;
use photocraft_color::{Color, ColorMode, SampleType};
use photocraft_doc::Size;
use photocraft_format::{Autosaver, RecoveryEntry, SaveOptions, list_recovery};
use std::sync::atomic::{AtomicUsize, Ordering};
-1
View File
@@ -10,7 +10,6 @@ rust-version.workspace = true
workspace = true
[dependencies]
photocraft-geom = { workspace = true }
photocraft-doc = { workspace = true }
photocraft-compose = { workspace = true }
photocraft-codecs = { workspace = true }
+1 -1
View File
@@ -1174,7 +1174,7 @@ mod tests {
break;
}
assert!(t.elapsed().as_secs() < 60, "doc_inspect never saw the finished job: {inspected}");
std::thread::sleep(std::time::Duration::from_millis(5));
tokio::time::sleep(std::time::Duration::from_millis(5)).await;
}
}
}
+1 -1
View File
@@ -218,7 +218,7 @@ pub(crate) fn before_command(s: &mut Session, id: &str) -> Result<Option<Value>>
return Ok(None);
}
match id {
"edit.undo" | "edit.stepBackward" => {
"edit.undo" => {
st.floating = None;
Ok(Some(json!({"floating": "returned"})))
}
-3
View File
@@ -8,9 +8,6 @@ license.workspace = true
workspace = true
[dependencies]
photocraft-geom = { workspace = true }
photocraft-color = { workspace = true }
photocraft-raster = { workspace = true }
serde_json = { workspace = true }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]