From 1106a8f667b9eccf81819c93625f61b8e090e14c Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 20 Nov 2026 19:28:51 -0800 Subject: [PATCH] Tests: check Revolve's surface alpha under colored lights in absolute terms colored_revolve_faces_leave_no_alpha_holes_at_one_to_one compared each representation only with its own 3x render, so a 60% opacity lost or applied twice by SVG or PDF import passed at both scales. The test now also reads the alpha inside the body: 153 within 3 levels with a fill opacity of 60%, 214 within 3 levels with 60% gradient stops (front and back faces at 60% each), and 255 when opaque. --- crates/engine/tests/it/three_d_light_color.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/crates/engine/tests/it/three_d_light_color.rs b/crates/engine/tests/it/three_d_light_color.rs index 40752a2fce..be06539537 100644 --- a/crates/engine/tests/it/three_d_light_color.rs +++ b/crates/engine/tests/it/three_d_light_color.rs @@ -719,7 +719,9 @@ fn alpha_against_supersampled(d: &Document) -> (usize, usize, u8, usize, Vec 10_000, "{name} {of}: {measured} pixels inside"); + // The 3x comparison passes when an opacity is lost or doubled at both scales, so the + // surface's alpha is also checked against the value it should have. + // With 60% gradient stops, each face takes the stops' opacity, so where the front and + // back of the body overlap the alpha is 1 - 0.4 * 0.4 of 255. + let alpha = render(&d).pixel(150, 200)[3]; + let expected = if name.ends_with("fill at 60%") { + 150..=156 + } else if name.ends_with("gradient at 60%") { + 211..=217 + } else { + 255..=255 + }; + if !expected.contains(&alpha) { + failures.push(format!("{name} {of}: surface alpha {alpha}, expected {expected:?}")); + } if off > 0 || past > 0 { failures.push(format!("{name} {of}: of {measured} pixels, {off} off (at most {worst}), {past} past the outline: {first:?}")); }