+ // Build up foreground grid (Rects and windows)
+ // - This should already be built (mutated on window move/resize/reorder)
+
+ // For all windows, check for intersection with damage rects
+ for( auto rect : m_damageRects )
+ {
+ // window list should be sorted by draw order (lowest first)
+ for( auto window : m_windows )
+ {
+ if( rect.HasIntersection( window->m_surface.m_rect ) )
+ {
+ // TODO: just reblit
+ CRect rel_rect = window->m_surface.m_rect.RelativeIntersection(rect);
+ BlitFromSurface( window->m_surface, rel_rect );
+ //window->Repaint( rel_rect );
+ }
+ }
+
+ // TODO: Blit from windows to a local surface, then blit from there to screen here
+ }
+
+ m_damageRects.clear();
+ m_video.Flush();