PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Merge PR #7142: perf(type): refresh type layers without cloning the document (#7092)
aionggd38019873a12
diff --cc crates/engine/src/type_cmds.rsindex 44b6a98be,b31820dec..ace379adc--- a/crates/engine/src/type_cmds.rs+++ b/crates/engine/src/type_cmds.rs@@@ -8,10 -8,9 +8,10 @@@use std::sync::Arc;- use photocraft_color::Color;+ use photocraft_color::{Color, PixelFormat};use photocraft_doc::text::{- AntiAlias, Caps, CharStyle, FontFeature, FontVariation, Kerning, Orientation, ParagraphRun, ParagraphStyle, TextAlign, TextDirection, TextRun, TextShape,+ AntiAlias, Caps, CharStyle, FontBaseline, FontFeature, FontVariation, Kerning, Orientation, ParagraphRun, ParagraphStyle, TextAlign, TextDirection,+ TextRun, TextShape,};use photocraft_doc::{Affine, Document, Layer, LayerContent, LayerId, TextLayer};use serde_json::{Value, json};@@@ -684,12 -635,8 +691,12 @@@ pub(crate) fn with_text_targetsmut f: impl FnMut(&mut TextLayer, (usize, usize)) -> Result<()>,) -> Result<Vec<LayerId>> {let ids = format_targets(s, p)?;+ let doc = &s.active().ok_or(EngineError::NoDocument)?.doc;+ for id in &ids {+ check_text_unlocked(doc, *id)?;+ }let damage = s.edit(label, |doc, _| {- let snapshot = doc.clone();+ let (dpi, format) = (doc.resolution_dpi, doc.pixel_format());let mut damage = Some(photocraft_geom::Rect::EMPTY);for id in &ids {let Some(LayerContent::Text(t)) = doc.layer_mut(*id).map(|l| &mut l.content) else { return Err(EngineError::NoLayer(*id)) };diff --cc crates/engine/src/type_extra_cmds.rsindex 6f7cf136e,275531501..fd54db1fe--- a/crates/engine/src/type_extra_cmds.rs+++ b/crates/engine/src/type_extra_cmds.rs@@@ -13,9 -13,10 +13,10 @@@ use photocraft_geom::Pointuse photocraft_text::render::PathEl;use serde_json::{Value, json};-use crate::commands::{CommandSpec, layer_param};+use crate::commands::{CommandSpec, explicit_layer, layer_param};use crate::type_cmds::{- check_text_unlocked, format_targets, has_format_target, is_auto_named, layer_name, refresh, replace_text, style_paragraphs, style_range, with_text_targets,+ check_text_unlocked, format_targets, has_format_target, is_auto_named, layer_name, refresh_at, replace_text, style_paragraphs, style_range,+ with_text_targets,};use crate::{EngineError, Result, Session};