ElyPDF: the old-tile test checks painted area covers the shown page (R2.6); shorter comments in patch 0041

This commit is contained in:
ZacharyZhang-NY committed 2026-10-09 07:25:55 -04:00
1 parent 3c6faf9a6e
commit cc589a07b3
8 files changed
+29 -9

No files matched your search

+3 -2
View File
@@ -70,10 +70,11 @@ fn drawn_tile(image: Arc<RenderImage>, page: usize, view: gpui::Entity<PdfView>)
|_, _, _| {},
move |bounds, _, window, cx| match window.paint_image(bounds, bounds, Default::default(), image, 0, false) {
Ok(()) => view.update(cx, |view, _| {
view.painted += 1;
if view.painted == 1 {
let area = f64::from(f32::from(bounds.size.width) * f32::from(bounds.size.height));
if view.painted == 0.0 && area > 0.0 {
log::info!("pdf: first tile drawn, page {page}");
}
view.painted += area;
}),
Err(error) => log::error!("pdf: drawing a page failed: {error}"),
},
+12 -1
View File
@@ -311,7 +311,18 @@ fn old_tiles_are_painted_and_freed_with_their_tab() {
});
cx.run_until_parked();
let (painted, kept) = cx.update(|_, app| (view.read(app).painted, view.read(app).backdrop.len()));
assert!(kept > 0 && painted >= before + kept as u64, "{kept} old tiles, {} paints", painted - before);
// Old tiles cover what shows of the page.
let shown = cx.update(|window, app| {
let read = view.read(app);
let room = read.room;
read.showing(window.scale_factor(), false).iter().map(|s| {
let (left, top) = (-f32::from(read.scroll.offset().x), -f32::from(read.scroll.offset().y));
let w = (s.place.x + s.place.w).min(left + f32::from(room.size.width)) - s.place.x.max(left);
let h = (s.place.y + s.place.h).min(top + f32::from(room.size.height)) - s.place.y.max(top);
f64::from(w.max(0.0) * h.max(0.0))
}).sum::<f64>()
});
assert!(kept > 0 && painted - before >= shown * 0.99, "{kept} old tiles painted {} of {shown}", painted - before);
cx.update(|_, app| view.update(app, |view, _| view.retire_all()));
assert!(cx.update(|_, app| view.read(app).backdrop.is_empty()), "closing hands every old tile over");
}
+3 -3
View File
@@ -37,8 +37,8 @@ pub struct PdfView {
pub tiles: HashMap<TileKey, Arc<RenderImage>>,
/// Images no longer drawn, freed at the next render.
pub retired: ely_gpui_component::primitives::Retired,
/// Tile images painted so far; the first is logged (PERF-05).
pub painted: u64,
/// Tile pixels painted; the first paint is logged (PERF-05).
pub painted: f64,
/// Tiles the worker could not draw; not asked again.
pub failed: HashSet<TileKey>,
/// Old tiles shown under their page until covered.
@@ -167,7 +167,7 @@ impl PdfView {
scroll: ScrollHandle::new(),
tiles: HashMap::new(),
retired: Default::default(),
painted: 0,
painted: 0.0,
failed: HashSet::new(),
backdrop: Vec::new(),
text: HashMap::new(),