From 872c85bf7d8df4dd8be043f909e2b231e31777d9 Mon Sep 17 00:00:00 2001 From: samhyun Date: Fri, 30 Oct 2026 09:13:26 +0900 Subject: [PATCH] M8: review on #1583: the too-large margin test asserts the capped sum The test only checked for a large finite margin, which the old largest-effect margin (1e308) passed as well. It now asserts the two capped reaches added up, so it fails on a return to either the old maximum or an overflowing sum. Co-Authored-By: Claude Opus 5.5 --- crates/render/src/draw.rs | 2 +- crates/render/src/retained_tests.rs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/render/src/draw.rs b/crates/render/src/draw.rs index a30c7bb01..97ff3ad83 100644 --- a/crates/render/src/draw.rs +++ b/crates/render/src/draw.rs @@ -474,7 +474,7 @@ pub(crate) fn bounds_within<'a>( /// The most one effect counts for in [`effect_margin`] (document units): far past any view, and /// sums of any number of them stay finite. -const MAX_REACH: f64 = 1e12; +pub(crate) const MAX_REACH: f64 = 1e12; /// How far (document units) effects that read outside a node's paint bounds reach: blurs, glass, /// drop shadows and texture. Culling and partial renders keep this much margin. diff --git a/crates/render/src/retained_tests.rs b/crates/render/src/retained_tests.rs index bdc1be196..e6c09ec5c 100644 --- a/crates/render/src/retained_tests.rs +++ b/crates/render/src/retained_tests.rs @@ -436,14 +436,15 @@ fn a_shadow_cast_from_a_blurred_layer_draws_the_same_in_a_cut_view() { assert_within(&part, &one, 390, 2, "the shadow of a blurred layer above the view"); } -/// Reaches too large to add (texture of 1e308, twice) still keep a margin, not none. +/// Reaches too large to add (texture of 1e308, twice) each count up to the cap and add up: a margin +/// that stays finite, not none, and not the largest one alone. #[test] fn effect_margins_too_large_to_add_stay_large() { let mut n = Node::new(NodeId(1), NodeKind::Rectangle, "T", 10.0, 10.0); let t = figcraft_doc::Texture { radius: 1e308, ..Default::default() }; n.effects = vec![Effect { kind: EffectKind::Texture(t.clone()), visible: true }, Effect { kind: EffectKind::Texture(t), visible: true }]; let m = crate::draw::effect_margin(&n); - assert!(m.is_finite() && m > 1e6, "{m}"); + assert_eq!(m, 2.0 * crate::draw::MAX_REACH); } /// Every channel of `a` within `tol` of the same channel of `b` from row `rows_down` on.