From ca5f82e5e9b99cae7fd01baad821da2b0040c743 Mon Sep 17 00:00:00 2001 From: grovesNL Date: Mon, 15 Jan 2024 11:46:17 -0330 Subject: [PATCH] Grow by a factor of `2` This reduces the amount of growing necessary for large glyphs --- src/text_atlas.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/text_atlas.rs b/src/text_atlas.rs index 6bec57b..320697d 100644 --- a/src/text_atlas.rs +++ b/src/text_atlas.rs @@ -131,8 +131,10 @@ impl InnerAtlas { return false; } - // TODO: Better resizing logic (?) - let new_size = (self.size + Self::INITIAL_SIZE).min(self.max_texture_dimension_2d); + // Grow each dimension by a factor of 2. The growth factor was chosen to match the growth + // factor of `Vec`.` + const GROWTH_FACTOR: u32 = 2; + let new_size = (self.size * GROWTH_FACTOR).min(self.max_texture_dimension_2d); self.packer.grow(size2(new_size as i32, new_size as i32));