From 5fd0c724b26c97e2df66c01b3924e31b141fa0f3 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 7 Nov 2019 06:51:42 +0100 Subject: Align text position to pixel grid in `iced_wgpu` This avoids re-rasterizing glyphs and cache reuploads when the HiDPI factor is nonintegral. --- wgpu/src/renderer.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'wgpu') diff --git a/wgpu/src/renderer.rs b/wgpu/src/renderer.rs index c8e1e10d..a7628bf4 100644 --- a/wgpu/src/renderer.rs +++ b/wgpu/src/renderer.rs @@ -365,8 +365,8 @@ impl Renderer { // Target physical coordinates directly to avoid blurry text let text = Section { screen_position: ( - text.screen_position.0 * dpi, - text.screen_position.1 * dpi, + (text.screen_position.0 * dpi).round(), + (text.screen_position.1 * dpi).round(), ), bounds: (text.bounds.0 * dpi, text.bounds.1 * dpi), scale: wgpu_glyph::Scale { -- cgit From 79f31b66c331207d9c5e1d31c226e49e8acb776f Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 7 Nov 2019 06:54:03 +0100 Subject: Increase initial size of text cache in `iced_wgpu` This reduces the amount of cache updates in general when text changes. The new cache should take 4MB of VRAM. I think this is reasonable for a modern GUI toolkit. In any case, we should be able to reduce this value in the future. --- wgpu/src/renderer.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'wgpu') diff --git a/wgpu/src/renderer.rs b/wgpu/src/renderer.rs index a7628bf4..f25e2855 100644 --- a/wgpu/src/renderer.rs +++ b/wgpu/src/renderer.rs @@ -74,6 +74,7 @@ impl Renderer { let glyph_brush = GlyphBrushBuilder::using_fonts_bytes(vec![default_font, mono_font]) + .initial_cache_size((2048, 2048)) .build(&mut device, TextureFormat::Bgra8UnormSrgb); let quad_pipeline = quad::Pipeline::new(&mut device); -- cgit