@@ -16,6 +16,7 @@ use crate::event::{ConfigCx, CursorIcon, EventState};
1616use crate :: geom:: { Coord , Offset , Rect , Size } ;
1717use crate :: layout:: SolveCache ;
1818use crate :: messages:: Erased ;
19+ use crate :: runner:: PresentResult ;
1920use crate :: theme:: { DrawCx , SizeCx , Theme , ThemeDraw , Window as _} ;
2021use crate :: window:: { BoxedWindow , Decorations , PopupDescriptor , WindowId , WindowWidget } ;
2122use crate :: {
@@ -674,33 +675,47 @@ impl<A: AppData, G: GraphicsInstance, T: Theme<G::Shared>> Window<A, G, T> {
674675 } else {
675676 shared. theme . clear_color ( )
676677 } ;
677- let time3 = window
678+ let result = window
678679 . surface
679680 . present ( & mut shared. draw . as_mut ( ) . unwrap ( ) . draw , clear_color) ;
680681
681- let text_dur_micros = take ( & mut window. surface . common_mut ( ) . dur_text ) ;
682- let end = Instant :: now ( ) ;
683- log:: trace!(
684- target: "kas_perf::wgpu::window" ,
685- "do_draw: {}μs ({}μs widgets, {}μs text, {}μs render, {}μs present)" ,
686- ( end - start) . as_micros( ) ,
687- ( time2 - start) . as_micros( ) ,
688- text_dur_micros. as_micros( ) ,
689- ( time3 - time2) . as_micros( ) ,
690- ( end - time2) . as_micros( )
691- ) ;
692-
693- const SECOND : Duration = Duration :: from_secs ( 1 ) ;
694- window. frame_count . 1 += 1 ;
695- if window. frame_count . 0 + SECOND <= end {
696- log:: debug!(
697- "Window {:?}: {} frames in last second" ,
698- window. window_id,
699- window. frame_count. 1
700- ) ;
701- window. frame_count . 0 = end;
702- window. frame_count . 1 = 0 ;
703- }
682+ match result {
683+ PresentResult :: Success ( time3) => {
684+ let text_dur_micros = take ( & mut window. surface . common_mut ( ) . dur_text ) ;
685+ let end = Instant :: now ( ) ;
686+ log:: trace!(
687+ target: "kas_perf::wgpu::window" ,
688+ "do_draw: {}μs ({}μs widgets, {}μs text, {}μs render, {}μs present)" ,
689+ ( end - start) . as_micros( ) ,
690+ ( time2 - start) . as_micros( ) ,
691+ text_dur_micros. as_micros( ) ,
692+ ( time3 - time2) . as_micros( ) ,
693+ ( end - time2) . as_micros( )
694+ ) ;
695+
696+ const SECOND : Duration = Duration :: from_secs ( 1 ) ;
697+ window. frame_count . 1 += 1 ;
698+ if window. frame_count . 0 + SECOND <= end {
699+ log:: debug!(
700+ "Window {:?}: {} frames in last second" ,
701+ window. window_id,
702+ window. frame_count. 1
703+ ) ;
704+ window. frame_count . 0 = end;
705+ window. frame_count . 1 = 0 ;
706+ }
707+ }
708+ PresentResult :: Dropped => ( ) ,
709+ PresentResult :: ReconfigureSurface => {
710+ let size: Size = window. surface_size ( ) . cast ( ) ;
711+ window
712+ . surface
713+ . configure ( & mut shared. draw . as_mut ( ) . unwrap ( ) . draw , size) ;
714+ }
715+ PresentResult :: Fatal => {
716+ self . ev_state . close_own_window ( ) ;
717+ }
718+ } ;
704719
705720 Ok ( ( ) )
706721 }
0 commit comments