From bf568714b69f0b38441b153d49cc4fca96f6c044 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Fri, 27 Oct 2023 19:03:22 +0200 Subject: [PATCH] examples/glupload: Upgrade to `glutin 0.31` Glutin completely detached from `winit` in the `0.30` upgrade, concerning itself exclusively with OpenGL and WSI APIs around it and leaving any windowing system interop to the `raw-window-handle` crate specifically designed for this purpose. This untanglement massively cleans up and simplifies the `glutin` codebase, and expands on surfaceless rendering as well as drawing to simple views (textures) on the screen as is common on Android, without having control over the entire "window" and event loop. Some winit boilerplate is however still provided as part of the `glutin-winit` crate. Most of the `glutin`+`winit` flow in this `glupload` example is adopted from `glutin`'s example, following platform-specific initialization sequences that heavily clutter the code (only creating a window upfront on Windows, only forcing transparency on macOS, and trying various fallback attributes to create a context). At the same time `winit`'s `Event::Resumed` and `Event::Suspended` event strategy is adopted: this event was previously for Android and iOS exclusively - where window handles come and go at the merit of the OS, rather than existing for the lifetime of the application - but is now emitted on all platforms for consistency. A `Surface` (via `RawWindowHandle`) is only available and usable after `Event::Resumed`, where we can create a GL surface and "current" the context on that surface for rendering. This is where the `GstPipeline` will be set to `Playing` so that data starts flowing. The inverse should happen in `Event::Suspended` where the `Surface` has to be given up again after un-currenting, before giving control back to the OS to free the rest of the resources. This will however be implemented when Android is brought online for these examples. Finally, now that the `gst-gl-egl` and `gst-gl-x11` features turn on the relevant features in `glutin` and `winit`, it is now possible to easily test `x11` on Wayland (over XWayland) without even unsetting `WAYLAND_DISPLAY`, by simply compiling the whole stack without EGL/ Wayland support (on the previous example `winit` would always default to a Wayland handle, while `glupload` could only create `GstGLDisplayX11`). Part-of: --- Cargo.lock | 1182 +++++++++++++++++----------------- examples/Cargo.toml | 21 +- examples/src/bin/glfilter.rs | 2 +- examples/src/glupload.rs | 478 +++++++++----- 4 files changed, 918 insertions(+), 765 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 702999a4f..8990f9cf1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,6 +8,46 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "ahash" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" +dependencies = [ + "cfg-if", + "getrandom", + "once_cell", + "version_check", + "zerocopy", +] + +[[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", + "ndk-context", + "ndk-sys", + "num_enum", + "thiserror", +] + +[[package]] +name = "android-properties" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04" + [[package]] name = "anyhow" version = "1.0.75" @@ -15,16 +55,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" [[package]] -name = "arrayref" -version = "0.3.7" +name = "as-raw-xcb-connection" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" - -[[package]] -name = "arrayvec" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" +checksum = "2d5f312b0a56c5cdf967c0aeb67f6289603354951683bc97ddc595ab974ba9aa" [[package]] name = "async-channel" @@ -39,6 +73,12 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "atomic_refcell" version = "0.1.13" @@ -78,6 +118,25 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" +[[package]] +name = "block-sys" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dd7cf50912cddc06dc5ea7c08c5e81c1b2c842a70d19def1848d54c586fed92" +dependencies = [ + "objc-sys", +] + +[[package]] +name = "block2" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15b55663a85f33501257357e6421bb33e769d5c9ffb5ba0921c975a123e35e68" +dependencies = [ + "block-sys", + "objc2", +] + [[package]] name = "bumpalo" version = "3.14.0" @@ -102,6 +161,12 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" +[[package]] +name = "bytes" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" + [[package]] name = "cairo-rs" version = "0.19.0" @@ -127,16 +192,28 @@ dependencies = [ [[package]] name = "calloop" -version = "0.10.6" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52e0d00eb1ea24371a97d2da6201c6747a633dc6dc1988ef503403b4c59504a8" +checksum = "7b50b5a44d59a98c55a9eeb518f39bf7499ba19fd98ee7d22618687f3f10adbf" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.1", "log", - "nix 0.25.1", - "slotmap", + "polling", + "rustix", + "slab", "thiserror", - "vec_map", +] + +[[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", ] [[package]] @@ -145,9 +222,16 @@ version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" 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-expr" version = "0.15.5" @@ -164,6 +248,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cfg_aliases" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" + [[package]] name = "cgl" version = "0.3.2" @@ -173,31 +263,6 @@ dependencies = [ "libc", ] -[[package]] -name = "cmake" -version = "0.1.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" -dependencies = [ - "cc", -] - -[[package]] -name = "cocoa" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f425db7937052c684daec3bd6375c8abe2d146dca4b8b143d6db777c39138f3a" -dependencies = [ - "bitflags 1.3.2", - "block", - "cocoa-foundation", - "core-foundation", - "core-graphics 0.22.3", - "foreign-types 0.3.2", - "libc", - "objc", -] - [[package]] name = "cocoa" version = "0.25.0" @@ -208,8 +273,8 @@ dependencies = [ "block", "cocoa-foundation", "core-foundation", - "core-graphics 0.23.1", - "foreign-types 0.5.0", + "core-graphics", + "foreign-types", "libc", "objc", ] @@ -234,6 +299,16 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" +[[package]] +name = "combine" +version = "4.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4" +dependencies = [ + "bytes", + "memchr", +] + [[package]] name = "concurrent-queue" version = "2.3.0" @@ -265,19 +340,6 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" -[[package]] -name = "core-graphics" -version = "0.22.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "core-graphics-types", - "foreign-types 0.3.2", - "libc", -] - [[package]] name = "core-graphics" version = "0.23.1" @@ -287,7 +349,7 @@ dependencies = [ "bitflags 1.3.2", "core-foundation", "core-graphics-types", - "foreign-types 0.5.0", + "foreign-types", "libc", ] @@ -302,18 +364,6 @@ dependencies = [ "libc", ] -[[package]] -name = "core-text" -version = "19.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99d74ada66e07c1cefa18f8abfba765b486f250de2e4a999e5727fc0dd4b4a25" -dependencies = [ - "core-foundation", - "core-graphics 0.22.3", - "foreign-types 0.3.2", - "libc", -] - [[package]] name = "crc32fast" version = "1.3.2" @@ -333,68 +383,10 @@ dependencies = [ ] [[package]] -name = "crossfont" -version = "0.5.1" +name = "cursor-icon" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21fd3add36ea31aba1520aa5288714dd63be506106753226d0eb387a93bc9c45" -dependencies = [ - "cocoa 0.24.1", - "core-foundation", - "core-foundation-sys", - "core-graphics 0.22.3", - "core-text", - "dwrote", - "foreign-types 0.5.0", - "freetype-rs", - "libc", - "log", - "objc", - "once_cell", - "pkg-config", - "servo-fontconfig", - "winapi", -] - -[[package]] -name = "cty" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35" - -[[package]] -name = "darling" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn 1.0.109", -] - -[[package]] -name = "darling_macro" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" -dependencies = [ - "darling_core", - "quote", - "syn 1.0.109", -] +checksum = "96a6ac251f4a2aca6b3f91340350eab87ae57c3f127ffeb585e92bd336717991" [[package]] name = "derive_more" @@ -430,20 +422,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" -[[package]] -name = "dwrote" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439a1c2ba5611ad3ed731280541d36d2e9c4ac5e7fb818a27b604bdc5a6aa65b" -dependencies = [ - "lazy_static", - "libc", - "serde", - "serde_derive", - "winapi", - "wio", -] - [[package]] name = "either" version = "1.9.0" @@ -494,13 +472,14 @@ dependencies = [ "anyhow", "byte-slice-cast", "cairo-rs", - "cocoa 0.25.0", + "cocoa", "derive_more", "futures", "gio", "gl_generator", "glib", "glutin", + "glutin-winit", "gstreamer", "gstreamer-allocators", "gstreamer-app", @@ -509,7 +488,6 @@ dependencies = [ "gstreamer-editing-services", "gstreamer-gl", "gstreamer-gl-egl", - "gstreamer-gl-wayland", "gstreamer-gl-x11", "gstreamer-pbutils", "gstreamer-play", @@ -520,21 +498,13 @@ dependencies = [ "gstreamer-video", "image", "memfd", - "memmap2 0.9.0", + "memmap2", "pango", "pangocairo", + "raw-window-handle 0.5.2", "uds", "windows", -] - -[[package]] -name = "expat-sys" -version = "2.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "658f19728920138342f68408b7cf7644d90d4784353d8ebc32e7e8663dbe45fa" -dependencies = [ - "cmake", - "pkg-config", + "winit", ] [[package]] @@ -562,21 +532,6 @@ dependencies = [ "miniz_oxide", ] -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared 0.1.1", -] - [[package]] name = "foreign-types" version = "0.5.0" @@ -584,7 +539,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965" dependencies = [ "foreign-types-macros", - "foreign-types-shared 0.3.1", + "foreign-types-shared", ] [[package]] @@ -598,40 +553,12 @@ dependencies = [ "syn 2.0.39", ] -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - [[package]] name = "foreign-types-shared" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" -[[package]] -name = "freetype-rs" -version = "0.26.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74eadec9d0a5c28c54bb9882e54787275152a4e36ce206b45d7451384e5bf5fb" -dependencies = [ - "bitflags 1.3.2", - "freetype-sys", - "libc", -] - -[[package]] -name = "freetype-sys" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a37d4011c0cc628dfa766fcc195454f4b068d7afdc2adfd28861191d866e731a" -dependencies = [ - "cmake", - "libc", - "pkg-config", -] - [[package]] name = "futures" version = "0.3.29" @@ -721,6 +648,27 @@ dependencies = [ "slab", ] +[[package]] +name = "gethostname" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb65d4ba3173c56a500b555b532f72c42e8d1fe64962b518897f8959fae2c177" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "getrandom" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + [[package]] name = "gio" version = "0.19.0" @@ -796,7 +744,7 @@ version = "0.19.0" source = "git+https://github.com/gtk-rs/gtk-rs-core#24ac2075336c7a1ccd5058fd3b732f6616f2f9da" dependencies = [ "heck", - "proc-macro-crate 2.0.0", + "proc-macro-crate", "proc-macro-error", "proc-macro2", "quote", @@ -814,69 +762,58 @@ dependencies = [ [[package]] name = "glutin" -version = "0.29.1" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "444c9ad294fdcaf20ccf6726b78f380b5450275540c9b68ab62f49726ad1c713" +checksum = "eca18d477e18c996c1fd1a50e04c6a745b67e2d512c7fb51f2757d9486a0e3ee" dependencies = [ + "bitflags 2.4.1", + "cfg_aliases", "cgl", - "cocoa 0.24.1", "core-foundation", + "dispatch", "glutin_egl_sys", - "glutin_gles2_sys", "glutin_glx_sys", - "glutin_wgl_sys", - "libloading 0.7.4", - "log", - "objc", + "icrate", + "libloading 0.8.1", + "objc2", "once_cell", - "osmesa-sys", - "parking_lot", "raw-window-handle 0.5.2", - "wayland-client", - "wayland-egl", - "winapi", + "wayland-sys", + "x11-dl", +] + +[[package]] +name = "glutin-winit" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ebcdfba24f73b8412c5181e56f092b5eff16671c514ce896b258a0a64bd7735" +dependencies = [ + "cfg_aliases", + "glutin", + "raw-window-handle 0.5.2", "winit", ] [[package]] name = "glutin_egl_sys" -version = "0.1.6" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68900f84b471f31ea1d1355567eb865a2cf446294f06cef8d653ed7bcf5f013d" +checksum = "77cc5623f5309ef433c3dd4ca1223195347fe62c413da8e2fdd0eb76db2d9bcd" dependencies = [ "gl_generator", - "winapi", -] - -[[package]] -name = "glutin_gles2_sys" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8094e708b730a7c8a1954f4f8a31880af00eb8a1c5b5bf85d28a0a3c6d69103" -dependencies = [ - "gl_generator", - "objc", + "windows-sys 0.48.0", ] [[package]] name = "glutin_glx_sys" -version = "0.1.8" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d93d0575865098580c5b3a423188cd959419912ea60b1e48e8b3b526f6d02468" +checksum = "a165fd686c10dcc2d45380b35796e577eacfd43d4660ee741ec8ebe2201b3b4f" dependencies = [ "gl_generator", "x11-dl", ] -[[package]] -name = "glutin_wgl_sys" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3da5951a1569dbab865c6f2a863efafff193a93caf05538d193e9e3816d21696" -dependencies = [ - "gl_generator", -] - [[package]] name = "gobject-sys" version = "0.19.0" @@ -1588,10 +1525,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] -name = "ident_case" -version = "1.0.1" +name = "icrate" +version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" +checksum = "99d3aaff8a54577104bafdf686ff18565c3b6903ca5782a2026ef06e2c7aa319" +dependencies = [ + "block2", + "dispatch", + "objc2", +] [[package]] name = "image" @@ -1618,18 +1560,6 @@ dependencies = [ "hashbrown", ] -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", -] - [[package]] name = "itertools" version = "0.11.0" @@ -1645,12 +1575,37 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +[[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 0.45.0", +] + [[package]] name = "jni-sys" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" +[[package]] +name = "jobserver" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" +dependencies = [ + "libc", +] + [[package]] name = "jpeg-decoder" version = "0.3.0" @@ -1672,12 +1627,6 @@ 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 = "libc" version = "0.2.150" @@ -1712,7 +1661,7 @@ checksum = "3af92c55d7d839293953fcd0fda5ecfe93297cfde6ffbdec13b41d99c0ba6607" dependencies = [ "bitflags 2.4.1", "libc", - "redox_syscall", + "redox_syscall 0.4.1", ] [[package]] @@ -1721,16 +1670,6 @@ version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829" -[[package]] -name = "lock_api" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" -dependencies = [ - "autocfg", - "scopeguard", -] - [[package]] name = "log" version = "0.4.20" @@ -1761,15 +1700,6 @@ dependencies = [ "rustix", ] -[[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.0" @@ -1781,9 +1711,9 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.6.5" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" dependencies = [ "autocfg", ] @@ -1804,18 +1734,6 @@ dependencies = [ "simd-adler32", ] -[[package]] -name = "mio" -version = "0.8.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" -dependencies = [ - "libc", - "log", - "wasi", - "windows-sys 0.48.0", -] - [[package]] name = "muldiv" version = "1.0.1" @@ -1824,15 +1742,17 @@ checksum = "956787520e75e9bd233246045d19f42fb73242759cc57fba9611d940ae96d4b0" [[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 1.3.2", + "bitflags 2.4.1", "jni-sys", + "log", "ndk-sys", "num_enum", "raw-window-handle 0.5.2", + "raw-window-handle 0.6.0", "thiserror", ] @@ -1842,49 +1762,20 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" -[[package]] -name = "ndk-glue" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0434fabdd2c15e0aab768ca31d5b7b333717f03cf02037d5a0a3ff3c278ed67f" -dependencies = [ - "libc", - "log", - "ndk", - "ndk-context", - "ndk-macro", - "ndk-sys", - "once_cell", - "parking_lot", -] - -[[package]] -name = "ndk-macro" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0df7ac00c4672f9d5aece54ee3347520b7e20f158656c7db2e6de01902eb7a6c" -dependencies = [ - "darling", - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[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 = "nix" -version = "0.24.3" +version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" +checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" dependencies = [ "bitflags 1.3.2", "cfg-if", @@ -1892,19 +1783,6 @@ dependencies = [ "memoffset", ] -[[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", - "libc", - "memoffset", -] - [[package]] name = "nom" version = "7.1.3" @@ -1948,23 +1826,23 @@ dependencies = [ [[package]] name = "num_enum" -version = "0.5.11" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f646caf906c20226733ed5b1374287eb97e3c2a5c227ce668c1f2ce20ae57c9" +checksum = "683751d591e6d81200c39fb0d1032608b77724f34114db54f571ff1317b337c0" dependencies = [ "num_enum_derive", ] [[package]] name = "num_enum_derive" -version = "0.5.11" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799" +checksum = "6c11e44798ad209ccdd91fc192f0526a369a01234f7373e1b141c96d7cee4f0e" dependencies = [ - "proc-macro-crate 1.3.1", + "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.39", ] [[package]] @@ -1982,6 +1860,28 @@ dependencies = [ "malloc_buf", ] +[[package]] +name = "objc-sys" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99e1d07c6eab1ce8b6382b8e3c7246fe117ff3f8b34be065f5ebace6749fe845" + +[[package]] +name = "objc2" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "559c5a40fdd30eb5e344fbceacf7595a81e242529fb4e21cf5f43fb4f11ff98d" +dependencies = [ + "objc-sys", + "objc2-encode", +] + +[[package]] +name = "objc2-encode" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d079845b37af429bfe5dfa76e6d087d788031045b25cfc6fd898486fd9847666" + [[package]] name = "once_cell" version = "1.18.0" @@ -1998,12 +1898,12 @@ dependencies = [ ] [[package]] -name = "osmesa-sys" -version = "0.1.2" +name = "orbclient" +version = "0.3.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88cfece6e95d2e717e0872a7f53a8684712ad13822a7979bc760b9c77ec0013b" +checksum = "52f0d54bde9774d3a51dcf281a5def240c71996bc6ca05d2c847ec8b2b216166" dependencies = [ - "shared_library", + "libredox", ] [[package]] @@ -2059,29 +1959,6 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" -[[package]] -name = "parking_lot" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-targets", -] - [[package]] name = "paste" version = "1.0.14" @@ -2125,22 +2002,26 @@ dependencies = [ "miniz_oxide", ] +[[package]] +name = "polling" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e53b6af1f60f36f8c2ac2aad5459d75a5a9b4be1e8cdd40264f315d78193e531" +dependencies = [ + "cfg-if", + "concurrent-queue", + "pin-project-lite", + "rustix", + "tracing", + "windows-sys 0.48.0", +] + [[package]] name = "pretty-hex" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6fa0831dd7cc608c38a5e323422a0077678fa5744aa2be4ad91c4ece8eec8d5" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - [[package]] name = "proc-macro-crate" version = "2.0.0" @@ -2183,6 +2064,15 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "quick-xml" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eff6510e86862b57b210fd8cbe8ed3f0d7d600b9c2863cd4549a2e033c66e956" +dependencies = [ + "memchr", +] + [[package]] name = "quote" version = "1.0.33" @@ -2192,21 +2082,27 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "raw-window-handle" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b800beb9b6e7d2df1fe337c9e3d04e3af22a124460fb4c30fcc22c9117cefb41" -dependencies = [ - "cty", -] - [[package]] name = "raw-window-handle" 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.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags 1.3.2", +] + [[package]] name = "redox_syscall" version = "0.4.1" @@ -2263,12 +2159,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" [[package]] -name = "safe_arch" -version = "0.5.2" +name = "same-file" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1ff3d6d9696af502cc3110dacce942840fb06ff4514cad92236ecc455f2ce05" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" dependencies = [ - "bytemuck", + "winapi-util", ] [[package]] @@ -2277,24 +2173,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "sctk-adwaita" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61270629cc6b4d77ec1907db1033d5c2e1a404c412743621981a871dc9c12339" -dependencies = [ - "crossfont", - "log", - "smithay-client-toolkit", - "tiny-skia", -] - [[package]] name = "semver" version = "1.0.20" @@ -2350,37 +2228,6 @@ dependencies = [ "serde", ] -[[package]] -name = "servo-fontconfig" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7e3e22fe5fd73d04ebf0daa049d3efe3eae55369ce38ab16d07ddd9ac5c217c" -dependencies = [ - "libc", - "servo-fontconfig-sys", -] - -[[package]] -name = "servo-fontconfig-sys" -version = "5.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e36b879db9892dfa40f95da1c38a835d41634b825fbd8c4c418093d53c24b388" -dependencies = [ - "expat-sys", - "freetype-sys", - "pkg-config", -] - -[[package]] -name = "shared_library" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a9e7e0f2bfae24d8a5b5a66c5b257a83c7412304311512a0c054cd5e619da11" -dependencies = [ - "lazy_static", - "libc", -] - [[package]] name = "shell-words" version = "1.1.0" @@ -2402,45 +2249,45 @@ dependencies = [ "autocfg", ] -[[package]] -name = "slotmap" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1e08e261d0e8f5c43123b7adf3e4ca1690d655377ac93a03b2c9d3e98de1342" -dependencies = [ - "version_check", -] - [[package]] name = "smallvec" -version = "1.11.1" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "smithay-client-toolkit" -version = "0.16.1" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "870427e30b8f2cbe64bf43ec4b86e88fe39b0a84b3f15efd9c9c2d020bc86eb9" +checksum = "60e3d9941fa3bacf7c2bf4b065304faa14164151254cd16ce1b1bc8fc381600f" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.1", "calloop", - "dlib", - "lazy_static", + "calloop-wayland-source", + "cursor-icon", + "libc", "log", - "memmap2 0.5.10", - "nix 0.24.3", - "pkg-config", + "memmap2", + "rustix", + "thiserror", + "wayland-backend", "wayland-client", + "wayland-csd-frame", "wayland-cursor", "wayland-protocols", + "wayland-protocols-wlr", + "wayland-scanner", + "xkeysym", ] [[package]] -name = "strsim" -version = "0.10.0" +name = "smol_str" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +checksum = "74212e6bbe9a4352329b2f68ba3130c15a3f26fe88ff22dbdc6cdd58fa85e99c" +dependencies = [ + "serde", +] [[package]] name = "syn" @@ -2491,7 +2338,7 @@ checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" dependencies = [ "cfg-if", "fastrand", - "redox_syscall", + "redox_syscall 0.4.1", "rustix", "windows-sys 0.48.0", ] @@ -2528,31 +2375,6 @@ dependencies = [ "syn 2.0.39", ] -[[package]] -name = "tiny-skia" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "642680569bb895b16e4b9d181c60be1ed136fa0c9c7f11d004daf053ba89bf82" -dependencies = [ - "arrayref", - "arrayvec", - "bytemuck", - "cfg-if", - "png", - "safe_arch", - "tiny-skia-path", -] - -[[package]] -name = "tiny-skia-path" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c114d32f0c2ee43d585367cb013dfaba967ab9f62b90d9af0d696e955e70fa6c" -dependencies = [ - "arrayref", - "bytemuck", -] - [[package]] name = "toml" version = "0.8.8" @@ -2574,17 +2396,6 @@ dependencies = [ "serde", ] -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "toml_edit" version = "0.20.7" @@ -2609,6 +2420,22 @@ 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 = "tutorials" version = "0.22.0" @@ -2616,7 +2443,7 @@ dependencies = [ "anyhow", "async-channel", "byte-slice-cast", - "cocoa 0.25.0", + "cocoa", "futures", "glib", "gstreamer", @@ -2644,10 +2471,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] -name = "vec_map" -version = "0.8.2" +name = "unicode-segmentation" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" [[package]] name = "version-compare" @@ -2661,6 +2488,16 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[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" @@ -2692,6 +2529,18 @@ dependencies = [ "wasm-bindgen-shared", ] +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9afec9963e3d0994cac82455b2b3502b81a7f40f9a0d32181f7528d9f4b43e02" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "wasm-bindgen-macro" version = "0.2.88" @@ -2722,85 +2571,111 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b" [[package]] -name = "wayland-client" -version = "0.29.5" +name = "wayland-backend" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f3b068c05a039c9f755f881dc50f01732214f5685e379829759088967c46715" +checksum = "19152ddd73f45f024ed4534d9ca2594e0ef252c1847695255dae47f34df9fbe4" dependencies = [ - "bitflags 1.3.2", + "cc", "downcast-rs", - "libc", - "nix 0.24.3", + "nix", "scoped-tls", - "wayland-commons", - "wayland-scanner", - "wayland-sys", -] - -[[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", ] [[package]] -name = "wayland-cursor" -version = "0.29.5" +name = "wayland-client" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6865c6b66f13d6257bef1cd40cbfe8ef2f150fb8ebbdb1e8e873455931377661" +checksum = "1ca7d52347346f5473bf2f56705f360e8440873052e575e55890c4fa57843ed3" dependencies = [ - "nix 0.24.3", + "bitflags 2.4.1", + "nix", + "wayland-backend", + "wayland-scanner", +] + +[[package]] +name = "wayland-csd-frame" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "625c5029dbd43d25e6aa9615e88b829a5cad13b2819c4ae129fdbb7c31ab4c7e" +dependencies = [ + "bitflags 2.4.1", + "cursor-icon", + "wayland-backend", +] + +[[package]] +name = "wayland-cursor" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44aa20ae986659d6c77d64d808a046996a932aa763913864dc40c359ef7ad5b" +dependencies = [ + "nix", "wayland-client", "xcursor", ] [[package]] -name = "wayland-egl" -version = "0.29.5" +name = "wayland-protocols" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "402de949f81a012926d821a2d659f930694257e76dd92b6e0042ceb27be4107d" +checksum = "e253d7107ba913923dc253967f35e8561a3c65f914543e46843c88ddd729e21c" dependencies = [ + "bitflags 2.4.1", + "wayland-backend", "wayland-client", - "wayland-sys", + "wayland-scanner", ] [[package]] -name = "wayland-protocols" -version = "0.29.5" +name = "wayland-protocols-plasma" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b950621f9354b322ee817a23474e479b34be96c2e909c14f7bc0100e9a970bc6" +checksum = "23803551115ff9ea9bce586860c5c5a971e360825a0309264102a9495a5ff479" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.1", + "wayland-backend", "wayland-client", - "wayland-commons", + "wayland-protocols", + "wayland-scanner", +] + +[[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", ] [[package]] name = "wayland-scanner" -version = "0.29.5" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f4303d8fa22ab852f789e75a967f0a2cdc430a607751c0499bada3e451cbd53" +checksum = "fb8e28403665c9f9513202b7e1ed71ec56fde5c107816843fb14057910b2c09c" dependencies = [ "proc-macro2", + "quick-xml", "quote", - "xml-rs", ] [[package]] name = "wayland-sys" -version = "0.29.5" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be12ce1a3c39ec7dba25594b97b42cb3195d54953ddb9d3d95a7c3902bc6e9d4" +checksum = "15a0c8eaff5216d07f226cb7a549159267f3467b289d9a2e52fd3ef5aae2b7af" dependencies = [ "dlib", - "lazy_static", + "log", + "once_cell", "pkg-config", ] @@ -2814,6 +2689,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "web-time" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57099a701fb3a8043f993e8228dc24229c7b942e2b009a1b962e54489ba1d3bf" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "winapi" version = "0.3.9" @@ -2830,6 +2715,24 @@ 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-wsapoll" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c17110f57155602a80dca10be03852116403c9ff3cd25b079d666f2aa3df6e" +dependencies = [ + "winapi", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -2843,7 +2746,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca229916c5ee38c2f2bc1e9d8f04df975b4bd93f9955dc69fabb5d91270045c9" dependencies = [ "windows-core", - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -2852,20 +2755,16 @@ version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", ] [[package]] name = "windows-sys" -version = "0.36.1" +version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" dependencies = [ - "windows_aarch64_msvc 0.36.1", - "windows_i686_gnu 0.36.1", - "windows_i686_msvc 0.36.1", - "windows_x86_64_gnu 0.36.1", - "windows_x86_64_msvc 0.36.1", + "windows-targets 0.42.2", ] [[package]] @@ -2874,7 +2773,22 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +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]] @@ -2883,15 +2797,21 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm", + "windows_aarch64_gnullvm 0.48.5", "windows_aarch64_msvc 0.48.5", "windows_i686_gnu 0.48.5", "windows_i686_msvc 0.48.5", "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm", + "windows_x86_64_gnullvm 0.48.5", "windows_x86_64_msvc 0.48.5", ] +[[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_gnullvm" version = "0.48.5" @@ -2900,9 +2820,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_msvc" -version = "0.36.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" [[package]] name = "windows_aarch64_msvc" @@ -2912,9 +2832,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_i686_gnu" -version = "0.36.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" [[package]] name = "windows_i686_gnu" @@ -2924,9 +2844,9 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_msvc" -version = "0.36.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_i686_msvc" @@ -2936,9 +2856,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_x86_64_gnu" -version = "0.36.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnu" @@ -2946,6 +2866,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[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_gnullvm" version = "0.48.5" @@ -2954,9 +2880,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_msvc" -version = "0.36.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "windows_x86_64_msvc" @@ -2966,35 +2892,49 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winit" -version = "0.27.5" +version = "0.29.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb796d6fbd86b2fd896c9471e6f04d39d750076ebe5680a3958f00f5ab97657c" +checksum = "161598019a9da35ab6c34dc46cd13546cba9dbf9816475d4dd9a639455016563" dependencies = [ - "bitflags 1.3.2", - "cocoa 0.24.1", + "ahash", + "android-activity", + "atomic-waker", + "bitflags 2.4.1", + "bytemuck", + "calloop", + "cfg_aliases", "core-foundation", - "core-graphics 0.22.3", - "dispatch", - "instant", + "core-graphics", + "cursor-icon", + "icrate", + "js-sys", "libc", "log", - "mio", + "memmap2", "ndk", - "ndk-glue", - "objc", + "ndk-sys", + "objc2", "once_cell", - "parking_lot", + "orbclient", "percent-encoding", - "raw-window-handle 0.4.3", "raw-window-handle 0.5.2", - "sctk-adwaita", + "redox_syscall 0.3.5", + "rustix", "smithay-client-toolkit", + "smol_str", + "unicode-segmentation", "wasm-bindgen", + "wasm-bindgen-futures", + "wayland-backend", "wayland-client", "wayland-protocols", + "wayland-protocols-plasma", "web-sys", - "windows-sys 0.36.1", + "web-time", + "windows-sys 0.48.0", "x11-dl", + "x11rb", + "xkbcommon-dl", ] [[package]] @@ -3006,15 +2946,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "wio" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d129932f4644ac2396cb456385cbf9e63b5b30c6e8dc4820bdca4eb082037a5" -dependencies = [ - "winapi", -] - [[package]] name = "x11-dl" version = "2.21.0" @@ -3026,6 +2957,32 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "x11rb" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1641b26d4dec61337c35a1b1aaf9e3cba8f46f0b43636c609ab0291a648040a" +dependencies = [ + "as-raw-xcb-connection", + "gethostname", + "libc", + "libloading 0.7.4", + "nix", + "once_cell", + "winapi", + "winapi-wsapoll", + "x11rb-protocol", +] + +[[package]] +name = "x11rb-protocol" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82d6c3f9a0fb6701fab8f6cea9b0c0bd5d6876f1f89f7fada07e558077c344bc" +dependencies = [ + "nix", +] + [[package]] name = "xcursor" version = "0.3.4" @@ -3035,8 +2992,47 @@ dependencies = [ "nom", ] +[[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" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fcb9cbac069e033553e8bb871be2fbdffcab578eb25bd0f7c508cedc6dcd75a" + +[[package]] +name = "zerocopy" +version = "0.7.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cd369a67c0edfef15010f980c3cbe45d7f651deac2cd67ce097cd801de16557" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2f140bda219a26ccc0cdb03dba58af72590c53b22642577d88a927bc5c87d6b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 4fcd4cb68..dceacf1a3 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -26,17 +26,20 @@ gst-rtsp-server = { package = "gstreamer-rtsp-server", path = "../gstreamer-rtsp gst-allocators = { package = "gstreamer-allocators", path = "../gstreamer-allocators", optional = true } gio = { git = "https://github.com/gtk-rs/gtk-rs-core", optional = true } anyhow = "1.0" -derive_more = "0.99.5" -futures = "0.3" byte-slice-cast = "1" cairo-rs = { git = "https://github.com/gtk-rs/gtk-rs-core", features=["use_glib"], optional = true } +derive_more = "0.99.5" +futures = "0.3" +glutin = { version = "0.31", optional = true, default-features = false } +glutin-winit = { version = "0.4", optional = true, default-features = false } +image = { version = "0.24", optional = true, default-features = false, features = ["png", "jpeg"] } +memfd = { version = "0.6", optional = true } +memmap2 = { version = "0.9", optional = true } pango = { git = "https://github.com/gtk-rs/gtk-rs-core", optional = true } pangocairo = { git = "https://github.com/gtk-rs/gtk-rs-core", optional = true } -glutin = { version = "0.29", optional = true } -image = { version = "0.24", optional = true, default-features = false, features = ["png", "jpeg"] } -memmap2 = { version = "0.9", optional = true } -memfd = { version = "0.6", optional = true } +raw-window-handle = { version = "0.5", optional = true } uds = { version = "0.4", optional = true } +winit = { version = "0.29", optional = true, default-features = false, features = ["rwh_05"] } [target.'cfg(windows)'.dependencies] windows = { version = "0.51", features=["Win32_Graphics_Direct3D11", @@ -57,9 +60,9 @@ rtsp-server = ["gst-rtsp-server", "gst-rtsp", "gst-sdp"] rtsp-server-record = ["gst-rtsp-server", "gst-rtsp", "gio"] pango-cairo = ["pango", "pangocairo", "cairo-rs"] overlay-composition = ["pango", "pangocairo", "cairo-rs"] -gl = ["gst-gl", "gl_generator", "glutin"] -gst-gl-x11 = ["dep:gst-gl-x11"] -gst-gl-egl = ["dep:gst-gl-egl"] +gl = ["dep:gst-gl", "dep:gl_generator", "dep:glutin", "dep:glutin-winit", "dep:winit", "dep:raw-window-handle"] +gst-gl-x11 = ["dep:gst-gl-x11", "glutin-winit?/glx"] # glx turns on x11 +gst-gl-egl = ["dep:gst-gl-egl", "glutin-winit?/egl", "glutin-winit?/x11", "glutin-winit?/wayland"] # Use X11 or Wayland via EGL allocators = ["gst-allocators", "memmap2", "memfd", "uds"] [[bin]] diff --git a/examples/src/bin/glfilter.rs b/examples/src/bin/glfilter.rs index 1f90c1a9c..07213397c 100644 --- a/examples/src/bin/glfilter.rs +++ b/examples/src/bin/glfilter.rs @@ -165,7 +165,7 @@ mod mirror { fn example_main() -> Result<()> { gst::init().unwrap(); - let glfilter = mirror::GLMirrorFilter::new(Some("foo")); + let glfilter = mirror::GLMirrorFilter::new(Some("Mirror filter")); App::new(Some(glfilter.as_ref())).and_then(main_loop) } diff --git a/examples/src/glupload.rs b/examples/src/glupload.rs index 8403ed87d..929658f37 100644 --- a/examples/src/glupload.rs +++ b/examples/src/glupload.rs @@ -1,15 +1,30 @@ -// This example demonstrates how to output GL textures, within an -// EGL/X11 context provided by the application, and render those -// textures in the GL application. +//! This example demonstrates how to output GL textures, within an EGL/X11 context provided by the +//! application, and render those textures in the GL application. +//! +//! This example follow common patterns from `glutin`: +//! // {videotestsrc} - { glsinkbin } -use std::{ffi::CStr, mem, ptr, sync}; +use std::{ + ffi::{CStr, CString}, + mem, + num::NonZeroU32, + ptr, +}; -use anyhow::Error; +use anyhow::{Context, Result}; use derive_more::{Display, Error}; +use glutin::{ + config::GetGlConfig as _, + context::AsRawContext as _, + display::{AsRawDisplay as _, GetGlDisplay as _}, + prelude::*, +}; +use glutin_winit::GlWindow as _; use gst::element_error; use gst_gl::prelude::*; +use raw_window_handle::HasRawWindowHandle as _; #[derive(Debug, Display, Error)] #[display(fmt = "Received error from {src}: {error} (debug: {debug:?})")] @@ -171,7 +186,7 @@ impl Gl { } } - fn resize(&self, size: glutin::dpi::PhysicalSize) { + fn resize(&self, size: winit::dpi::PhysicalSize) { unsafe { self.gl .Viewport(0, 0, size.width as i32, size.height as i32); @@ -179,14 +194,17 @@ impl Gl { } } -fn load(gl_context: &glutin::WindowedContext) -> Gl { - let gl = gl::Gl::load_with(|ptr| gl_context.get_proc_address(ptr) as *const _); +fn load(gl_display: &impl glutin::display::GlDisplay) -> Gl { + let gl = gl::Gl::load_with(|symbol| { + let symbol = CString::new(symbol).unwrap(); + gl_display.get_proc_address(&symbol).cast() + }); let version = unsafe { - let data = CStr::from_ptr(gl.GetString(gl::VERSION) as *const _) - .to_bytes() - .to_vec(); - String::from_utf8(data).unwrap() + let version = gl.GetString(gl::VERSION); + assert!(!version.is_null()); + let version = CStr::from_ptr(version.cast()); + version.to_string_lossy() }; println!("OpenGL version {version}"); @@ -313,140 +331,199 @@ pub(crate) struct App { pipeline: gst::Pipeline, appsink: gst_app::AppSink, bus: gst::Bus, - event_loop: glutin::event_loop::EventLoop, - windowed_context: glutin::WindowedContext, + event_loop: winit::event_loop::EventLoop, + window: Option, + not_current_gl_context: Option, shared_context: gst_gl::GLContext, } impl App { - pub(crate) fn new(gl_element: Option<&gst::Element>) -> Result { + pub(crate) fn new(gl_element: Option<&gst::Element>) -> Result { gst::init()?; let (pipeline, appsink) = App::create_pipeline(gl_element)?; let bus = pipeline .bus() - .expect("Pipeline without bus. Shouldn't happen!"); + .context("Pipeline without bus. Shouldn't happen!")?; - let event_loop = glutin::event_loop::EventLoopBuilder::with_user_event().build(); - let window = glutin::window::WindowBuilder::new().with_title("GL rendering"); - let windowed_context = glutin::ContextBuilder::new() - .with_vsync(true) - .build_windowed(window, &event_loop)?; + let event_loop = winit::event_loop::EventLoopBuilder::with_user_event().build()?; - let windowed_context = unsafe { windowed_context.make_current().map_err(|(_, err)| err)? }; + // Only Windows requires the window to be present before creating a `glutin::Display`. Other + // platforms don't really need one (and on Android, none exists until `Event::Resumed`). + let window_builder = cfg!(windows).then(|| { + winit::window::WindowBuilder::new() + .with_transparent(true) + .with_title("GL rendering") + }); - #[cfg(any(feature = "gst-gl-x11"))] - let inner_window = windowed_context.window(); + let display_builder = + glutin_winit::DisplayBuilder::new().with_window_builder(window_builder); + // XXX on macOS/cgl only one config can be queried at a time. If transparency is needed, + // add .with_transparency(true) to ConfigTemplateBuilder. EGL on X11 doesn't support + // transparency at all. + let template = glutin::config::ConfigTemplateBuilder::new().with_alpha_size(8); + let (window, gl_config) = display_builder + .build(&event_loop, template, |configs| { + configs + .reduce(|current, new_config| { + let prefer_transparency = + new_config.supports_transparency().unwrap_or(false) + & !current.supports_transparency().unwrap_or(false); - let shared_context: gst_gl::GLContext; - if cfg!(target_os = "linux") { - #[cfg(any(feature = "gst-gl-x11"))] - use glutin::platform::unix::WindowExtUnix; - use glutin::platform::{unix::RawHandle, ContextTraitExt}; - - let api = App::map_gl_api(windowed_context.get_api()); - - let (gl_context, gl_display, platform) = match unsafe { windowed_context.raw_handle() } - { - #[cfg(any(feature = "gst-gl-egl"))] - RawHandle::Egl(egl_context) => { - let gl_display = - if let Some(display) = unsafe { windowed_context.get_egl_display() } { - unsafe { gst_gl_egl::GLDisplayEGL::with_egl_display(display as usize) } - .unwrap() + if prefer_transparency || new_config.num_samples() > current.num_samples() { + new_config } else { - panic!("EGL window without EGL Display") - }; - - ( - egl_context as usize, - gl_display.upcast::(), - gst_gl::GLPlatform::EGL, - ) - } - #[cfg(feature = "gst-gl-x11")] - RawHandle::Glx(glx_context) => { - let gl_display = if let Some(display) = inner_window.xlib_display() { - unsafe { gst_gl_x11::GLDisplayX11::with_display(display as usize) }.unwrap() - } else { - panic!("X11 window without X Display") - }; - - ( - glx_context as usize, - gl_display.upcast::(), - gst_gl::GLPlatform::GLX, - ) - } - #[allow(unreachable_patterns)] - handler => panic!("Unsupported platform: {handler:?}."), - }; - - shared_context = - unsafe { gst_gl::GLContext::new_wrapped(&gl_display, gl_context, platform, api) } - .unwrap(); - - shared_context - .activate(true) - .expect("Couldn't activate wrapped GL context"); - - shared_context.fill_info()?; - - let gl_context = shared_context.clone(); - let event_proxy = sync::Mutex::new(event_loop.create_proxy()); - - #[allow(clippy::single_match)] - bus.set_sync_handler(move |_, msg| { - match msg.view() { - gst::MessageView::NeedContext(ctxt) => { - let context_type = ctxt.context_type(); - if context_type == *gst_gl::GL_DISPLAY_CONTEXT_TYPE { - if let Some(el) = - msg.src().map(|s| s.downcast_ref::().unwrap()) - { - let context = gst::Context::new(context_type, true); - context.set_gl_display(&gl_display); - el.set_context(&context); - } + current } - if context_type == "gst.gl.app_context" { - if let Some(el) = - msg.src().map(|s| s.downcast_ref::().unwrap()) - { - let mut context = gst::Context::new(context_type, true); - { - let context = context.get_mut().unwrap(); - let s = context.structure_mut(); - s.set("context", &gl_context); - } - el.set_context(&context); - } + }) + .unwrap() + }) + .expect("Failed to build display"); + println!( + "Picked a config with {} samples and transparency {}. Pixel format: {:?}", + gl_config.num_samples(), + gl_config.supports_transparency().unwrap_or(false), + gl_config.color_buffer_type() + ); + println!("Config supports GL API(s) {:?}", gl_config.api()); + + // XXX The display could be obtained from any object created by it, so we can query it from + // the config. + let gl_display = gl_config.display(); + let raw_gl_display = gl_display.raw_display(); + + println!("Using raw display connection {:?}", raw_gl_display); + + let raw_window_handle = window.as_ref().map(|window| window.raw_window_handle()); + + // The context creation part. It can be created before surface and that's how + // it's expected in multithreaded + multiwindow operation mode, since you + // can send NotCurrentContext, but not Surface. + let context_attributes = + glutin::context::ContextAttributesBuilder::new().build(raw_window_handle); + + // Since glutin by default tries to create OpenGL core context, which may not be + // present we should try gles. + let fallback_context_attributes = glutin::context::ContextAttributesBuilder::new() + .with_context_api(glutin::context::ContextApi::Gles(None)) + .build(raw_window_handle); + + // There are also some old devices that support neither modern OpenGL nor GLES. + // To support these we can try and create a 2.1 context. + let legacy_context_attributes = glutin::context::ContextAttributesBuilder::new() + .with_context_api(glutin::context::ContextApi::OpenGl(Some( + glutin::context::Version::new(2, 1), + ))) + .build(raw_window_handle); + + let not_current_gl_context = unsafe { + gl_display + .create_context(&gl_config, &context_attributes) + .or_else(|_| { + gl_display + .create_context(&gl_config, &fallback_context_attributes) + .or_else(|_| { + gl_display.create_context(&gl_config, &legacy_context_attributes) + }) + }) + } + .context("failed to create context")?; + + let raw_gl_context = not_current_gl_context.raw_context(); + + println!("Using raw GL context {:?}", raw_gl_context); + + #[cfg(not(target_os = "linux"))] + compile_error!("This example only has Linux support"); + + let api = App::map_gl_api(gl_config.api()); + + let (raw_gl_context, gst_gl_display, platform) = match (raw_gl_display, raw_gl_context) { + #[cfg(feature = "gst-gl-egl")] + ( + glutin::display::RawDisplay::Egl(egl_display), + glutin::context::RawContext::Egl(egl_context), + ) => { + let gl_display = + unsafe { gst_gl_egl::GLDisplayEGL::with_egl_display(egl_display as usize) } + .context("Failed to create GLDisplayEGL from raw `EGLDisplay`")? + .upcast::(); + + (egl_context as usize, gl_display, gst_gl::GLPlatform::EGL) + } + #[cfg(feature = "gst-gl-x11")] + ( + glutin::display::RawDisplay::Glx(glx_display), + glutin::context::RawContext::Glx(glx_context), + ) => { + let gl_display = + unsafe { gst_gl_x11::GLDisplayX11::with_display(glx_display as usize) } + .context("Failed to create GLDisplayX11 from raw X11 `Display`")? + .upcast::(); + (glx_context as usize, gl_display, gst_gl::GLPlatform::GLX) + } + #[allow(unreachable_patterns)] + handler => anyhow::bail!("Unsupported platform: {handler:?}."), + }; + + let shared_context = unsafe { + gst_gl::GLContext::new_wrapped(&gst_gl_display, raw_gl_context, platform, api) + } + .context("Couldn't wrap GL context")?; + + let gl_context = shared_context.clone(); + let event_proxy = event_loop.create_proxy(); + + #[allow(clippy::single_match)] + bus.set_sync_handler(move |_, msg| { + match msg.view() { + gst::MessageView::NeedContext(ctxt) => { + let context_type = ctxt.context_type(); + if context_type == *gst_gl::GL_DISPLAY_CONTEXT_TYPE { + if let Some(el) = + msg.src().map(|s| s.downcast_ref::().unwrap()) + { + let context = gst::Context::new(context_type, true); + context.set_gl_display(&gst_gl_display); + el.set_context(&context); + } + } + if context_type == "gst.gl.app_context" { + if let Some(el) = + msg.src().map(|s| s.downcast_ref::().unwrap()) + { + let mut context = gst::Context::new(context_type, true); + { + let context = context.get_mut().unwrap(); + let s = context.structure_mut(); + s.set("context", &gl_context); + } + el.set_context(&context); } } - _ => (), } + _ => (), + } - if let Err(e) = event_proxy.lock().unwrap().send_event(Message::BusEvent) { - eprintln!("Failed to send BusEvent to event proxy: {e}") - } + if let Err(e) = event_proxy.send_event(Message::BusEvent) { + eprintln!("Failed to send BusEvent to event proxy: {e}") + } - gst::BusSyncReply::Pass - }); - } else { - panic!("This example only has Linux support"); - } + gst::BusSyncReply::Pass + }); Ok(App { pipeline, appsink, bus, event_loop, - windowed_context, + window, + not_current_gl_context: Some(not_current_gl_context), shared_context, }) } - fn setup(&self, event_loop: &glutin::event_loop::EventLoop) -> Result<(), Error> { + fn setup(&self, event_loop: &winit::event_loop::EventLoop) -> Result<()> { let event_proxy = event_loop.create_proxy(); self.appsink.set_callbacks( gst_app::AppSinkCallbacks::builder() @@ -510,22 +587,33 @@ impl App { .build(), ); - self.pipeline.set_state(gst::State::Playing)?; - Ok(()) } - fn map_gl_api(api: glutin::Api) -> gst_gl::GLAPI { - match api { - glutin::Api::OpenGl => gst_gl::GLAPI::OPENGL3, - glutin::Api::OpenGlEs => gst_gl::GLAPI::GLES2, - _ => gst_gl::GLAPI::empty(), - } + /// Converts from to + /// . + fn map_gl_api(api: glutin::config::Api) -> gst_gl::GLAPI { + use glutin::config::Api; + use gst_gl::GLAPI; + + let mut gst_gl_api = GLAPI::empty(); + // In gstreamer: + // GLAPI::OPENGL: Desktop OpenGL up to and including 3.1. The compatibility profile when the OpenGL version is >= 3.2 + // GLAPI::OPENGL3: Desktop OpenGL >= 3.2 core profile + // In glutin, API::OPENGL is set for every context API, except EGL where it is set based on + // EGL_RENDERABLE_TYPE containing EGL_OPENGL_BIT: + // https://registry.khronos.org/EGL/sdk/docs/man/html/eglChooseConfig.xhtml + gst_gl_api.set(GLAPI::OPENGL | GLAPI::OPENGL3, api.contains(Api::OPENGL)); + gst_gl_api.set(GLAPI::GLES1, api.contains(Api::GLES1)); + // OpenGL ES 2.x and 3.x + gst_gl_api.set(GLAPI::GLES2, api.intersects(Api::GLES2 | Api::GLES3)); + + gst_gl_api } fn create_pipeline( gl_element: Option<&gst::Element>, - ) -> Result<(gst::Pipeline, gst_app::AppSink), Error> { + ) -> Result<(gst::Pipeline, gst_app::AppSink)> { let pipeline = gst::Pipeline::default(); let src = gst::ElementFactory::make("videotestsrc").build()?; @@ -565,7 +653,7 @@ impl App { } } - fn handle_messages(bus: &gst::Bus) -> Result<(), Error> { + fn handle_messages(bus: &gst::Bus) -> Result<()> { use gst::MessageView; for msg in bus.iter() { @@ -590,77 +678,143 @@ impl App { } } -pub(crate) fn main_loop(app: App) -> Result<(), Error> { +pub(crate) fn main_loop(app: App) -> Result<()> { app.setup(&app.event_loop)?; - println!( - "Pixel format of the window's GL context {:?}", - app.windowed_context.get_pixel_format() - ); - - let gl = load(&app.windowed_context); - - let mut curr_frame: Option> = None; - let App { + pipeline, bus, event_loop, - pipeline, + mut window, + mut not_current_gl_context, shared_context, - windowed_context, .. } = app; - event_loop.run(move |event, _, cf| { - *cf = glutin::event_loop::ControlFlow::Wait; + let mut curr_frame: Option> = None; + + let mut running_state = None::<( + Gl, + glutin::context::PossiblyCurrentContext, + glutin::surface::Surface, + )>; + + Ok(event_loop.run(move |event, window_target| { + window_target.set_control_flow(winit::event_loop::ControlFlow::Wait); let mut needs_redraw = false; match event { - glutin::event::Event::LoopDestroyed => { + winit::event::Event::LoopExiting => { pipeline.send_event(gst::event::Eos::new()); pipeline.set_state(gst::State::Null).unwrap(); } - glutin::event::Event::WindowEvent { event, .. } => match event { - glutin::event::WindowEvent::CloseRequested - | glutin::event::WindowEvent::KeyboardInput { - input: - glutin::event::KeyboardInput { - state: glutin::event::ElementState::Released, - virtual_keycode: Some(glutin::event::VirtualKeyCode::Escape), + winit::event::Event::WindowEvent { event, .. } => match event { + winit::event::WindowEvent::CloseRequested + | winit::event::WindowEvent::KeyboardInput { + event: + winit::event::KeyEvent { + state: winit::event::ElementState::Released, + logical_key: + winit::keyboard::Key::Named(winit::keyboard::NamedKey::Escape), .. }, .. - } => *cf = glutin::event_loop::ControlFlow::Exit, - glutin::event::WindowEvent::Resized(physical_size) => { - windowed_context.resize(physical_size); - gl.resize(physical_size); + } => window_target.exit(), + winit::event::WindowEvent::Resized(size) => { + // Some platforms like EGL require resizing GL surface to update the size + // Notable platforms here are Wayland and macOS, other don't require it + // and the function is no-op, but it's wise to resize it for portability + // reasons. + if let Some((gl, gl_context, gl_surface)) = &running_state { + gl_surface.resize( + gl_context, + // XXX Ignore minimizing + NonZeroU32::new(size.width).unwrap(), + NonZeroU32::new(size.height).unwrap(), + ); + gl.resize(size); + } } + winit::event::WindowEvent::RedrawRequested => needs_redraw = true, _ => (), }, - glutin::event::Event::RedrawRequested(_) => needs_redraw = true, // Receive a frame - glutin::event::Event::UserEvent(Message::Frame(info, buffer)) => { + winit::event::Event::UserEvent(Message::Frame(info, buffer)) => { if let Ok(frame) = gst_gl::GLVideoFrame::from_buffer_readable(buffer, &info) { curr_frame = Some(frame); needs_redraw = true; } } // Handle all pending messages when we are awaken by set_sync_handler - glutin::event::Event::UserEvent(Message::BusEvent) => { + winit::event::Event::UserEvent(Message::BusEvent) => { App::handle_messages(&bus).unwrap(); } + winit::event::Event::Resumed => { + let not_current_gl_context = not_current_gl_context + .take() + .expect("There must be a NotCurrentContext prior to Event::Resumed"); + + let gl_config = not_current_gl_context.config(); + let gl_display = gl_config.display(); + + let window = window.get_or_insert_with(|| { + let window_builder = winit::window::WindowBuilder::new().with_transparent(true); + glutin_winit::finalize_window(window_target, window_builder, &gl_config) + .unwrap() + }); + + let attrs = window.build_surface_attributes(<_>::default()); + let gl_surface = unsafe { + gl_config + .display() + .create_window_surface(&gl_config, &attrs) + .unwrap() + }; + + // Make it current. + let gl_context = not_current_gl_context.make_current(&gl_surface).unwrap(); + + // Tell GStreamer that the context has been made current (for borrowed contexts, + // this does not try to make it current again) + shared_context.activate(true).unwrap(); + + shared_context + .fill_info() + .expect("Couldn't fill context info"); + + // The context needs to be current for the Renderer to set up shaders and buffers. + // It also performs function loading, which needs a current context on WGL. + let gl = load(&gl_display); + + // Try setting vsync. + if let Err(res) = gl_surface.set_swap_interval( + &gl_context, + glutin::surface::SwapInterval::Wait(std::num::NonZeroU32::new(1).unwrap()), + ) { + eprintln!("Error setting vsync: {res:?}"); + } + + pipeline.set_state(gst::State::Playing).unwrap(); + + assert!(running_state + .replace((gl, gl_context, gl_surface)) + .is_none()); + } _ => (), } if needs_redraw { - if let Some(frame) = curr_frame.as_ref() { - let sync_meta = frame.buffer().meta::().unwrap(); - sync_meta.wait(&shared_context); - if let Ok(texture) = frame.texture_id(0) { - gl.draw_frame(texture as gl::types::GLuint); + if let Some((gl, gl_context, gl_surface)) = &running_state { + if let Some(frame) = curr_frame.as_ref() { + let sync_meta = frame.buffer().meta::().unwrap(); + sync_meta.wait(&shared_context); + if let Ok(texture) = frame.texture_id(0) { + gl.draw_frame(texture as gl::types::GLuint); + } } + + gl_surface.swap_buffers(gl_context).unwrap(); } - windowed_context.swap_buffers().unwrap(); } - }) + })?) }