Ensure that all shaping and layout uses scratch buffer
This commit is contained in:
parent
5d1aa67804
commit
80d120dfa5
1 changed files with 21 additions and 7 deletions
|
|
@ -291,7 +291,13 @@ impl Buffer {
|
||||||
for line in &mut self.lines {
|
for line in &mut self.lines {
|
||||||
if line.shape_opt().is_some() {
|
if line.shape_opt().is_some() {
|
||||||
line.reset_layout();
|
line.reset_layout();
|
||||||
line.layout(font_system, self.metrics.font_size, self.width, self.wrap);
|
line.layout_in_buffer(
|
||||||
|
&mut self.scratch,
|
||||||
|
font_system,
|
||||||
|
self.metrics.font_size,
|
||||||
|
self.width,
|
||||||
|
self.wrap,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -394,7 +400,11 @@ impl Buffer {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert a [`Cursor`] to a [`LayoutCursor`]
|
/// Convert a [`Cursor`] to a [`LayoutCursor`]
|
||||||
pub fn layout_cursor(&mut self, font_system: &mut FontSystem, cursor: Cursor) -> Option<LayoutCursor> {
|
pub fn layout_cursor(
|
||||||
|
&mut self,
|
||||||
|
font_system: &mut FontSystem,
|
||||||
|
cursor: Cursor,
|
||||||
|
) -> Option<LayoutCursor> {
|
||||||
let layout = self.line_layout(font_system, cursor.line)?;
|
let layout = self.line_layout(font_system, cursor.line)?;
|
||||||
for (layout_i, layout_line) in layout.iter().enumerate() {
|
for (layout_i, layout_line) in layout.iter().enumerate() {
|
||||||
for (glyph_i, glyph) in layout_line.glyphs.iter().enumerate() {
|
for (glyph_i, glyph) in layout_line.glyphs.iter().enumerate() {
|
||||||
|
|
@ -428,7 +438,7 @@ impl Buffer {
|
||||||
line_i: usize,
|
line_i: usize,
|
||||||
) -> Option<&ShapeLine> {
|
) -> Option<&ShapeLine> {
|
||||||
let line = self.lines.get_mut(line_i)?;
|
let line = self.lines.get_mut(line_i)?;
|
||||||
Some(line.shape(font_system))
|
Some(line.shape_in_buffer(&mut self.scratch, font_system))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Lay out the provided line index and return the result
|
/// Lay out the provided line index and return the result
|
||||||
|
|
@ -438,7 +448,13 @@ impl Buffer {
|
||||||
line_i: usize,
|
line_i: usize,
|
||||||
) -> Option<&[LayoutLine]> {
|
) -> Option<&[LayoutLine]> {
|
||||||
let line = self.lines.get_mut(line_i)?;
|
let line = self.lines.get_mut(line_i)?;
|
||||||
Some(line.layout(font_system, self.metrics.font_size, self.width, self.wrap))
|
Some(line.layout_in_buffer(
|
||||||
|
&mut self.scratch,
|
||||||
|
font_system,
|
||||||
|
self.metrics.font_size,
|
||||||
|
self.width,
|
||||||
|
self.wrap,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the current [`Metrics`]
|
/// Get the current [`Metrics`]
|
||||||
|
|
@ -882,9 +898,7 @@ impl Buffer {
|
||||||
Motion::Down => {
|
Motion::Down => {
|
||||||
let mut layout_cursor = self.layout_cursor(font_system, cursor)?;
|
let mut layout_cursor = self.layout_cursor(font_system, cursor)?;
|
||||||
|
|
||||||
let layout_len = self
|
let layout_len = self.line_layout(font_system, layout_cursor.line)?.len();
|
||||||
.line_layout(font_system, layout_cursor.line)?
|
|
||||||
.len();
|
|
||||||
|
|
||||||
if cursor.x_opt.is_none() {
|
if cursor.x_opt.is_none() {
|
||||||
cursor.x_opt = Some(
|
cursor.x_opt = Some(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue