usermode/axwin4 - Blit to screen planned
[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                 for( auto window : m_windows )
38                 {
39                         if( rect.HasIntersection( window->m_surface.m_rect ) )
40                         {
41                                 // TODO: just reblit
42                                 CRect   rel_rect = window->m_surface.m_rect.RelativeIntersection(rect);
43                                 BlitFromSurface( window->m_surface, rel_rect );
44                                 //window->Repaint( rel_rect );
45                         }
46                 }
47         }
48
49         m_damageRects.clear();
50 }
51
52 void CCompositor::DamageArea(const CRect& area)
53 {
54         // 1. Locate intersection with any existing damaged areas
55         // 2. Append after removing intersections
56 }
57
58 void CCompositor::BlitFromSurface(const CSurface& dest, const CRect& src_rect)
59 {
60         for( unsigned int i = 0; i < src_rect.m_h; i ++ )
61         {
62                 m_video.BlitLine(
63                         dest.GetScanline(src_rect.m_y, src_rect.m_y),
64                         dest.m_rect.m_y + src_rect.m_y + i,
65                         dest.m_rect.m_x + src_rect.m_x,
66                         src_rect.m_w
67                         );
68         }
69 }
70
71 }       // namespace AxWin
72

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