diff options
author | 2019-12-19 17:07:09 +0100 | |
---|---|---|
committer | 2019-12-19 17:07:09 +0100 | |
commit | c822ea753e6121cc53aa1a75112af6063e3e06dd (patch) | |
tree | af5fc66fa1284a52c260951cff1d1ac882c888d0 /wgpu | |
parent | 441c6730e91a782e697ce9c0f9dd69883138b551 (diff) | |
parent | 0d7e236039c4a3e4115bf276810abb50d7868ddf (diff) | |
download | iced-c822ea753e6121cc53aa1a75112af6063e3e06dd.tar.gz iced-c822ea753e6121cc53aa1a75112af6063e3e06dd.tar.bz2 iced-c822ea753e6121cc53aa1a75112af6063e3e06dd.zip |
Merge pull request #130 from hecrj/fix/resize-measure-cache
Resize text measure cache to avoid panic
Diffstat (limited to '')
-rw-r--r-- | wgpu/src/text.rs | 22 |
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 { |