3 * - By John Hodge (thePowersGang)
9 #include <CCompositor.hpp>
14 CCompositor::CCompositor(CVideo& video):
20 CWindow* CCompositor::CreateWindow(CClient& client, const ::std::string& name)
22 return new CWindow(*this, client, name);
25 bool CCompositor::GetScreenDims(unsigned int ScreenID, unsigned int* W, unsigned int* H)
36 m_video.GetDims(*W, *H);
41 void CCompositor::Redraw()
43 // Redraw the screen and clear damage rects
44 if( m_damageRects.empty() )
47 // Build up foreground grid (Rects and windows)
48 // - This should already be built (mutated on window move/resize/reorder)
50 // For all windows, check for intersection with damage rects
51 for( auto rect : m_damageRects )
53 // window list should be sorted by draw order (lowest first)
54 for( auto window : m_windows )
56 if( rect.HasIntersection( window->m_surface.m_rect ) )
59 CRect rel_rect = window->m_surface.m_rect.RelativeIntersection(rect);
60 BlitFromSurface( window->m_surface, rel_rect );
61 //window->Repaint( rel_rect );
65 // TODO: Blit from windows to a local surface, then blit from there to screen here
68 m_damageRects.clear();
72 void CCompositor::DamageArea(const CRect& area)
74 m_damageRects.push_back( area );
75 // 1. Locate intersection with any existing damaged areas
76 // 2. Append after removing intersections
79 void CCompositor::BlitFromSurface(const CSurface& dest, const CRect& src_rect)
81 for( unsigned int i = 0; i < src_rect.m_h; i ++ )
84 dest.GetScanline(src_rect.m_y, src_rect.m_y),
85 dest.m_rect.m_y + src_rect.m_y + i,
86 dest.m_rect.m_x + src_rect.m_x,