From 665422e256b5eb8fed23f1a13900838e0e3bcb44 Mon Sep 17 00:00:00 2001 From: aentity Date: Tue, 13 Jul 2021 22:27:48 -0400 Subject: Use ceil on svg dimensions, fix svg memory usage Calls ceil() on dimension bounds as this appears fix svg memory unbounded usage because no longer cache miss. The height and width return from resvg seem to always be ceiling of float dimensions, so we try to match. --- wgpu/src/image/vector.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'wgpu/src/image/vector.rs') diff --git a/wgpu/src/image/vector.rs b/wgpu/src/image/vector.rs index 8c7de617..cd511a45 100644 --- a/wgpu/src/image/vector.rs +++ b/wgpu/src/image/vector.rs @@ -75,8 +75,8 @@ impl Cache { let id = handle.id(); let (width, height) = ( - (scale * width).round() as u32, - (scale * height).round() as u32, + (scale * width).ceil() as u32, + (scale * height).ceil() as u32, ); // TODO: Optimize! @@ -122,6 +122,7 @@ impl Cache { device, encoder, )?; + log::debug!("allocating {} {}x{}", id, width, height); let _ = self.svg_hits.insert(id); let _ = self.rasterized_hits.insert((id, width, height)); -- cgit