try to improve performance
This commit is contained in:
parent
8f329e091d
commit
c33dab5644
2 changed files with 53 additions and 45 deletions
|
@ -43,19 +43,25 @@ pub struct SdfTerm {
|
||||||
fg_layers: HashMap<Point2<i16>, (bool, LayerId2d)>,
|
fg_layers: HashMap<Point2<i16>, (bool, LayerId2d)>,
|
||||||
|
|
||||||
font_height: u32,
|
font_height: u32,
|
||||||
//font: Mutex<Font>,
|
font: Arc<Vec<u8>>,
|
||||||
|
|
||||||
renderer: Arc<Mutex<MarpBackend>>
|
renderer: Arc<Mutex<MarpBackend>>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SdfTerm {
|
impl SdfTerm {
|
||||||
pub fn new(renderer: Arc<Mutex<MarpBackend>>) -> Self {
|
pub fn new(renderer: Arc<Mutex<MarpBackend>>) -> Self {
|
||||||
|
|
||||||
|
let font_path = Path::new("/usr/share/fonts/TTF/FiraCode-Medium.ttf");
|
||||||
|
let mut font_file = File::open(font_path).unwrap();
|
||||||
|
let mut font_data = Vec::new();
|
||||||
|
font_file.read_to_end(&mut font_data).unwrap();
|
||||||
|
|
||||||
SdfTerm {
|
SdfTerm {
|
||||||
src_view: None,
|
src_view: None,
|
||||||
bg_layers: HashMap::new(),
|
bg_layers: HashMap::new(),
|
||||||
fg_layers: HashMap::new(),
|
fg_layers: HashMap::new(),
|
||||||
font_height: 30,
|
font_height: 30,
|
||||||
//font: Mutex::new(Font::from_path(Path::new("/usr/share/fonts/TTF/FiraCode-Medium.ttf"),0).unwrap()),
|
font: Arc::new(font_data),
|
||||||
renderer
|
renderer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -147,8 +153,9 @@ impl SdfTerm {
|
||||||
|
|
||||||
// foreground layer
|
// foreground layer
|
||||||
if let Some(c) = atom.c {
|
if let Some(c) = atom.c {
|
||||||
let font = Font::from_path(Path::new("/usr/share/fonts/TTF/FiraCode-Light.ttf"),0).unwrap();
|
let font_index = 0;
|
||||||
let mut ch = Character::from_font(&font, c).with_size(1.0).with_tesselation_factor(0.01);
|
let fontkit = Font::from_bytes(self.font.clone(), font_index).unwrap();
|
||||||
|
let mut ch = Character::from_font(&fontkit, c).with_size(1.0);
|
||||||
|
|
||||||
let (r,g,b) = atom.style.fg_color.unwrap_or((0, 0, 0));
|
let (r,g,b) = atom.style.fg_color.unwrap_or((0, 0, 0));
|
||||||
|
|
||||||
|
|
|
@ -145,17 +145,6 @@ async fn main() {
|
||||||
|
|
||||||
//now check if a rerender was requested, or if we worked on all
|
//now check if a rerender was requested, or if we worked on all
|
||||||
//events on that batch
|
//events on that batch
|
||||||
term_port.update();
|
|
||||||
renderer.lock().unwrap().set_layer_order(
|
|
||||||
vec![
|
|
||||||
//vec![ color_layer_id.into() ].into_iter(),
|
|
||||||
sdf_term.read().unwrap().get_order().into_iter()
|
|
||||||
]
|
|
||||||
.into_iter()
|
|
||||||
.flatten()
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
.as_slice()
|
|
||||||
);
|
|
||||||
|
|
||||||
match event{
|
match event{
|
||||||
winit::event::Event::WindowEvent{window_id: _, event: winit::event::WindowEvent::Resized(newsize)} => {
|
winit::event::Event::WindowEvent{window_id: _, event: winit::event::WindowEvent::Resized(newsize)} => {
|
||||||
|
@ -163,6 +152,7 @@ async fn main() {
|
||||||
}
|
}
|
||||||
winit::event::Event::WindowEvent{window_id: _, event: winit::event::WindowEvent::KeyboardInput{ device_id, input, is_synthetic }} => {
|
winit::event::Event::WindowEvent{window_id: _, event: winit::event::WindowEvent::KeyboardInput{ device_id, input, is_synthetic }} => {
|
||||||
if input.state == winit::event::ElementState::Pressed {
|
if input.state == winit::event::ElementState::Pressed {
|
||||||
|
|
||||||
if let Some(kc) = input.virtual_keycode {
|
if let Some(kc) = input.virtual_keycode {
|
||||||
match kc {
|
match kc {
|
||||||
winit::event::VirtualKeyCode::Space => {
|
winit::event::VirtualKeyCode::Space => {
|
||||||
|
@ -321,17 +311,6 @@ async fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
winit::event::Event::MainEventsCleared => {
|
|
||||||
window.request_redraw();
|
|
||||||
}
|
|
||||||
winit::event::Event::RedrawRequested(_) => {
|
|
||||||
//term_port.update();
|
|
||||||
renderer.lock().unwrap().render(&window);
|
|
||||||
}
|
|
||||||
_ => {},
|
|
||||||
}
|
|
||||||
|
|
||||||
status_chars.clear();
|
status_chars.clear();
|
||||||
let cur = process_list_editor.get_cursor();
|
let cur = process_list_editor.get_cursor();
|
||||||
|
@ -361,6 +340,28 @@ async fn main() {
|
||||||
status_chars.push(TerminalAtom::new(c, TerminalStyle::fg_color((200, 200, 20))));
|
status_chars.push(TerminalAtom::new(c, TerminalStyle::fg_color((200, 200, 20))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
winit::event::Event::MainEventsCleared => {
|
||||||
|
window.request_redraw();
|
||||||
|
}
|
||||||
|
winit::event::Event::RedrawRequested(_) => {
|
||||||
|
term_port.update();
|
||||||
|
renderer.lock().unwrap().set_layer_order(
|
||||||
|
vec![
|
||||||
|
//vec![ color_layer_id.into() ].into_iter(),
|
||||||
|
sdf_term.read().unwrap().get_order().into_iter()
|
||||||
|
]
|
||||||
|
.into_iter()
|
||||||
|
.flatten()
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.as_slice()
|
||||||
|
);
|
||||||
|
|
||||||
|
renderer.lock().unwrap().render(&window);
|
||||||
|
}
|
||||||
|
_ => {},
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue