image: Force minimum tile size of 1000x1000

Everything else does not make sense loading performance
wise.

Part-of: <https://gitlab.gnome.org/GNOME/loupe/-/merge_requests/276>
This commit is contained in:
Sophie Herold 2023-08-13 13:11:49 +02:00
parent 07513f5940
commit 65a5f39861

View file

@ -818,7 +818,6 @@ impl LpImage {
self.queue_draw(); self.queue_draw();
imp.frame_buffer.rcu(|tiles| { imp.frame_buffer.rcu(|tiles| {
let mut new_tiles = (**tiles).clone(); let mut new_tiles = (**tiles).clone();
// TODO: Use an area larger than the viewport
new_tiles.cleanup(imp.zoom_target.get(), self.preload_area()); new_tiles.cleanup(imp.zoom_target.get(), self.preload_area());
new_tiles new_tiles
}); });
@ -1271,8 +1270,13 @@ impl LpImage {
fn request_tiles(&self) { fn request_tiles(&self) {
if let Some(decoder) = self.imp().decoder.borrow().as_ref() { if let Some(decoder) = self.imp().decoder.borrow().as_ref() {
if self.zoom_animation().state() != adw::AnimationState::Playing { if self.zoom_animation().state() != adw::AnimationState::Playing {
// Force minimum tile size of 1000x1000 since with smaller
// tiles the tiled rendering advantage disappears
let x_inset = f32::min(-3., (self.viewport().width() - 1000.) / 2.);
let y_inset = f32::min(-3., (self.viewport().height() - 1000.) / 2.);
decoder.request(crate::decoder::TileRequest { decoder.request(crate::decoder::TileRequest {
viewport: self.viewport().inset_r(-3., -3.), viewport: self.viewport().inset_r(x_inset, y_inset),
area: self.preload_area(), area: self.preload_area(),
zoom: self.imp().zoom_target.get(), zoom: self.imp().zoom_target.get(),
}); });