From 65b613e6e4750c81f70948d176819f6093273274 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Mon, 18 Dec 2023 13:54:08 -0700 Subject: [PATCH] Add glyphon renderer --- Cargo.lock | 1431 +++++++++++++++++++++++--------------- Cargo.toml | 30 +- README.md | 4 + src/main.rs | 619 +++++++---------- src/renderer/mod.rs | 60 ++ src/renderer/software.rs | 141 ++++ src/renderer/wgpu.rs | 145 ++++ 7 files changed, 1511 insertions(+), 919 deletions(-) create mode 100644 src/renderer/mod.rs create mode 100644 src/renderer/software.rs create mode 100644 src/renderer/wgpu.rs diff --git a/Cargo.lock b/Cargo.lock index 6d812f4..3e3a060 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18,6 +18,15 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046" +[[package]] +name = "addr2line" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +dependencies = [ + "gimli", +] + [[package]] name = "adler" version = "1.0.2" @@ -31,12 +40,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" dependencies = [ "cfg-if 1.0.0", - "getrandom", "once_cell", "version_check", "zerocopy", ] +[[package]] +name = "aho-corasick" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] + [[package]] name = "alacritty_config" version = "0.1.1" @@ -73,13 +90,13 @@ dependencies = [ "dirs", "libc", "log", - "mio", + "mio 0.6.23", "mio-anonymous-pipes", "mio-extras", "miow 0.3.7", "nix 0.24.3", "parking_lot 0.12.1", - "regex-automata", + "regex-automata 0.1.10", "serde", "serde_yaml", "signal-hook", @@ -89,6 +106,12 @@ dependencies = [ "windows-sys 0.36.1", ] +[[package]] +name = "allocator-api2" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" + [[package]] name = "android-activity" version = "0.4.3" @@ -101,39 +124,27 @@ dependencies = [ "jni-sys", "libc", "log", - "ndk 0.7.0", + "ndk", "ndk-context", - "ndk-sys 0.4.1+23.1.7779620", + "ndk-sys", "num_enum 0.6.1", ] -[[package]] -name = "android-activity" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "052ad56e336bcc615a214bffbeca6c181ee9550acec193f0327e0b103b033a4d" -dependencies = [ - "android-properties", - "bitflags 2.4.1", - "cc", - "cesu8", - "jni", - "jni-sys", - "libc", - "log", - "ndk 0.8.0", - "ndk-context", - "ndk-sys 0.5.0+25.2.9519653", - "num_enum 0.7.1", - "thiserror", -] - [[package]] name = "android-properties" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04" +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "arrayref" version = "0.3.7" @@ -147,16 +158,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] -name = "as-raw-xcb-connection" -version = "1.0.1" +name = "ash" +version = "0.37.3+1.3.251" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "175571dd1d178ced59193a6fc02dde1b972eb0bc56c892cde9beeceac5bf0f6b" - -[[package]] -name = "atomic-waker" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" +checksum = "39e9c3835d686b0a6084ab4234fcd1b07dbf6e4767dce60874b12356a25ecd4a" +dependencies = [ + "libloading 0.7.4", +] [[package]] name = "autocfg" @@ -164,12 +172,42 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "backtrace" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +dependencies = [ + "addr2line", + "cc", + "cfg-if 1.0.0", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + [[package]] name = "base64" version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +[[package]] +name = "bit-set" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + [[package]] name = "bitflags" version = "1.3.2" @@ -194,16 +232,7 @@ version = "0.1.0-beta.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fa55741ee90902547802152aaf3f8e5248aab7e21468089560d4c8840561146" dependencies = [ - "objc-sys 0.2.0-beta.2", -] - -[[package]] -name = "block-sys" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dd7cf50912cddc06dc5ea7c08c5e81c1b2c842a70d19def1848d54c586fed92" -dependencies = [ - "objc-sys 0.3.2", + "objc-sys", ] [[package]] @@ -212,18 +241,8 @@ version = "0.2.0-alpha.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8dd9e63c1744f755c2f60332b88de39d341e5e86239014ad839bd71c106dec42" dependencies = [ - "block-sys 0.1.0-beta.1", - "objc2-encode 2.0.0-pre.2", -] - -[[package]] -name = "block2" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15b55663a85f33501257357e6421bb33e769d5c9ffb5ba0921c975a123e35e68" -dependencies = [ - "block-sys 0.2.0", - "objc2 0.4.1", + "block-sys", + "objc2-encode", ] [[package]] @@ -237,51 +256,19 @@ name = "bytemuck" version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" -dependencies = [ - "bytemuck_derive", -] - -[[package]] -name = "bytemuck_derive" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "965ab7eb5f8f97d2a083c799f3a1b994fc397b2fe2da5d1da1626ce15a39f2b1" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.41", -] - -[[package]] -name = "bytes" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "calloop" -version = "0.12.3" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b50b5a44d59a98c55a9eeb518f39bf7499ba19fd98ee7d22618687f3f10adbf" +checksum = "52e0d00eb1ea24371a97d2da6201c6747a633dc6dc1988ef503403b4c59504a8" dependencies = [ - "bitflags 2.4.1", + "bitflags 1.3.2", "log", - "polling", - "rustix", - "slab", + "nix 0.25.1", + "slotmap", "thiserror", -] - -[[package]] -name = "calloop-wayland-source" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f0ea9b9476c7fad82841a8dbb380e2eae480c21910feba80725b46931ed8f02" -dependencies = [ - "calloop", - "rustix", - "wayland-backend", - "wayland-client", + "vec_map", ] [[package]] @@ -294,12 +281,6 @@ dependencies = [ "libc", ] -[[package]] -name = "cesu8" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" - [[package]] name = "cfg-if" version = "0.1.10" @@ -320,16 +301,16 @@ checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" [[package]] name = "cocoa" -version = "0.25.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6140449f97a6e97f9511815c5632d84c8aacf8ac271ad77c559218161a1373c" +checksum = "f425db7937052c684daec3bd6375c8abe2d146dca4b8b143d6db777c39138f3a" dependencies = [ "bitflags 1.3.2", "block", "cocoa-foundation", "core-foundation", - "core-graphics 0.23.1", - "foreign-types 0.5.0", + "core-graphics", + "foreign-types 0.3.2", "libc", "objc", ] @@ -349,23 +330,20 @@ dependencies = [ ] [[package]] -name = "combine" -version = "4.6.6" +name = "codespan-reporting" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" dependencies = [ - "bytes", - "memchr", + "termcolor", + "unicode-width", ] [[package]] -name = "concurrent-queue" -version = "2.4.0" +name = "com-rs" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d16048cd947b08fa32c24458a22f5dc5e835264f689f4f5653210c69fd107363" -dependencies = [ - "crossbeam-utils", -] +checksum = "bf43edc576402991846b093a7ca18a3477e0ef9c588cde84964b5d3e43016642" [[package]] name = "core-foundation" @@ -396,19 +374,6 @@ dependencies = [ "libc", ] -[[package]] -name = "core-graphics" -version = "0.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "970a29baf4110c26fedbc7f82107d42c23f7e88e404c4577ed73fe99ff85a212" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "core-graphics-types", - "foreign-types 0.5.0", - "libc", -] - [[package]] name = "core-graphics-types" version = "0.1.3" @@ -425,10 +390,16 @@ name = "cosmic-term" version = "0.1.0" dependencies = [ "alacritty_terminal", + "bytemuck", "cosmic-text", + "env_logger", + "glyphon", + "log", + "pollster", "softbuffer", - "tiny-skia", - "winit 0.29.4", + "tiny-skia 0.11.3", + "wgpu", + "winit 0.28.6", ] [[package]] @@ -461,30 +432,16 @@ dependencies = [ ] [[package]] -name = "crossbeam-utils" -version = "0.8.17" +name = "d3d12" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d96137f14f244c37f989d9fff8f95e6c18b918e71f36638f8c49112e4c78f" +checksum = "e16e44ab292b1dddfdaf7be62cfd8877df52f2f3fde5858d95bab606be259f20" dependencies = [ - "cfg-if 1.0.0", + "bitflags 2.4.1", + "libloading 0.8.1", + "winapi 0.3.9", ] -[[package]] -name = "ctor" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30d2b3721e861707777e3195b0158f950ae6dc4a27e4d02ff9f67e3eb3de199e" -dependencies = [ - "quote", - "syn 2.0.41", -] - -[[package]] -name = "cursor-icon" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96a6ac251f4a2aca6b3f91340350eab87ae57c3f127ffeb585e92bd336717991" - [[package]] name = "dirs" version = "4.0.0" @@ -527,40 +484,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" [[package]] -name = "drm" -version = "0.10.0" +name = "env_logger" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97fb1b703ffbc7ebd216eba7900008049a56ace55580ecb2ee7fa801e8d8be87" +checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece" dependencies = [ - "bitflags 2.4.1", - "bytemuck", - "drm-ffi", - "drm-fourcc", - "nix 0.27.1", + "humantime", + "is-terminal", + "log", + "regex", + "termcolor", ] -[[package]] -name = "drm-ffi" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba7d1c19c4b6270e89d59fb27dc6d02a317c658a8a54e54781e1db9b5947595d" -dependencies = [ - "drm-sys", - "nix 0.27.1", -] - -[[package]] -name = "drm-fourcc" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0aafbcdb8afc29c1a7ee5fbe53b5d62f4565b35a042a662ca9fecd0b54dae6f4" - -[[package]] -name = "drm-sys" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a4f1c0468062a56cd5705f1e3b5409eb286d5596a2028ec8e947595d7e715ae" - [[package]] name = "equivalent" version = "1.0.1" @@ -578,10 +513,32 @@ dependencies = [ ] [[package]] -name = "fastrand" -version = "2.0.1" +name = "etagere" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +checksum = "306960881d6c46bd0dd6b7f07442a441418c08d0d3e63d8d080b0f64c6343e4e" +dependencies = [ + "euclid", + "svg_fmt", +] + +[[package]] +name = "euclid" +version = "0.22.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f253bc5c813ca05792837a0ff4b3a580336b224512d48f7eda1d7dd9210787" +dependencies = [ + "num-traits", +] + +[[package]] +name = "fastrand" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" +dependencies = [ + "instant", +] [[package]] name = "fdeflate" @@ -602,6 +559,18 @@ dependencies = [ "miniz_oxide", ] +[[package]] +name = "flume" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181" +dependencies = [ + "futures-core", + "futures-sink", + "nanorand", + "spin", +] + [[package]] name = "fontconfig-parser" version = "0.5.3" @@ -619,7 +588,7 @@ checksum = "98b88c54a38407f7352dd2c4238830115a6377741098ffd1f997c813d0e088a6" dependencies = [ "fontconfig-parser", "log", - "memmap2", + "memmap2 0.9.2", "slotmap", "tinyvec", "ttf-parser", @@ -684,10 +653,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" [[package]] -name = "gethostname" -version = "0.3.0" +name = "futures-core" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb65d4ba3173c56a500b555b532f72c42e8d1fe64962b518897f8959fae2c177" +checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" + +[[package]] +name = "futures-sink" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" + +[[package]] +name = "gethostname" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1ebd34e35c46e00bb73e81363248d627782724609fe1b6396f553f68fe3862e" dependencies = [ "libc", "winapi 0.3.9", @@ -700,8 +681,112 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" dependencies = [ "cfg-if 1.0.0", + "js-sys", "libc", "wasi", + "wasm-bindgen", +] + +[[package]] +name = "gimli" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" + +[[package]] +name = "gl_generator" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d" +dependencies = [ + "khronos_api", + "log", + "xml-rs", +] + +[[package]] +name = "glow" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "886c2a30b160c4c6fec8f987430c26b526b7988ca71f664e6a699ddf6f9601e4" +dependencies = [ + "js-sys", + "slotmap", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "glutin_wgl_sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8098adac955faa2d31079b65dc48841251f69efd3ac25477903fc424362ead" +dependencies = [ + "gl_generator", +] + +[[package]] +name = "glyphon" +version = "0.3.0" +source = "git+https://github.com/jackpot51/glyphon.git?branch=refactor#32981e779ff02c87c5dedc699139bfcc51cd7256" +dependencies = [ + "cosmic-text", + "etagere", + "lru", + "wgpu", +] + +[[package]] +name = "gpu-alloc" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbcd2dba93594b227a1f57ee09b8b9da8892c34d55aa332e034a228d0fe6a171" +dependencies = [ + "bitflags 2.4.1", + "gpu-alloc-types", +] + +[[package]] +name = "gpu-alloc-types" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98ff03b468aa837d70984d55f5d3f846f6ec31fe34bbb97c4f85219caeee1ca4" +dependencies = [ + "bitflags 2.4.1", +] + +[[package]] +name = "gpu-allocator" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40fe17c8a05d60c38c0a4e5a3c802f2f1ceb66b76c67d96ffb34bef0475a7fad" +dependencies = [ + "backtrace", + "log", + "presser", + "thiserror", + "winapi 0.3.9", + "windows", +] + +[[package]] +name = "gpu-descriptor" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc11df1ace8e7e564511f53af41f3e42ddc95b56fd07b3f4445d2a6048bc682c" +dependencies = [ + "bitflags 2.4.1", + "gpu-descriptor-types", + "hashbrown 0.14.3", +] + +[[package]] +name = "gpu-descriptor-types" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bf0b36e6f090b7e1d8a4b49c0cb81c1f8376f72198c65dd3ad9ff3556b8b78c" +dependencies = [ + "bitflags 2.4.1", ] [[package]] @@ -715,18 +800,44 @@ name = "hashbrown" version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +dependencies = [ + "ahash", + "allocator-api2", +] [[package]] -name = "icrate" -version = "0.0.4" +name = "hassle-rs" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99d3aaff8a54577104bafdf686ff18565c3b6903ca5782a2026ef06e2c7aa319" +checksum = "1397650ee315e8891a0df210707f0fc61771b0cc518c3023896064c5407cb3b0" dependencies = [ - "block2 0.3.0", - "dispatch", - "objc2 0.4.1", + "bitflags 1.3.2", + "com-rs", + "libc", + "libloading 0.7.4", + "thiserror", + "widestring", + "winapi 0.3.9", ] +[[package]] +name = "hermit-abi" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" + +[[package]] +name = "hexf-parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df" + +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + [[package]] name = "indexmap" version = "1.9.3" @@ -759,6 +870,17 @@ dependencies = [ "web-sys", ] +[[package]] +name = "io-lifetimes" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys 0.48.0", +] + [[package]] name = "iovec" version = "0.1.4" @@ -769,19 +891,14 @@ dependencies = [ ] [[package]] -name = "jni" -version = "0.21.1" +name = "is-terminal" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ - "cesu8", - "cfg-if 1.0.0", - "combine", - "jni-sys", - "log", - "thiserror", - "walkdir", - "windows-sys 0.45.0", + "hermit-abi", + "rustix", + "windows-sys 0.48.0", ] [[package]] @@ -818,6 +935,29 @@ dependencies = [ "winapi-build", ] +[[package]] +name = "khronos-egl" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6aae1df220ece3c0ada96b8153459b67eebe9ae9212258bb0134ae60416fdf76" +dependencies = [ + "libc", + "libloading 0.8.1", + "pkg-config", +] + +[[package]] +name = "khronos_api" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + [[package]] name = "lazycell" version = "1.3.0" @@ -909,6 +1049,15 @@ dependencies = [ "serde", ] +[[package]] +name = "lru" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a83fb7698b3643a0e34f9ae6f2e8f0178c0fd42f8b59d493aa271ff3a5bf21" +dependencies = [ + "hashbrown 0.14.3", +] + [[package]] name = "malloc_buf" version = "0.0.6" @@ -924,6 +1073,15 @@ version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" +[[package]] +name = "memmap2" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" +dependencies = [ + "libc", +] + [[package]] name = "memmap2" version = "0.9.2" @@ -951,6 +1109,21 @@ dependencies = [ "autocfg", ] +[[package]] +name = "metal" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c43f73953f8cbe511f021b58f18c3ce1c3d1ae13fe953293e13345bf83217f25" +dependencies = [ + "bitflags 2.4.1", + "block", + "core-graphics-types", + "foreign-types 0.5.0", + "log", + "objc", + "paste", +] + [[package]] name = "miniz_oxide" version = "0.7.1" @@ -980,13 +1153,25 @@ dependencies = [ "winapi 0.2.8", ] +[[package]] +name = "mio" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" +dependencies = [ + "libc", + "log", + "wasi", + "windows-sys 0.48.0", +] + [[package]] name = "mio-anonymous-pipes" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6bc513025fe5005a3aa561b50fdb2cda5a150b84800ae02acd8aa9ed62ca1a6b" dependencies = [ - "mio", + "mio 0.6.23", "miow 0.3.7", "parking_lot 0.11.2", "spsc-buffer", @@ -1001,7 +1186,7 @@ checksum = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19" dependencies = [ "lazycell", "log", - "mio", + "mio 0.6.23", "slab", ] @@ -1013,7 +1198,7 @@ checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0" dependencies = [ "iovec", "libc", - "mio", + "mio 0.6.23", ] [[package]] @@ -1037,6 +1222,35 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "naga" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae585df4b6514cf8842ac0f1ab4992edc975892704835b549cf818dc0191249e" +dependencies = [ + "bit-set", + "bitflags 2.4.1", + "codespan-reporting", + "hexf-parse", + "indexmap 2.1.0", + "log", + "num-traits", + "rustc-hash", + "spirv", + "termcolor", + "thiserror", + "unicode-xid", +] + +[[package]] +name = "nanorand" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a51313c5820b0b02bd422f4b44776fbf47961755c74ce64afc73bfad10226c3" +dependencies = [ + "getrandom", +] + [[package]] name = "ndk" version = "0.7.0" @@ -1045,24 +1259,9 @@ checksum = "451422b7e4718271c8b5b3aadf5adedba43dc76312454b387e98fae0fc951aa0" dependencies = [ "bitflags 1.3.2", "jni-sys", - "ndk-sys 0.4.1+23.1.7779620", + "ndk-sys", "num_enum 0.5.11", - "raw-window-handle 0.5.2", - "thiserror", -] - -[[package]] -name = "ndk" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2076a31b7010b17a38c01907c45b945e8f11495ee4dd588309718901b1f7a5b7" -dependencies = [ - "bitflags 2.4.1", - "jni-sys", - "log", - "ndk-sys 0.5.0+25.2.9519653", - "num_enum 0.7.1", - "raw-window-handle 0.6.0", + "raw-window-handle", "thiserror", ] @@ -1081,15 +1280,6 @@ dependencies = [ "jni-sys", ] -[[package]] -name = "ndk-sys" -version = "0.5.0+25.2.9519653" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c196769dd60fd4f363e11d948139556a344e79d451aeb2fa2fd040738ef7691" -dependencies = [ - "jni-sys", -] - [[package]] name = "net2" version = "0.2.39" @@ -1113,6 +1303,19 @@ dependencies = [ "memoffset 0.6.5", ] +[[package]] +name = "nix" +version = "0.25.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f346ff70e7dbfd675fe90590b92d59ef2de15a8779ae305ebcbfd3f0caf59be4" +dependencies = [ + "autocfg", + "bitflags 1.3.2", + "cfg-if 1.0.0", + "libc", + "memoffset 0.6.5", +] + [[package]] name = "nix" version = "0.26.4" @@ -1123,17 +1326,16 @@ dependencies = [ "cfg-if 1.0.0", "libc", "memoffset 0.7.1", + "pin-utils", ] [[package]] -name = "nix" -version = "0.27.1" +name = "num-traits" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ - "bitflags 2.4.1", - "cfg-if 1.0.0", - "libc", + "autocfg", ] [[package]] @@ -1154,15 +1356,6 @@ dependencies = [ "num_enum_derive 0.6.1", ] -[[package]] -name = "num_enum" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "683751d591e6d81200c39fb0d1032608b77724f34114db54f571ff1317b337c0" -dependencies = [ - "num_enum_derive 0.7.1", -] - [[package]] name = "num_enum_derive" version = "0.5.11" @@ -1187,18 +1380,6 @@ dependencies = [ "syn 2.0.41", ] -[[package]] -name = "num_enum_derive" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c11e44798ad209ccdd91fc192f0526a369a01234f7373e1b141c96d7cee4f0e" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 2.0.41", -] - [[package]] name = "objc" version = "0.2.7" @@ -1206,6 +1387,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" dependencies = [ "malloc_buf", + "objc_exception", ] [[package]] @@ -1214,31 +1396,15 @@ version = "0.2.0-beta.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b9834c1e95694a05a828b59f55fa2afec6288359cda67146126b3f90a55d7" -[[package]] -name = "objc-sys" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7c71324e4180d0899963fc83d9d241ac39e699609fc1025a850aadac8257459" - [[package]] name = "objc2" version = "0.3.0-beta.3.patch-leaks.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e01640f9f2cb1220bbe80325e179e532cb3379ebcd1bf2279d703c19fe3a468" dependencies = [ - "block2 0.2.0-alpha.6", - "objc-sys 0.2.0-beta.2", - "objc2-encode 2.0.0-pre.2", -] - -[[package]] -name = "objc2" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "559c5a40fdd30eb5e344fbceacf7595a81e242529fb4e21cf5f43fb4f11ff98d" -dependencies = [ - "objc-sys 0.3.2", - "objc2-encode 3.0.0", + "block2", + "objc-sys", + "objc2-encode", ] [[package]] @@ -1247,14 +1413,26 @@ version = "2.0.0-pre.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "abfcac41015b00a120608fdaa6938c44cb983fee294351cc4bac7638b4e50512" dependencies = [ - "objc-sys 0.2.0-beta.2", + "objc-sys", ] [[package]] -name = "objc2-encode" -version = "3.0.0" +name = "objc_exception" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d079845b37af429bfe5dfa76e6d087d788031045b25cfc6fd898486fd9847666" +checksum = "ad970fb455818ad6cba4c122ad012fae53ae8b4795f86378bce65e4f6bab2ca4" +dependencies = [ + "cc", +] + +[[package]] +name = "object" +version = "0.32.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" +dependencies = [ + "memchr", +] [[package]] name = "once_cell" @@ -1328,6 +1506,12 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + [[package]] name = "percent-encoding" version = "2.3.1" @@ -1335,10 +1519,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] -name = "pin-project-lite" -version = "0.2.13" +name = "pin-utils" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" @@ -1360,18 +1544,16 @@ dependencies = [ ] [[package]] -name = "polling" -version = "3.3.1" +name = "pollster" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf63fa624ab313c11656b4cda960bfc46c410187ad493c41f6ba2d8c1e991c9e" -dependencies = [ - "cfg-if 1.0.0", - "concurrent-queue", - "pin-project-lite", - "rustix", - "tracing", - "windows-sys 0.52.0", -] +checksum = "22686f4785f02a4fcc856d3b3bb19bf6c8160d103f7a99cc258bddd0251dc7f2" + +[[package]] +name = "presser" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8cf8e6a8aa66ce33f63993ffc4ea4271eb5b0530a9002db8455ea6050c77bfa" [[package]] name = "proc-macro-crate" @@ -1393,10 +1575,16 @@ dependencies = [ ] [[package]] -name = "quick-xml" -version = "0.30.0" +name = "profiling" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eff6510e86862b57b210fd8cbe8ed3f0d7d600b9c2863cd4549a2e033c66e956" +checksum = "1de09527cd2ea2c2d59fb6c2f8c1ab8c71709ed9d1b6d60b0e1c9fbb6fdcb33c" + +[[package]] +name = "quick-xml" +version = "0.28.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce5e73202a820a31f8a0ee32ada5e21029c81fd9e3ebf668a40832e4219d9d1" dependencies = [ "memchr", ] @@ -1410,6 +1598,12 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "range-alloc" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8a99fddc9f0ba0a85884b8d14e3592853e787d581ca1816c91349b10e4eeab" + [[package]] name = "rangemap" version = "1.4.0" @@ -1422,12 +1616,6 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9" -[[package]] -name = "raw-window-handle" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42a9830a0e1b9fb145ebb365b8bc4ccd75f290f98c0247deafbbe2c75cefb544" - [[package]] name = "redox_syscall" version = "0.2.16" @@ -1466,13 +1654,36 @@ dependencies = [ "thiserror", ] +[[package]] +name = "regex" +version = "1.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata 0.4.3", + "regex-syntax 0.8.2", +] + [[package]] name = "regex-automata" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" dependencies = [ - "regex-syntax", + "regex-syntax 0.6.29", +] + +[[package]] +name = "regex-automata" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.8.2", ] [[package]] @@ -1481,6 +1692,18 @@ version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" +[[package]] +name = "regex-syntax" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" + +[[package]] +name = "renderdoc-sys" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "216080ab382b992234dda86873c18d4c48358f5cfcb70fd693d7f6f2131b628b" + [[package]] name = "roxmltree" version = "0.18.1" @@ -1490,6 +1713,12 @@ dependencies = [ "xmlparser", ] +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + [[package]] name = "rustc-hash" version = "1.1.0" @@ -1532,15 +1761,6 @@ version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - [[package]] name = "scoped-tls" version = "1.0.1" @@ -1555,15 +1775,14 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "sctk-adwaita" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1729a30a469de249c6effc17ec8d039b0aa29b3af79b819b7f51cb6ab8046a90" +version = "0.5.4" +source = "git+https://github.com/pop-os/sctk-adwaita?branch=wayland-resize#da85380dfb8f0c13aed51c5bddaad0ba3654cb1f" dependencies = [ "ab_glyph", "log", - "memmap2", + "memmap2 0.5.10", "smithay-client-toolkit", - "tiny-skia", + "tiny-skia 0.8.4", ] [[package]] @@ -1621,7 +1840,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29ad2e15f37ec9a6cc544097b78a1ec90001e9f71b81338ca39f430adaca99af" dependencies = [ "libc", - "mio", + "mio 0.6.23", "mio-uds", "signal-hook", ] @@ -1667,81 +1886,92 @@ checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "smithay-client-toolkit" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60e3d9941fa3bacf7c2bf4b065304faa14164151254cd16ce1b1bc8fc381600f" +version = "0.16.1" +source = "git+https://github.com/pop-os/client-toolkit?branch=wayland-resize#515820fc86cf8cb3ac8d087dc6c87852767627ca" dependencies = [ - "bitflags 2.4.1", + "bitflags 1.3.2", "calloop", - "calloop-wayland-source", - "cursor-icon", - "libc", + "dlib", + "lazy_static", "log", - "memmap2", - "rustix", - "thiserror", - "wayland-backend", - "wayland-client", - "wayland-csd-frame", + "memmap2 0.5.10", + "nix 0.24.3", + "pkg-config", + "wayland-client 0.29.5", "wayland-cursor", "wayland-protocols", - "wayland-protocols-wlr", - "wayland-scanner 0.31.0", - "xkeysym", -] - -[[package]] -name = "smol_str" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74212e6bbe9a4352329b2f68ba3130c15a3f26fe88ff22dbdc6cdd58fa85e99c" -dependencies = [ - "serde", ] [[package]] name = "softbuffer" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfa97594e034a52bfc0f7a2764f0445bd6dcf1c27136779b244473f9c24f9c5e" +version = "0.2.0" +source = "git+https://github.com/pop-os/softbuffer.git?branch=cosmic#e11ceac52589f9cad0cac95f86382c1f5fa9f440" dependencies = [ - "as-raw-xcb-connection", "bytemuck", "cfg_aliases", "cocoa", - "core-graphics 0.23.1", - "drm", + "core-graphics", "fastrand", - "foreign-types 0.5.0", - "js-sys", + "foreign-types 0.3.2", "log", - "memmap2", + "nix 0.26.4", "objc", - "raw-window-handle 0.6.0", + "raw-window-handle", "redox_syscall 0.4.1", - "rustix", - "tiny-xlib", + "thiserror", "wasm-bindgen", "wayland-backend", - "wayland-client", - "wayland-sys", + "wayland-client 0.30.2", + "wayland-sys 0.30.1", "web-sys", - "windows-sys 0.48.0", + "windows-sys 0.42.0", + "x11-dl", "x11rb", ] +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +dependencies = [ + "lock_api", +] + +[[package]] +name = "spirv" +version = "0.2.0+1.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "246bfa38fe3db3f1dfc8ca5a2cdeb7348c78be2112740cc0ec8ef18b6d94f830" +dependencies = [ + "bitflags 1.3.2", + "num-traits", +] + [[package]] name = "spsc-buffer" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be6c3f39c37a4283ee4b43d1311c828f2e1fb0541e76ea0cb1a2abd9ef2f5b3b" +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "strict-num" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731" +[[package]] +name = "svg_fmt" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fb1df15f412ee2e9dfc1c504260fa695c1c3f10fe9f4a6ee2d2184d7d6450e2" + [[package]] name = "swash" version = "0.1.8" @@ -1783,6 +2013,15 @@ dependencies = [ "libc", ] +[[package]] +name = "termcolor" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449" +dependencies = [ + "winapi-util", +] + [[package]] name = "thiserror" version = "1.0.51" @@ -1803,6 +2042,20 @@ dependencies = [ "syn 2.0.41", ] +[[package]] +name = "tiny-skia" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df8493a203431061e901613751931f047d1971337153f96d0e5e363d6dbf6a67" +dependencies = [ + "arrayref", + "arrayvec", + "bytemuck", + "cfg-if 1.0.0", + "png", + "tiny-skia-path 0.8.4", +] + [[package]] name = "tiny-skia" version = "0.11.3" @@ -1815,7 +2068,18 @@ dependencies = [ "cfg-if 1.0.0", "log", "png", - "tiny-skia-path", + "tiny-skia-path 0.11.3", +] + +[[package]] +name = "tiny-skia-path" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adbfb5d3f3dd57a0e11d12f4f13d4ebbbc1b5c15b7ab0a156d030b21da5f677c" +dependencies = [ + "arrayref", + "bytemuck", + "strict-num", ] [[package]] @@ -1829,18 +2093,6 @@ dependencies = [ "strict-num", ] -[[package]] -name = "tiny-xlib" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4098d49269baa034a8d1eae9bd63e9fa532148d772121dace3bcd6a6c98eb6d" -dependencies = [ - "as-raw-xcb-connection", - "ctor", - "libloading 0.8.1", - "tracing", -] - [[package]] name = "tinyvec" version = "1.6.0" @@ -1858,9 +2110,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "toml_datetime" -version = "0.6.5" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" [[package]] name = "toml_edit" @@ -1873,22 +2125,6 @@ dependencies = [ "winnow", ] -[[package]] -name = "tracing" -version = "0.1.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" -dependencies = [ - "pin-project-lite", - "tracing-core", -] - -[[package]] -name = "tracing-core" -version = "0.1.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" - [[package]] name = "ttf-parser" version = "0.20.0" @@ -1949,12 +2185,24 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + [[package]] name = "utf8parse" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + [[package]] name = "version_check" version = "0.9.4" @@ -1981,16 +2229,6 @@ dependencies = [ "quote", ] -[[package]] -name = "walkdir" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" -dependencies = [ - "same-file", - "winapi-util", -] - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -2065,88 +2303,80 @@ checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" [[package]] name = "wayland-backend" -version = "0.3.2" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19152ddd73f45f024ed4534d9ca2594e0ef252c1847695255dae47f34df9fbe4" +checksum = "41b48e27457e8da3b2260ac60d0a94512f5cba36448679f3747c0865b7893ed8" dependencies = [ "cc", "downcast-rs", + "io-lifetimes", "nix 0.26.4", "scoped-tls", "smallvec", - "wayland-sys", + "wayland-sys 0.30.1", ] [[package]] name = "wayland-client" -version = "0.31.1" +version = "0.29.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ca7d52347346f5473bf2f56705f360e8440873052e575e55890c4fa57843ed3" +checksum = "3f3b068c05a039c9f755f881dc50f01732214f5685e379829759088967c46715" dependencies = [ - "bitflags 2.4.1", - "nix 0.26.4", - "wayland-backend", - "wayland-scanner 0.31.0", + "bitflags 1.3.2", + "downcast-rs", + "libc", + "nix 0.24.3", + "scoped-tls", + "wayland-commons", + "wayland-scanner 0.29.5", + "wayland-sys 0.29.5", ] [[package]] -name = "wayland-csd-frame" -version = "0.3.0" +name = "wayland-client" +version = "0.30.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "625c5029dbd43d25e6aa9615e88b829a5cad13b2819c4ae129fdbb7c31ab4c7e" +checksum = "489c9654770f674fc7e266b3c579f4053d7551df0ceb392f153adb1f9ed06ac8" dependencies = [ - "bitflags 2.4.1", - "cursor-icon", + "bitflags 1.3.2", + "nix 0.26.4", "wayland-backend", + "wayland-scanner 0.30.1", +] + +[[package]] +name = "wayland-commons" +version = "0.29.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8691f134d584a33a6606d9d717b95c4fa20065605f798a3f350d78dced02a902" +dependencies = [ + "nix 0.24.3", + "once_cell", + "smallvec", + "wayland-sys 0.29.5", ] [[package]] name = "wayland-cursor" -version = "0.31.0" +version = "0.29.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44aa20ae986659d6c77d64d808a046996a932aa763913864dc40c359ef7ad5b" +checksum = "6865c6b66f13d6257bef1cd40cbfe8ef2f150fb8ebbdb1e8e873455931377661" dependencies = [ - "nix 0.26.4", - "wayland-client", + "nix 0.24.3", + "wayland-client 0.29.5", "xcursor", ] [[package]] name = "wayland-protocols" -version = "0.31.0" +version = "0.29.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e253d7107ba913923dc253967f35e8561a3c65f914543e46843c88ddd729e21c" +checksum = "b950621f9354b322ee817a23474e479b34be96c2e909c14f7bc0100e9a970bc6" dependencies = [ - "bitflags 2.4.1", - "wayland-backend", - "wayland-client", - "wayland-scanner 0.31.0", -] - -[[package]] -name = "wayland-protocols-plasma" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23803551115ff9ea9bce586860c5c5a971e360825a0309264102a9495a5ff479" -dependencies = [ - "bitflags 2.4.1", - "wayland-backend", - "wayland-client", - "wayland-protocols", - "wayland-scanner 0.31.0", -] - -[[package]] -name = "wayland-protocols-wlr" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad1f61b76b6c2d8742e10f9ba5c3737f6530b4c243132c2a2ccc8aa96fe25cd6" -dependencies = [ - "bitflags 2.4.1", - "wayland-backend", - "wayland-client", - "wayland-protocols", - "wayland-scanner 0.31.0", + "bitflags 1.3.2", + "wayland-client 0.29.5", + "wayland-commons", + "wayland-scanner 0.29.5", ] [[package]] @@ -2162,9 +2392,9 @@ dependencies = [ [[package]] name = "wayland-scanner" -version = "0.31.0" +version = "0.30.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb8e28403665c9f9513202b7e1ed71ec56fde5c107816843fb14057910b2c09c" +checksum = "b9b873b257fbc32ec909c0eb80dea312076a67014e65e245f5eb69a6b8ab330e" dependencies = [ "proc-macro2", "quick-xml", @@ -2173,36 +2403,145 @@ dependencies = [ [[package]] name = "wayland-sys" -version = "0.31.1" +version = "0.29.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15a0c8eaff5216d07f226cb7a549159267f3467b289d9a2e52fd3ef5aae2b7af" +checksum = "be12ce1a3c39ec7dba25594b97b42cb3195d54953ddb9d3d95a7c3902bc6e9d4" dependencies = [ "dlib", + "lazy_static", + "pkg-config", +] + +[[package]] +name = "wayland-sys" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96b2a02ac608e07132978689a6f9bf4214949c85998c247abadd4f4129b1aa06" +dependencies = [ + "dlib", + "lazy_static", "log", - "once_cell", "pkg-config", ] [[package]] name = "web-sys" -version = "0.3.66" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f" +checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" dependencies = [ "js-sys", "wasm-bindgen", ] [[package]] -name = "web-time" -version = "0.2.3" +name = "wgpu" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57099a701fb3a8043f993e8228dc24229c7b942e2b009a1b962e54489ba1d3bf" +checksum = "30e7d227c9f961f2061c26f4cb0fbd4df0ef37e056edd0931783599d6c94ef24" dependencies = [ + "arrayvec", + "cfg-if 1.0.0", + "flume", "js-sys", + "log", + "naga", + "parking_lot 0.12.1", + "profiling", + "raw-window-handle", + "smallvec", + "static_assertions", "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "wgpu-core", + "wgpu-hal", + "wgpu-types", ] +[[package]] +name = "wgpu-core" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef91c1d62d1e9e81c79e600131a258edf75c9531cbdbde09c44a011a47312726" +dependencies = [ + "arrayvec", + "bit-vec", + "bitflags 2.4.1", + "codespan-reporting", + "log", + "naga", + "parking_lot 0.12.1", + "profiling", + "raw-window-handle", + "rustc-hash", + "smallvec", + "thiserror", + "web-sys", + "wgpu-hal", + "wgpu-types", +] + +[[package]] +name = "wgpu-hal" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b84ecc802da3eb67b4cf3dd9ea6fe45bbb47ef13e6c49c5c3240868a9cc6cdd9" +dependencies = [ + "android_system_properties", + "arrayvec", + "ash", + "bit-set", + "bitflags 2.4.1", + "block", + "core-graphics-types", + "d3d12", + "glow", + "glutin_wgl_sys", + "gpu-alloc", + "gpu-allocator", + "gpu-descriptor", + "hassle-rs", + "js-sys", + "khronos-egl", + "libc", + "libloading 0.8.1", + "log", + "metal", + "naga", + "objc", + "once_cell", + "parking_lot 0.12.1", + "profiling", + "range-alloc", + "raw-window-handle", + "renderdoc-sys", + "rustc-hash", + "smallvec", + "thiserror", + "wasm-bindgen", + "web-sys", + "wgpu-types", + "winapi 0.3.9", +] + +[[package]] +name = "wgpu-types" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d5ed5f0edf0de351fe311c53304986315ce866f394a2e6df0c4b3c70774bcdd" +dependencies = [ + "bitflags 2.4.1", + "js-sys", + "web-sys", +] + +[[package]] +name = "widestring" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "653f141f39ec16bba3c5abe400a0c60da7468261cc2cbf36805022876bc721a8" + [[package]] name = "winapi" version = "0.2.8" @@ -2255,6 +2594,25 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows" +version = "0.51.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca229916c5ee38c2f2bc1e9d8f04df975b4bd93f9955dc69fabb5d91270045c9" +dependencies = [ + "windows-core", + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-core" +version = "0.51.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" +dependencies = [ + "windows-targets 0.48.5", +] + [[package]] name = "windows-sys" version = "0.36.1" @@ -2268,6 +2626,21 @@ dependencies = [ "windows_x86_64_msvc 0.36.1", ] +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + [[package]] name = "windows-sys" version = "0.45.0" @@ -2498,24 +2871,58 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winit" -version = "0.28.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9596d90b45384f5281384ab204224876e8e8bf7d58366d9b795ad99aa9894b94" +version = "0.28.6" +source = "git+https://github.com/pop-os/winit.git?branch=master#c6ad672264b2e320cd15a531f67e133d9ecd39bf" dependencies = [ - "android-activity 0.4.3", + "android-activity", "bitflags 1.3.2", "cfg_aliases", "core-foundation", - "core-graphics 0.22.3", + "core-graphics", "dispatch", "instant", "libc", "log", - "ndk 0.7.0", - "objc2 0.3.0-beta.3.patch-leaks.3", + "mio 0.8.10", + "ndk", + "objc2", "once_cell", "orbclient", - "raw-window-handle 0.5.2", + "percent-encoding", + "raw-window-handle", + "redox_syscall 0.3.5", + "sctk-adwaita", + "smithay-client-toolkit", + "wasm-bindgen", + "wayland-client 0.29.5", + "wayland-commons", + "wayland-protocols", + "wayland-scanner 0.29.5", + "web-sys", + "windows-sys 0.45.0", + "x11-dl", +] + +[[package]] +name = "winit" +version = "0.28.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9596d90b45384f5281384ab204224876e8e8bf7d58366d9b795ad99aa9894b94" +dependencies = [ + "android-activity", + "bitflags 1.3.2", + "cfg_aliases", + "core-foundation", + "core-graphics", + "dispatch", + "instant", + "libc", + "log", + "ndk", + "objc2", + "once_cell", + "orbclient", + "raw-window-handle", "redox_syscall 0.3.5", "serde", "wasm-bindgen", @@ -2524,54 +2931,6 @@ dependencies = [ "windows-sys 0.45.0", ] -[[package]] -name = "winit" -version = "0.29.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d25d662bb83b511acd839534bb2d88521b0bbc81440969cb077d23c4db9e62c7" -dependencies = [ - "ahash", - "android-activity 0.5.0", - "atomic-waker", - "bitflags 2.4.1", - "bytemuck", - "calloop", - "cfg_aliases", - "core-foundation", - "core-graphics 0.23.1", - "cursor-icon", - "icrate", - "js-sys", - "libc", - "log", - "memmap2", - "ndk 0.8.0", - "ndk-sys 0.5.0+25.2.9519653", - "objc2 0.4.1", - "once_cell", - "orbclient", - "percent-encoding", - "raw-window-handle 0.6.0", - "redox_syscall 0.3.5", - "rustix", - "sctk-adwaita", - "smithay-client-toolkit", - "smol_str", - "unicode-segmentation", - "wasm-bindgen", - "wasm-bindgen-futures", - "wayland-backend", - "wayland-client", - "wayland-protocols", - "wayland-protocols-plasma", - "web-sys", - "web-time", - "windows-sys 0.48.0", - "x11-dl", - "x11rb", - "xkbcommon-dl", -] - [[package]] name = "winnow" version = "0.5.28" @@ -2604,15 +2963,14 @@ dependencies = [ [[package]] name = "x11rb" -version = "0.12.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1641b26d4dec61337c35a1b1aaf9e3cba8f46f0b43636c609ab0291a648040a" +checksum = "cdf3c79412dd91bae7a7366b8ad1565a85e35dd049affc3a6a2c549e97419617" dependencies = [ - "as-raw-xcb-connection", "gethostname", "libc", "libloading 0.7.4", - "nix 0.26.4", + "nix 0.25.1", "once_cell", "winapi 0.3.9", "winapi-wsapoll", @@ -2621,11 +2979,11 @@ dependencies = [ [[package]] name = "x11rb-protocol" -version = "0.12.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82d6c3f9a0fb6701fab8f6cea9b0c0bd5d6876f1f89f7fada07e558077c344bc" +checksum = "e0b1513b141123073ce54d5bb1d33f801f17508fbd61e02060b1214e96d39c56" dependencies = [ - "nix 0.26.4", + "nix 0.25.1", ] [[package]] @@ -2634,25 +2992,6 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a0ccd7b4a5345edfcd0c3535718a4e9ff7798ffc536bb5b5a0e26ff84732911" -[[package]] -name = "xkbcommon-dl" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6924668544c48c0133152e7eec86d644a056ca3d09275eb8d5cdb9855f9d8699" -dependencies = [ - "bitflags 2.4.1", - "dlib", - "log", - "once_cell", - "xkeysym", -] - -[[package]] -name = "xkeysym" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "054a8e68b76250b253f671d1268cb7f1ae089ec35e195b2efb2a4e9a836d0621" - [[package]] name = "xml-rs" version = "0.8.19" diff --git a/Cargo.toml b/Cargo.toml index 9e5ed4b..58133b1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,10 +7,36 @@ edition = "2021" [dependencies] alacritty_terminal = "0.19" -softbuffer = "0.4" +bytemuck = "1.14" +env_logger = "0.10" +log = "0.4" tiny-skia = "0.11" -winit = "0.29" [dependencies.cosmic-text] git = "https://github.com/pop-os/cosmic-text.git" branch = "refactor" + +[dependencies.glyphon] +git = "https://github.com/jackpot51/glyphon.git" +branch = "refactor" +optional = true + +[dependencies.pollster] +version = "0.3" +optional = true + +[dependencies.softbuffer] +git = "https://github.com/pop-os/softbuffer.git" +branch = "cosmic" + +[dependencies.wgpu] +version = "0.18" +optional = true + +[dependencies.winit] +git = "https://github.com/pop-os/winit.git" +branch = "master" + +[features] +default = [] +wgpu = ["dep:glyphon", "dep:pollster", "dep:wgpu"] diff --git a/README.md b/README.md index 8ac14cd..b74dbbe 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,6 @@ # cosmic-term WIP COSMIC terminal emulator, built using [alacritty\_terminal](https://docs.rs/alacritty_terminal) that is provided by the [alacritty](https://github.com/alacritty/alacritty) project. `cosmic-term` provides bidirectional rendering and ligatures with a custom renderer based on [cosmic-text](https://github.com/pop-os/cosmic-text). + +The `wgpu` feature, enabled by default, supports GPU rendering using `glyphon` +and `wgpu`. If `wgpu` is not enabled or fails to initialize, then rendering falls +back to using `softbuffer` and `tiny-skia`. diff --git a/src/main.rs b/src/main.rs index 5721e3f..97454d8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,17 +14,21 @@ use alacritty_terminal::{ }; use cosmic_text::{ Attrs, AttrsList, Buffer, BufferLine, Family, FontSystem, Metrics, Shaping, Style, SwashCache, - SwashContent, Weight, Wrap, + Weight, Wrap, }; -use std::{mem, num::NonZeroU32, rc::Rc, slice, sync::Arc, time::Instant}; -use tiny_skia::{ColorU8, Paint, PixmapMut, PixmapPaint, PixmapRef, Rect, Transform}; +use std::{mem, rc::Rc, sync::Arc, time::Instant}; use winit::{ - event::{ElementState, Event as WinitEvent, KeyEvent, Modifiers, WindowEvent}, + event::{ + ElementState, Event as WinitEvent, KeyboardInput, ModifiersState, VirtualKeyCode, + WindowEvent, + }, event_loop::{ControlFlow, EventLoopBuilder, EventLoopProxy}, - keyboard::{Key, ModifiersState, NamedKey}, window::WindowBuilder, }; +use self::renderer::Renderer; +mod renderer; + #[derive(Clone, Copy, Debug)] struct Size { width: f32, @@ -132,6 +136,8 @@ fn colors() -> Colors { } fn main() { + env_logger::init(); + let mut font_system = FontSystem::new(); let mut swash_cache = SwashCache::new(); let metrics = Metrics::new(14.0, 20.0); @@ -147,9 +153,7 @@ fn main() { }; println!("{}, {}", cell_width, cell_height); - let event_loop = EventLoopBuilder::::with_user_event() - .build() - .unwrap(); + let event_loop = EventLoopBuilder::::with_user_event().build(); let event_loop_proxy = event_loop.create_proxy(); let window = Rc::new(WindowBuilder::new().build(&event_loop).unwrap()); let (width, height) = { @@ -180,380 +184,253 @@ fn main() { let mut notifier = Notifier(pty_event_loop.channel()); let pty_join_handle = pty_event_loop.spawn(); - let context = softbuffer::Context::new(window.clone()).unwrap(); - let mut surface = softbuffer::Surface::new(&context, window.clone()).unwrap(); - let mut modifiers = Modifiers::default(); - event_loop - .run(move |event, elwt| { - elwt.set_control_flow(ControlFlow::Wait); + let mut renderer = Renderer::new(window.clone()).unwrap(); + let mut modifiers = ModifiersState::default(); + event_loop.run(move |event, _elwt, control_flow| { + *control_flow = ControlFlow::Wait; - match event { - WinitEvent::WindowEvent { - window_id, - event: WindowEvent::RedrawRequested, - } if window_id == window.id() => { - let instant = Instant::now(); + match event { + WinitEvent::RedrawRequested(window_id) if window_id == window.id() => { + let instant = Instant::now(); - let (width, height) = { - let size = window.inner_size(); - (size.width, size.height) - }; - surface - .resize( - NonZeroU32::new(width).unwrap(), - NonZeroU32::new(height).unwrap(), - ) - .unwrap(); + renderer.render(&mut buffer, &mut font_system, &mut swash_cache); - let mut surface_buffer = surface.buffer_mut().unwrap(); - let surface_buffer_u8 = unsafe { - slice::from_raw_parts_mut( - surface_buffer.as_mut_ptr() as *mut u8, - surface_buffer.len() * 4, - ) - }; - let mut pixmap = - PixmapMut::from_bytes(surface_buffer_u8, width, height).unwrap(); - pixmap.fill(tiny_skia::Color::from_rgba8(0, 0, 0, 0xFF)); - - // Set scroll to view scroll - //TODO buffer.set_scroll(*scroll); - // Set size, will relayout and shape until scroll if changed - buffer.set_size(&mut font_system, width as f32, height as f32); - // Shape until scroll, ensures scroll is clamped - buffer.shape_until_scroll(&mut font_system, true); - // Update scroll after buffer clamps it - //TODO *scroll = buffer.scroll(); - - let mut paint = Paint::default(); - paint.anti_alias = false; - let pixmap_paint = PixmapPaint::default(); - let transform = Transform::identity(); - for run in buffer.layout_runs() { - for glyph in run.glyphs.iter() { - let physical_glyph = glyph.physical((0., 0.), 1.0); - - let glyph_color = match glyph.color_opt { - Some(some) => some, - None => cosmic_text::Color::rgb(0xFF, 0xFF, 0xFF), - }; - - let background_color = cosmic_text::Color(glyph.metadata as u32); - if background_color.0 != 0xFF000000 { - //TODO: Have to swap RGB for BGR - paint.set_color_rgba8( - background_color.b(), - background_color.g(), - background_color.r(), - background_color.a(), - ); - pixmap.fill_rect( - Rect::from_xywh( - glyph.x, - run.line_top, - glyph.w, - metrics.line_height, - ) - .unwrap(), - &paint, - transform, - None, - ); - } - - match swash_cache.get_image(&mut font_system, physical_glyph.cache_key) - { - Some(image) if !image.data.is_empty() => { - let mut data = Vec::with_capacity( - (image.placement.width * image.placement.height) as usize, - ); - match image.content { - SwashContent::Mask => { - let mut i = 0; - while i < image.data.len() { - //TODO: Have to swap RGB for BGR - data.push( - ColorU8::from_rgba( - glyph_color.b(), - glyph_color.g(), - glyph_color.r(), - image.data[i], - ) - .premultiply(), - ); - i += 1; - } - } - SwashContent::Color => { - let mut i = 0; - while i < image.data.len() { - //TODO: Have to swap RGB for BGR - data.push( - ColorU8::from_rgba( - image.data[i + 2], - image.data[i + 1], - image.data[i], - image.data[i + 3], - ) - .premultiply(), - ); - i += 4; - } - } - SwashContent::SubpixelMask => { - todo!("TODO: SubpixelMask"); - } - } - - let glyph_pixmap = PixmapRef::from_bytes( - unsafe { - slice::from_raw_parts( - data.as_ptr() as *const u8, - data.len() * 4, - ) - }, - image.placement.width, - image.placement.height, - ) - .unwrap(); - pixmap.draw_pixmap( - physical_glyph.x + image.placement.left, - run.line_y as i32 + physical_glyph.y - image.placement.top, - glyph_pixmap, - &pixmap_paint, - transform, - None, - ); - } - _ => {} - } + println!("draw {:?}", instant.elapsed()); + } + WinitEvent::WindowEvent { + event: WindowEvent::ReceivedCharacter(c), + window_id, + } if window_id == window.id() => { + match (modifiers.logo(), modifiers.ctrl(), modifiers.alt()) { + (true, _, _) => {} // Ignore super + (false, true, _) => { + // Control keys + if c >= 'a' && c <= 'z' { + notifier.notify(vec![(c as u8) - b'a' + 1]); } } - buffer.set_redraw(false); - - surface_buffer.present().unwrap(); - - println!("draw {:?}", instant.elapsed()); - } - WinitEvent::WindowEvent { - event: - WindowEvent::KeyboardInput { - event: - KeyEvent { - logical_key, - text: text_opt, - state: ElementState::Pressed, - .. - }, - .. - }, - window_id, - } if window_id == window.id() => { - println!("{:?} {:?}", modifiers, text_opt); - match ( - modifiers.state().contains(ModifiersState::SUPER), - modifiers.state().contains(ModifiersState::CONTROL), - modifiers.state().contains(ModifiersState::ALT), - ) { - (true, _, _) => {} // Ignore super - (false, true, _) => match text_opt { - Some(text) if text.len() == 1 => { - // Control keys - let c = text.chars().next().unwrap_or_default(); - if c >= 'a' && c <= 'z' { - notifier.notify(vec![(c as u8) - b'a' + 1]); - } - } - _ => {} - }, - (false, false, true) => match text_opt { - Some(text) => { - // Alt keys - //TODO: handle alt keys with no text - let mut bytes = text.as_bytes().to_vec(); - bytes.insert(0, b'\x1B'); - notifier.notify(bytes); - } - None => {} - }, - (false, false, false) => match text_opt { - Some(text) => { - notifier.notify(text.as_bytes().to_vec()); - } - None => match logical_key { - Key::Named(NamedKey::ArrowUp) => { - notifier.notify(b"\x1B[A".as_slice()); - } - Key::Named(NamedKey::ArrowDown) => { - notifier.notify(b"\x1B[B".as_slice()); - } - Key::Named(NamedKey::ArrowRight) => { - notifier.notify(b"\x1B[C".as_slice()); - } - Key::Named(NamedKey::ArrowLeft) => { - notifier.notify(b"\x1B[D".as_slice()); - } - Key::Named(NamedKey::End) => { - notifier.notify(b"\x1B[F".as_slice()); - } - Key::Named(NamedKey::Home) => { - notifier.notify(b"\x1B[H".as_slice()); - } - _ => {} - }, - }, + (false, false, true) => { + // Alt keys + let mut buf = [0x1B, 0, 0, 0, 0]; + let str = c.encode_utf8(&mut buf[1..]); + notifier.notify(str.as_bytes().to_vec()); + } + (false, false, false) => { + let mut buf = [0, 0, 0, 0]; + let str = c.encode_utf8(&mut buf); + notifier.notify(str.as_bytes().to_vec()); } } - WinitEvent::WindowEvent { - event: WindowEvent::ModifiersChanged(new_modifiers), - window_id, - } if window_id == window.id() => { - modifiers = new_modifiers; - } - WinitEvent::WindowEvent { - event: WindowEvent::Resized(physical_size), - window_id, - } if window_id == window.id() => { - dimensions.width = physical_size.width as f32; - dimensions.height = physical_size.height as f32; - notifier.on_resize(dimensions.into()); - term.lock().resize(dimensions); - window.request_redraw(); - } - WinitEvent::WindowEvent { - event: WindowEvent::CloseRequested, - window_id, - } if window_id == window.id() => { - term.lock().exit(); - } - WinitEvent::UserEvent(user_event) => { - println!("{:?}", user_event); - match user_event { - TermEvent::Exit => elwt.exit(), - TermEvent::PtyWrite(text) => notifier.notify(text.into_bytes()), - TermEvent::Title(title) => { - window.set_title(&title); + } + WinitEvent::WindowEvent { + event: + WindowEvent::KeyboardInput { + input: + KeyboardInput { + state: ElementState::Pressed, + virtual_keycode: Some(virtual_keycode), + .. + }, + .. + }, + window_id, + } if window_id == window.id() => { + match (modifiers.logo(), modifiers.ctrl(), modifiers.alt()) { + (true, _, _) => {} // Ignore super + (false, true, _) => { + // Control keys will use ReceivedCharacter instead + } + (false, false, true) => { + //TODO: support Alt keys without character + } + (false, false, false) => match virtual_keycode { + VirtualKeyCode::Up => { + notifier.notify(b"\x1B[A".as_slice()); + } + VirtualKeyCode::Down => { + notifier.notify(b"\x1B[B".as_slice()); + } + VirtualKeyCode::Right => { + notifier.notify(b"\x1B[C".as_slice()); + } + VirtualKeyCode::Left => { + notifier.notify(b"\x1B[D".as_slice()); + } + VirtualKeyCode::End => { + notifier.notify(b"\x1B[F".as_slice()); + } + VirtualKeyCode::Home => { + notifier.notify(b"\x1B[H".as_slice()); } _ => {} - } - - let instant = Instant::now(); - - //TODO: is redraw needed after all events? - //TODO: use LineDamageBounds - { - let mut last_point = Point::new(Line(0), Column(0)); - let mut text = String::new(); - let mut attrs_list = AttrsList::new(default_attrs); - let term_guard = term.lock(); - let grid = term_guard.grid(); - for indexed in grid.display_iter() { - if indexed.point.line != last_point.line { - let line_i = last_point.line.0 as usize; - while line_i >= buffer.lines.len() { - buffer.lines.push(BufferLine::new( - "", - AttrsList::new(default_attrs), - Shaping::Advanced, - )); - buffer.set_redraw(true); - } - - if buffer.lines[line_i].set_text(text.clone(), attrs_list.clone()) { - buffer.set_redraw(true); - } - - text.clear(); - attrs_list.clear_spans(); - } - //TODO: use indexed.point.column? - - //TODO: skip leading spacer? - if indexed.cell.flags.contains(Flags::WIDE_CHAR_SPACER) { - // Skip wide spacers (cells after wide characters) - continue; - } - - let start = text.len(); - text.push(indexed.cell.c); - if let Some(zerowidth) = indexed.cell.zerowidth() { - for &c in zerowidth { - text.push(c); - } - } - let end = text.len(); - - let convert_color = |color| { - let rgb = match color { - Color::Named(named_color) => match colors[named_color] { - Some(rgb) => rgb, - None => { - eprintln!("missing named color {:?}", named_color); - Rgb::default() - } - }, - Color::Spec(rgb) => rgb, - Color::Indexed(index) => match colors[index as usize] { - Some(rgb) => rgb, - None => { - eprintln!("missing indexed color {}", index); - Rgb::default() - } - }, - }; - cosmic_text::Color::rgb(rgb.r, rgb.g, rgb.b) - }; - - let mut attrs = default_attrs; - let mut fg = convert_color(indexed.cell.fg); - let mut bg = convert_color(indexed.cell.bg); - //TODO: better handling of cursor - if indexed.point == grid.cursor.point { - mem::swap(&mut fg, &mut bg); - } - attrs = attrs.color(fg); - // Use metadata as background color - attrs = attrs.metadata(bg.0 as usize); - //TODO: more flags - if indexed.cell.flags.contains(Flags::BOLD) { - attrs = attrs.weight(Weight::BOLD); - } - if indexed.cell.flags.contains(Flags::ITALIC) { - attrs = attrs.style(Style::Italic); - } - if attrs != attrs_list.defaults() { - attrs_list.add_span(start..end, attrs); - } - - last_point = indexed.point; - } - - //TODO: do not repeat! - let line_i = last_point.line.0 as usize; - while line_i >= buffer.lines.len() { - buffer.lines.push(BufferLine::new( - "", - AttrsList::new(default_attrs), - Shaping::Advanced, - )); - buffer.set_redraw(true); - } - - if buffer.lines[line_i].set_text(text, attrs_list) { - buffer.set_redraw(true); - } - } - - if buffer.redraw() { - window.request_redraw(); - } - - println!("buffer update {:?}", instant.elapsed()); + }, } - _ => {} } - }) - .unwrap(); + WinitEvent::WindowEvent { + event: WindowEvent::ModifiersChanged(new_modifiers), + window_id, + } if window_id == window.id() => { + modifiers = new_modifiers; + } + WinitEvent::WindowEvent { + event: WindowEvent::Resized(physical_size), + window_id, + } if window_id == window.id() => { + let instant = Instant::now(); + + dimensions.width = physical_size.width as f32; + dimensions.height = physical_size.height as f32; + + notifier.on_resize(dimensions.into()); + + term.lock().resize(dimensions); + + buffer.set_size( + &mut font_system, + dimensions.width as f32, + dimensions.height as f32, + ); + + renderer.resize(physical_size.width, physical_size.height); + + println!("resize {:?}", instant.elapsed()); + } + WinitEvent::WindowEvent { + event: WindowEvent::CloseRequested, + window_id, + } if window_id == window.id() => { + term.lock().exit(); + } + WinitEvent::UserEvent(user_event) => { + println!("{:?}", user_event); + match user_event { + //TODO: other error codes? + TermEvent::Exit => *control_flow = ControlFlow::ExitWithCode(0), + TermEvent::PtyWrite(text) => notifier.notify(text.into_bytes()), + TermEvent::Title(title) => { + window.set_title(&title); + } + _ => {} + } + + let instant = Instant::now(); + + //TODO: is redraw needed after all events? + //TODO: use LineDamageBounds + { + let mut last_point = Point::new(Line(0), Column(0)); + let mut text = String::new(); + let mut attrs_list = AttrsList::new(default_attrs); + let term_guard = term.lock(); + let grid = term_guard.grid(); + for indexed in grid.display_iter() { + if indexed.point.line != last_point.line { + let line_i = last_point.line.0 as usize; + while line_i >= buffer.lines.len() { + buffer.lines.push(BufferLine::new( + "", + AttrsList::new(default_attrs), + Shaping::Advanced, + )); + buffer.set_redraw(true); + } + + if buffer.lines[line_i].set_text(text.clone(), attrs_list.clone()) { + buffer.set_redraw(true); + } + + text.clear(); + attrs_list.clear_spans(); + } + //TODO: use indexed.point.column? + + //TODO: skip leading spacer? + if indexed.cell.flags.contains(Flags::WIDE_CHAR_SPACER) { + // Skip wide spacers (cells after wide characters) + continue; + } + + let start = text.len(); + text.push(indexed.cell.c); + if let Some(zerowidth) = indexed.cell.zerowidth() { + for &c in zerowidth { + text.push(c); + } + } + let end = text.len(); + + let convert_color = |color| { + let rgb = match color { + Color::Named(named_color) => match colors[named_color] { + Some(rgb) => rgb, + None => { + eprintln!("missing named color {:?}", named_color); + Rgb::default() + } + }, + Color::Spec(rgb) => rgb, + Color::Indexed(index) => match colors[index as usize] { + Some(rgb) => rgb, + None => { + eprintln!("missing indexed color {}", index); + Rgb::default() + } + }, + }; + cosmic_text::Color::rgb(rgb.r, rgb.g, rgb.b) + }; + + let mut attrs = default_attrs; + let mut fg = convert_color(indexed.cell.fg); + let mut bg = convert_color(indexed.cell.bg); + //TODO: better handling of cursor + if indexed.point == grid.cursor.point { + mem::swap(&mut fg, &mut bg); + } + attrs = attrs.color(fg); + // Use metadata as background color + attrs = attrs.metadata(bg.0 as usize); + //TODO: more flags + if indexed.cell.flags.contains(Flags::BOLD) { + attrs = attrs.weight(Weight::BOLD); + } + if indexed.cell.flags.contains(Flags::ITALIC) { + attrs = attrs.style(Style::Italic); + } + if attrs != attrs_list.defaults() { + attrs_list.add_span(start..end, attrs); + } + + last_point = indexed.point; + } + + //TODO: do not repeat! + let line_i = last_point.line.0 as usize; + while line_i >= buffer.lines.len() { + buffer.lines.push(BufferLine::new( + "", + AttrsList::new(default_attrs), + Shaping::Advanced, + )); + buffer.set_redraw(true); + } + + if buffer.lines[line_i].set_text(text, attrs_list) { + buffer.set_redraw(true); + } + } + + buffer.shape_until_scroll(&mut font_system, true); + + if buffer.redraw() { + window.request_redraw(); + } + + println!("buffer update {:?}", instant.elapsed()); + } + _ => {} + } + }); //TODO: hangs after event loop exit pty_join_handle.join().unwrap(); } diff --git a/src/renderer/mod.rs b/src/renderer/mod.rs new file mode 100644 index 0000000..75b5a47 --- /dev/null +++ b/src/renderer/mod.rs @@ -0,0 +1,60 @@ +use cosmic_text::{Buffer, FontSystem, SwashCache}; +use std::rc::Rc; +use winit::window::Window; + +pub use self::software::SoftwareRenderer; +pub mod software; + +#[cfg(feature = "wgpu")] +pub use self::wgpu::WgpuRenderer; +#[cfg(feature = "wgpu")] +pub mod wgpu; + +pub enum Renderer { + Software(SoftwareRenderer), + #[cfg(feature = "wgpu")] + Wgpu(WgpuRenderer), +} + +impl Renderer { + pub fn new(window: Rc) -> Result { + #[cfg(feature = "wgpu")] + match WgpuRenderer::new(window.clone()) { + Ok(renderer) => return Ok(Self::Wgpu(renderer)), + Err(err) => { + log::error!("failed to use hardware rendering: {}", err); + } + } + + SoftwareRenderer::new(window).map(Renderer::Software) + } + + pub fn render( + &mut self, + buffer: &mut Buffer, + font_system: &mut FontSystem, + swash_cache: &mut SwashCache, + ) { + match self { + Self::Software(renderer) => { + renderer.render(buffer, font_system, swash_cache); + } + #[cfg(feature = "wgpu")] + Self::Wgpu(renderer) => { + renderer.render(buffer, font_system, swash_cache); + } + } + } + + pub fn resize(&mut self, width: u32, height: u32) { + match self { + Self::Software(renderer) => { + renderer.resize(width, height); + } + #[cfg(feature = "wgpu")] + Self::Wgpu(renderer) => { + renderer.resize(width, height); + } + } + } +} diff --git a/src/renderer/software.rs b/src/renderer/software.rs new file mode 100644 index 0000000..6bee1e0 --- /dev/null +++ b/src/renderer/software.rs @@ -0,0 +1,141 @@ +use cosmic_text::{Buffer, FontSystem, SwashCache, SwashContent}; +use std::{rc::Rc, slice}; +use tiny_skia::{ColorU8, Paint, Pixmap, PixmapPaint, PixmapRef, Rect, Transform}; +use winit::window::Window; + +pub struct SoftwareRenderer { + pub window: Rc, + pub context: softbuffer::GraphicsContext, +} + +impl SoftwareRenderer { + pub fn new(window: Rc) -> Result { + let context = unsafe { softbuffer::GraphicsContext::new(&*window, &*window) } + .map_err(|err| format!("failed to create context: {}", err))?; + Ok(Self { window, context }) + } + + pub fn render( + &mut self, + buffer: &mut Buffer, + font_system: &mut FontSystem, + swash_cache: &mut SwashCache, + ) { + let (width, height) = { + let size = self.window.inner_size(); + (size.width, size.height) + }; + + let mut pixmap = Pixmap::new(width, height).unwrap(); + //TODO: configurable background + pixmap.fill(tiny_skia::Color::from_rgba8(0, 0, 0, 0xFF)); + + let line_height = buffer.metrics().line_height; + let mut paint = Paint::default(); + paint.anti_alias = false; + let pixmap_paint = PixmapPaint::default(); + let transform = Transform::identity(); + for run in buffer.layout_runs() { + for glyph in run.glyphs.iter() { + let physical_glyph = glyph.physical((0., 0.), 1.0); + + let glyph_color = match glyph.color_opt { + Some(some) => some, + None => cosmic_text::Color::rgb(0xFF, 0xFF, 0xFF), + }; + + let background_color = cosmic_text::Color(glyph.metadata as u32); + if background_color.0 != 0xFF000000 { + //TODO: Have to swap RGB for BGR + paint.set_color_rgba8( + background_color.b(), + background_color.g(), + background_color.r(), + background_color.a(), + ); + pixmap.fill_rect( + Rect::from_xywh(glyph.x, run.line_top, glyph.w, line_height).unwrap(), + &paint, + transform, + None, + ); + } + + match swash_cache.get_image(font_system, physical_glyph.cache_key) { + Some(image) if !image.data.is_empty() => { + let mut data = Vec::with_capacity( + (image.placement.width * image.placement.height) as usize, + ); + match image.content { + SwashContent::Mask => { + let mut i = 0; + while i < image.data.len() { + //TODO: Have to swap RGB for BGR + data.push( + ColorU8::from_rgba( + glyph_color.b(), + glyph_color.g(), + glyph_color.r(), + image.data[i], + ) + .premultiply(), + ); + i += 1; + } + } + SwashContent::Color => { + let mut i = 0; + while i < image.data.len() { + //TODO: Have to swap RGB for BGR + data.push( + ColorU8::from_rgba( + image.data[i + 2], + image.data[i + 1], + image.data[i], + image.data[i + 3], + ) + .premultiply(), + ); + i += 4; + } + } + SwashContent::SubpixelMask => { + todo!("TODO: SubpixelMask"); + } + } + + let glyph_pixmap = PixmapRef::from_bytes( + unsafe { + slice::from_raw_parts(data.as_ptr() as *const u8, data.len() * 4) + }, + image.placement.width, + image.placement.height, + ) + .unwrap(); + pixmap.draw_pixmap( + physical_glyph.x + image.placement.left, + run.line_y as i32 + physical_glyph.y - image.placement.top, + glyph_pixmap, + &pixmap_paint, + transform, + None, + ); + } + _ => {} + } + } + } + buffer.set_redraw(false); + + self.context.set_buffer( + bytemuck::cast_slice(pixmap.data()), + width as u16, + height as u16, + ); + } + + pub fn resize(&mut self, width: u32, height: u32) { + //TODO: resize image here for better performance + self.window.request_redraw(); + } +} diff --git a/src/renderer/wgpu.rs b/src/renderer/wgpu.rs new file mode 100644 index 0000000..95026ab --- /dev/null +++ b/src/renderer/wgpu.rs @@ -0,0 +1,145 @@ +use glyphon::{ + Attrs, Buffer, Color, Family, FontSystem, Metrics, Resolution, Shaping, SwashCache, TextArea, + TextAtlas, TextBounds, TextRenderer, +}; +use std::{error::Error, rc::Rc}; +use wgpu::{ + CommandEncoderDescriptor, CompositeAlphaMode, Device, DeviceDescriptor, Features, Instance, + InstanceDescriptor, Limits, LoadOp, MultisampleState, Operations, PresentMode, Queue, + RenderPassColorAttachment, RenderPassDescriptor, RequestAdapterOptions, Surface, + SurfaceConfiguration, TextureFormat, TextureUsages, TextureViewDescriptor, +}; +use winit::window::Window; + +pub struct WgpuRenderer { + pub window: Rc, + pub device: Device, + pub queue: Queue, + pub surface: Surface, + pub config: SurfaceConfiguration, + pub atlas: TextAtlas, + pub text_renderer: TextRenderer, +} + +impl WgpuRenderer { + async fn new_async(window: Rc) -> Result { + let size = window.inner_size(); + + let instance = Instance::new(InstanceDescriptor::default()); + let adapter = instance + .request_adapter(&RequestAdapterOptions::default()) + .await + .ok_or(format!("failed to request adapter"))?; + let (device, queue) = adapter + .request_device( + &DeviceDescriptor { + label: None, + features: Features::empty(), + limits: Limits::downlevel_defaults(), + }, + None, + ) + .await + .map_err(|err| format!("failed to request device: {}", err))?; + let surface = unsafe { instance.create_surface(&*window) } + .map_err(|err| format!("failed to create surface: {}", err))?; + let swapchain_format = TextureFormat::Bgra8UnormSrgb; + let mut config = SurfaceConfiguration { + usage: TextureUsages::RENDER_ATTACHMENT, + format: swapchain_format, + width: size.width, + height: size.height, + present_mode: PresentMode::Fifo, + alpha_mode: CompositeAlphaMode::Opaque, + view_formats: vec![], + }; + surface.configure(&device, &config); + + let mut atlas = TextAtlas::new(&device, &queue, swapchain_format); + let mut text_renderer = + TextRenderer::new(&mut atlas, &device, MultisampleState::default(), None); + Ok(Self { + window, + device, + queue, + surface, + config, + atlas, + text_renderer, + }) + } + + pub fn new(window: Rc) -> Result { + pollster::block_on(Self::new_async(window)) + } + + pub fn render( + &mut self, + buffer: &mut Buffer, + font_system: &mut FontSystem, + swash_cache: &mut SwashCache, + ) { + self.text_renderer + .prepare( + &self.device, + &self.queue, + font_system, + &mut self.atlas, + Resolution { + width: self.config.width, + height: self.config.height, + }, + [TextArea { + buffer: &buffer, + left: 0.0, + top: 0.0, + scale: 1.0, + bounds: TextBounds { + left: 0, + top: 0, + right: self.config.width as i32, + bottom: self.config.height as i32, + }, + default_color: Color::rgb(255, 255, 255), + }], + swash_cache, + ) + .unwrap(); + + let frame = self.surface.get_current_texture().unwrap(); + let view = frame.texture.create_view(&TextureViewDescriptor::default()); + let mut encoder = self + .device + .create_command_encoder(&CommandEncoderDescriptor { label: None }); + { + let mut pass = encoder.begin_render_pass(&RenderPassDescriptor { + label: None, + color_attachments: &[Some(RenderPassColorAttachment { + view: &view, + resolve_target: None, + ops: Operations { + load: LoadOp::Clear(wgpu::Color::BLACK), + store: wgpu::StoreOp::Store, + }, + })], + depth_stencil_attachment: None, + timestamp_writes: None, + occlusion_query_set: None, + }); + + self.text_renderer.render(&self.atlas, &mut pass).unwrap(); + } + + self.queue.submit(Some(encoder.finish())); + frame.present(); + + self.atlas.trim(); + } + + pub fn resize(&mut self, width: u32, height: u32) { + self.config.width = width; + self.config.height = height; + self.surface.configure(&self.device, &self.config); + self.window.request_redraw(); + } +}