From 1e87961d1611ed31f58b407f208295c97c0d2944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Mon, 17 Mar 2025 14:07:23 +0400 Subject: [PATCH] feat(server): add Framebuffer helper struct MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will hold the updated bitmap data for the whole framebuffer. Signed-off-by: Marc-André Lureau --- crates/ironrdp-server/src/display.rs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/crates/ironrdp-server/src/display.rs b/crates/ironrdp-server/src/display.rs index 5f0912f3..22d502a6 100644 --- a/crates/ironrdp-server/src/display.rs +++ b/crates/ironrdp-server/src/display.rs @@ -1,7 +1,7 @@ use core::num::NonZeroU16; use anyhow::Result; -use bytes::Bytes; +use bytes::{Bytes, BytesMut}; use ironrdp_displaycontrol::pdu::DisplayControlMonitorLayout; use ironrdp_pdu::pointer::PointerPositionAttribute; @@ -56,6 +56,30 @@ pub struct ColorPointer { pub xor_mask: Vec, } +pub struct Framebuffer { + pub width: NonZeroU16, + pub height: NonZeroU16, + pub format: PixelFormat, + pub data: BytesMut, + pub stride: usize, +} + +impl TryInto for BitmapUpdate { + type Error = &'static str; + + fn try_into(self) -> Result { + assert_eq!(self.top, 0); + assert_eq!(self.left, 0); + Ok(Framebuffer { + width: self.width, + height: self.height, + format: self.format, + data: self.data.try_into_mut().map_err(|_| "BitmapUpdate is shared")?, + stride: self.stride, + }) + } +} + /// Bitmap Display Update /// /// Bitmap updates are encoded using RDP 6.0 compression, fragmented and sent using