@@ -28,7 +28,6 @@ impl<B: Brush> RangedBuilder<'_, B> {
2828 pub fn push_default < ' a > ( & mut self , property : impl Into < StyleProperty < ' a , B > > ) {
2929 let resolved = self
3030 . lcx
31- . rcx
3231 . resolve_property ( self . fcx , & property. into ( ) , self . scale ) ;
3332 self . lcx . ranged_style_builder . push_default ( resolved) ;
3433 }
@@ -40,7 +39,6 @@ impl<B: Brush> RangedBuilder<'_, B> {
4039 ) {
4140 let resolved = self
4241 . lcx
43- . rcx
4442 . resolve_property ( self . fcx , & property. into ( ) , self . scale ) ;
4543 self . lcx . ranged_style_builder . push ( resolved, range) ;
4644 }
@@ -54,14 +52,8 @@ impl<B: Brush> RangedBuilder<'_, B> {
5452 self . lcx . ranged_style_builder . finish ( & mut self . lcx . styles ) ;
5553
5654 // Call generic layout builder method
57- build_into_layout (
58- layout,
59- self . scale ,
60- self . quantize ,
61- text. as_ref ( ) ,
62- self . lcx ,
63- self . fcx ,
64- ) ;
55+ self . lcx
56+ . build_into_layout ( layout, self . scale , self . quantize , text. as_ref ( ) , self . fcx ) ;
6557 }
6658
6759 pub fn build ( self , text : impl AsRef < str > ) -> Layout < B > {
@@ -84,7 +76,6 @@ impl<B: Brush> TreeBuilder<'_, B> {
8476 pub fn push_style_span ( & mut self , style : TextStyle < ' _ , B > ) {
8577 let resolved = self
8678 . lcx
87- . rcx
8879 . resolve_entire_style_set ( self . fcx , & style, self . scale ) ;
8980 self . lcx . tree_style_builder . push_style_span ( resolved) ;
9081 }
@@ -96,11 +87,15 @@ impl<B: Brush> TreeBuilder<'_, B> {
9687 ' s : ' iter ,
9788 B : ' iter ,
9889 {
99- self . lcx . tree_style_builder . push_style_modification_span (
100- properties
101- . into_iter ( )
102- . map ( |p| self . lcx . rcx . resolve_property ( self . fcx , p, self . scale ) ) ,
103- ) ;
90+ // FIXME: eliminate allocation if/when the "style builders" are extracted
91+ // from the LayoutContext
92+ let resolved_properties: Vec < _ > = properties
93+ . into_iter ( )
94+ . map ( |p| self . lcx . resolve_property ( self . fcx , p, self . scale ) )
95+ . collect ( ) ;
96+ self . lcx
97+ . tree_style_builder
98+ . push_style_modification_span ( resolved_properties. into_iter ( ) ) ;
10499 }
105100
106101 pub fn pop_style_span ( & mut self ) {
@@ -134,7 +129,8 @@ impl<B: Brush> TreeBuilder<'_, B> {
134129 let text = self . lcx . tree_style_builder . finish ( & mut self . lcx . styles ) ;
135130
136131 // Call generic layout builder method
137- build_into_layout ( layout, self . scale , self . quantize , & text, self . lcx , self . fcx ) ;
132+ self . lcx
133+ . build_into_layout ( layout, self . scale , self . quantize , & text, self . fcx ) ;
138134
139135 text
140136 }
@@ -146,60 +142,3 @@ impl<B: Brush> TreeBuilder<'_, B> {
146142 ( layout, text)
147143 }
148144}
149-
150- fn build_into_layout < B : Brush > (
151- layout : & mut Layout < B > ,
152- scale : f32 ,
153- quantize : bool ,
154- text : & str ,
155- lcx : & mut LayoutContext < B > ,
156- fcx : & mut FontContext ,
157- ) {
158- lcx. analyze_text ( text) ;
159-
160- layout. data . clear ( ) ;
161- layout. data . scale = scale;
162- layout. data . quantize = quantize;
163- layout. data . has_bidi = !lcx. bidi . levels ( ) . is_empty ( ) ;
164- layout. data . base_level = lcx. bidi . base_level ( ) ;
165- layout. data . text_len = text. len ( ) ;
166-
167- let mut char_index = 0 ;
168- for ( i, style) in lcx. styles . iter ( ) . enumerate ( ) {
169- for _ in text[ style. range . clone ( ) ] . chars ( ) {
170- lcx. info [ char_index] . 1 = i as u16 ;
171- char_index += 1 ;
172- }
173- }
174-
175- // Copy the visual styles into the layout
176- layout
177- . data
178- . styles
179- . extend ( lcx. styles . iter ( ) . map ( |s| s. style . as_layout_style ( ) ) ) ;
180-
181- // Sort the inline boxes as subsequent code assumes that they are in text index order.
182- // Note: It's important that this is a stable sort to allow users to control the order of contiguous inline boxes
183- lcx. inline_boxes . sort_by_key ( |b| b. index ) ;
184-
185- {
186- let query = fcx. collection . query ( & mut fcx. source_cache ) ;
187- super :: shape:: shape_text (
188- & lcx. rcx ,
189- query,
190- & lcx. styles ,
191- & lcx. inline_boxes ,
192- & lcx. info ,
193- lcx. bidi . levels ( ) ,
194- & mut lcx. scx ,
195- text,
196- layout,
197- ) ;
198- }
199-
200- // Move inline boxes into the layout
201- layout. data . inline_boxes . clear ( ) ;
202- core:: mem:: swap ( & mut layout. data . inline_boxes , & mut lcx. inline_boxes ) ;
203-
204- layout. data . finish ( ) ;
205- }
0 commit comments