summaryrefslogtreecommitdiffstats
path: root/wgpu
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2019-12-19 17:07:09 +0100
committerLibravatar GitHub <noreply@github.com>2019-12-19 17:07:09 +0100
commitc822ea753e6121cc53aa1a75112af6063e3e06dd (patch)
treeaf5fc66fa1284a52c260951cff1d1ac882c888d0 /wgpu
parent441c6730e91a782e697ce9c0f9dd69883138b551 (diff)
parent0d7e236039c4a3e4115bf276810abb50d7868ddf (diff)
downloadiced-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.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 {