image: Fix textures and bg color not reloading
The reload procedure for changed image files is triggered but the old data has to be deleted to be re-generated. Part-of: <https://gitlab.gnome.org/Incubator/loupe/-/merge_requests/176>
This commit is contained in:
parent
aca49427a1
commit
8669b870af
2 changed files with 21 additions and 0 deletions
|
|
@ -143,6 +143,14 @@ impl FrameBuffer {
|
|||
self.current().cleanup(zoom, viewport);
|
||||
}
|
||||
|
||||
/// Delete all stored information
|
||||
///
|
||||
/// Used when reloading image
|
||||
pub fn reset(&mut self) {
|
||||
self.update_sender = None;
|
||||
self.images.clear();
|
||||
}
|
||||
|
||||
pub fn contains(&self, zoom: f64, coordinates: Coordinates) -> bool {
|
||||
self.images
|
||||
.front()
|
||||
|
|
@ -410,6 +418,7 @@ impl RectExt for graphene::Rect {
|
|||
pub trait FrameBufferExt {
|
||||
fn push(&self, tile: Tile);
|
||||
fn push_frame(&self, tile: Tile, dimensions: Coordinates, delay: Duration);
|
||||
fn reset(&self);
|
||||
/// Return true if the next frame should be shown and removes the outdated frame
|
||||
fn frame_timeout(&self, elapsed: Duration) -> bool;
|
||||
/// Returns the number of currently buffered frames
|
||||
|
|
@ -448,6 +457,14 @@ impl FrameBufferExt for ArcSwap<FrameBuffer> {
|
|||
});
|
||||
}
|
||||
|
||||
fn reset(&self) {
|
||||
self.rcu(|tiling_store| {
|
||||
let mut new_store = (**tiling_store).clone();
|
||||
new_store.reset();
|
||||
Arc::new(new_store)
|
||||
});
|
||||
}
|
||||
|
||||
fn frame_timeout(&self, elapsed: Duration) -> bool {
|
||||
if let Some(next_frame) = self.load().images.get(1) {
|
||||
if elapsed >= next_frame.delay {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue