mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-03 06:31:42 +01:00
Fix migration gate regressions
This commit is contained in:
4 files changed
+23
-12
No files matched your search
@@ -5,7 +5,7 @@ use serde_json::json;
|
||||
/// Legacy descriptor syntax must reach the same commands and parameters as version 16.
|
||||
#[test]
|
||||
fn legacy_v12_commands_import_like_v16() {
|
||||
let bytes = include_bytes!("../../fixtures/atn/v12-commands.atn");
|
||||
let bytes = include_bytes!("../fixtures/atn/v12-commands.atn");
|
||||
let modern = atn::write(&atn::parse(bytes).unwrap()).unwrap();
|
||||
let expected = vec![
|
||||
("filter.blur.gaussianBlur".into(), json!({"radius": 2.5})),
|
||||
|
||||
@@ -824,7 +824,10 @@ fn inflate(bytes: &[u8]) -> Result<std::borrow::Cow<'_, [u8]>, IoError> {
|
||||
/// [`inflate`] with an explicit `limit`, which also applies to uncompressed input.
|
||||
fn inflate_with_limit(bytes: &[u8], limit: u64) -> Result<std::borrow::Cow<'_, [u8]>, IoError> {
|
||||
let limit = usize::try_from(limit).unwrap_or(usize::MAX);
|
||||
craft_svg::svgz::inflate(bytes, limit).map_err(|e| IoError::Svg(e.to_string()))
|
||||
craft_svg::svgz::inflate(bytes, limit).map_err(|e| match e {
|
||||
craft_svg::svgz::Error::TooLarge(_) if bytes.starts_with(&[0x1f, 0x8b]) => IoError::Svg(format!("compressed SVG inflates past {limit} bytes")),
|
||||
error => IoError::Svg(error.to_string()),
|
||||
})
|
||||
}
|
||||
|
||||
/// The deepest element nesting in `xml`, stopping as soon as it passes `limit` (the result is
|
||||
|
||||
@@ -239,7 +239,7 @@ fn unsupported_raw_falls_back_to_the_embedded_preview() {
|
||||
}
|
||||
|
||||
/// A DNG 1.7 laid out as converters write one with JPEG XL raw data: an 8×6 JPEG thumbnail in
|
||||
/// IFD0, raw data this reader refuses (here floating-point LinearRaw), and a 40×30 preview
|
||||
/// IFD0, raw data this reader refuses (here 64-bit floating-point LinearRaw), and a 40×30 preview
|
||||
/// compressed with JPEG XL, stored as the raw is (IFD0 Orientation 6).
|
||||
fn dng_with_jxl_preview() -> Vec<u8> {
|
||||
use zune_core::{bit_depth::BitDepth, colorspace::ColorSpace, options::EncoderOptions};
|
||||
@@ -250,18 +250,18 @@ fn dng_with_jxl_preview() -> Vec<u8> {
|
||||
let mut preview = Vec::new();
|
||||
zune_jpegxl::JxlSimpleEncoder::new(&rgb, EncoderOptions::new(w, h, ColorSpace::RGB, BitDepth::Eight)).encode(&mut preview).unwrap();
|
||||
let mut t = TiffBuilder::default();
|
||||
let raw_strip = t.blob(vec![0; 4 * 4 * 3 * 2]);
|
||||
let raw_strip = t.blob(vec![0; 4 * 4 * 3 * 8]);
|
||||
let raw = t.ifd(vec![
|
||||
(254, Val::Long(vec![0])),
|
||||
(256, Val::Long(vec![4])),
|
||||
(257, Val::Long(vec![4])),
|
||||
(258, Val::Short(vec![16, 16, 16])),
|
||||
(258, Val::Short(vec![64, 64, 64])),
|
||||
(259, Val::Short(vec![1])),
|
||||
(262, Val::Short(vec![34892])),
|
||||
(273, Val::Blobs(vec![raw_strip])),
|
||||
(277, Val::Short(vec![3])),
|
||||
(278, Val::Long(vec![4])),
|
||||
(279, Val::Long(vec![4 * 4 * 3 * 2])),
|
||||
(279, Val::Long(vec![4 * 4 * 3 * 8])),
|
||||
(339, Val::Short(vec![3, 3, 3])),
|
||||
]);
|
||||
let preview_len = preview.len() as u32;
|
||||
|
||||
@@ -565,16 +565,24 @@ pub(super) fn offer_live_retouch(app: &mut PhotocraftApp, d: &Drag) {
|
||||
let rest: Vec<_> = d.points.get(fed..).unwrap_or_default().iter().map(|q| photocraft_engine::paint::StrokePoint::new(q[0], q[1], q[2] as f32)).collect();
|
||||
// A refused offer (the brush changed mid-stroke, say) leaves the commit to render the stroke.
|
||||
match stroke {
|
||||
EngineStroke::Retouch(mut live) if !dab && (rest.is_empty() || live.push(&rest).is_ok()) => {
|
||||
let _ = app.session.offer_live_retouch(*live);
|
||||
}
|
||||
EngineStroke::Dab(mut live) if dab && (rest.is_empty() || live.push(&rest).is_ok()) => {
|
||||
let _ = app.session.offer_live_dab(*live);
|
||||
}
|
||||
EngineStroke::Retouch(live) if !dab => offer_retouch(app, live, &rest),
|
||||
EngineStroke::Dab(live) if dab => offer_dab(app, live, &rest),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn offer_retouch(app: &mut PhotocraftApp, mut live: Box<photocraft_engine::retouch_cmds::LiveRetouch>, rest: &[photocraft_engine::paint::StrokePoint]) {
|
||||
if rest.is_empty() || live.push(rest).is_ok() {
|
||||
let _ = app.session.offer_live_retouch(*live);
|
||||
}
|
||||
}
|
||||
|
||||
fn offer_dab(app: &mut PhotocraftApp, mut live: Box<photocraft_engine::retouch_cmds::LiveDab>, rest: &[photocraft_engine::paint::StrokePoint]) {
|
||||
if rest.is_empty() || live.push(rest).is_ok() {
|
||||
let _ = app.session.offer_live_dab(*live);
|
||||
}
|
||||
}
|
||||
|
||||
/// A pen tap (a drag still at its one press point when released) paints its dab at the highest
|
||||
/// pressure the pen reached during the contact, not just the first sample's (#1798). A mouse is
|
||||
/// unchanged at full pressure.
|
||||
|
||||
Reference in new issue
Block a user