3 * - By John Hodge (thePowersGang)
9 #include <compositor.hpp>
10 #include <CCompositor.hpp>
14 CCompositor::CCompositor(CVideo& video):
20 CWindow* CCompositor::CreateWindow(CClient& client)
22 return new CWindow(client, "TODO");
25 void CCompositor::Redraw()
27 // Redraw the screen and clear damage rects
28 if( m_damageRects.empty() )
31 // Build up foreground grid (Rects and windows)
32 // - This should already be built (mutated on window move/resize/reorder)
34 // For all windows, check for intersection with damage rects
35 for( auto rect : m_damageRects )
37 // window list should be sorted by draw order (lowest first)
38 for( auto window : m_windows )
40 if( rect.HasIntersection( window->m_surface.m_rect ) )
43 CRect rel_rect = window->m_surface.m_rect.RelativeIntersection(rect);
44 BlitFromSurface( window->m_surface, rel_rect );
45 //window->Repaint( rel_rect );
49 // TODO: Blit from windows to a local surface, then blit from there to screen here
52 m_damageRects.clear();
55 void CCompositor::DamageArea(const CRect& area)
57 m_damageRects.push_back( area );
58 // 1. Locate intersection with any existing damaged areas
59 // 2. Append after removing intersections
62 void CCompositor::BlitFromSurface(const CSurface& dest, const CRect& src_rect)
64 for( unsigned int i = 0; i < src_rect.m_h; i ++ )
67 dest.GetScanline(src_rect.m_y, src_rect.m_y),
68 dest.m_rect.m_y + src_rect.m_y + i,
69 dest.m_rect.m_x + src_rect.m_x,