build(client): update softbuffer dependency (#187)

This commit is contained in:
Benoît Cortier 2023-08-29 11:28:36 -04:00 committed by GitHub
parent aeec4c0a67
commit d466861a89
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 110 additions and 59 deletions

57
Cargo.lock generated
View file

@ -179,6 +179,12 @@ version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"
[[package]]
name = "as-raw-xcb-connection"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d5f312b0a56c5cdf967c0aeb67f6289603354951683bc97ddc595ab974ba9aa"
[[package]]
name = "asn1-rs"
version = "0.5.2"
@ -950,7 +956,7 @@ version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412"
dependencies = [
"libloading 0.8.0",
"libloading",
]
[[package]]
@ -1303,9 +1309,9 @@ dependencies = [
[[package]]
name = "gethostname"
version = "0.2.3"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1ebd34e35c46e00bb73e81363248d627782724609fe1b6396f553f68fe3862e"
checksum = "bb65d4ba3173c56a500b555b532f72c42e8d1fe64962b518897f8959fae2c177"
dependencies = [
"libc",
"winapi",
@ -2097,16 +2103,6 @@ dependencies = [
"winapi",
]
[[package]]
name = "libloading"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d580318f95776505201b28cf98eb1fa5e4be3b689633ba6a3e6cd880ff22d8cb"
dependencies = [
"cfg-if 1.0.0",
"windows-sys 0.48.0",
]
[[package]]
name = "libm"
version = "0.2.7"
@ -2249,6 +2245,15 @@ dependencies = [
"libc",
]
[[package]]
name = "memmap2"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d28bba84adfe6646737845bc5ebbfa2c08424eb1c37e94a1fd2a82adb56a872"
dependencies = [
"libc",
]
[[package]]
name = "memoffset"
version = "0.6.5"
@ -3583,7 +3588,7 @@ checksum = "cda4e97be1fd174ccc2aae81c8b694e803fa99b34e8fd0f057a9d70698e3ed09"
dependencies = [
"ab_glyph",
"log",
"memmap2",
"memmap2 0.5.10",
"smithay-client-toolkit",
"tiny-skia",
]
@ -3829,7 +3834,7 @@ dependencies = [
"dlib",
"lazy_static",
"log",
"memmap2",
"memmap2 0.5.10",
"nix 0.24.3",
"pkg-config",
"wayland-client 0.29.5",
@ -3859,9 +3864,9 @@ dependencies = [
[[package]]
name = "softbuffer"
version = "0.2.1"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2b953f6ba7285f0af131eb748aabd8ddaf53e0b81dda3ba5d803b0847d6559f"
checksum = "7cc7e34c6782f6fe16e384f25d009ed7b30f70e022d77966769a0366232c4dc4"
dependencies = [
"bytemuck",
"cfg_aliases",
@ -3869,12 +3874,13 @@ dependencies = [
"core-graphics",
"fastrand 1.9.0",
"foreign-types",
"js-sys",
"log",
"memmap2 0.6.2",
"nix 0.26.2",
"objc",
"raw-window-handle",
"redox_syscall",
"thiserror",
"wasm-bindgen",
"wayland-backend",
"wayland-client 0.30.2",
@ -5077,14 +5083,15 @@ dependencies = [
[[package]]
name = "x11rb"
version = "0.11.1"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdf3c79412dd91bae7a7366b8ad1565a85e35dd049affc3a6a2c549e97419617"
checksum = "b1641b26d4dec61337c35a1b1aaf9e3cba8f46f0b43636c609ab0291a648040a"
dependencies = [
"as-raw-xcb-connection",
"gethostname",
"libc",
"libloading 0.7.4",
"nix 0.25.1",
"libloading",
"nix 0.26.2",
"once_cell",
"winapi",
"winapi-wsapoll",
@ -5093,11 +5100,11 @@ dependencies = [
[[package]]
name = "x11rb-protocol"
version = "0.11.1"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0b1513b141123073ce54d5bb1d33f801f17508fbd61e02060b1214e96d39c56"
checksum = "82d6c3f9a0fb6701fab8f6cea9b0c0bd5d6876f1f89f7fada07e558077c344bc"
dependencies = [
"nix 0.25.1",
"nix 0.26.2",
]
[[package]]

View file

@ -34,25 +34,25 @@ ironrdp-tokio.workspace = true
sspi = { workspace = true, features = ["network_client", "dns_resolver"] } # enable additional features
# GUI
softbuffer = "0.2.0"
winit = "0.28.3"
softbuffer = "0.3"
winit = "0.28"
# CLI
clap = { version = "4.2", features = ["derive", "cargo"] }
exitcode = "1.1.2"
inquire = "0.6.0"
exitcode = "1.1"
inquire = "0.6"
# Logging
tracing.workspace = true
tracing-subscriber = { version = "0.3.16", features = ["env-filter"] }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
# Async, futures
tokio = { version = "1", features = ["full"]}
# Utils
chrono = "0.4.24"
whoami = "1.4.0"
anyhow = "1.0.70"
smallvec = "1.10.0"
tap = "1.0.1"
chrono = "0.4"
whoami = "1.4"
anyhow = "1.0"
smallvec = "1.10"
tap = "1"
semver = "1"

View file

@ -1,5 +1,6 @@
use std::num::NonZeroU32;
use anyhow::Context as _;
use softbuffer::GraphicsContext;
use tokio::sync::mpsc;
use winit::dpi::LogicalPosition;
use winit::event::{self, Event, WindowEvent};
@ -11,7 +12,7 @@ use crate::rdp::{RdpInputEvent, RdpOutputEvent};
pub struct GuiContext {
pub window: Window,
pub event_loop: EventLoop<RdpOutputEvent>,
pub graphics_context: GraphicsContext,
pub context: softbuffer::Context,
}
impl GuiContext {
@ -21,15 +22,15 @@ impl GuiContext {
let window = WindowBuilder::new()
.with_title("IronRDP")
.build(&event_loop)
.context("Unable to create winit Window")?;
.context("unable to create winit Window")?;
let graphics_context = unsafe { GraphicsContext::new(&window, &window) }
.map_err(|e| anyhow::Error::msg(format!("Unable to initialize graphics context: {e}")))?;
let context = unsafe { softbuffer::Context::new(&window) }
.map_err(|e| anyhow::Error::msg(format!("unable to initialize softbuffer context: {e}")))?;
Ok(Self {
window,
event_loop,
graphics_context,
context,
})
}
@ -37,27 +38,16 @@ impl GuiContext {
let Self {
window,
event_loop,
mut graphics_context,
context,
} = self;
let (mut image_width, mut image_height) = {
let window_size = window.inner_size();
(
u16::try_from(window_size.width).unwrap(),
u16::try_from(window_size.height).unwrap(),
)
};
let mut image_buffer = vec![0; usize::from(image_width) * usize::from(image_height)];
let mut surface = unsafe { softbuffer::Surface::new(&context, &window) }.expect("surface");
let mut input_database = ironrdp::input::Database::new();
event_loop.run(move |event, _, control_flow| {
*control_flow = ControlFlow::Wait;
let image_width = &mut image_width;
let image_height = &mut image_height;
let image_buffer = &mut image_buffer;
match event {
Event::WindowEvent { window_id, event } if window_id == window.id() => match event {
WindowEvent::Resized(size) => {
@ -199,14 +189,19 @@ impl GuiContext {
_ => {}
},
Event::RedrawRequested(window_id) if window_id == window.id() => {
graphics_context.set_buffer(image_buffer, *image_width, *image_height);
// TODO: is there something we should handle here?
}
Event::UserEvent(RdpOutputEvent::Image { buffer, width, height }) => {
*image_buffer = buffer;
*image_width = width;
*image_height = height;
surface
.resize(
NonZeroU32::new(u32::from(width)).unwrap(),
NonZeroU32::new(u32::from(height)).unwrap(),
)
.expect("surface resize");
graphics_context.set_buffer(image_buffer, width, height);
let mut sb_buffer = surface.buffer_mut().expect("surface buffer");
sb_buffer.copy_from_slice(buffer.as_slice());
sb_buffer.present().expect("buffer present");
}
Event::UserEvent(RdpOutputEvent::ConnectionFailure(error)) => {
error!(?error);

49
fuzz/Cargo.lock generated
View file

@ -237,6 +237,9 @@ version = "0.1.0"
dependencies = [
"bitflags",
"ironrdp-pdu",
"ironrdp-svc",
"thiserror",
"tracing",
]
[[package]]
@ -298,6 +301,14 @@ dependencies = [
"x509-cert",
]
[[package]]
name = "ironrdp-svc"
version = "0.1.0"
dependencies = [
"bitflags",
"ironrdp-pdu",
]
[[package]]
name = "jobserver"
version = "0.1.26"
@ -408,6 +419,12 @@ version = "1.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
[[package]]
name = "pin-project-lite"
version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58"
[[package]]
name = "pkcs1"
version = "0.7.5"
@ -556,6 +573,38 @@ dependencies = [
"syn 2.0.25",
]
[[package]]
name = "tracing"
version = "0.1.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
dependencies = [
"cfg-if",
"pin-project-lite",
"tracing-attributes",
"tracing-core",
]
[[package]]
name = "tracing-attributes"
version = "0.1.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.25",
]
[[package]]
name = "tracing-core"
version = "0.1.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a"
dependencies = [
"once_cell",
]
[[package]]
name = "typenum"
version = "1.16.0"