Usermode/axwin4 - Continuing
[tpg/acess2.git] / Usermode / Applications / axwin4_src / Server / compositor.cpp
1 /*
2  * Acess2 GUI v4
3  * - By John Hodge (thePowersGang)
4  *
5  * compositor.cpp
6  * - Window compositor
7  */
8 #include <video.hpp>
9 #include <compositor.hpp>
10 #include <CCompositor.hpp>
11
12 namespace AxWin {
13
14 CCompositor::CCompositor(CVideo& video):
15         m_video(video)
16 {
17         // 
18 }
19
20 CWindow* CCompositor::CreateWindow(CClient& client)
21 {
22         return new CWindow(client, "TODO");
23 }
24
25 void CCompositor::Redraw()
26 {
27         // Redraw the screen and clear damage rects
28         if( m_damageRects.empty() )
29                 return ;
30         
31         // Build up foreground grid (Rects and windows)
32         // - This should already be built (mutated on window move/resize/reorder)
33         
34         // For all windows, check for intersection with damage rects
35         for( auto rect : m_damageRects )
36         {
37                 // window list should be sorted by draw order (lowest first)
38                 for( auto window : m_windows )
39                 {
40                         if( rect.HasIntersection( window->m_surface.m_rect ) )
41                         {
42                                 // TODO: just reblit
43                                 CRect   rel_rect = window->m_surface.m_rect.RelativeIntersection(rect);
44                                 BlitFromSurface( window->m_surface, rel_rect );
45                                 //window->Repaint( rel_rect );
46                         }
47                 }
48                 
49                 // TODO: Blit from windows to a local surface, then blit from there to screen here
50         }
51
52         m_damageRects.clear();
53 }
54
55 void CCompositor::DamageArea(const CRect& area)
56 {
57         m_damageRects.push_back( area );
58         // 1. Locate intersection with any existing damaged areas
59         // 2. Append after removing intersections
60 }
61
62 void CCompositor::BlitFromSurface(const CSurface& dest, const CRect& src_rect)
63 {
64         for( unsigned int i = 0; i < src_rect.m_h; i ++ )
65         {
66                 m_video.BlitLine(
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,
70                         src_rect.m_w
71                         );
72         }
73 }
74
75 }       // namespace AxWin
76

UCC git Repository :: git.ucc.asn.au