Taking time for drawing and caching
This commit is contained in:
parent
2c524625c1
commit
21ea774a00
@ -3,6 +3,7 @@ use std::{
|
||||
collections::BTreeMap,
|
||||
path::{Path, PathBuf},
|
||||
rc::Rc,
|
||||
time::Instant,
|
||||
};
|
||||
|
||||
use async_channel::Sender;
|
||||
@ -31,6 +32,7 @@ impl PageCache {
|
||||
|
||||
pub fn cache_pages(&mut self, page_numbers: Vec<usize>) {
|
||||
println!("Caching pages {:?}", page_numbers);
|
||||
let begin_of_cashing = Instant::now();
|
||||
for page_number in page_numbers {
|
||||
if self.pages.contains_key(&page_number) {
|
||||
continue;
|
||||
@ -44,7 +46,10 @@ impl PageCache {
|
||||
}
|
||||
}
|
||||
}
|
||||
println!("done caching");
|
||||
println!(
|
||||
"done caching in {}ms",
|
||||
begin_of_cashing.elapsed().as_millis()
|
||||
);
|
||||
}
|
||||
|
||||
fn remove_most_distant_page(&mut self, current_page_number: usize) -> Result<(), ()> {
|
||||
|
@ -1,3 +1,5 @@
|
||||
use std::time::Instant;
|
||||
|
||||
use cairo::Context;
|
||||
|
||||
use crate::ui::DocumentCanvas;
|
||||
@ -10,13 +12,17 @@ pub fn draw(
|
||||
) {
|
||||
println!("Draw");
|
||||
if let Some(document_canvas) = document_canvas {
|
||||
let begin_of_drawing = Instant::now();
|
||||
if document_canvas.num_pages.unwrap_or(0) > 1 {
|
||||
draw_two_pages(document_canvas, context, area_width, area_height);
|
||||
} else {
|
||||
draw_single_page(document_canvas, context, area_width, area_height);
|
||||
}
|
||||
|
||||
println!("Finished drawing");
|
||||
println!(
|
||||
"Finished drawing in {}ms",
|
||||
begin_of_drawing.elapsed().as_millis()
|
||||
);
|
||||
document_canvas.cache_surrounding_pages();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user