mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-04 19:41:36 -05:00
Image Trace sampler test: a step runs until the press lifecycle reported its events
run_ui stopped stepping once egui had seen every pointer event of the step. The press lifecycle reports one phase a pass, so a pass that brings a release and the next press (two clicks in one frame) reports the press's Down one pass later and holds its release for the pass after that, asking for a repaint. The step ended before that pass, and the second click of review_597048_two_ordinary_clicks_in_one_frame_survive_ sampler_correction never reached the tool, so the group did not isolate. It passed before by accident: with craft-libs a4b6d3b6ca every other frame ran a second pass, and the held release landed in it. With 6fcf61c81 each of these frames runs one pass. The step now also counts the phases owed and runs empty frames until the passes have caught up.
This commit is contained in:
@@ -31,13 +31,15 @@ fn pointer_events(events: &[Event]) -> usize {
|
||||
events.iter().filter(|event| matches!(event, Event::PointerMoved(_) | Event::PointerButton { .. })).count()
|
||||
}
|
||||
|
||||
/// One step of the app: the frame of `raw`, then empty frames at its time until all its pointer events arrived. A frame
|
||||
/// can take more than one pass, and egui gives the frame's events to its first; the framework gives a pass one press,
|
||||
/// as its last pointer event, and holds the events after it for the next frame ("Input pacing", one press per pass).
|
||||
/// One step of the app: the frame of `raw`, then empty frames at its time until all its pointer events arrived and the
|
||||
/// press lifecycle reported them. A frame can take more than one pass, and egui gives the frame's events to its first;
|
||||
/// the framework gives a pass one press, as its last pointer event, and holds the events after it for the next frame
|
||||
/// ("Input pacing", one press per pass). The lifecycle reports one phase a pass: a pass that brings a release and the
|
||||
/// next press reports the press's Down in the next pass, and the release that follows it one pass later still.
|
||||
fn run_ui(app: &mut VectorcraftApp, ctx: &egui::Context, mut raw: RawInput) -> egui::FullOutput {
|
||||
let (sent, time, screen_rect) = (pointer_events(&raw.events), raw.time, raw.screen_rect);
|
||||
let mut frames = Vec::new();
|
||||
let mut arrived = 0;
|
||||
let (mut arrived, mut owed) = (0, 0);
|
||||
loop {
|
||||
let mut first = None;
|
||||
let out = ctx.run_ui(raw, |ui| {
|
||||
@@ -49,8 +51,10 @@ fn run_ui(app: &mut VectorcraftApp, ctx: &egui::Context, mut raw: RawInput) -> e
|
||||
});
|
||||
let first = first.expect("a frame runs a pass");
|
||||
arrived += pointer_events(&first.events);
|
||||
let buttons = first.events.iter().filter(|event| matches!(event, Event::PointerButton { .. })).count();
|
||||
owed = (owed + buttons).saturating_sub(out.platform_output.num_completed_passes);
|
||||
frames.push(first);
|
||||
if arrived >= sent {
|
||||
if arrived >= sent && owed == 0 {
|
||||
FRAME_INPUT.with(|input| *input.borrow_mut() = Some((frames, ctx.cumulative_pass_nr())));
|
||||
return out;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user