mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-27 02:22:14 +00:00
Canvas redraw: the let-go test receives the worker's job; the fit cache's key documented
Review follow-ups: - The test that art measured for an edit not drawn on this thread is let go first checks that measuring the edit through the canvas's renderer holds art, so a measure that held nothing can't pass it. Its worker is a test channel whose job the test receives, in place of a real thread's pending job, which a finished frame could clear. Taking out either let_go_of_measured fails it. - fit_has_art's comment says why its one kept answer can't be stale: a document's uid is never reused in the process and its revision only moves forward.
This commit is contained in:
@@ -10693,14 +10693,23 @@ fn art_measured_for_an_edit_not_drawn_here_is_let_go() {
|
||||
app.run("effect.apply", json!({"effect": "threeD.extrude", "ids": [id], "params": {"depth": 60.0}})).unwrap();
|
||||
let ctx = egui::Context::default();
|
||||
shapes(&mut app, &ctx);
|
||||
// A worker whose jobs the test receives: none finishes unless the test says so.
|
||||
let mut jobs = None;
|
||||
if worker {
|
||||
app.canvas.worker = crate::render_worker::Worker::spawn(ctx.clone());
|
||||
let (w, rx, done) = crate::render_worker::Worker::test_channel();
|
||||
app.canvas.worker = Some(w);
|
||||
jobs = Some((rx, done));
|
||||
app.canvas.last_ms = 100.0;
|
||||
}
|
||||
app.run("effect.setParams", json!({"ids": [id], "index": 0, "item": null, "params": {"depth": 5.0}})).unwrap();
|
||||
// Measured through the canvas's renderer, the edit holds the art made for it.
|
||||
let (shown, opts) = app.canvas.shown.clone().unwrap();
|
||||
let now = app.session.active().unwrap().doc.clone();
|
||||
app.canvas.renderer.changed(&shown, &now, &opts);
|
||||
assert!(app.canvas.renderer.measured_bytes() > 0, "worker {worker}: art held");
|
||||
shapes(&mut app, &ctx);
|
||||
if worker {
|
||||
assert!(app.canvas.worker.as_ref().is_some_and(|w| w.pending.is_some()), "the worker draws it");
|
||||
if let Some((rx, _)) = &jobs {
|
||||
assert!(rx.try_recv().is_ok(), "the worker draws it");
|
||||
}
|
||||
assert_eq!(app.canvas.renderer.measured_bytes(), 0, "worker {worker}");
|
||||
app.canvas.worker = None;
|
||||
|
||||
@@ -314,7 +314,10 @@ pub struct MenuFacts {
|
||||
|
||||
/// Whether an unlocked artboard of `indices` has art that Fit to Artwork Bounds fits it to. The
|
||||
/// answer is kept for the document's revision: the canvas menu asks on every frame it is open
|
||||
/// without its [`MenuFacts`], and measuring builds the solids of 3D effects.
|
||||
/// without its [`MenuFacts`], and measuring builds the solids of 3D effects. One answer is kept,
|
||||
/// the last asked: a document's uid is never given to another in the process, and its revision
|
||||
/// only moves forward (a document read again, or a batch rolled back, moves past it), so a kept
|
||||
/// answer is never another document's or another state's.
|
||||
pub(crate) fn fit_has_art(app: &VectorcraftApp, indices: &[usize]) -> bool {
|
||||
/// The document's uid and revision, the artboards asked about, and the answer.
|
||||
type Kept = Option<(u64, u64, Vec<usize>, bool)>;
|
||||
|
||||
Reference in New Issue
Block a user