summaryrefslogtreecommitdiff
path: root/src/export/render.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-05-25 10:33:20 +0200
committerLaurenz <laurmaedje@gmail.com>2022-05-25 10:55:08 +0200
commit362a7f2a8ac76f944efa05eabcab0960817777c5 (patch)
tree07f1a177fbbecdbd11e69bba9baa6a5301b25382 /src/export/render.rs
parent018860da9c72df846d80051a1408b3e632fbaaf6 (diff)
Thread-local query cache
Diffstat (limited to 'src/export/render.rs')
-rw-r--r--src/export/render.rs15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/export/render.rs b/src/export/render.rs
index 50257e1c..34fb4331 100644
--- a/src/export/render.rs
+++ b/src/export/render.rs
@@ -12,6 +12,7 @@ use crate::geom::{
self, Geometry, Length, Paint, PathElement, Shape, Size, Stroke, Transform,
};
use crate::image::{Image, RasterImage, Svg};
+use crate::query::query_ref;
use crate::Context;
/// Export a frame into a rendered image.
@@ -240,17 +241,15 @@ fn render_outline_glyph(
return Some(());
}
- // TODO(query)
+ // Rasterize the glyph with `pixglyph`.
// Try to retrieve a prepared glyph or prepare it from scratch if it
// doesn't exist, yet.
- let glyph = ctx
- .query((text.face_id, id), |ctx, (face_id, id)| {
- pixglyph::Glyph::load(ctx.fonts.get(face_id).ttf(), id)
- })
- .as_ref()?;
+ let bitmap = query_ref(
+ (&ctx.fonts, text.face_id, id),
+ |(fonts, face_id, id)| pixglyph::Glyph::load(fonts.get(face_id).ttf(), id),
+ |glyph| glyph.as_ref().map(|g| g.rasterize(ts.tx, ts.ty, ppem)),
+ )?;
- // Rasterize the glyph with `pixglyph`.
- let bitmap = glyph.rasterize(ts.tx, ts.ty, ppem);
let cw = canvas.width() as i32;
let ch = canvas.height() as i32;
let mw = bitmap.width as i32;