Usermode/AxWin4 - Server implemenation moving along
[tpg/acess2.git] / Usermode / Applications / axwin4_src / Server / compositor.cpp
index db943c5..4052145 100644 (file)
@@ -5,28 +5,37 @@
  * compositor.cpp
  * - Window compositor
  */
-#include <CVideo.hpp>
+#include <video.hpp>
 #include <CCompositor.hpp>
+#include <cassert>
 
 namespace AxWin {
 
-CCompositor*   CCompositor::s_instance;
-
-void CCompositor::Initialise(const CConfigCompositor& config)
+CCompositor::CCompositor(CVideo& video):
+       m_video(video)
 {
-       assert(!CCompositor::s_instance);
-       CCompositor::s_instance = new CCompositor(config);
+       // 
 }
 
-CCompositor::CCompositor(const CConfigCompositor& config):
-       m_config(config)
+CWindow* CCompositor::CreateWindow(CClient& client, const ::std::string& name)
 {
-       // 
+       return new CWindow(*this, client, name);
 }
 
-IWindow* CCompositor::CreateWindow(CClient& client)
+bool CCompositor::GetScreenDims(unsigned int ScreenID, unsigned int* W, unsigned int* H)
 {
-       return new CWindow(client);
+       assert(W && H);
+       if( ScreenID != 0 )
+       {
+               *W = 0;
+               *H = 0;
+               return false;
+       }
+       else
+       {
+               m_video.GetDims(*W, *H);
+               return true;
+       }
 }
 
 void CCompositor::Redraw()
@@ -35,12 +44,49 @@ void CCompositor::Redraw()
        if( m_damageRects.empty() )
                return ;
        
-       // For all windows, check for intersection with damage rect
+       // 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();
 }
 
-void CCompositor::DamageArea(const Rect& area)
+void CCompositor::DamageArea(const CRect& area)
 {
+       m_damageRects.push_back( area );
+       // 1. Locate intersection with any existing damaged areas
+       // 2. Append after removing intersections
+}
 
+void CCompositor::BlitFromSurface(const CSurface& dest, const CRect& src_rect)
+{
+       for( unsigned int i = 0; i < src_rect.m_h; i ++ )
+       {
+               m_video.BlitLine(
+                       dest.GetScanline(src_rect.m_y, src_rect.m_y),
+                       dest.m_rect.m_y + src_rect.m_y + i,
+                       dest.m_rect.m_x + src_rect.m_x,
+                       src_rect.m_w
+                       );
+       }
 }
 
 }      // namespace AxWin

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