#882: pixel-exact Composition viewer at 100 % and above

Problem: the viewer blurred hard edges even at Full resolution and 100 %
(reported on Discord). The frame rect was centred without snapping to
physical pixels, so bilinear sampling blended neighbouring pixels at 1:1
(worst at 125 %/150 % display scaling); More Accurate also magnified
bilinearly, so 200 %+ and lower resolutions were smoothed; and Zoom In /
Zoom Out stepped in points, so at 125 % scaling they never reached 100 %.

Fix: snap the frame origin (and the ViewerMap overlays use) to the
physical pixel grid; magnify with nearest in both Zoom Quality modes
(CPU texture options and the GPU frame sampler), keeping the averaged
minification below 100 % (#417); the snapshot texture follows the same
options; Zoom In / Out step through screen-pixel magnifications.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
vangel76
2026-10-11 18:50:53 +02:00
co-authored by Claude Opus 5.5
parent 67434e9038
commit 8ac8612ace
5 changed files with 105 additions and 14 deletions
+22
View File
@@ -1948,3 +1948,25 @@ fn vertex_tools_edit_motion_path_keyframes() {
click(&mut h, quarter);
assert_eq!(keys(&h).len(), 3);
}
/// #882: at 100 % (and 200 %) on a scaled display the frame's corner sits on a physical pixel, so
/// every comp pixel covers whole screen pixels instead of being blended with its neighbour.
#[test]
fn frame_sits_on_the_physical_pixel_grid() {
for ppp in [1.0f32, 1.25, 1.5] {
let mut s = Session::default();
s.execute("comp.new", json!({"name": "Grid", "width": 301, "height": 201, "duration": 1})).unwrap();
let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1000.0)).with_pixels_per_point(ppp).build_eframe(move |_| EffectcraftApp::new(s));
h.run_steps(3);
for (mag, pan) in [(1.0f32, [0.3f32, 0.37]), (2.0, [-0.45, 0.2])] {
h.state_mut().ui.viewer.zoom = Some(mag / ppp);
h.state_mut().ui.viewer.pan = pan;
h.run_steps(2);
let c = rect(&h, "viewer.comp");
for v in [c.min.x * ppp, c.min.y * ppp] {
assert!((v - v.round()).abs() < 1e-3, "ppp {ppp}, {mag}×: corner at {v} physical px");
}
assert!((c.width() * ppp - 301.0 * mag).abs() < 1e-2, "ppp {ppp}, {mag}×: {} physical px wide", c.width() * ppp);
}
}
}