Use cosmic-text shape-run-cache

This commit is contained in:
Jeremy Soller 2024-02-08 11:28:41 -07:00
parent 19f5b6e0eb
commit bf7668dbd7
No known key found for this signature in database
GPG key ID: D02FD439211AF56F
4 changed files with 8 additions and 15 deletions

4
Cargo.lock generated
View file

@ -953,8 +953,8 @@ dependencies = [
[[package]]
name = "cosmic-text"
version = "0.10.0"
source = "git+https://github.com/pop-os/cosmic-text.git#be471833c9ee563866f07593354a41dd40761a18"
version = "0.11.1"
source = "git+https://github.com/pop-os/cosmic-text.git#cb447ea8c6717d558994575b93a00baa549d01f8"
dependencies = [
"bitflags 2.4.2",
"fontdb",

View file

@ -23,6 +23,7 @@ palette = "0.7"
[dependencies.cosmic-text]
git = "https://github.com/pop-os/cosmic-text.git"
features = ["shape-run-cache"]
[dependencies.libcosmic]
git = "https://github.com/pop-os/libcosmic.git"

View file

@ -371,6 +371,8 @@ impl Terminal {
buffer.set_size(font_system.raw(), width as f32, height as f32);
});
self.needs_update = true;
log::debug!("resize {:?}", instant.elapsed());
}
}
@ -780,9 +782,11 @@ impl Terminal {
buffer.set_redraw(true);
}
// Shape and trim shape run cache
{
let mut font_system = font_system().write().unwrap();
buffer.shape_until_scroll(font_system.raw(), true);
font_system.raw().shape_run_cache.trim(1024);
}
}

View file

@ -8,7 +8,7 @@ use alacritty_terminal::{
use cosmic::{
cosmic_theme::palette::{blend::Compose, WithAlpha},
iced::{
advanced::graphics::text::{font_system, Raw},
advanced::graphics::text::Raw,
event::{Event, Status},
keyboard::{Event as KeyEvent, KeyCode, Modifiers},
mouse::{self, Button, Event as MouseEvent, ScrollDelta},
@ -147,12 +147,6 @@ where
terminal.needs_update = false;
}
// Ensure terminal is shaped
terminal.with_buffer_mut(|buffer| {
let mut font_system = font_system().write().unwrap();
buffer.shape_until_scroll(font_system.raw(), true);
});
// Calculate layout lines
terminal.with_buffer(|buffer| {
let mut layout_lines = 0;
@ -250,12 +244,6 @@ where
terminal.needs_update = false;
}
// Ensure terminal is shaped
terminal.with_buffer_mut(|buffer| {
let mut font_system = font_system().write().unwrap();
buffer.shape_until_scroll(font_system.raw(), true);
});
// Render default background
{
let meta = &terminal.metadata_set[terminal.default_attrs().metadata];