M8: turning soft proof on or off redraws the image around the view

This commit is contained in:
bflatastic committed 2026-11-17 18:06:05 +07:00
1 parent c391f13ccd
commit a7355eed5e
2 files changed
+13 -5

No files matched your search

+9 -5
View File
@@ -181,8 +181,9 @@ fn same_view(a: &View, b: &View) -> bool {
#[derive(Default)]
pub struct Surround {
retained: Retained,
/// The file, page and view of the image handed over last.
of: Option<(u64, NodeId, View)>,
/// The file, page and view of the image handed over last, and whether it was soft-proofed
/// (marked after the render, so the kept image can't tell).
of: Option<(u64, NodeId, View, bool)>,
}
impl Surround {
@@ -196,21 +197,24 @@ impl Surround {
}
let want = surround_view(&job.view);
let view = match &self.of {
Some((uid, page, have))
Some((uid, page, have, _))
if *uid == job.uid && *page == job.page && have.scale.to_bits() == want.scale.to_bits() && reaches(have, &job.view) =>
{
have.clone()
}
_ => want,
};
let same = self.of.as_ref().is_some_and(|(uid, page, have)| *uid == job.uid && *page == job.page && same_view(have, &view));
let same = self
.of
.as_ref()
.is_some_and(|(uid, page, have, proof)| *uid == job.uid && *page == job.page && *proof == job.proof && same_view(have, &view));
let t0 = Instant::now();
let d = guarded(&mut self.retained, |r| {
let (snapped, pix, work) = r.render(&job.doc, job.page, &view, &options(job))?;
(!(same && work == Work::Reused)).then(|| done(job, snapped, pix, work, t0.elapsed().as_secs_f64() * 1000.0, true))
});
if d.is_some() {
self.of = Some((job.uid, job.page, view));
self.of = Some((job.uid, job.page, view, job.proof));
}
d
}
@@ -52,6 +52,10 @@ fn the_image_around_the_view_is_kept_for_small_pans_and_moved_for_far_ones() {
let ds = s.ds().unwrap();
let edited = job(&ds.doc, ds.page, ds.uid, view_at((570.0, 150.0), 1.0, 400, 300));
assert!(matches!(around.render(&edited).expect("after an edit").work, Work::Partial { .. }));
// Soft proof marks the image after it renders: turning it on or off hands over a new one.
assert!(around.render(&Job { proof: true, ..edited.clone() }).is_some(), "proof on");
assert!(around.render(&Job { proof: true, ..edited.clone() }).is_none());
assert!(around.render(&edited).is_some(), "proof off");
// Another zoom starts over; pixel preview has none.
let zoomed = job(&ds.doc, ds.page, ds.uid, view_at((570.0, 150.0), 2.0, 400, 300));
assert_eq!(around.render(&zoomed).expect("another zoom").work, Work::Full);