Avoid allocating text_areas in text::Pipeline

This commit is contained in:
Héctor Ramón Jiménez 2023-02-05 18:30:11 +01:00
parent 6cf4a10906
commit f37b87fbab
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
2 changed files with 5 additions and 8 deletions

View file

@ -60,7 +60,7 @@ path = "../graphics"
[dependencies.glyphon] [dependencies.glyphon]
version = "0.2" version = "0.2"
git = "https://github.com/hecrj/glyphon.git" git = "https://github.com/hecrj/glyphon.git"
rev = "304dcaf8443bec7194891fdef3df468a6eaeb7d9" rev = "3c2acb9dea5b9fcb0fa650b3c73b3a3242c62f4a"
[dependencies.tracing] [dependencies.tracing]
version = "0.1.6" version = "0.1.6"

View file

@ -123,10 +123,8 @@ impl Pipeline {
bottom: ((bounds.y + bounds.height) * scale_factor) as i32, bottom: ((bounds.y + bounds.height) * scale_factor) as i32,
}; };
let text_areas: Vec<_> = sections let text_areas =
.iter() sections.iter().zip(keys.iter()).map(|(section, key)| {
.zip(keys.iter())
.map(|(section, key)| {
let buffer = fields let buffer = fields
.render_cache .render_cache
.get(key) .get(key)
@ -163,8 +161,7 @@ impl Pipeline {
top: top as i32, top: top as i32,
bounds, bounds,
} }
}) });
.collect();
renderer renderer
.prepare( .prepare(
@ -175,7 +172,7 @@ impl Pipeline {
width: target_size.width, width: target_size.width,
height: target_size.height, height: target_size.height,
}, },
&text_areas, text_areas,
glyphon::Color::rgb(0, 0, 0), glyphon::Color::rgb(0, 0, 0),
&mut glyphon::SwashCache::new(fields.fonts), &mut glyphon::SwashCache::new(fields.fonts),
) )