@@ -4,6 +4,7 @@ pub(crate) mod rfx;
4
4
use core:: { cmp, fmt} ;
5
5
6
6
use anyhow:: { Context , Result } ;
7
+ use ironrdp_acceptor:: DesktopSize ;
7
8
use ironrdp_core:: { Encode , WriteCursor } ;
8
9
use ironrdp_pdu:: fast_path:: { EncryptionFlags , FastPathHeader , FastPathUpdatePdu , Fragmentation , UpdateCode } ;
9
10
use ironrdp_pdu:: geometry:: ExclusiveRectangle ;
@@ -14,7 +15,7 @@ use ironrdp_pdu::surface_commands::{ExtendedBitmapDataPdu, SurfaceBitsPdu, Surfa
14
15
use self :: bitmap:: BitmapEncoder ;
15
16
use self :: rfx:: RfxEncoder ;
16
17
use super :: BitmapUpdate ;
17
- use crate :: { ColorPointer , RGBAPointer } ;
18
+ use crate :: { ColorPointer , Framebuffer , RGBAPointer } ;
18
19
19
20
#[ derive( Debug , Copy , Clone , PartialEq , Eq ) ]
20
21
#[ repr( u8 ) ]
@@ -28,6 +29,9 @@ const MAX_FASTPATH_UPDATE_SIZE: usize = 16_374;
28
29
const FASTPATH_HEADER_SIZE : usize = 6 ;
29
30
30
31
pub ( crate ) struct UpdateEncoder {
32
+ desktop_size : DesktopSize ,
33
+ // FIXME: draw updates on the framebuffer
34
+ framebuffer : Option < Framebuffer > ,
31
35
pdu_encoder : PduEncoder ,
32
36
bitmap_updater : BitmapUpdater ,
33
37
}
@@ -41,7 +45,7 @@ impl fmt::Debug for UpdateEncoder {
41
45
}
42
46
43
47
impl 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 {
45
49
let pdu_encoder = PduEncoder :: new ( ) ;
46
50
let bitmap_updater = if !surface_flags. contains ( CmdFlags :: SET_SURFACE_BITS ) {
47
51
BitmapUpdater :: Bitmap ( BitmapHandler :: new ( ) )
@@ -53,11 +57,17 @@ impl UpdateEncoder {
53
57
} ;
54
58
55
59
Self {
60
+ desktop_size,
61
+ framebuffer : None ,
56
62
pdu_encoder,
57
63
bitmap_updater,
58
64
}
59
65
}
60
66
67
+ pub ( crate ) fn set_desktop_size ( & mut self , size : DesktopSize ) {
68
+ self . desktop_size = size;
69
+ }
70
+
61
71
pub ( crate ) fn rgba_pointer ( & mut self , ptr : RGBAPointer ) -> Result < UpdateFragmenter < ' _ > > {
62
72
let xor_mask = ptr. data ;
63
73
@@ -114,7 +124,18 @@ impl UpdateEncoder {
114
124
}
115
125
116
126
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
118
139
}
119
140
120
141
pub ( crate ) fn fragmenter_from_owned ( & self , res : UpdateFragmenterOwned ) -> UpdateFragmenter < ' _ > {
0 commit comments