fix view count
This commit is contained in:
@@ -3,7 +3,7 @@ use std::{
|
||||
sync::mpsc::{Receiver, Sender, channel},
|
||||
};
|
||||
|
||||
use image::DynamicImage;
|
||||
use image::{DynamicImage, GenericImageView};
|
||||
|
||||
use crate::{render::TexturePrimitive, util::RefCounter};
|
||||
|
||||
@@ -25,6 +25,7 @@ pub struct Textures {
|
||||
}
|
||||
|
||||
pub enum TextureUpdate<'a> {
|
||||
PushFree,
|
||||
Push(&'a DynamicImage),
|
||||
Set(u32, &'a DynamicImage),
|
||||
Free(u32),
|
||||
@@ -84,7 +85,10 @@ impl Textures {
|
||||
|
||||
pub fn updates(&mut self) -> impl Iterator<Item = TextureUpdate<'_>> {
|
||||
self.updates.drain(..).map(|u| match u {
|
||||
Update::Push(i) => TextureUpdate::Push(self.images[i as usize].as_ref().unwrap()),
|
||||
Update::Push(i) => self.images[i as usize]
|
||||
.as_ref()
|
||||
.map(TextureUpdate::Push)
|
||||
.unwrap_or(TextureUpdate::PushFree),
|
||||
Update::Set(i) => TextureUpdate::Set(i, self.images[i as usize].as_ref().unwrap()),
|
||||
Update::Free(i) => TextureUpdate::Free(i),
|
||||
})
|
||||
|
||||
@@ -137,7 +137,6 @@ impl<Ctx> Ui<Ctx> {
|
||||
where
|
||||
Ctx: 'static,
|
||||
{
|
||||
self.free();
|
||||
let mut painter = Painter::new(
|
||||
&self.widgets,
|
||||
&mut self.primitives,
|
||||
@@ -152,6 +151,7 @@ impl<Ctx> Ui<Ctx> {
|
||||
for id in self.updates.drain(..) {
|
||||
painter.redraw(&id.id);
|
||||
}
|
||||
self.free();
|
||||
}
|
||||
|
||||
/// free any resources that don't have references anymore
|
||||
|
||||
Reference in New Issue
Block a user