@@ -4,6 +4,7 @@ pub(crate) mod rfx;
44use core:: { cmp, fmt} ;
55
66use anyhow:: { Context , Result } ;
7+ use ironrdp_acceptor:: DesktopSize ;
78use ironrdp_core:: { Encode , WriteCursor } ;
89use ironrdp_pdu:: fast_path:: { EncryptionFlags , FastPathHeader , FastPathUpdatePdu , Fragmentation , UpdateCode } ;
910use ironrdp_pdu:: geometry:: ExclusiveRectangle ;
@@ -14,7 +15,7 @@ use ironrdp_pdu::surface_commands::{ExtendedBitmapDataPdu, SurfaceBitsPdu, Surfa
1415use self :: bitmap:: BitmapEncoder ;
1516use self :: rfx:: RfxEncoder ;
1617use super :: BitmapUpdate ;
17- use crate :: { ColorPointer , RGBAPointer } ;
18+ use crate :: { ColorPointer , Framebuffer , RGBAPointer } ;
1819
1920#[ derive( Debug , Copy , Clone , PartialEq , Eq ) ]
2021#[ repr( u8 ) ]
@@ -28,6 +29,9 @@ const MAX_FASTPATH_UPDATE_SIZE: usize = 16_374;
2829const FASTPATH_HEADER_SIZE : usize = 6 ;
2930
3031pub ( crate ) struct UpdateEncoder {
32+ desktop_size : DesktopSize ,
33+ // FIXME: draw updates on the framebuffer
34+ framebuffer : Option < Framebuffer > ,
3135 pdu_encoder : PduEncoder ,
3236 bitmap_updater : BitmapUpdater ,
3337}
@@ -41,7 +45,7 @@ impl fmt::Debug for UpdateEncoder {
4145}
4246
4347impl UpdateEncoder {
44- pub ( crate ) fn new ( surface_flags : CmdFlags , remotefx : Option < ( EntropyBits , u8 ) > ) -> Self {
48+ pub ( crate ) fn new ( desktop_size : DesktopSize , surface_flags : CmdFlags , remotefx : Option < ( EntropyBits , u8 ) > ) -> Self {
4549 let pdu_encoder = PduEncoder :: new ( ) ;
4650 let bitmap_updater = if !surface_flags. contains ( CmdFlags :: SET_SURFACE_BITS ) {
4751 BitmapUpdater :: Bitmap ( BitmapHandler :: new ( ) )
@@ -53,11 +57,17 @@ impl UpdateEncoder {
5357 } ;
5458
5559 Self {
60+ desktop_size,
61+ framebuffer : None ,
5662 pdu_encoder,
5763 bitmap_updater,
5864 }
5965 }
6066
67+ pub ( crate ) fn set_desktop_size ( & mut self , size : DesktopSize ) {
68+ self . desktop_size = size;
69+ }
70+
6171 pub ( crate ) fn rgba_pointer ( & mut self , ptr : RGBAPointer ) -> Result < UpdateFragmenter < ' _ > > {
6272 let xor_mask = ptr. data ;
6373
@@ -114,7 +124,18 @@ impl UpdateEncoder {
114124 }
115125
116126 pub ( crate ) fn bitmap ( & mut self , bitmap : BitmapUpdate ) -> Result < UpdateFragmenter < ' _ > > {
117- self . bitmap_updater . handle ( & bitmap, & mut self . pdu_encoder )
127+ let res = self . bitmap_updater . handle ( & bitmap, & mut self . pdu_encoder ) ;
128+ if bitmap. x == 0
129+ && bitmap. y == 0
130+ && bitmap. width . get ( ) == self . desktop_size . width
131+ && bitmap. height . get ( ) == self . desktop_size . height
132+ {
133+ match bitmap. try_into ( ) {
134+ Ok ( framebuffer) => self . framebuffer = Some ( framebuffer) ,
135+ Err ( err) => warn ! ( "Failed to convert bitmap to framebuffer: {}" , err) ,
136+ }
137+ }
138+ res
118139 }
119140
120141 pub ( crate ) fn fragmenter_from_owned ( & self , res : UpdateFragmenterOwned ) -> UpdateFragmenter < ' _ > {
0 commit comments