From 4e73bd8ad9efd3dc1e2c7d2abbffd61e7e667d4c Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Fri, 23 Jun 2023 10:20:52 +0200 Subject: [PATCH 1/3] Use new `NativeWindow::lock()` API in `dummy_render()` --- agdk-cpal/Cargo.toml | 4 +- agdk-eframe/Cargo.toml | 4 +- agdk-egui/Cargo.toml | 4 +- agdk-mainloop/Cargo.lock | 301 ++++++++++++++++++++++++++++--------- agdk-mainloop/Cargo.toml | 13 +- agdk-mainloop/src/lib.rs | 32 ++-- agdk-oboe/Cargo.toml | 4 +- agdk-winit-wgpu/Cargo.toml | 4 +- na-egui/Cargo.toml | 2 - na-mainloop/Cargo.lock | 298 +++++++++++++++++++++++++++--------- na-mainloop/Cargo.toml | 19 +-- na-mainloop/src/lib.rs | 32 ++-- na-openxr-info/Cargo.toml | 4 +- na-openxr-wgpu/Cargo.toml | 2 - na-subclass-jni/Cargo.lock | 165 ++++++++++---------- na-subclass-jni/Cargo.toml | 17 +-- na-subclass-jni/src/lib.rs | 32 ++-- na-winit-wgpu/Cargo.toml | 2 - 18 files changed, 633 insertions(+), 306 deletions(-) diff --git a/agdk-cpal/Cargo.toml b/agdk-cpal/Cargo.toml index 199640c..72e7095 100644 --- a/agdk-cpal/Cargo.toml +++ b/agdk-cpal/Cargo.toml @@ -3,8 +3,6 @@ name = "agdk-cpal" version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] log = "0.4" android_logger = "0.11.0" @@ -15,4 +13,4 @@ anyhow = "1" [lib] name="main" -crate_type=["cdylib"] \ No newline at end of file +crate_type=["cdylib"] diff --git a/agdk-eframe/Cargo.toml b/agdk-eframe/Cargo.toml index 08590c6..2d896dd 100644 --- a/agdk-eframe/Cargo.toml +++ b/agdk-eframe/Cargo.toml @@ -4,8 +4,6 @@ version = "0.1.0" edition = "2021" resolver = "2" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] log = "0.4" winit = { version = "0.28", features = [ "android-game-activity" ] } @@ -32,4 +30,4 @@ crate_type=["cdylib"] [[bin]] path="src/lib.rs" name="agdk-eframe" -required-features = [ "desktop" ] \ No newline at end of file +required-features = [ "desktop" ] diff --git a/agdk-egui/Cargo.toml b/agdk-egui/Cargo.toml index 6705124..3eab5d1 100644 --- a/agdk-egui/Cargo.toml +++ b/agdk-egui/Cargo.toml @@ -4,8 +4,6 @@ version = "0.1.0" edition = "2021" resolver = "2" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] log = "0.4" pollster = "0.2" @@ -37,4 +35,4 @@ required-features = [ "desktop" ] #[patch.crates-io] #egui = { version = "0.22", path = "../../egui/crates/egui" } #egui-wgpu = { version = "0.22", path = "../../egui/crates/egui-wgpu" } -#egui-winit = { version = "0.22", path = "../../egui/crates/egui-winit" } \ No newline at end of file +#egui-winit = { version = "0.22", path = "../../egui/crates/egui-winit" } diff --git a/agdk-mainloop/Cargo.lock b/agdk-mainloop/Cargo.lock index 5038d1b..f257b45 100644 --- a/agdk-mainloop/Cargo.lock +++ b/agdk-mainloop/Cargo.lock @@ -10,27 +10,28 @@ dependencies = [ "android_logger", "log", "ndk", - "ndk-sys", ] [[package]] name = "aho-corasick" -version = "1.0.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ "memchr", ] [[package]] name = "android-activity" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c77a0045eda8b888c76ea473c2b0515ba6f471d318f8927c5c72240937035a6" +checksum = "052ad56e336bcc615a214bffbeca6c181ee9550acec193f0327e0b103b033a4d" dependencies = [ "android-properties", "bitflags", "cc", + "cesu8", + "jni", "jni-sys", "libc", "log", @@ -38,6 +39,7 @@ dependencies = [ "ndk-context", "ndk-sys", "num_enum", + "thiserror", ] [[package]] @@ -65,24 +67,47 @@ dependencies = [ ] [[package]] -name = "autocfg" -version = "1.1.0" +name = "bitflags" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" [[package]] -name = "bitflags" -version = "1.3.2" +name = "bytes" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "cc" -version = "1.0.79" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ "jobserver", + "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 = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "combine" +version = "4.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4" +dependencies = [ + "bytes", + "memchr", ] [[package]] @@ -95,22 +120,44 @@ dependencies = [ "regex", ] +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "hashbrown" -version = "0.12.3" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" [[package]] name = "indexmap" -version = "1.9.3" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" dependencies = [ - "autocfg", + "equivalent", "hashbrown", ] +[[package]] +name = "jni" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" +dependencies = [ + "cesu8", + "cfg-if", + "combine", + "jni-sys", + "log", + "thiserror", + "walkdir", + "windows-sys", +] + [[package]] name = "jni-sys" version = "0.3.0" @@ -119,39 +166,40 @@ checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" [[package]] name = "jobserver" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" +checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" dependencies = [ "libc", ] [[package]] name = "libc" -version = "0.2.144" +version = "0.2.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" +checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" [[package]] name = "log" -version = "0.4.18" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "memchr" -version = "2.5.0" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "ndk" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "451422b7e4718271c8b5b3aadf5adedba43dc76312454b387e98fae0fc951aa0" +checksum = "2076a31b7010b17a38c01907c45b945e8f11495ee4dd588309718901b1f7a5b7" dependencies = [ "bitflags", "jni-sys", + "log", "ndk-sys", "num_enum", "raw-window-handle", @@ -166,39 +214,39 @@ checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" [[package]] name = "ndk-sys" -version = "0.4.1+23.1.7779620" +version = "0.5.0+25.2.9519653" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cf2aae958bd232cac5069850591667ad422d263686d75b52a065f9badeee5a3" +checksum = "8c196769dd60fd4f363e11d948139556a344e79d451aeb2fa2fd040738ef7691" dependencies = [ "jni-sys", ] [[package]] name = "num_enum" -version = "0.5.11" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f646caf906c20226733ed5b1374287eb97e3c2a5c227ce668c1f2ce20ae57c9" +checksum = "70bf6736f74634d299d00086f02986875b3c2d924781a6a2cb6c201e73da0ceb" dependencies = [ "num_enum_derive", ] [[package]] name = "num_enum_derive" -version = "0.5.11" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799" +checksum = "56ea360eafe1022f7cc56cd7b869ed57330fb2453d0c7831d99b74c65d2f5597" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.109", + "syn", ] [[package]] name = "once_cell" -version = "1.17.2" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9670a07f94779e00908f3e686eab508878ebb390ba6e604d3a284c00e8d0487b" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "proc-macro-crate" @@ -212,33 +260,45 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.59" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6aeca18b86b413c660b781aa319e4e2648a3e6f9eadc9b47e9038e6fe9f3451b" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.28" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] [[package]] name = "raw-window-handle" -version = "0.5.2" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9" +checksum = "42a9830a0e1b9fb145ebb365b8bc4ccd75f290f98c0247deafbbe2c75cefb544" [[package]] name = "regex" -version = "1.8.3" +version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81ca098a9821bd52d6b24fd8b10bd081f47d39c22778cafaa75a2857a62c6390" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" dependencies = [ "aho-corasick", "memchr", @@ -247,26 +307,24 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.7.2" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] -name = "syn" -version = "1.0.109" +name = "same-file" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "winapi-util", ] [[package]] name = "syn" -version = "2.0.18" +version = "2.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32d41677bcbe24c20c52e7c70b0d8db04134c5d1066bf98662e2871ad200ea3e" +checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" dependencies = [ "proc-macro2", "quote", @@ -275,35 +333,35 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.40" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.40" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn", ] [[package]] name = "toml_datetime" -version = "0.6.2" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a76a9312f5ba4c2dec6b9161fdf25d87ad8a09256ccea5a556fef03c706a10f" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" [[package]] name = "toml_edit" -version = "0.19.10" +version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2380d56e8670370eee6566b0bfd4265f65b3f432e8c6d85623f728d4fa31f739" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ "indexmap", "toml_datetime", @@ -312,15 +370,122 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.9" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[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 = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "winnow" -version = "0.4.6" +version = "0.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61de7bac303dc551fe038e2b3cef0f571087a47571ea6e79a87692ac99b99699" +checksum = "a3b801d0e0a6726477cc207f60162da452f3a95adb368399bef20a946e06f65c" dependencies = [ "memchr", ] diff --git a/agdk-mainloop/Cargo.toml b/agdk-mainloop/Cargo.toml index bd2a8d5..246d4b1 100644 --- a/agdk-mainloop/Cargo.toml +++ b/agdk-mainloop/Cargo.toml @@ -3,15 +3,12 @@ name = "agdk-mainloop" version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] -log = "0.4" +android-activity = { version = "0.5.0", features = ["native-activity"] } android_logger = "0.11.0" -android-activity = { version = "0.4", features = ["game-activity"] } -ndk-sys = "0.4" -ndk = "0.7" +log = "0.4" +ndk = "0.8.0" [lib] -name="main" -crate_type=["cdylib"] \ No newline at end of file +name = "main" +crate_type = ["cdylib"] diff --git a/agdk-mainloop/src/lib.rs b/agdk-mainloop/src/lib.rs index 166ee69..c33cac9 100644 --- a/agdk-mainloop/src/lib.rs +++ b/agdk-mainloop/src/lib.rs @@ -1,5 +1,6 @@ use android_activity::{AndroidApp, InputStatus, MainEvent, PollEvent}; use log::info; +use ndk::native_window::HardwareBufferFormat; #[no_mangle] fn android_main(app: AndroidApp) { @@ -38,6 +39,16 @@ fn android_main(app: AndroidApp) { } MainEvent::InitWindow { .. } => { native_window = app.native_window(); + if let Some(nw) = &native_window { + // Set the backing buffer to a known format (without changing + // the size) so that we can safely draw to it in dummy_render(). + nw.set_buffers_geometry( + 0, + 0, + Some(HardwareBufferFormat::R8G8B8A8_UNORM), + ) + .unwrap() + } redraw_pending = true; } MainEvent::TerminateWindow { .. } => { @@ -91,16 +102,15 @@ fn android_main(app: AndroidApp) { /// responsive, otherwise it will stop delivering input /// events to us. fn dummy_render(native_window: &ndk::native_window::NativeWindow) { - unsafe { - let mut buf: ndk_sys::ANativeWindow_Buffer = std::mem::zeroed(); - let mut rect: ndk_sys::ARect = std::mem::zeroed(); - ndk_sys::ANativeWindow_lock( - native_window.ptr().as_ptr() as _, - &mut buf as _, - &mut rect as _, - ); - // Note: we don't try and touch the buffer since that - // also requires us to handle various buffer formats - ndk_sys::ANativeWindow_unlockAndPost(native_window.ptr().as_ptr() as _); + let mut lock = native_window.lock(None).unwrap(); + let (w, h) = (lock.width(), lock.height()); + + for (y, line) in lock.lines().unwrap().enumerate() { + let r = y * 255 / h; + for (x, pixels) in line.chunks_mut(4).enumerate() { + let g = x * 255 / w; + pixels[0].write(r as u8); + pixels[1].write(g as u8); + } } } diff --git a/agdk-oboe/Cargo.toml b/agdk-oboe/Cargo.toml index 4c9e509..1a9a5c5 100644 --- a/agdk-oboe/Cargo.toml +++ b/agdk-oboe/Cargo.toml @@ -3,8 +3,6 @@ name = "agdk-oboe" version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] log = "0.4" android_logger = "0.13.1" @@ -14,4 +12,4 @@ atomic_float = "0.1" [lib] name="main" -crate_type=["cdylib"] \ No newline at end of file +crate_type=["cdylib"] diff --git a/agdk-winit-wgpu/Cargo.toml b/agdk-winit-wgpu/Cargo.toml index 029f878..1cc129b 100644 --- a/agdk-winit-wgpu/Cargo.toml +++ b/agdk-winit-wgpu/Cargo.toml @@ -3,8 +3,6 @@ name = "agdk-winit-wgpu" version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] log = "0.4" winit = { version = "0.28", features = ["android-game-activity"]} @@ -46,4 +44,4 @@ crate_type=["cdylib"] [[bin]] path="src/lib.rs" name="test-winit-wgpu" -required-features = [ "desktop" ] \ No newline at end of file +required-features = [ "desktop" ] diff --git a/na-egui/Cargo.toml b/na-egui/Cargo.toml index cdd18ec..795c69e 100644 --- a/na-egui/Cargo.toml +++ b/na-egui/Cargo.toml @@ -4,8 +4,6 @@ version = "0.1.0" edition = "2021" resolver = "2" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] log = "0.4" pollster = "0.2" diff --git a/na-mainloop/Cargo.lock b/na-mainloop/Cargo.lock index f0112ef..d8147c2 100644 --- a/na-mainloop/Cargo.lock +++ b/na-mainloop/Cargo.lock @@ -4,22 +4,24 @@ version = 3 [[package]] name = "aho-corasick" -version = "1.0.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ "memchr", ] [[package]] name = "android-activity" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c77a0045eda8b888c76ea473c2b0515ba6f471d318f8927c5c72240937035a6" +checksum = "052ad56e336bcc615a214bffbeca6c181ee9550acec193f0327e0b103b033a4d" dependencies = [ "android-properties", "bitflags", "cc", + "cesu8", + "jni", "jni-sys", "libc", "log", @@ -27,6 +29,7 @@ dependencies = [ "ndk-context", "ndk-sys", "num_enum", + "thiserror", ] [[package]] @@ -54,32 +57,49 @@ dependencies = [ ] [[package]] -name = "autocfg" -version = "1.1.0" +name = "bitflags" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" [[package]] -name = "bitflags" -version = "1.3.2" +name = "bytes" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "cc" -version = "1.0.79" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ "jobserver", + "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 = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "combine" +version = "4.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4" +dependencies = [ + "bytes", + "memchr", +] + [[package]] name = "env_logger" version = "0.10.0" @@ -90,22 +110,44 @@ dependencies = [ "regex", ] +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "hashbrown" -version = "0.12.3" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" [[package]] name = "indexmap" -version = "1.9.3" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" dependencies = [ - "autocfg", + "equivalent", "hashbrown", ] +[[package]] +name = "jni" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" +dependencies = [ + "cesu8", + "cfg-if", + "combine", + "jni-sys", + "log", + "thiserror", + "walkdir", + "windows-sys", +] + [[package]] name = "jni-sys" version = "0.3.0" @@ -114,33 +156,30 @@ checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" [[package]] name = "jobserver" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" +checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" dependencies = [ "libc", ] [[package]] name = "libc" -version = "0.2.144" +version = "0.2.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" +checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" [[package]] name = "log" -version = "0.4.17" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "memchr" -version = "2.5.0" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "na-mainloop" @@ -150,17 +189,17 @@ dependencies = [ "android_logger", "log", "ndk", - "ndk-sys", ] [[package]] name = "ndk" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "451422b7e4718271c8b5b3aadf5adedba43dc76312454b387e98fae0fc951aa0" +checksum = "2076a31b7010b17a38c01907c45b945e8f11495ee4dd588309718901b1f7a5b7" dependencies = [ "bitflags", "jni-sys", + "log", "ndk-sys", "num_enum", "raw-window-handle", @@ -175,39 +214,39 @@ checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" [[package]] name = "ndk-sys" -version = "0.4.1+23.1.7779620" +version = "0.5.0+25.2.9519653" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cf2aae958bd232cac5069850591667ad422d263686d75b52a065f9badeee5a3" +checksum = "8c196769dd60fd4f363e11d948139556a344e79d451aeb2fa2fd040738ef7691" dependencies = [ "jni-sys", ] [[package]] name = "num_enum" -version = "0.5.11" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f646caf906c20226733ed5b1374287eb97e3c2a5c227ce668c1f2ce20ae57c9" +checksum = "70bf6736f74634d299d00086f02986875b3c2d924781a6a2cb6c201e73da0ceb" dependencies = [ "num_enum_derive", ] [[package]] name = "num_enum_derive" -version = "0.5.11" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799" +checksum = "56ea360eafe1022f7cc56cd7b869ed57330fb2453d0c7831d99b74c65d2f5597" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.109", + "syn", ] [[package]] name = "once_cell" -version = "1.17.1" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "proc-macro-crate" @@ -221,33 +260,45 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.58" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa1fb82fc0c281dd9671101b66b771ebbe1eaf967b96ac8740dcba4b70005ca8" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.27" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f4f29d145265ec1c483c7c654450edde0bfe043d3938d6972630663356d9500" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] [[package]] name = "raw-window-handle" -version = "0.5.2" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9" +checksum = "42a9830a0e1b9fb145ebb365b8bc4ccd75f290f98c0247deafbbe2c75cefb544" [[package]] name = "regex" -version = "1.8.2" +version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1a59b5d8e97dee33696bf13c5ba8ab85341c002922fba050069326b9c498974" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" dependencies = [ "aho-corasick", "memchr", @@ -256,26 +307,24 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.7.2" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] -name = "syn" -version = "1.0.109" +name = "same-file" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "winapi-util", ] [[package]] name = "syn" -version = "2.0.16" +version = "2.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6f671d4b5ffdb8eadec19c0ae67fe2639df8684bd7bc4b83d986b8db549cf01" +checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" dependencies = [ "proc-macro2", "quote", @@ -284,35 +333,35 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.40" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.40" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn", ] [[package]] name = "toml_datetime" -version = "0.6.2" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a76a9312f5ba4c2dec6b9161fdf25d87ad8a09256ccea5a556fef03c706a10f" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" [[package]] name = "toml_edit" -version = "0.19.10" +version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2380d56e8670370eee6566b0bfd4265f65b3f432e8c6d85623f728d4fa31f739" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ "indexmap", "toml_datetime", @@ -321,15 +370,122 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.9" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[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 = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "winnow" -version = "0.4.6" +version = "0.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61de7bac303dc551fe038e2b3cef0f571087a47571ea6e79a87692ac99b99699" +checksum = "a3b801d0e0a6726477cc207f60162da452f3a95adb368399bef20a946e06f65c" dependencies = [ "memchr", ] diff --git a/na-mainloop/Cargo.toml b/na-mainloop/Cargo.toml index 63f234c..38538e6 100644 --- a/na-mainloop/Cargo.toml +++ b/na-mainloop/Cargo.toml @@ -3,20 +3,15 @@ name = "na-mainloop" version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] -log = "0.4" +android-activity = { version = "0.5.0", features = ["native-activity"] } android_logger = "0.11.0" -android-activity = { version = "0.4", features = [ "native-activity" ] } -#android-activity = { path = "../../android-activity/android-activity", features = [ "native-activity" ] } -ndk-sys = "0.4" -ndk = "0.7" +log = "0.4" +ndk = "0.8.0" [lib] -#name="na_mainloop" -crate_type=["cdylib"] - +# name = "na_mainloop" +crate_type = ["cdylib"] #################### # cargo apk config # @@ -27,7 +22,7 @@ crate_type=["cdylib"] package = "com.foo.bar" # Specifies the array of targets to build for. -build_targets = [ "aarch64-linux-android" ] +build_targets = ["aarch64-linux-android"] # Path to your application's resources folder. # If not specified, resources will not be included in the APK. @@ -182,4 +177,4 @@ label = "Application Name" #port = "8080" #path = "/rust-windowing/android-ndk-rs/tree/master/cargo-apk" #path_prefix = "/rust-windowing/" -#mime_type = "image/jpeg" \ No newline at end of file +#mime_type = "image/jpeg" diff --git a/na-mainloop/src/lib.rs b/na-mainloop/src/lib.rs index 166ee69..c33cac9 100644 --- a/na-mainloop/src/lib.rs +++ b/na-mainloop/src/lib.rs @@ -1,5 +1,6 @@ use android_activity::{AndroidApp, InputStatus, MainEvent, PollEvent}; use log::info; +use ndk::native_window::HardwareBufferFormat; #[no_mangle] fn android_main(app: AndroidApp) { @@ -38,6 +39,16 @@ fn android_main(app: AndroidApp) { } MainEvent::InitWindow { .. } => { native_window = app.native_window(); + if let Some(nw) = &native_window { + // Set the backing buffer to a known format (without changing + // the size) so that we can safely draw to it in dummy_render(). + nw.set_buffers_geometry( + 0, + 0, + Some(HardwareBufferFormat::R8G8B8A8_UNORM), + ) + .unwrap() + } redraw_pending = true; } MainEvent::TerminateWindow { .. } => { @@ -91,16 +102,15 @@ fn android_main(app: AndroidApp) { /// responsive, otherwise it will stop delivering input /// events to us. fn dummy_render(native_window: &ndk::native_window::NativeWindow) { - unsafe { - let mut buf: ndk_sys::ANativeWindow_Buffer = std::mem::zeroed(); - let mut rect: ndk_sys::ARect = std::mem::zeroed(); - ndk_sys::ANativeWindow_lock( - native_window.ptr().as_ptr() as _, - &mut buf as _, - &mut rect as _, - ); - // Note: we don't try and touch the buffer since that - // also requires us to handle various buffer formats - ndk_sys::ANativeWindow_unlockAndPost(native_window.ptr().as_ptr() as _); + let mut lock = native_window.lock(None).unwrap(); + let (w, h) = (lock.width(), lock.height()); + + for (y, line) in lock.lines().unwrap().enumerate() { + let r = y * 255 / h; + for (x, pixels) in line.chunks_mut(4).enumerate() { + let g = x * 255 / w; + pixels[0].write(r as u8); + pixels[1].write(g as u8); + } } } diff --git a/na-openxr-info/Cargo.toml b/na-openxr-info/Cargo.toml index 7d9cbe4..4e76368 100644 --- a/na-openxr-info/Cargo.toml +++ b/na-openxr-info/Cargo.toml @@ -3,8 +3,6 @@ name = "na-openxr-info" version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] log = "0.4" openxr = { version = "0.17" } @@ -30,4 +28,4 @@ crate_type=["cdylib"] [[bin]] path="src/lib.rs" name="test-winit-wgpu" -required-features = [ "desktop" ] \ No newline at end of file +required-features = [ "desktop" ] diff --git a/na-openxr-wgpu/Cargo.toml b/na-openxr-wgpu/Cargo.toml index b321ee5..e749fab 100644 --- a/na-openxr-wgpu/Cargo.toml +++ b/na-openxr-wgpu/Cargo.toml @@ -3,8 +3,6 @@ name = "na-openxr-wgpu" version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] log = "0.4" ash = "0.37" diff --git a/na-subclass-jni/Cargo.lock b/na-subclass-jni/Cargo.lock index dcd8fc7..765d61b 100644 --- a/na-subclass-jni/Cargo.lock +++ b/na-subclass-jni/Cargo.lock @@ -4,22 +4,24 @@ version = 3 [[package]] name = "aho-corasick" -version = "1.0.1" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" +checksum = "6748e8def348ed4d14996fa801f4122cd763fff530258cdc03f64b25f89d3a5a" dependencies = [ "memchr", ] [[package]] name = "android-activity" -version = "0.4.1" +version = "0.5.0-beta.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c77a0045eda8b888c76ea473c2b0515ba6f471d318f8927c5c72240937035a6" +checksum = "934936a9ad4dc79563cd6644fcef68dc328f105d927679454de39ad03ca1cfe8" dependencies = [ "android-properties", "bitflags", "cc", + "cesu8", + "jni", "jni-sys", "libc", "log", @@ -27,6 +29,7 @@ dependencies = [ "ndk-context", "ndk-sys", "num_enum", + "thiserror", ] [[package]] @@ -53,17 +56,11 @@ dependencies = [ "once_cell", ] -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - [[package]] name = "bitflags" -version = "1.3.2" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" [[package]] name = "bytes" @@ -73,11 +70,12 @@ checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" [[package]] name = "cc" -version = "1.0.79" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ "jobserver", + "libc", ] [[package]] @@ -112,27 +110,33 @@ dependencies = [ "regex", ] +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "hashbrown" -version = "0.12.3" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" [[package]] name = "indexmap" -version = "1.9.3" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" dependencies = [ - "autocfg", + "equivalent", "hashbrown", ] [[package]] name = "itoa" -version = "1.0.6" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "jni" @@ -167,15 +171,15 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.144" +version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] name = "log" -version = "0.4.18" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "memchr" @@ -193,19 +197,19 @@ dependencies = [ "log", "ndk", "ndk-context", - "ndk-sys", "serde", "serde_json", ] [[package]] name = "ndk" -version = "0.7.0" +version = "0.8.0-beta.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "451422b7e4718271c8b5b3aadf5adedba43dc76312454b387e98fae0fc951aa0" +checksum = "49f58741784b0f6ac12311c3f6fbdb3c766a992f8914d035c77a07b5fd2940dc" dependencies = [ "bitflags", "jni-sys", + "log", "ndk-sys", "num_enum", "raw-window-handle", @@ -220,39 +224,39 @@ checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" [[package]] name = "ndk-sys" -version = "0.4.1+23.1.7779620" +version = "0.5.0-beta.0+25.2.9519653" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cf2aae958bd232cac5069850591667ad422d263686d75b52a065f9badeee5a3" +checksum = "ff38603775cba10d0f1141fab1b167df73662a0636a4b631c187fe11fb624042" dependencies = [ "jni-sys", ] [[package]] name = "num_enum" -version = "0.5.11" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f646caf906c20226733ed5b1374287eb97e3c2a5c227ce668c1f2ce20ae57c9" +checksum = "70bf6736f74634d299d00086f02986875b3c2d924781a6a2cb6c201e73da0ceb" dependencies = [ "num_enum_derive", ] [[package]] name = "num_enum_derive" -version = "0.5.11" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799" +checksum = "56ea360eafe1022f7cc56cd7b869ed57330fb2453d0c7831d99b74c65d2f5597" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.109", + "syn", ] [[package]] name = "once_cell" -version = "1.17.1" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "proc-macro-crate" @@ -266,18 +270,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.59" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6aeca18b86b413c660b781aa319e4e2648a3e6f9eadc9b47e9038e6fe9f3451b" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.28" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -290,9 +294,21 @@ checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9" [[package]] name = "regex" -version = "1.8.3" +version = "1.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12de2eff854e5fa4b1295edd650e227e9d8fb0c9e90b12e7f36d6a6811791a29" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81ca098a9821bd52d6b24fd8b10bd081f47d39c22778cafaa75a2857a62c6390" +checksum = "49530408a136e16e5b486e883fbb6ba058e8e4e8ae6621a77b048b314336e629" dependencies = [ "aho-corasick", "memchr", @@ -301,15 +317,15 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.7.2" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" [[package]] name = "ryu" -version = "1.0.13" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" [[package]] name = "same-file" @@ -322,29 +338,29 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.163" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.163" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn", ] [[package]] name = "serde_json" -version = "1.0.96" +version = "1.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" +checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360" dependencies = [ "itoa", "ryu", @@ -353,20 +369,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.109" +version = "2.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32d41677bcbe24c20c52e7c70b0d8db04134c5d1066bf98662e2871ad200ea3e" +checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a" dependencies = [ "proc-macro2", "quote", @@ -375,35 +380,35 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.40" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +checksum = "97a802ec30afc17eee47b2855fc72e0c4cd62be9b4efe6591edde0ec5bd68d8f" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.40" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +checksum = "6bb623b56e39ab7dcd4b1b98bb6c8f8d907ed255b18de254088016b27a8ee19b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn", ] [[package]] name = "toml_datetime" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a76a9312f5ba4c2dec6b9161fdf25d87ad8a09256ccea5a556fef03c706a10f" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" [[package]] name = "toml_edit" -version = "0.19.10" +version = "0.19.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2380d56e8670370eee6566b0bfd4265f65b3f432e8c6d85623f728d4fa31f739" +checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a" dependencies = [ "indexmap", "toml_datetime", @@ -412,9 +417,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.9" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" +checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" [[package]] name = "walkdir" @@ -525,9 +530,9 @@ checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "winnow" -version = "0.4.6" +version = "0.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61de7bac303dc551fe038e2b3cef0f571087a47571ea6e79a87692ac99b99699" +checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc" dependencies = [ "memchr", ] diff --git a/na-subclass-jni/Cargo.toml b/na-subclass-jni/Cargo.toml index 8cef04a..1cbb679 100644 --- a/na-subclass-jni/Cargo.toml +++ b/na-subclass-jni/Cargo.toml @@ -3,23 +3,20 @@ name = "na-subclass-jni" version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] -log = "0.4" +android-activity = { version = "0.5.0", features = ["native-activity"] } android_logger = "0.11.0" -android-activity = { version = "0.4", features = [ "native-activity" ] } -ndk-context = "0.1" -ndk = "0.7" -ndk-sys = "0.4" jni = "0.21" +log = "0.4" +ndk = "0.8.0" +ndk-context = "0.1" serde = { version = "1", features = ["derive"] } serde_json = "1" [lib] #name="na_subclass_jni" -crate_type=["cdylib"] +crate_type = ["cdylib"] #################### @@ -31,7 +28,7 @@ crate_type=["cdylib"] package = "com.foo.bar" # Specifies the array of targets to build for. -build_targets = [ "aarch64-linux-android" ] +build_targets = ["aarch64-linux-android"] # Path to your application's resources folder. # If not specified, resources will not be included in the APK. @@ -186,4 +183,4 @@ label = "Application Name" #port = "8080" #path = "/rust-windowing/android-ndk-rs/tree/master/cargo-apk" #path_prefix = "/rust-windowing/" -#mime_type = "image/jpeg" \ No newline at end of file +#mime_type = "image/jpeg" diff --git a/na-subclass-jni/src/lib.rs b/na-subclass-jni/src/lib.rs index 3330038..d20c9b6 100644 --- a/na-subclass-jni/src/lib.rs +++ b/na-subclass-jni/src/lib.rs @@ -1,5 +1,6 @@ use android_activity::{AndroidApp, InputStatus, MainEvent, PollEvent}; use log::info; +use ndk::native_window::HardwareBufferFormat; #[no_mangle] fn android_main(app: AndroidApp) { @@ -38,6 +39,16 @@ fn android_main(app: AndroidApp) { } MainEvent::InitWindow { .. } => { native_window = app.native_window(); + if let Some(nw) = &native_window { + // Set the backing buffer to a known format (without changing + // the size) so that we can safely draw to it in dummy_render(). + nw.set_buffers_geometry( + 0, + 0, + Some(HardwareBufferFormat::R8G8B8A8_UNORM), + ) + .unwrap() + } redraw_pending = true; } MainEvent::TerminateWindow { .. } => { @@ -91,17 +102,16 @@ fn android_main(app: AndroidApp) { /// responsive, otherwise it will stop delivering input /// events to us. fn dummy_render(native_window: &ndk::native_window::NativeWindow) { - unsafe { - let mut buf: ndk_sys::ANativeWindow_Buffer = std::mem::zeroed(); - let mut rect: ndk_sys::ARect = std::mem::zeroed(); - ndk_sys::ANativeWindow_lock( - native_window.ptr().as_ptr() as _, - &mut buf as _, - &mut rect as _, - ); - // Note: we don't try and touch the buffer since that - // also requires us to handle various buffer formats - ndk_sys::ANativeWindow_unlockAndPost(native_window.ptr().as_ptr() as _); + let mut lock = native_window.lock(None).unwrap(); + let (w, h) = (lock.width(), lock.height()); + + for (y, line) in lock.lines().unwrap().enumerate() { + let r = y * 255 / h; + for (x, pixels) in line.chunks_mut(4).enumerate() { + let g = x * 255 / w; + pixels[0].write(r as u8); + pixels[1].write(g as u8); + } } } diff --git a/na-winit-wgpu/Cargo.toml b/na-winit-wgpu/Cargo.toml index ca45e69..e40a73b 100644 --- a/na-winit-wgpu/Cargo.toml +++ b/na-winit-wgpu/Cargo.toml @@ -3,8 +3,6 @@ name = "na-winit-wgpu" version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] log = "0.4" winit = { version = "0.28", features = ["android-native-activity"] } From 58cf3775e581f0fe40507912529fef6c5a81e79a Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Sat, 26 Aug 2023 22:19:17 +0200 Subject: [PATCH 2/3] DRAFT: Make compatible with `android-activity 0.5.0-beta.1` release --- agdk-cpal/src/lib.rs | 2 +- agdk-mainloop/src/lib.rs | 2 +- agdk-oboe/src/lib.rs | 2 +- na-mainloop/src/lib.rs | 2 +- na-subclass-jni/src/lib.rs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/agdk-cpal/src/lib.rs b/agdk-cpal/src/lib.rs index d769037..ea28d92 100644 --- a/agdk-cpal/src/lib.rs +++ b/agdk-cpal/src/lib.rs @@ -147,7 +147,7 @@ fn android_main(app: AndroidApp) { redraw_pending = false; // Handle input - app.input_events(|event| { + app.input_events_iter().unwrap().next(|event| { info!("Input Event: {event:?}"); InputStatus::Unhandled }); diff --git a/agdk-mainloop/src/lib.rs b/agdk-mainloop/src/lib.rs index c33cac9..c60e4b5 100644 --- a/agdk-mainloop/src/lib.rs +++ b/agdk-mainloop/src/lib.rs @@ -80,7 +80,7 @@ fn android_main(app: AndroidApp) { redraw_pending = false; // Handle input - app.input_events(|event| { + app.input_events_iter().unwrap().next(|event| { info!("Input Event: {event:?}"); InputStatus::Unhandled }); diff --git a/agdk-oboe/src/lib.rs b/agdk-oboe/src/lib.rs index bf54fd9..4ed9233 100644 --- a/agdk-oboe/src/lib.rs +++ b/agdk-oboe/src/lib.rs @@ -75,7 +75,7 @@ fn android_main(app: AndroidApp) { redraw_pending = false; // Handle input - app.input_events(|event| { + app.input_events_iter().unwrap().next(|event| { info!("Input Event: {event:?}"); InputStatus::Unhandled }); diff --git a/na-mainloop/src/lib.rs b/na-mainloop/src/lib.rs index c33cac9..c60e4b5 100644 --- a/na-mainloop/src/lib.rs +++ b/na-mainloop/src/lib.rs @@ -80,7 +80,7 @@ fn android_main(app: AndroidApp) { redraw_pending = false; // Handle input - app.input_events(|event| { + app.input_events_iter().unwrap().next(|event| { info!("Input Event: {event:?}"); InputStatus::Unhandled }); diff --git a/na-subclass-jni/src/lib.rs b/na-subclass-jni/src/lib.rs index d20c9b6..1dd1400 100644 --- a/na-subclass-jni/src/lib.rs +++ b/na-subclass-jni/src/lib.rs @@ -80,7 +80,7 @@ fn android_main(app: AndroidApp) { redraw_pending = false; // Handle input - app.input_events(|event| { + app.input_events_iter().unwrap().next(|event| { info!("Input Event: {event:?}"); InputStatus::Unhandled }); From 455ddd6fe989b2ed89d61c57cd50f150154ac3ff Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Sat, 26 Aug 2023 22:19:42 +0200 Subject: [PATCH 3/3] Lints --- na-openxr-info/src/lib.rs | 2 +- na-winit-glutin/src/lib.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/na-openxr-info/src/lib.rs b/na-openxr-info/src/lib.rs index 8003c78..de9b263 100644 --- a/na-openxr-info/src/lib.rs +++ b/na-openxr-info/src/lib.rs @@ -1,4 +1,4 @@ -///! Based on https://github.com/Ralith/openxrs/blob/master/openxr/examples/hello.rs +//! Based on https://github.com/Ralith/openxrs/blob/master/openxr/examples/hello.rs use openxr as xr; #[cfg(target_os = "android")] diff --git a/na-winit-glutin/src/lib.rs b/na-winit-glutin/src/lib.rs index 692025e..6a49c29 100644 --- a/na-winit-glutin/src/lib.rs +++ b/na-winit-glutin/src/lib.rs @@ -245,7 +245,7 @@ impl App { .build(Some(raw_window_handle)); unsafe { glutin_display - .create_context(&config, &context_attributes) + .create_context(config, &context_attributes) .unwrap_or_else(|_| { glutin_display .create_context(config, &fallback_context_attributes) @@ -268,7 +268,7 @@ impl App { } fn ensure_surface_and_context(&mut self, event_loop: &EventLoopWindowTarget) { - let window = winit::window::Window::new(&event_loop).unwrap(); + let window = winit::window::Window::new(event_loop).unwrap(); let raw_window_handle = window.raw_window_handle(); // Lazily initialize, egl, wgl, glx etc