PSD: transform a file's clipping path in place instead of copying it

file_clipped owns the path psdread::clipping_path reads, so it moves it
to the image's place without making a second copy of every anchor.
This commit is contained in:
dotCooCoo
2026-11-14 16:39:17 -08:00
parent d0f1346f87
commit 8eded96792
+2 -2
View File
@@ -1074,8 +1074,8 @@ pub(super) fn raster_doc(name: &str, bytes: &[u8]) -> Result<Document> {
/// space (a PSD or PSB file's, [`psdread::clipping_path`]): a clip group of that path (even-odd,
/// with no paint) and the image. Without one the image stays as it is.
pub(crate) fn file_clipped(d: &mut Document, image: Node, clip: Option<vectorcraft_geom::PathData>) -> Node {
let (Some(path), NodeKind::Image(im)) = (clip, &image.kind) else { return image };
let path = path.transformed(im.xf);
let (Some(mut path), NodeKind::Image(im)) = (clip, &image.kind) else { return image };
path.transform(im.xf);
let none = vectorcraft_color::Paint::None;
let mut clip = Node::path(d.alloc_id(), path, vectorcraft_doc::Appearance::basic(none.clone(), none, 0.0));
if let NodeKind::Path { clipping, rule, .. } = &mut clip.kind {