1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-31 13:50:04 -04:00

eframe: always provide a texture allocator

This commit is contained in:
Emil Ernerfeldt
2021-02-28 19:09:48 +01:00
parent fdb1aa6bec
commit 84cc227f11
6 changed files with 15 additions and 12 deletions

View File

@@ -45,7 +45,7 @@ impl epi::App for ColorTest {
ui.separator();
}
ScrollArea::auto_sized().show(ui, |ui| {
self.ui(ui, frame.tex_allocator());
self.ui(ui, &mut Some(frame.tex_allocator()));
});
});
}

View File

@@ -278,14 +278,16 @@ impl TexMngr {
url: &str,
image: &Image,
) -> Option<egui::TextureId> {
let tex_allocator = frame.tex_allocator().as_mut()?;
if self.loaded_url != url {
if let Some(texture_id) = self.texture_id.take() {
tex_allocator.free(texture_id);
frame.tex_allocator().free(texture_id);
}
self.texture_id =
Some(tex_allocator.alloc_srgba_premultiplied(image.size, &image.pixels));
self.texture_id = Some(
frame
.tex_allocator()
.alloc_srgba_premultiplied(image.size, &image.pixels),
);
self.loaded_url = url.to_owned();
}
self.texture_id