tiling: Store tiling for each layer and fix bugs
Tilings now have a flexible origin and are stored with the tile layer. This allows to make the first tile centered in the viewport, allowing for faster getting a complete viewport. This also fixes some rendering bugs caused by forgetting tiles the were still needed. But not all of them. Fixes #83, #94 Issue #82 Part-of: <https://gitlab.gnome.org/Incubator/loupe/-/merge_requests/179>
This commit is contained in:
parent
587599f50b
commit
e5d5841e5d
4 changed files with 276 additions and 230 deletions
|
|
@ -806,7 +806,7 @@ impl LpImage {
|
|||
imp.frame_buffer.rcu(|tiles| {
|
||||
let mut new_tiles = (**tiles).clone();
|
||||
// TODO: Use an area larger than the viewport
|
||||
new_tiles.cleanup(imp.zoom_target.get(), self.viewport());
|
||||
new_tiles.cleanup(imp.zoom_target.get(), self.preload_area());
|
||||
new_tiles
|
||||
});
|
||||
if imp.background_color.borrow().is_none() {
|
||||
|
|
@ -1235,7 +1235,8 @@ impl LpImage {
|
|||
if let Some(decoder) = self.imp().decoder.borrow().as_ref() {
|
||||
if self.zoom_animation().state() != adw::AnimationState::Playing {
|
||||
decoder.request(crate::decoder::TileRequest {
|
||||
viewport: self.viewport(),
|
||||
viewport: self.viewport().inset_r(-3., -3.),
|
||||
area: self.preload_area(),
|
||||
zoom: self.imp().zoom_target.get(),
|
||||
});
|
||||
}
|
||||
|
|
@ -1253,6 +1254,11 @@ impl LpImage {
|
|||
graphene::Rect::new(x, y, width, height)
|
||||
}
|
||||
|
||||
fn preload_area(&self) -> graphene::Rect {
|
||||
let viewport = self.viewport();
|
||||
viewport.inset_r(-viewport.width() / 3., -viewport.height() / 3.)
|
||||
}
|
||||
|
||||
/// Animation that makes larger zoom steps (from buttons etc) look smooth
|
||||
fn zoom_animation(&self) -> &adw::TimedAnimation {
|
||||
self.imp().zoom_animation.get_or_init(|| {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue