Skip to content

Commit 1e87961

Browse files
elmarcoCBenoit
authored andcommitted
feat(server): add Framebuffer helper struct
This will hold the updated bitmap data for the whole framebuffer. Signed-off-by: Marc-André Lureau <[email protected]>
1 parent 3c43fdd commit 1e87961

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

crates/ironrdp-server/src/display.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use core::num::NonZeroU16;
22

33
use anyhow::Result;
4-
use bytes::Bytes;
4+
use bytes::{Bytes, BytesMut};
55
use ironrdp_displaycontrol::pdu::DisplayControlMonitorLayout;
66
use ironrdp_pdu::pointer::PointerPositionAttribute;
77

@@ -56,6 +56,30 @@ pub struct ColorPointer {
5656
pub xor_mask: Vec<u8>,
5757
}
5858

59+
pub struct Framebuffer {
60+
pub width: NonZeroU16,
61+
pub height: NonZeroU16,
62+
pub format: PixelFormat,
63+
pub data: BytesMut,
64+
pub stride: usize,
65+
}
66+
67+
impl TryInto<Framebuffer> for BitmapUpdate {
68+
type Error = &'static str;
69+
70+
fn try_into(self) -> Result<Framebuffer, Self::Error> {
71+
assert_eq!(self.top, 0);
72+
assert_eq!(self.left, 0);
73+
Ok(Framebuffer {
74+
width: self.width,
75+
height: self.height,
76+
format: self.format,
77+
data: self.data.try_into_mut().map_err(|_| "BitmapUpdate is shared")?,
78+
stride: self.stride,
79+
})
80+
}
81+
}
82+
5983
/// Bitmap Display Update
6084
///
6185
/// Bitmap updates are encoded using RDP 6.0 compression, fragmented and sent using

0 commit comments

Comments
 (0)