Render: redraw the effects on a shadowed radial or mirror repeat's copies

A radial or mirror repeat with an effect of its own, such as a drop shadow,
takes its bounds from the object-effects branch, which falls back to
`own_box`. `own_box` measured the placed steps of a spine-aligned blend but
not the rotated or reflected copies of a repeat, so moving such a repeat left
the copies' geometry effects outside the redrawn area. `own_box` now unions
a repeat's placed copies as #9936 does in `cull_bounds_in`.

`placed_live_effect_bounds` now looks for effects below the node only: the
node's own effects run on the placed whole and its callers measure them, so a
repeat or blend whose only effect is its own no longer expands its copies or
steps to measure them.
This commit is contained in:
dotCooCoo committed 2026-11-28 13:59:20 -08:00
1 parent 170d491cb9
commit 06c260f637
2 files changed
+46 -10

No files matched your search

+13 -10
View File
@@ -843,12 +843,13 @@ pub(crate) fn with_own_raster_reach(symbols: &SymbolBoxes, n: &Node, b: Rect) ->
b.inflate(o, o)
}
/// `n`'s own box, type's grown to hold its glyphs ([`glyphs_box`]) and a blend's to hold its
/// spine-placed keys and steps: what it draws when its object effects leave it as it is
/// (Revolve builds no art from type).
/// `n`'s own box, type's grown to hold its glyphs ([`glyphs_box`]), a blend's to hold its
/// spine-placed keys and steps and a radial or mirror repeat's to hold its placed copies: what it
/// draws when its object effects leave it as it is (Revolve builds no art from type).
fn own_box(symbols: &SymbolBoxes, n: &Node) -> Option<Rect> {
let b = match &n.kind {
NodeKind::Blend { .. } => vectorcraft_geom::union_opt(n.reach_bounds_with(symbols), placed_live_effect_bounds(symbols, n)),
NodeKind::Repeat(_) => vectorcraft_geom::union_opt(n.visual_bounds_with(symbols), placed_live_effect_bounds(symbols, n)),
_ => n.visual_bounds_with(symbols),
}?;
Some(match &n.kind {
@@ -860,7 +861,8 @@ fn own_box(symbols: &SymbolBoxes, n: &Node) -> Option<Rect> {
/// A radial or mirror repeat's copies or a spine-aligned blend's steps, measured after they are
/// rotated or reflected. Geometry effects run on the placed shapes, so their reach on the source
/// need not cover what they paint.
/// Without effects, the renderer keeps the quick bounds without evaluating the copies or steps.
/// Without effects inside it, the renderer keeps the quick bounds without evaluating the copies or
/// steps; `n`'s own effects run on the placed whole and are measured by the caller.
fn placed_live_effect_bounds(symbols: &SymbolBoxes, n: &Node) -> Option<Rect> {
match &n.kind {
NodeKind::Blend { spec, .. } if spec.orientation == vectorcraft_doc::BlendOrientation::AlignToPath => {}
@@ -869,12 +871,13 @@ fn placed_live_effect_bounds(symbols: &SymbolBoxes, n: &Node) -> Option<Rect> {
}
let mut has_effects = false;
n.walk(&mut |c| {
has_effects |= has_fx(c)
|| has_object_fx(c)
|| match &c.kind {
NodeKind::SymbolInstance { symbol, .. } => symbols.has_effects(symbol),
_ => false,
};
has_effects |= !std::ptr::eq(c, n)
&& (has_fx(c)
|| has_object_fx(c)
|| match &c.kind {
NodeKind::SymbolInstance { symbol, .. } => symbols.has_effects(symbol),
_ => false,
});
});
if !has_effects {
return None;
+33
View File
@@ -227,6 +227,39 @@ fn moving_a_slanted_mirror_repeat_redraws_the_effects_on_its_reflected_copy() {
}
}
#[test]
fn moving_a_shadowed_radial_or_mirror_repeat_redraws_the_effects_on_its_copies() {
for radial in [true, false] {
let mut old = Document::new(110.0, 80.0);
let source_id = old.alloc_id();
let mut source = Node::path(
source_id,
shapes::rectangle(Rect::new(47.0, 25.0, 49.0, 45.0)),
Appearance::basic(Paint::solid(Color::BLACK), Paint::None, 0.0),
);
source.appearance.effects.push(vectorcraft_doc::Effect {
id: "distort.transform".into(),
params: serde_json::json!({"scaleH": 400, "scaleV": 100, "reference": 4}),
visible: true,
});
let repeat = if radial {
vectorcraft_doc::RepeatSpec::radial(vec![Arc::new(source)], 4, Some(12.0))
} else {
vectorcraft_doc::RepeatSpec::mirror(vec![Arc::new(source)], 45.0, 6.0)
};
let id = old.alloc_id();
let mut node = Node::new(id, vectorcraft_doc::NodeKind::Repeat(repeat));
// The repeat's own effect sends its bounds through the object-effects branch.
node.appearance.effects.push(shadow());
old.insert(Some(old.layers[0].id), 0, node).unwrap();
let mut moved = old.clone();
moved.node_mut(id).unwrap().transform(Affine::translate((3.0, 4.0)), false);
// A partial redraw must reproduce the whole frame, both on the move and on Undo.
area(redraw(&old, &moved));
area(redraw(&moved, &old));
}
}
#[test]
fn adding_removing_and_restacking_change_those_objects() {
let (old, [loose, _, _, _, other]) = document();