From 8dca96469e0c1561bc88800f58db2e7a01dc12be Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Wed, 15 Jan 2025 16:52:03 +0800 Subject: [PATCH] chore: Update GPUI with MSAA and PathBuilder. (#548) --- Cargo.lock | 88 ++++++++++++++++++++++++++++------ crates/ui/src/input/element.rs | 8 ++-- 2 files changed, 79 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 89a0f825..7460e02f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -474,7 +474,7 @@ dependencies = [ "bitflags 2.6.0", "cexpr", "clang-sys", - "itertools 0.11.0", + "itertools 0.13.0", "log", "prettyplease", "proc-macro2", @@ -527,7 +527,7 @@ checksum = "b81e1519b0d82120d2fd469d5bfb2919a9361c48b02d82d04befc1cdd2002452" [[package]] name = "blade-graphics" version = "0.6.0" -source = "git+https://github.com/kvark/blade?rev=091a8401033847bb9b6ace3fcf70448d069621c5#091a8401033847bb9b6ace3fcf70448d069621c5" +source = "git+https://github.com/kvark/blade?rev=b16f5c7bd873c7126f48c82c39e7ae64602ae74f#b16f5c7bd873c7126f48c82c39e7ae64602ae74f" dependencies = [ "ash", "ash-window", @@ -559,7 +559,7 @@ dependencies = [ [[package]] name = "blade-macros" version = "0.3.0" -source = "git+https://github.com/kvark/blade?rev=091a8401033847bb9b6ace3fcf70448d069621c5#091a8401033847bb9b6ace3fcf70448d069621c5" +source = "git+https://github.com/kvark/blade?rev=b16f5c7bd873c7126f48c82c39e7ae64602ae74f#b16f5c7bd873c7126f48c82c39e7ae64602ae74f" dependencies = [ "proc-macro2", "quote", @@ -569,7 +569,7 @@ dependencies = [ [[package]] name = "blade-util" version = "0.2.0" -source = "git+https://github.com/kvark/blade?rev=091a8401033847bb9b6ace3fcf70448d069621c5#091a8401033847bb9b6ace3fcf70448d069621c5" +source = "git+https://github.com/kvark/blade?rev=b16f5c7bd873c7126f48c82c39e7ae64602ae74f#b16f5c7bd873c7126f48c82c39e7ae64602ae74f" dependencies = [ "blade-graphics", "bytemuck", @@ -952,7 +952,7 @@ dependencies = [ [[package]] name = "collections" version = "0.1.0" -source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#c7371557a03965b6c421b7bdb58f484f7eff5ace" +source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#1c322c0f2daa50f46644832a6a1cdf15bcf921ea" dependencies = [ "indexmap 2.7.0", "rustc-hash 2.1.0", @@ -1316,7 +1316,7 @@ dependencies = [ [[package]] name = "derive_refineable" version = "0.1.0" -source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#c7371557a03965b6c421b7bdb58f484f7eff5ace" +source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#1c322c0f2daa50f46644832a6a1cdf15bcf921ea" dependencies = [ "proc-macro2", "quote", @@ -1685,6 +1685,12 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ce81f49ae8a0482e4c55ea62ebbd7e5a686af544c00b9d090bba3ff9be97b3d" +[[package]] +name = "float_next_after" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bf7cc16383c4b8d58b9905a8509f02926ce3058053c056376248d958c9df1e8" + [[package]] name = "flume" version = "0.11.1" @@ -2269,7 +2275,7 @@ dependencies = [ [[package]] name = "gpui" version = "0.1.0" -source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#c7371557a03965b6c421b7bdb58f484f7eff5ace" +source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#1c322c0f2daa50f46644832a6a1cdf15bcf921ea" dependencies = [ "anyhow", "as-raw-xcb-connection", @@ -2306,6 +2312,7 @@ dependencies = [ "itertools 0.14.0", "linkme", "log", + "lyon", "media", "metal", "num_cpus", @@ -2354,7 +2361,7 @@ dependencies = [ [[package]] name = "gpui_macros" version = "0.1.0" -source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#c7371557a03965b6c421b7bdb58f484f7eff5ace" +source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#1c322c0f2daa50f46644832a6a1cdf15bcf921ea" dependencies = [ "proc-macro2", "quote", @@ -2544,7 +2551,7 @@ dependencies = [ [[package]] name = "http_client" version = "0.1.0" -source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#c7371557a03965b6c421b7bdb58f484f7eff5ace" +source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#1c322c0f2daa50f46644832a6a1cdf15bcf921ea" dependencies = [ "anyhow", "bytes", @@ -3013,6 +3020,58 @@ dependencies = [ "imgref", ] +[[package]] +name = "lyon" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e7f9cda98b5430809e63ca5197b06c7d191bf7e26dfc467d5a3f0290e2a74f" +dependencies = [ + "lyon_algorithms", + "lyon_tessellation", +] + +[[package]] +name = "lyon_algorithms" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f13c9be19d257c7d37e70608ed858e8eab4b2afcea2e3c9a622e892acbf43c08" +dependencies = [ + "lyon_path", + "num-traits", +] + +[[package]] +name = "lyon_geom" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8af69edc087272df438b3ee436c4bb6d7c04aa8af665cfd398feae627dbd8570" +dependencies = [ + "arrayvec", + "euclid", + "num-traits", +] + +[[package]] +name = "lyon_path" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e0b8aec2f58586f6eef237985b9a9b7cb3a3aff4417c575075cf95bf925252e" +dependencies = [ + "lyon_geom", + "num-traits", +] + +[[package]] +name = "lyon_tessellation" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "579d42360a4b09846eff2feef28f538696c7d6c7439bfa65874ff3cbe0951b2c" +dependencies = [ + "float_next_after", + "lyon_path", + "num-traits", +] + [[package]] name = "mac" version = "0.1.1" @@ -3070,7 +3129,7 @@ dependencies = [ [[package]] name = "media" version = "0.1.0" -source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#c7371557a03965b6c421b7bdb58f484f7eff5ace" +source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#1c322c0f2daa50f46644832a6a1cdf15bcf921ea" dependencies = [ "anyhow", "bindgen", @@ -3352,6 +3411,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", + "libm", ] [[package]] @@ -4349,7 +4409,7 @@ dependencies = [ [[package]] name = "refineable" version = "0.1.0" -source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#c7371557a03965b6c421b7bdb58f484f7eff5ace" +source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#1c322c0f2daa50f46644832a6a1cdf15bcf921ea" dependencies = [ "derive_refineable", ] @@ -4677,7 +4737,7 @@ checksum = "d369a96f978623eb3dc28807c4852d6cc617fed53da5d3c400feff1ef34a714a" [[package]] name = "semantic_version" version = "0.1.0" -source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#c7371557a03965b6c421b7bdb58f484f7eff5ace" +source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#1c322c0f2daa50f46644832a6a1cdf15bcf921ea" dependencies = [ "anyhow", "serde", @@ -5116,7 +5176,7 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "sum_tree" version = "0.1.0" -source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#c7371557a03965b6c421b7bdb58f484f7eff5ace" +source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#1c322c0f2daa50f46644832a6a1cdf15bcf921ea" dependencies = [ "arrayvec", "log", @@ -5801,7 +5861,7 @@ checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" [[package]] name = "util" version = "0.1.0" -source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#c7371557a03965b6c421b7bdb58f484f7eff5ace" +source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#1c322c0f2daa50f46644832a6a1cdf15bcf921ea" dependencies = [ "anyhow", "async-fs 2.1.2", diff --git a/crates/ui/src/input/element.rs b/crates/ui/src/input/element.rs index 4e4d9d20..7a6e185b 100644 --- a/crates/ui/src/input/element.rs +++ b/crates/ui/src/input/element.rs @@ -271,11 +271,13 @@ impl TextElement { // print_points_as_svg_path(&line_corners, &points); let first_p = *points.get(0).unwrap(); - let mut path = gpui::Path::new(bounds.origin + first_p); + let mut builder = gpui::PathBuilder::fill(); + builder.move_to(bounds.origin + first_p); for p in points.iter().skip(1) { - path.line_to(bounds.origin + *p); + builder.line_to(bounds.origin + *p); } - Some(path) + + builder.build().ok() } }