From d763f0f5a6a700352ee8926c15c8e58624f705c9 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Fri, 15 Jan 2021 16:53:02 +0100 Subject: =?UTF-8?q?Split=20state=20and=20scopes,=20less=20ref-counting=20?= =?UTF-8?q?=F0=9F=94=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/mod.rs | 10 +++++----- src/layout/text.rs | 3 +-- 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'src/layout') 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 { +pub fn layout(tree: &Tree, env: &mut Env) -> Vec { 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, ), -- cgit v1.2.3