diff --git a/egui_demo_lib/src/apps/color_test.rs b/egui_demo_lib/src/apps/color_test.rs index bad00548..b9dd4baf 100644 --- a/egui_demo_lib/src/apps/color_test.rs +++ b/egui_demo_lib/src/apps/color_test.rs @@ -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())); }); }); } diff --git a/egui_demo_lib/src/apps/http_app.rs b/egui_demo_lib/src/apps/http_app.rs index 35899d66..eb890e0c 100644 --- a/egui_demo_lib/src/apps/http_app.rs +++ b/egui_demo_lib/src/apps/http_app.rs @@ -278,14 +278,16 @@ impl TexMngr { url: &str, image: &Image, ) -> Option { - 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 diff --git a/egui_glium/src/backend.rs b/egui_glium/src/backend.rs index 87432690..abb777a2 100644 --- a/egui_glium/src/backend.rs +++ b/egui_glium/src/backend.rs @@ -191,7 +191,7 @@ pub fn run(mut app: Box) -> ! { let mut app_output = epi::backend::AppOutput::default(); let mut frame = epi::backend::FrameBuilder { info: integration_info(&display, None), - tex_allocator: Some(&mut painter), + tex_allocator: &mut painter, #[cfg(feature = "http")] http: http.clone(), output: &mut app_output, @@ -229,7 +229,7 @@ pub fn run(mut app: Box) -> ! { let mut app_output = epi::backend::AppOutput::default(); let mut frame = epi::backend::FrameBuilder { info: integration_info(&display, previous_frame_time), - tex_allocator: Some(&mut painter), + tex_allocator: &mut painter, #[cfg(feature = "http")] http: http.clone(), output: &mut app_output, diff --git a/egui_web/src/backend.rs b/egui_web/src/backend.rs index 3fc37deb..d78483ac 100644 --- a/egui_web/src/backend.rs +++ b/egui_web/src/backend.rs @@ -206,7 +206,7 @@ impl AppRunner { seconds_since_midnight: Some(seconds_since_midnight()), native_pixels_per_point: Some(native_pixels_per_point()), }, - tex_allocator: Some(self.web_backend.painter.as_tex_allocator()), + tex_allocator: self.web_backend.painter.as_tex_allocator(), #[cfg(feature = "http")] http: self.http.clone(), output: &mut app_output, diff --git a/epi/CHANGELOG.md b/epi/CHANGELOG.md index c0b66b5e..9f6f305c 100644 --- a/epi/CHANGELOG.md +++ b/epi/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). * You can control the initial size of the native window with `App::initial_window_size`. * You can control the maximum egui web canvas size with `App::max_size_points`. +* `Frame::tex_allocator()` no longer returns an `Option` (there is always a texture allocator). ## 0.9.0 - 2021-02-07 diff --git a/epi/src/lib.rs b/epi/src/lib.rs index 11d86290..b89d3574 100644 --- a/epi/src/lib.rs +++ b/epi/src/lib.rs @@ -156,9 +156,9 @@ impl<'a> Frame<'a> { &self.0.info } - /// A way to allocate textures (on integrations that support it). - pub fn tex_allocator(&mut self) -> &mut Option<&'a mut dyn TextureAllocator> { - &mut self.0.tex_allocator + /// A way to allocate textures. + pub fn tex_allocator(&mut self) -> &mut dyn TextureAllocator { + self.0.tex_allocator } /// Signal the app to stop/exit/quit the app (only works for native apps, not web apps). @@ -368,7 +368,7 @@ pub mod backend { /// Information about the integration. pub info: IntegrationInfo, /// A way to allocate textures (on integrations that support it). - pub tex_allocator: Option<&'a mut dyn TextureAllocator>, + pub tex_allocator: &'a mut dyn TextureAllocator, /// Do http requests. #[cfg(feature = "http")] pub http: std::sync::Arc,