more stable with 3 threads

macos-click-through
keith 4 years ago
parent f198f23551
commit 668f3f9aaf

89
Cargo.lock generated

@ -196,9 +196,9 @@ checksum = "7b02b629252fe8ef6460461409564e2c21d0c8e77e0944f3d189ff06c4e932ad"
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.0.59" version = "1.0.60"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66120af515773fb005778dc07c261bd201ec8ce50bd6e7144c927753fe013381" checksum = "ef611cc68ff783f18535d77ddd080185275713d852c4f5cbb6122c462a7a825c"
[[package]] [[package]]
name = "cexpr" name = "cexpr"
@ -329,11 +329,11 @@ dependencies = [
[[package]] [[package]]
name = "core-foundation" name = "core-foundation"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b5ed8e7e76c45974e15e41bfa8d5b0483cd90191639e01d8f5f1e606299d3fb" checksum = "0a89e2ae426ea83155dccf10c0fa6b1463ef6d5fcb44cee0b224a408fa640a62"
dependencies = [ dependencies = [
"core-foundation-sys 0.8.0", "core-foundation-sys 0.8.1",
"libc", "libc",
] ]
@ -345,9 +345,9 @@ checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac"
[[package]] [[package]]
name = "core-foundation-sys" name = "core-foundation-sys"
version = "0.8.0" version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a21fa21941700a3cd8fcb4091f361a6a712fac632f85d9f487cc892045d55c6" checksum = "c0af3b5e4601de3837c9332e29e0aae47a0d46ebfa246d12b82f564bac233393"
[[package]] [[package]]
name = "core-graphics" name = "core-graphics"
@ -363,12 +363,12 @@ dependencies = [
[[package]] [[package]]
name = "core-graphics" name = "core-graphics"
version = "0.22.0" version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6082396a349fa49674ba1bda4077332a18bf150e8fa75745ece07085e29a113" checksum = "fc239bba52bab96649441699533a68de294a101533b0270b2d65aa402b29a7f9"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"core-foundation 0.9.0", "core-foundation 0.9.1",
"core-graphics-types", "core-graphics-types",
"foreign-types", "foreign-types",
"libc", "libc",
@ -376,24 +376,24 @@ dependencies = [
[[package]] [[package]]
name = "core-graphics-types" name = "core-graphics-types"
version = "0.1.0" version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e92f5d519093a4178296707dbaa3880eae85a5ef5386675f361a1cf25376e93c" checksum = "3a68b68b3446082644c91ac778bf50cd4104bfb002b5a6a7c44cca5a2c70788b"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"core-foundation 0.9.0", "core-foundation 0.9.1",
"foreign-types", "foreign-types",
"libc", "libc",
] ]
[[package]] [[package]]
name = "core-text" name = "core-text"
version = "19.0.0" version = "19.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04dfae50af11e72657fe7174cddb1ecddc5398037f7f6f39533ad69207c9a4e2" checksum = "d2c7f46e8b820fd5f4b28528104b28b0a91cbe9e9c5bde8017087fb44bc93a60"
dependencies = [ dependencies = [
"core-foundation 0.9.0", "core-foundation 0.9.1",
"core-graphics 0.22.0", "core-graphics 0.22.1",
"foreign-types", "foreign-types",
"libc", "libc",
] ]
@ -515,7 +515,7 @@ checksum = "cb582b60359da160a9477ee80f15c8d784c477e69c217ef2cdd4169c24ea380f"
dependencies = [ dependencies = [
"proc-macro2 1.0.21", "proc-macro2 1.0.21",
"quote 1.0.7", "quote 1.0.7",
"syn 1.0.40", "syn 1.0.41",
] ]
[[package]] [[package]]
@ -526,7 +526,7 @@ checksum = "71f31892cd5c62e414316f2963c5689242c43d8e7bbcaaeca97e5e28c95d91d9"
dependencies = [ dependencies = [
"proc-macro2 1.0.21", "proc-macro2 1.0.21",
"quote 1.0.7", "quote 1.0.7",
"syn 1.0.40", "syn 1.0.41",
] ]
[[package]] [[package]]
@ -597,9 +597,9 @@ dependencies = [
[[package]] [[package]]
name = "either" name = "either"
version = "1.6.0" version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd56b59865bce947ac5958779cfa508f6c3b9497cc762b7e24a12d11ccde2c4f" checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
[[package]] [[package]]
name = "encoding_rs" name = "encoding_rs"
@ -701,8 +701,8 @@ checksum = "1f9042cb45150fb2b2a012fc03d0f1d2071f18e90397b9d2a5ec8ade8464bf20"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"byteorder", "byteorder",
"core-foundation 0.9.0", "core-foundation 0.9.1",
"core-graphics 0.22.0", "core-graphics 0.22.1",
"core-text", "core-text",
"dirs", "dirs",
"dwrote", "dwrote",
@ -819,7 +819,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf8c27ca13930dc4ffe474880040fe9e0f03c2121600dc9c95423624cab3e467" checksum = "bf8c27ca13930dc4ffe474880040fe9e0f03c2121600dc9c95423624cab3e467"
dependencies = [ dependencies = [
"cc", "cc",
"core-graphics 0.22.0", "core-graphics 0.22.1",
"core-text", "core-text",
"foreign-types", "foreign-types",
"freetype", "freetype",
@ -847,9 +847,9 @@ dependencies = [
[[package]] [[package]]
name = "hermit-abi" name = "hermit-abi"
version = "0.1.15" version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3deed196b6e7f9e44a2ae8d94225d80302d81208b1bb673fd21fe634645c85a9" checksum = "4c30f6d0bc6b00693347368a67d41b58f2fb851215ff1da49e90fe2c5c667151"
dependencies = [ dependencies = [
"libc", "libc",
] ]
@ -891,9 +891,12 @@ dependencies = [
[[package]] [[package]]
name = "instant" name = "instant"
version = "0.1.6" version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b141fdc7836c525d4d594027d318c84161ca17aaf8113ab1f81ab93ae897485" checksum = "63312a18f7ea8760cdd0a7c5aac1a619752a246b833545e3e36d1f81f7cd9e66"
dependencies = [
"cfg-if",
]
[[package]] [[package]]
name = "iovec" name = "iovec"
@ -1061,9 +1064,9 @@ dependencies = [
[[package]] [[package]]
name = "memoffset" name = "memoffset"
version = "0.5.5" version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c198b026e1bbf08a937e94c6c60f9ec4a2267f5b0d2eec9c1b21b061ce2be55f" checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa"
dependencies = [ dependencies = [
"autocfg 1.0.1", "autocfg 1.0.1",
] ]
@ -1160,7 +1163,7 @@ dependencies = [
"cfg-if", "cfg-if",
"proc-macro2 1.0.21", "proc-macro2 1.0.21",
"quote 1.0.7", "quote 1.0.7",
"syn 1.0.40", "syn 1.0.41",
] ]
[[package]] [[package]]
@ -1357,7 +1360,7 @@ dependencies = [
"proc-macro-crate", "proc-macro-crate",
"proc-macro2 1.0.21", "proc-macro2 1.0.21",
"quote 1.0.7", "quote 1.0.7",
"syn 1.0.40", "syn 1.0.41",
] ]
[[package]] [[package]]
@ -1636,9 +1639,9 @@ dependencies = [
[[package]] [[package]]
name = "rayon-core" name = "rayon-core"
version = "1.8.0" version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91739a34c4355b5434ce54c9086c5895604a9c278586d1f1aa95e04f66b525a0" checksum = "e8c4fec834fb6e6d2dd5eece3c7b432a52f0ba887cf40e595190c4107edc08bf"
dependencies = [ dependencies = [
"crossbeam-channel", "crossbeam-channel",
"crossbeam-deque", "crossbeam-deque",
@ -1735,7 +1738,7 @@ checksum = "7903c2cf599db8f310b392332f38367ca4acc84420fa1aee3536299f433c10d5"
dependencies = [ dependencies = [
"quote 1.0.7", "quote 1.0.7",
"rust-embed-utils", "rust-embed-utils",
"syn 1.0.40", "syn 1.0.41",
"walkdir", "walkdir",
] ]
@ -1959,7 +1962,7 @@ dependencies = [
[[package]] [[package]]
name = "skulpin" name = "skulpin"
version = "0.10.0" version = "0.10.0"
source = "git+https://github.com/aclysma/skulpin?branch=master#e4abfe06f10565bcf17c57c79ad6bf626033cf9c" source = "git+https://github.com/aclysma/skulpin?branch=master#fd476242e176383faf0db127cde0408d0b20cfd0"
dependencies = [ dependencies = [
"log", "log",
"skulpin-app-winit", "skulpin-app-winit",
@ -1971,7 +1974,7 @@ dependencies = [
[[package]] [[package]]
name = "skulpin-app-winit" name = "skulpin-app-winit"
version = "0.4.0" version = "0.4.0"
source = "git+https://github.com/aclysma/skulpin?branch=master#e4abfe06f10565bcf17c57c79ad6bf626033cf9c" source = "git+https://github.com/aclysma/skulpin?branch=master#fd476242e176383faf0db127cde0408d0b20cfd0"
dependencies = [ dependencies = [
"log", "log",
"skulpin-renderer", "skulpin-renderer",
@ -1981,7 +1984,7 @@ dependencies = [
[[package]] [[package]]
name = "skulpin-renderer" name = "skulpin-renderer"
version = "0.4.0" version = "0.4.0"
source = "git+https://github.com/aclysma/skulpin?branch=master#e4abfe06f10565bcf17c57c79ad6bf626033cf9c" source = "git+https://github.com/aclysma/skulpin?branch=master#fd476242e176383faf0db127cde0408d0b20cfd0"
dependencies = [ dependencies = [
"ash", "ash",
"log", "log",
@ -1992,7 +1995,7 @@ dependencies = [
[[package]] [[package]]
name = "skulpin-renderer-sdl2" name = "skulpin-renderer-sdl2"
version = "0.4.0" version = "0.4.0"
source = "git+https://github.com/aclysma/skulpin?branch=master#e4abfe06f10565bcf17c57c79ad6bf626033cf9c" source = "git+https://github.com/aclysma/skulpin?branch=master#fd476242e176383faf0db127cde0408d0b20cfd0"
dependencies = [ dependencies = [
"log", "log",
"sdl2", "sdl2",
@ -2002,7 +2005,7 @@ dependencies = [
[[package]] [[package]]
name = "skulpin-renderer-winit" name = "skulpin-renderer-winit"
version = "0.4.0" version = "0.4.0"
source = "git+https://github.com/aclysma/skulpin?branch=master#e4abfe06f10565bcf17c57c79ad6bf626033cf9c" source = "git+https://github.com/aclysma/skulpin?branch=master#fd476242e176383faf0db127cde0408d0b20cfd0"
dependencies = [ dependencies = [
"cocoa", "cocoa",
"log", "log",
@ -2082,9 +2085,9 @@ dependencies = [
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.40" version = "1.0.41"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "963f7d3cc59b59b9325165add223142bbf1df27655d07789f109896d353d8350" checksum = "6690e3e9f692504b941dc6c3b188fd28df054f7fb8469ab40680df52fdcc842b"
dependencies = [ dependencies = [
"proc-macro2 1.0.21", "proc-macro2 1.0.21",
"quote 1.0.7", "quote 1.0.7",
@ -2138,7 +2141,7 @@ checksum = "bd80fc12f73063ac132ac92aceea36734f04a1d93c1240c6944e23a3b8841793"
dependencies = [ dependencies = [
"proc-macro2 1.0.21", "proc-macro2 1.0.21",
"quote 1.0.7", "quote 1.0.7",
"syn 1.0.40", "syn 1.0.41",
] ]
[[package]] [[package]]

@ -46,10 +46,10 @@ winapi = "0.3.8"
[target.'cfg(windows)'.build-dependencies] [target.'cfg(windows)'.build-dependencies]
winres = "0.1.11" winres = "0.1.11"
sdl2-sys = { version = "0.34", default-features = false, features = ["bundled", "static-link"] } sdl2-sys = { version = "0.34.3", default-features = false, features = ["bundled", "static-link"] }
[target.'cfg(macos)'.build-dependencies] [target.'cfg(macos)'.build-dependencies]
sdl2-sys = { version = "0.34", default-features = false, features = ["bundled", "static-link"] } sdl2-sys = { version = "0.34.3", default-features = false, features = ["bundled", "static-link"] }
[profile.release] [profile.release]
debug = true debug = true

@ -80,7 +80,6 @@ pub struct Editor {
pub windows: HashMap<u64, Window>, pub windows: HashMap<u64, Window>,
pub cursor: Cursor, pub cursor: Cursor,
pub defined_styles: HashMap<u64, Arc<Style>>, pub defined_styles: HashMap<u64, Arc<Style>>,
pub previous_style: Option<Arc<Style>>,
pub mode_list: Vec<CursorMode>, pub mode_list: Vec<CursorMode>,
pub current_mode: EditorMode, pub current_mode: EditorMode,
pub draw_command_sender: Sender<DrawCommand>, pub draw_command_sender: Sender<DrawCommand>,
@ -93,7 +92,6 @@ impl Editor {
windows: HashMap::new(), windows: HashMap::new(),
cursor: Cursor::new(), cursor: Cursor::new(),
defined_styles: HashMap::new(), defined_styles: HashMap::new(),
previous_style: None,
mode_list: Vec::new(), mode_list: Vec::new(),
current_mode: EditorMode::Unknown(String::from("")), current_mode: EditorMode::Unknown(String::from("")),
draw_command_sender, draw_command_sender,
@ -158,17 +156,14 @@ impl Editor {
cells, cells,
} => { } => {
let defined_styles = &self.defined_styles; let defined_styles = &self.defined_styles;
let mut previous_style = self.previous_style.clone();
self.windows.get_mut(&grid).map(|window| { self.windows.get_mut(&grid).map(|window| {
window.draw_grid_line( window.draw_grid_line(
row, row,
column_start, column_start,
cells, cells,
defined_styles, defined_styles
&mut previous_style,
) )
}); });
self.previous_style = previous_style;
} }
RedrawEvent::Clear { grid } => { RedrawEvent::Clear { grid } => {
self.windows self.windows

@ -102,7 +102,7 @@ impl Window {
grid_top: self.grid_top, grid_top: self.grid_top,
width: self.grid.width, width: self.grid.width,
height: self.grid.height, height: self.grid.height,
floating: self.anchor_info.is_some() floating: self.anchor_info.is_some(),
}); });
} }
@ -228,9 +228,9 @@ impl Window {
row: u64, row: u64,
column_start: u64, column_start: u64,
cells: Vec<GridLineCell>, cells: Vec<GridLineCell>,
defined_styles: &HashMap<u64, Arc<Style>>, defined_styles: &HashMap<u64, Arc<Style>>
previous_style: &mut Option<Arc<Style>>,
) { ) {
let mut previous_style = None;
if row < self.grid.height { if row < self.grid.height {
let mut column_pos = column_start; let mut column_pos = column_start;
for cell in cells { for cell in cells {
@ -239,7 +239,7 @@ impl Window {
&mut column_pos, &mut column_pos,
cell, cell,
defined_styles, defined_styles,
previous_style, &mut previous_style,
); );
} }
} else { } else {

@ -148,8 +148,9 @@ impl Renderer {
let region = self.compute_text_region(grid_pos, cell_width); let region = self.compute_text_region(grid_pos, cell_width);
canvas.clip_rect(region, None, Some(false)); canvas.clip_rect(region, None, Some(false));
self.paint.set_blend_mode(BlendMode::Src); self.paint.set_blend_mode(BlendMode::Src);
let transparent = Color::from_argb(0, 255, 255, 255); let transparent = Color::from_argb(0, 0, 0, 0);
self.paint.set_color(transparent); self.paint.set_color(transparent);
canvas.draw_rect(region, &self.paint); canvas.draw_rect(region, &self.paint);

@ -1,6 +1,6 @@
use skulpin::skia_safe::gpu::SurfaceOrigin; use skulpin::skia_safe::gpu::SurfaceOrigin;
use skulpin::skia_safe::{ use skulpin::skia_safe::{
Budgeted, Canvas, ImageInfo, Rect, Surface, Point, Paint, Color, image_filters::blur Budgeted, Canvas, ImageInfo, Rect, Surface, Point, Paint, Color, BlendMode, image_filters::blur
}; };
use skulpin::skia_safe::canvas::{ use skulpin::skia_safe::canvas::{
SaveLayerRec, SaveLayerRec,
@ -146,11 +146,12 @@ impl RenderedWindow {
paint.set_color(Color::from_argb(a, 255, 255, 255)); paint.set_color(Color::from_argb(a, 255, 255, 255));
} }
let background_snapshot = self.background_surface.image_snapshot(); self.background_surface.draw(root_canvas.as_mut(), (current_pixel_position.x, current_pixel_position.y), Some(&paint));
root_canvas.draw_image(background_snapshot, (current_pixel_position.x, current_pixel_position.y), Some(&paint));
let foreground_snapshot = self.foreground_surface.image_snapshot(); let mut paint = Paint::default();
root_canvas.draw_image(foreground_snapshot, (current_pixel_position.x, current_pixel_position.y), None); paint.set_blend_mode(BlendMode::SrcOver);
self.foreground_surface.draw(root_canvas.as_mut(), (current_pixel_position.x, current_pixel_position.y), Some(&paint));
if self.floating { if self.floating {
root_canvas.restore(); root_canvas.restore();
@ -174,25 +175,44 @@ impl RenderedWindow {
let new_destination: Point = (grid_left as f32, grid_top as f32).into(); let new_destination: Point = (grid_left as f32, grid_top as f32).into();
if self.grid_destination != new_destination { if self.grid_destination != new_destination {
self.t = 0.0; // Reset animation as we have a new destination. if self.grid_start_position.x.abs() > f32::EPSILON || self.grid_start_position.y.abs() > f32::EPSILON {
self.grid_start_position = self.grid_current_position; self.t = 0.0; // Reset animation as we have a new destination.
self.grid_destination = new_destination; self.grid_start_position = self.grid_current_position;
self.grid_destination = new_destination;
} else {
// We don't want to animate since the window is animating out of the start location,
// so we set t to 2.0 to stop animations.
self.t = 2.0;
self.grid_start_position = new_destination;
self.grid_destination = new_destination;
}
} }
if grid_width != self.grid_width || grid_height != self.grid_height { if grid_width != self.grid_width || grid_height != self.grid_height {
let mut old_background = self.background_surface; {
self.background_surface = build_window_surface(old_background.canvas(), &renderer, grid_width, grid_height); let mut old_background = self.background_surface;
old_background.draw(self.background_surface.canvas(), (0.0, 0.0), None); self.background_surface = build_window_surface(old_background.canvas(), &renderer, grid_width, grid_height);
old_background.draw(self.background_surface.canvas(), (0.0, 0.0), None);
let mut old_foreground = self.foreground_surface; }
self.foreground_surface = build_window_surface(old_foreground.canvas(), &renderer, grid_width, grid_height);
old_foreground.draw(self.foreground_surface.canvas(), (0.0, 0.0), None); {
let mut old_foreground = self.foreground_surface;
self.foreground_surface = build_window_surface(old_foreground.canvas(), &renderer, grid_width, grid_height);
old_foreground.draw(self.foreground_surface.canvas(), (0.0, 0.0), None);
}
self.grid_width = grid_width; self.grid_width = grid_width;
self.grid_height = grid_height; self.grid_height = grid_height;
} }
self.floating = floating; self.floating = floating;
if self.hidden {
self.hidden = false;
self.t = 2.0; // We don't want to animate since the window is becoming visible, so we set t to 2.0 to stop animations.
self.grid_start_position = new_destination;
self.grid_destination = new_destination;
}
}, },
WindowDrawCommand::Cell { WindowDrawCommand::Cell {
text, cell_width, window_left, window_top, style text, cell_width, window_left, window_top, style
@ -217,7 +237,7 @@ impl RenderedWindow {
grid_position, grid_position,
cell_width, cell_width,
&style, &style,
); );
} }
}, },
WindowDrawCommand::Scroll { WindowDrawCommand::Scroll {
@ -266,7 +286,14 @@ impl RenderedWindow {
let foreground_canvas = self.foreground_surface.canvas(); let foreground_canvas = self.foreground_surface.canvas();
self.foreground_surface = build_window_surface(foreground_canvas, &renderer, self.grid_width, self.grid_height); self.foreground_surface = build_window_surface(foreground_canvas, &renderer, self.grid_width, self.grid_height);
}, },
WindowDrawCommand::Show => self.hidden = false, WindowDrawCommand::Show => {
if self.hidden {
self.hidden = false;
self.t = 2.0; // We don't want to animate since the window is becoming visible, so we set t to 2.0 to stop animations.
self.grid_start_position = self.grid_destination;
self.grid_destination = self.grid_destination;
}
},
WindowDrawCommand::Hide => self.hidden = true, WindowDrawCommand::Hide => self.hidden = true,
_ => {} _ => {}
}; };

Loading…
Cancel
Save