Fix Pixel Align Stroke follow-up review cases

This commit is contained in:
Gabriel Heuser committed 2026-11-09 14:05:14 +02:00
1 parent 6960d17119
commit 4e3fa96aff
15 files changed
+284 -23

No files matched your search

+6
View File
@@ -59,6 +59,12 @@ pub(crate) fn layer_identity(layer: &Layer, h: &mut std::collections::hash_map::
}
}
LayerContent::Adjustment(a) => format!("{a:?}").hash(h),
LayerContent::Shape(shape) => {
layer.surface().map_or(0, |s| surface_fp(s, pin)).hash(h);
format!("{:?}{:?}{:?}{:?}", shape.path, shape.fill, shape.stroke, shape.live).hash(h);
(shape.pixel_align_stroke, shape.psd_coordinate_frame, shape.psd_raw.is_some()).hash(h);
(shape.density.to_bits(), shape.feather.to_bits()).hash(h);
}
_ => layer.surface().map_or(0, |s| surface_fp(s, pin)).hash(h),
}
if let Some(m) = &layer.mask {
+23
View File
@@ -4718,3 +4718,26 @@ fn pixel_align_psd_effect_layer_roi_matches_document_frame() {
}
}
}
#[test]
fn pixel_align_round2_effect_identity_tracks_alignment_provenance() {
use std::hash::Hasher;
let mut layer = Layer::new("shape", LayerContent::Shape(photocraft_doc::ShapeLayer::default()));
let key = |layer: &Layer| {
let mut h = std::collections::hash_map::DefaultHasher::new();
super::fx_cache::layer_identity(layer, &mut h, &mut |_| {});
h.finish()
};
let original = key(&layer);
let LayerContent::Shape(sh) = &mut layer.content else { panic!() };
sh.pixel_align_stroke = true;
let aligned = key(&layer);
assert_ne!(original, aligned);
let LayerContent::Shape(sh) = &mut layer.content else { panic!() };
sh.psd_coordinate_frame = Some([1000, 2000]);
let framed = key(&layer);
assert_ne!(aligned, framed);
let LayerContent::Shape(sh) = &mut layer.content else { panic!() };
sh.psd_raw = Some(std::sync::Arc::new(Vec::new()));
assert_ne!(framed, key(&layer));
}
+4
View File
@@ -78,7 +78,11 @@ fn edit_path(s: &mut Session, cmd: &str, p: &Value, label: &str, f: impl FnOnce(
let shape = layer.filter(|id| s.active().and_then(|d| d.doc.layer(*id)).is_some_and(|l| matches!(l.content, LayerContent::Shape(_))));
let path = match shape {
Some(id) => with_shape(s, id, label, |sh, _| {
let previous = sh.path.clone();
f(&mut sh.path).map_err(|e| bad(cmd, e))?;
if sh.path != previous {
sh.psd_coordinate_frame = None;
}
sh.live = None;
sh.psd_raw = None;
Ok(path_json(&sh.path))
+22 -3
View File
@@ -204,8 +204,15 @@ pub fn transform_shape(sh: &mut ShapeLayer, a: &Affine) {
sh.path = sh.path.transform(a);
let [m0, m1, m2, m3, tx, ty] = a.m;
// Only integer translations preserve the original quantization error per axis.
if m0 != 1.0 || m1 != 0.0 || m2 != 0.0 || m3 != 1.0 || !tx.is_finite() || !ty.is_finite() || tx != tx.round() || ty != ty.round() {
// Signed axis permutations preserve the original quantization error.
let near = |x: f64, target: f64| (x - target).abs() <= 1e-12;
let unit = |x: f64| near(x.abs(), 1.0);
let translation = tx.is_finite() && ty.is_finite() && near(tx, tx.round()) && near(ty, ty.round());
if translation && unit(m0) && unit(m3) && near(m1, 0.0) && near(m2, 0.0) {
// Translation or reflection keeps the original axes.
} else if translation && unit(m1) && unit(m2) && near(m0, 0.0) && near(m3, 0.0) {
sh.psd_coordinate_frame = sh.psd_coordinate_frame.map(|[w, h]| [h, w]);
} else {
sh.psd_coordinate_frame = None;
}
let axis_aligned = m1.abs() < 1e-12 && m2.abs() < 1e-12 && m0 > 0.0 && m3 > 0.0;
@@ -409,6 +416,9 @@ pub(crate) fn with_shape<R>(s: &mut Session, id: LayerId, label: &str, f: impl F
let LayerContent::Shape(mut sh) = std::mem::replace(&mut l.content, LayerContent::Fill(Fill::Solid(Color::BLACK))) else {
return Err(EngineError::Other(format!("layer {} is not a shape layer", id.0)));
};
if sh.psd_coordinate_frame.is_none() && sh.psd_raw.is_some() {
sh.psd_coordinate_frame = Some([snapshot.size.width, snapshot.size.height]);
}
let r = f(&mut sh, l);
if r.is_ok() {
refresh_shape(&snapshot, &mut sh);
@@ -537,7 +547,16 @@ pub(super) fn path_to_shape(s: &mut Session, p: &Value) -> Result<Value> {
Some(Value::String(n)) if !n.trim().is_empty() => Some(n.clone()),
Some(_) => return Err(bad(CMD, "`layerName` must be a name that isn't empty")),
};
let mut sh = ShapeLayer { path, fill, stroke, pixel_align_stroke, ..Default::default() };
let psd_coordinate_frame = if name == Some("layer") && p.get("path").is_none_or(Value::is_null) {
let st = s.active().ok_or(EngineError::NoDocument)?;
st.active_layer.and_then(|id| st.doc.layer(id)).and_then(|layer| match &layer.content {
LayerContent::Shape(source) => source.psd_coordinate_frame.or_else(|| source.psd_raw.as_ref().map(|_| [st.doc.size.width, st.doc.size.height])),
_ => None,
})
} else {
None
};
let mut sh = ShapeLayer { path, fill, stroke, pixel_align_stroke, psd_coordinate_frame, ..Default::default() };
let id = s.edit("New Shape Layer", |doc, active| {
refresh_shape(doc, &mut sh);
let name = layer_name.unwrap_or_else(|| doc.next_layer_name(default_name("path")));
+27
View File
@@ -212,3 +212,30 @@ fn pixel_align_psd_integer_translation_retains_coordinate_allowance() {
let LayerContent::Shape(fractional) = &s.active().unwrap().doc.layer(id).unwrap().content else { panic!("shape") };
assert!(fractional.psd_coordinate_frame.is_none());
}
#[test]
fn pixel_align_round2_grid_transforms_conversion_and_point_edits() {
use photocraft_doc::LayerContent;
let mut s = Session::new();
s.execute("file.new", json!({"width":1000,"height":2000})).unwrap();
s.execute("shape.create", json!({"rect":[10,10,60,60],"pixelAlignStroke":true})).unwrap();
let id = s.active().unwrap().active_layer.unwrap();
let LayerContent::Shape(sh) = &mut std::sync::Arc::make_mut(&mut s.active_mut().unwrap().doc).layer_mut(id).unwrap().content else { panic!() };
sh.psd_coordinate_frame = Some([1000, 2000]);
for (matrix, frame) in [(json!([-1, 0, 0, 1, 100, 0]), [1000, 2000]), (json!([0, 1, -1, 0, 100, 0]), [2000, 1000])] {
s.execute("shape.edit", json!({"layer":id.0,"transform":matrix})).unwrap();
let LayerContent::Shape(sh) = &s.active().unwrap().doc.layer(id).unwrap().content else { panic!() };
assert_eq!(sh.psd_coordinate_frame, Some(frame));
s.undo();
}
s.execute("path.toShape", json!({"name":"layer","pixelAlignStroke":true,"stroke":{"width":1}})).unwrap();
let copied = s.active().unwrap().active_layer.unwrap();
let LayerContent::Shape(sh) = &s.active().unwrap().doc.layer(copied).unwrap().content else { panic!() };
assert_eq!(sh.psd_coordinate_frame, Some([1000, 2000]));
s.execute("path.moveAnchors", json!({"name":"layer","layer":copied.0,"anchors":[[0,0]],"move":[0.00001,0]})).unwrap();
let LayerContent::Shape(sh) = &s.active().unwrap().doc.layer(copied).unwrap().content else { panic!() };
assert!(sh.psd_coordinate_frame.is_none());
s.undo();
let LayerContent::Shape(sh) = &s.active().unwrap().doc.layer(copied).unwrap().content else { panic!() };
assert_eq!(sh.psd_coordinate_frame, Some([1000, 2000]));
}
+13 -4
View File
@@ -447,7 +447,7 @@ impl Loader<'_> {
})
}
fn layer(&mut self, m: &LayerM, depth: usize) -> Result<Layer> {
fn layer(&mut self, m: &LayerM, depth: usize, frame: [u32; 2]) -> Result<Layer> {
if depth > MAX_GROUP_DEPTH {
return Err(too_deep());
}
@@ -457,10 +457,19 @@ impl Loader<'_> {
if let ContentM::Group { children: kids, .. } = &m.content {
children.reserve(kids.len());
for c in kids {
children.push(self.layer(c, depth + 1)?);
children.push(self.layer(c, depth + 1, frame)?);
}
}
self.layer_with(m, children)
let mut layer = self.layer_with(m, children)?;
// Older native files predate explicit PSD coordinate provenance.
if let LayerContent::Shape(shape) = &mut layer.content
&& shape.pixel_align_stroke
&& shape.psd_raw.is_some()
&& shape.psd_coordinate_frame.is_none()
{
shape.psd_coordinate_frame = Some(frame);
}
Ok(layer)
}
/// One layer, given its already converted group children.
@@ -622,7 +631,7 @@ impl Loader<'_> {
max_ids(&m.layers, 0, &mut max)?;
self.preserve_ids = reserve_ids_through(max);
}
let layers = m.layers.iter().map(|l| self.layer(l, 0)).collect::<Result<Vec<_>>>()?;
let layers = m.layers.iter().map(|l| self.layer(l, 0, [m.size.width, m.size.height])).collect::<Result<Vec<_>>>()?;
let mut channels = Vec::with_capacity(m.channels.len());
for c in &m.channels {
channels.push(self.channel(c)?);
+17
View File
@@ -1137,3 +1137,20 @@ fn pixel_align_stroke_roundtrips_and_defaults_for_legacy_files() {
let disabled_json = serde_json::to_value(disabled).unwrap();
assert!(disabled_json.get("pixel_align_stroke").is_none());
}
#[test]
fn pixel_align_round2_legacy_psd_provenance_is_migrated() {
let mut doc = rich_doc(ColorMode::Rgb, SampleType::U8);
let layer = Layer::new(
"legacy PSD",
LayerContent::Shape(photocraft_doc::ShapeLayer { pixel_align_stroke: true, psd_raw: Some(std::sync::Arc::new(vec![1, 2, 3])), ..Default::default() }),
);
let id = layer.id;
doc.layers.push(layer);
let bytes = save_to_bytes(&doc, &SaveOptions::default()).unwrap();
let loaded = load_from_bytes(&bytes).unwrap();
let LayerContent::Shape(sh) = &loaded.layer(id).unwrap().content else { panic!() };
assert_eq!(sh.psd_coordinate_frame, Some([doc.size.width, doc.size.height]));
let saved = save_to_bytes(&loaded, &SaveOptions::default()).unwrap();
assert_eq!(load_from_bytes(&saved).unwrap(), loaded);
}
+5 -1
View File
@@ -109,6 +109,7 @@ pub(crate) fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui, tool: Tool
o.stroke_width = enabled_stroke_width(o.stroke_width);
}
}
let previous_alignment_preference = o.pixel_align_stroke;
let alignment_edit = pixel_align_option(ui, &mut o.pixel_align_stroke, target.as_ref().map(|s| s.pixel_align_stroke), paint);
match tool {
Tool::Rectangle => {
@@ -190,10 +191,13 @@ pub(crate) fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui, tool: Tool
}
// A click can commit a numeric expression and toggle alignment in the same frame.
// Merge after the other controls so both changes reach the same history step.
edit = merge_pixel_alignment_edit(edit, alignment_edit);
edit = merge_pixel_alignment_edit(edit, alignment_edit.clone());
if let (Some(mut p), Some(s)) = (edit, &target) {
p["layer"] = json!(s.layer.0);
if let Err(e) = app.run("shape.edit", p) {
if alignment_edit.is_some() {
app.ui.tool_options.pixel_align_stroke = previous_alignment_preference;
}
app.ui.status = e;
app.ui.status_error = true;
recent = None;
@@ -197,6 +197,32 @@ fn new_document_preview(
} else {
let mut work = PreviewReduction::new(compiled, layout);
work.advance();
if !work.complete() {
// Keep the whole changing shape visible while exact document coverage is streamed.
// Cap this extra raster at 512 pixels per axis, independently of document dimensions.
let preview_factor = bounds.width().max(bounds.height()).div_ceil(512).max(layout.factor);
let size = [bounds.width().div_ceil(preview_factor) as usize, bounds.height().div_ceil(preview_factor) as usize];
let scale = 1.0 / f64::from(preview_factor);
let mut proxy = shape.clone();
proxy.path =
proxy.path.transform(&photocraft_geom::Affine { m: [scale, 0.0, 0.0, scale, -f64::from(bounds.x0) * scale, -f64::from(bounds.y0) * scale] });
proxy.live = None;
proxy.pixel_align_stroke = false;
proxy.feather *= scale as f32;
if let Some(stroke) = &mut proxy.stroke {
stroke.width *= scale as f32;
}
let output = photocraft_geom::Rect::new(0, 0, size[0] as i32, size[1] as i32);
let frame = photocraft_geom::Rect::new(
((f64::from(canvas.x0) - f64::from(bounds.x0)) * scale).floor() as i32,
((f64::from(canvas.y0) - f64::from(bounds.y0)) * scale).floor() as i32,
((f64::from(canvas.x1) - f64::from(bounds.x0)) * scale).ceil() as i32,
((f64::from(canvas.y1) - f64::from(bounds.y0)) * scale).ceil() as i32,
);
let fallback = photocraft_vector::CompiledShape::with_frames(&proxy, photocraft_vector::DEFAULT_TOLERANCE, output, frame).render_rgba(output);
let bytes: Vec<u8> = fallback.iter().flat_map(|p| p.map(|v| (v.clamp(0.0, 1.0) * 255.0).round() as u8)).collect();
work.set_fallback(egui::ColorImage::from_rgba_unmultiplied(size, &bytes));
}
let image = work.image();
let reduction = (!work.complete()).then(|| Arc::new(Mutex::new(work)));
(image, reduction, egui::TextureOptions::LINEAR)
@@ -37,13 +37,29 @@ pub(super) struct PreviewReduction {
compiled: CompiledShape,
layout: PreviewLayout,
sums: Vec<[f64; 4]>,
weights: Vec<f64>,
fallback: Option<egui::ColorImage>,
cursor: [i32; 2],
}
impl PreviewReduction {
/// Allocate only the validated output grid, retaining the compiled document renderer.
pub fn new(compiled: CompiledShape, layout: PreviewLayout) -> Self {
Self { compiled, layout, sums: vec![[0.0; 4]; layout.size[0] * layout.size[1]], cursor: [layout.bounds.x0, layout.bounds.y0] }
Self {
compiled,
layout,
sums: vec![[0.0; 4]; layout.size[0] * layout.size[1]],
weights: vec![0.0; layout.size[0] * layout.size[1]],
fallback: None,
cursor: [layout.bounds.x0, layout.bounds.y0],
}
}
/// A bounded full-shape approximation fills pixels not yet visited by native reduction.
pub fn set_fallback(&mut self, image: egui::ColorImage) {
if image.size.into_iter().all(|side| side > 0) && image.size[0] <= self.layout.size[0] && image.size[1] <= self.layout.size[1] {
self.fallback = Some(image);
}
}
/// Every native source tile has contributed to the reduced image.
@@ -85,6 +101,9 @@ impl PreviewReduction {
let y = i64::from(tile.y0) - i64::from(self.layout.bounds.y0) + (i / tile.width() as usize) as i64;
let index = (y as usize / factor) * self.layout.size[0] + x as usize / factor;
let Some(sum) = self.sums.get_mut(index) else { continue };
if let Some(weight) = self.weights.get_mut(index) {
*weight += 1.0;
}
let alpha = f64::from(pixel[3].clamp(0.0, 1.0));
for channel in 0..3 {
sum[channel] += f64::from(pixel[channel].clamp(0.0, 1.0)) * alpha;
@@ -93,13 +112,30 @@ impl PreviewReduction {
}
}
/// Unvisited source pixels and partial final footprints are transparent, not stretched.
/// Blend the complete approximation into unvisited pixels; completion uses native sums only.
pub fn image(&self) -> egui::ColorImage {
let area = f64::from(self.layout.factor).powi(2);
let pixels = self
.sums
.iter()
.map(|sum| {
.enumerate()
.map(|(index, sum)| {
let mut sum = *sum;
if !self.complete()
&& let Some(pixel) = self.fallback.as_ref().and_then(|image| {
let x = index % self.layout.size[0] * image.size[0] / self.layout.size[0];
let y = index / self.layout.size[0] * image.size[1] / self.layout.size[1];
image.pixels.get(y * image.size[0] + x)
})
{
let missing = (area - self.weights.get(index).copied().unwrap_or(0.0)).max(0.0);
let color = pixel.to_srgba_unmultiplied();
let alpha = f64::from(color[3]) / 255.0;
for channel in 0..3 {
sum[channel] += f64::from(color[channel]) / 255.0 * alpha * missing;
}
sum[3] += alpha * missing;
}
if sum[3] <= 0.0 {
return egui::Color32::TRANSPARENT;
}
@@ -1027,3 +1027,32 @@ fn pixel_align_preview_views_progress_independently_and_release_hidden_view() {
assert!(ctx.data(|d| d.get_temp::<DocumentDragCache>(ids[1])).is_none());
assert!(ctx.data(|d| d.get_temp::<DocumentDragCache>(ids[0])).is_some());
}
#[test]
fn pixel_align_round2_changing_preview_has_complete_fill() {
let ctx = egui::Context::default();
let mut shape = photocraft_doc::ShapeLayer {
path: photocraft_vector::shapes::rect(0.0, 0.0, 2050.0, 2050.0),
fill: Some(photocraft_doc::Fill::Solid(photocraft_doc::Color::BLACK)),
pixel_align_stroke: true,
..Default::default()
};
for x in [0.0, 1.0, 2.0] {
shape.path = photocraft_vector::shapes::rect(x, 0.0, 2050.0, 2050.0);
let mut output = ctx.run_ui(Default::default(), |ui| {
let painter = ui.ctx().layer_painter(egui::LayerId::background());
let cache = new_document_preview(
&painter,
&shape,
photocraft_geom::Rect::new(0, 0, 2200, 2200),
photocraft_geom::Rect::new(0, 0, 2200, 2200),
egui::TextureOptions::LINEAR,
)
.unwrap();
assert!(cache.reduction.is_some());
let image = cache.reduction.as_ref().unwrap().lock().unwrap().image();
assert!(image.pixels[(image.size[1] - 5) * image.size[0] + image.size[0] - 5].a() > 240);
});
output.textures_delta.clear();
}
}
@@ -1169,3 +1169,18 @@ fn pixel_align_properties_keeps_pending_live_geometry_expression() {
assert_eq!(shape(h.state()), &after);
}
}
#[test]
fn pixel_align_round2_locked_shape_toolbar_restores_preference() {
let mut app = app("rgb", 8);
app.run("shape.create", json!({"rect":[20,20,60,60],"pixelAlignStroke":false})).unwrap();
let id = app.session.active().unwrap().active_layer.unwrap();
std::sync::Arc::make_mut(&mut app.session.active_mut().unwrap().doc).layer_mut(id).unwrap().locks.all = true;
app.ui.tool_options.pixel_align_stroke = false;
let mut h = harness(app, false);
h.get_by_label("Pixel Align Stroke").click();
h.run_steps(3);
assert!(h.state().ui.status_error);
assert!(!h.state().ui.tool_options.pixel_align_stroke);
assert!(!shape(h.state()).pixel_align_stroke);
}
+12 -4
View File
@@ -13,11 +13,10 @@ fn same(a: f64, b: f64) -> bool {
/// A PSD path is rounded to signed 8.24 fractions of the document dimensions. Only
/// imported PSD geometry gets its half-quantum allowance; native paths keep the strict epsilon.
pub(crate) fn coordinate_tolerance(shape: &ShapeLayer, canvas: Rect) -> (f64, f64) {
pub(crate) fn coordinate_tolerance(shape: &ShapeLayer, _canvas: Rect) -> (f64, f64) {
let [width, height] = match shape.psd_coordinate_frame {
Some(frame) => frame,
// Compatibility with shapes loaded from older native files.
None if shape.psd_raw.is_some() => [canvas.width(), canvas.height()],
// Import and native-load migration supply provenance. A render ROI cannot.
None => return (ALIGN_EPSILON, ALIGN_EPSILON),
};
// Valid PSB dimensions need less than 0.009 px; cap hostile oversized frames too.
@@ -265,13 +264,22 @@ fn equivalent_live_path(expected: &Path, stored: &Path) -> bool {
if !a.closed || !b.closed || a.op != b.op || a.knots.len() != b.knots.len() {
return false;
}
let matching = |left: &[photocraft_doc::Knot], right: &[photocraft_doc::Knot]| {
left.iter().zip(right).all(|(l, r)| {
l.smooth == r.smooth
&& [l.anchor, l.in_ctrl, l.out_ctrl].into_iter().zip([r.anchor, r.in_ctrl, r.out_ctrl]).all(|(p, q)| same(p.x, q.x) && same(p.y, q.y))
})
};
if matching(&a.knots, &b.knots) {
return true;
}
let mut reversed = a.knots.clone();
reversed.reverse();
for knot in &mut reversed {
std::mem::swap(&mut knot.in_ctrl, &mut knot.out_ctrl);
}
for _ in 0..reversed.len() {
if reversed == b.knots {
if matching(&reversed, &b.knots) {
return true;
}
reversed.rotate_left(1);
+35 -1
View File
@@ -1455,7 +1455,8 @@ fn pixel_alignment_psd_allowance_is_axis_specific_and_render_only() {
path: Path::new(vec![Subpath::polyline(&[(10.0, quantize(20.0, 300_000.0)), (54.0, quantize(20.0, 300_000.0))])]),
pixel_align_stroke: true,
stroke: Some(ShapeStroke { width: 1.0, ..Default::default() }),
// The renderer uses only the retained-block marker; decoded coordinates remain authoritative.
// Provenance is independent of the render region and raw export block.
psd_coordinate_frame: Some([100, 300_000]),
psd_raw: Some(std::sync::Arc::new(Vec::new())),
..Default::default()
};
@@ -1580,3 +1581,36 @@ fn pixel_alignment_reflected_live_line_accepts_reversed_outline_but_rejects_stal
shape.path.subpaths[0].knots[0].out_ctrl.x += 0.25;
assert!(pixel_aligned_line_fill_path(&shape).is_none());
}
#[test]
fn pixel_alignment_round2_quarter_turn_accepts_roundoff_not_stale_controls() {
let live = photocraft_doc::LiveShape::Line { from: [0.0, 20.0], to: [40.0, 20.0], weight: 1.0 };
let a = photocraft_geom::Affine::rotate(std::f64::consts::FRAC_PI_2).then(&photocraft_geom::Affine::translate(40.0, 0.0));
let p = a.apply(photocraft_geom::Point::new(0.0, 20.0));
let q = a.apply(photocraft_geom::Point::new(40.0, 20.0));
let mut sh = ShapeLayer {
path: shapes::live_path(&live).transform(&a),
live: Some(photocraft_doc::LiveShape::Line { from: [p.x, p.y], to: [q.x, q.y], weight: 1.0 }),
fill: Some(Fill::Solid(Color::BLACK)),
pixel_align_stroke: true,
..Default::default()
};
assert!(pixel_aligned_line_fill_path(&sh).is_some());
sh.path.subpaths[0].knots[0].out_ctrl.x += 0.001;
assert!(pixel_aligned_line_fill_path(&sh).is_none());
}
#[test]
fn pixel_alignment_round2_missing_provenance_does_not_depend_on_roi() {
let sh = ShapeLayer {
path: shapes::rect(10.00001, 10.00001, 60.0, 60.0),
stroke: Some(ShapeStroke { width: 1.0, ..Default::default() }),
pixel_align_stroke: true,
psd_raw: Some(std::sync::Arc::new(Vec::new())),
..Default::default()
};
let clip = Rect::new(0, 0, 80, 80);
let a = CompiledShape::new(&sh, DEFAULT_TOLERANCE, clip).render_rgba(clip);
let b = CompiledShape::with_frames(&sh, DEFAULT_TOLERANCE, clip, Rect::new(0, 0, 1000, 1000)).render_rgba(clip);
assert_eq!(a, b);
}
+11 -7
View File
@@ -23,7 +23,9 @@ the legacy renderer. Native projects serialize the option only when enabled.
PSD shapes map it to the `vstk` descriptor's `strokeStyleStrokeAdjust` boolean
([Adobe Generator documentation](https://github.com/adobe-photoshop/generator-core/wiki/JSON-event-format/6a7f39780beb75b0f9988779975201f44e6978f2));
a missing field defaults to false. Changing only this flag preserves unknown
stroke descriptor entries. This mapping does not claim pixel-for-pixel Photoshop
stroke descriptor entries when the imported fill state also matches. If a shape
has `vstk` but no fill block, normalizing its fill state can rebuild the descriptor
and discard unknown stroke entries. This mapping does not claim pixel-for-pixel Photoshop
rendering parity.
## Rendering policy
@@ -68,7 +70,8 @@ Rectangle clipping and normal coverage account for that error at render time,
while the original path still determines dash lengths and phase. Native paths
retain the strict floating-point epsilon; genuinely fractional centerlines beyond
the allowance retain legacy rendering. Appearance edits preserve the allowance
while the original PSD path block is retained.
using saved coordinate provenance, independently of the raw PSD block. Integer-grid
reflections and quarter-turns retain it; point edits that change geometry clear it.
## Deliberate limits
@@ -87,13 +90,14 @@ so zoom cannot make a fractional-width stroke eligible. Integer grid zooms use
nearest filtering; rotated or fractional views filter the document coverage.
The preview texture is capped at 2048 pixels per dimension. Larger visible bounds
are reduced by box-filtering the original aligned document pixels, using small
native tiles and premultiplied colour averages. No alignment is disabled at the
size threshold, and stored geometry and dash phase remain unchanged. Very large
native tiles and premultiplied colour averages. The completed preview retains
alignment across the size threshold; stored geometry and dash phase remain unchanged. Very large
previews complete progressively: each draw pass processes at most 4,194,304 source
pixels, requests another frame if needed, and releases the working sums when
complete or when the drag ends. While dragging such a large shape, its painted preview can be partial
until the remaining tiles have been processed; the vector feedback outline stays
visible. This bounds both allocation and per-frame raster work, including on WASM.
complete or when the drag ends. A complete approximation, rasterized at the bounded
texture size, fills unprocessed pixels while geometry changes. Native coverage
replaces it as reduction completes. This bounds both allocation and per-frame
raster work, including on WASM.
Filled Line/ArrowLine alignment requires live parameters matching the current
path, and is disabled for density/feather masks. A point edit or transform that