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.
This commit is contained in:
Héctor Ramón Jiménez 2019-12-18 23:14:54 +01:00
parent 0f2e20f5e5
commit 0d7e236039

View File

@ -136,11 +136,23 @@ impl Pipeline {
// it uses a lifetimed `GlyphCalculatorGuard` with side-effects on drop. // it uses a lifetimed `GlyphCalculatorGuard` with side-effects on drop.
// This makes stuff quite inconvenient. A manual method for trimming the // This makes stuff quite inconvenient. A manual method for trimming the
// cache would make our lives easier. // cache would make our lives easier.
let _ = self loop {
.measure_brush let action = self
.borrow_mut() .measure_brush
.process_queued(|_, _| {}, |_| {}) .borrow_mut()
.expect("Trim text measurements"); .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 { pub fn find_font(&self, font: iced_native::Font) -> wgpu_glyph::FontId {