diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-01-15 16:53:02 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-01-15 16:53:02 +0100 |
| commit | d763f0f5a6a700352ee8926c15c8e58624f705c9 (patch) | |
| tree | d287edfdab9793a796404516c7313689e4e69964 /src/layout | |
| parent | 0f0416054f263b80ccec1a463ce4ab20913bdf71 (diff) | |
Split state and scopes, less ref-counting 🔀
Diffstat (limited to 'src/layout')
| -rw-r--r-- | src/layout/mod.rs | 10 | ||||
| -rw-r--r-- | src/layout/text.rs | 3 |
2 files changed, 6 insertions, 7 deletions
diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 714bac4b..44960de7 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -8,7 +8,7 @@ mod spacing; mod stack; mod text; -use crate::env::{ResourceId, SharedEnv}; +use crate::env::{Env, ResourceId}; use crate::geom::*; use crate::shaping::Shaped; @@ -21,7 +21,7 @@ pub use stack::*; pub use text::*; /// Layout a tree into a collection of frames. -pub fn layout(tree: &Tree, env: SharedEnv) -> Vec<Frame> { +pub fn layout(tree: &Tree, env: &mut Env) -> Vec<Frame> { tree.layout(&mut LayoutContext { env }) } @@ -65,10 +65,10 @@ pub trait Layout { } /// The context for layouting. -#[derive(Debug, Clone)] -pub struct LayoutContext { +#[derive(Debug)] +pub struct LayoutContext<'a> { /// The environment from which fonts are gathered. - pub env: SharedEnv, + pub env: &'a mut Env, } /// A collection of areas to layout into. diff --git a/src/layout/text.rs b/src/layout/text.rs index cfd83372..ee85ee17 100644 --- a/src/layout/text.rs +++ b/src/layout/text.rs @@ -25,13 +25,12 @@ pub struct NodeText { impl Layout for NodeText { fn layout(&self, ctx: &mut LayoutContext, _: &Areas) -> Layouted { - let mut env = ctx.env.borrow_mut(); Layouted::Frame( shaping::shape( &self.text, self.dir, self.font_size, - &mut env.fonts, + &mut ctx.env.fonts, &self.families, self.variant, ), |
