File tree Expand file tree Collapse file tree 1 file changed +12
-9
lines changed
Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -290,6 +290,10 @@ fn draw(host: String, pwd: String) {
290290 let mut b = Vec :: < u8 > :: with_capacity ( dlen) ;
291291 let c = Vec :: < u8 > :: with_capacity ( dlen) ;
292292 let mut unzip = DefDecoder :: new ( c) ;
293+ // FPS
294+ let mut last = std:: time:: Instant :: now ( ) ;
295+ let mut fps = 0u8 ;
296+ let mut fpscount = 0u8 ;
293297 // 接收第一帧数据
294298 let mut header = [ 0u8 ; 3 ] ;
295299 if let Err ( _) = conn. read_exact ( & mut header) {
@@ -325,15 +329,7 @@ fn draw(host: String, pwd: String) {
325329 if let Ok ( mut _buf) = work_buf. write ( ) {
326330 _buf. copy_from_slice ( & a) ;
327331 }
328- tx. send ( Msg :: Draw ) ;
329- }
330- } ) ;
331- let mut last = std:: time:: Instant :: now ( ) ;
332- let mut fps = 0u8 ;
333- let mut fpscount = 0u8 ;
334- while app:: wait ( ) {
335- match rx. recv ( ) {
336- Some ( Msg :: Draw ) => {
332+ {
337333 let cur = std:: time:: Instant :: now ( ) ;
338334 let dur = cur. duration_since ( last) ;
339335 fpscount += 1 ;
@@ -345,6 +341,13 @@ fn draw(host: String, pwd: String) {
345341 fps = fpscount;
346342 fpscount = 0 ;
347343 }
344+ }
345+ tx. send ( Msg :: Draw ) ;
346+ }
347+ } ) ;
348+ while app:: wait ( ) {
349+ match rx. recv ( ) {
350+ Some ( Msg :: Draw ) => {
348351 frame. redraw ( ) ;
349352 }
350353 _ => { }
You can’t perform that action at this time.
0 commit comments