summaryrefslogtreecommitdiffstats
path: root/wgpu/src/text.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-12-18 23:14:54 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-12-18 23:14:54 +0100
commit0d7e236039c4a3e4115bf276810abb50d7868ddf (patch)
tree9b3b22b3fa7fdd36852f173962eced5cad4998b6 /wgpu/src/text.rs
parent0f2e20f5e5b1f0658ab4e6cbe6fdda9ca97f2b36 (diff)
downloadiced-0d7e236039c4a3e4115bf276810abb50d7868ddf.tar.gz
iced-0d7e236039c4a3e4115bf276810abb50d7868ddf.tar.bz2
iced-0d7e236039c4a3e4115bf276810abb50d7868ddf.zip
Resize text measure cache to avoid panic
This should not be really necessary, as we are not really drawing anything with the measure brush... But we are using `glyph_brush` in an unconventional way, so that may be the cause. We need to redesign `wgpu_glyph` or come up with an alternative.
Diffstat (limited to 'wgpu/src/text.rs')
-rw-r--r--wgpu/src/text.rs22
1 files changed, 17 insertions, 5 deletions
diff --git a/wgpu/src/text.rs b/wgpu/src/text.rs
index e9a1602f..880ad1a6 100644
--- a/wgpu/src/text.rs
+++ b/wgpu/src/text.rs
@@ -136,11 +136,23 @@ impl Pipeline {
// it uses a lifetimed `GlyphCalculatorGuard` with side-effects on drop.
// This makes stuff quite inconvenient. A manual method for trimming the
// cache would make our lives easier.
- let _ = self
- .measure_brush
- .borrow_mut()
- .process_queued(|_, _| {}, |_| {})
- .expect("Trim text measurements");
+ loop {
+ let action = self
+ .measure_brush
+ .borrow_mut()
+ .process_queued(|_, _| {}, |_| {});
+
+ match action {
+ Ok(_) => break,
+ Err(glyph_brush::BrushError::TextureTooSmall { suggested }) => {
+ let (width, height) = suggested;
+
+ self.measure_brush
+ .borrow_mut()
+ .resize_texture(width, height);
+ }
+ }
+ }
}
pub fn find_font(&self, font: iced_native::Font) -> wgpu_glyph::FontId {