aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorJoe Wilm <joe@jwilm.com>2016-06-07 21:15:53 -0700
committerJoe Wilm <joe@jwilm.com>2016-06-07 21:15:53 -0700
commit6c82fa9d7b39a6ae70f1e233c9123b9d32c30623 (patch)
tree1a4ec091f5deb6391bc2d81262e49795377fcbb8 /src/main.rs
parent781c67f0a06d7be9b3625afac57325c4dbcc3c9b (diff)
downloadalacritty-6c82fa9d7b39a6ae70f1e233c9123b9d32c30623.tar.gz
alacritty-6c82fa9d7b39a6ae70f1e233c9123b9d32c30623.zip
Only draw when terminal state has changed
This is achieved by setting a `dirty` flag when the terminal receives an event that causes visible state to change. The implementation is pretty much crap because most methods know about the flag. Figure out something better later.
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs36
1 files changed, 20 insertions, 16 deletions
diff --git a/src/main.rs b/src/main.rs
index 98daddf1..fd22b304 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -193,26 +193,30 @@ fn main() {
gl::Clear(gl::COLOR_BUFFER_BIT);
}
- {
- let _sampler = meter.sampler();
+ if terminal.dirty() {
+ {
+ let _sampler = meter.sampler();
- renderer.with_api(&props, |mut api| {
- // Draw the grid
- api.render_grid(terminal.grid(), &mut glyph_cache);
+ renderer.with_api(&props, |mut api| {
+ // Draw the grid
+ api.render_grid(terminal.grid(), &mut glyph_cache);
- // Also draw the cursor
- api.render_cursor(terminal.cursor(), &mut glyph_cache);
- })
- }
+ // Also draw the cursor
+ api.render_cursor(terminal.cursor(), &mut glyph_cache);
+ })
+ }
- // Draw render timer
- let timing = format!("{:.3} usec", meter.average());
- let color = Rgb { r: 0xd5, g: 0x4e, b: 0x53 };
- renderer.with_api(&props, |mut api| {
- api.render_string(&timing[..], &mut glyph_cache, &color);
- });
+ // Draw render timer
+ let timing = format!("{:.3} usec", meter.average());
+ let color = Rgb { r: 0xd5, g: 0x4e, b: 0x53 };
+ renderer.with_api(&props, |mut api| {
+ api.render_string(&timing[..], &mut glyph_cache, &color);
+ });
+
+ terminal.clear_dirty();
- window.swap_buffers().unwrap();
+ window.swap_buffers().unwrap();
+ }
}
// TODO handle child cleanup