X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FApplications%2Faxwin4_src%2FServer%2Fcompositor.cpp;h=7a18747aa14af6f931209a078fedc8926e19eb2d;hb=4d0188930e7d0e571db78d1d2e3c4d9b3f0fe8fb;hp=db943c5747701e7852adcec47b3a6fb146bb179b;hpb=12b7fdacb831478b4fdc648f6a146c9d2285b9d6;p=tpg%2Facess2.git diff --git a/Usermode/Applications/axwin4_src/Server/compositor.cpp b/Usermode/Applications/axwin4_src/Server/compositor.cpp index db943c57..7a18747a 100644 --- a/Usermode/Applications/axwin4_src/Server/compositor.cpp +++ b/Usermode/Applications/axwin4_src/Server/compositor.cpp @@ -5,42 +5,122 @@ * compositor.cpp * - Window compositor */ -#include +#include #include +#include namespace AxWin { -CCompositor* CCompositor::s_instance; +CCompositor::CCompositor(CVideo& video): + m_video(video) +{ + // +} -void CCompositor::Initialise(const CConfigCompositor& config) +CWindow* CCompositor::CreateWindow(CClient& client, const ::std::string& name) { - assert(!CCompositor::s_instance); - CCompositor::s_instance = new CCompositor(config); + return new CWindow(*this, client, name); } -CCompositor::CCompositor(const CConfigCompositor& config): - m_config(config) +void CCompositor::ShowWindow(CWindow* window) { - // + DamageArea(window->m_surface.m_rect); + // TODO: Append to separate sub-lists (or to separate lists all together) + // if flags AXWIN4_WNDFLAG_KEEPBELOW or AXWIN4_WNDFLAG_KEEPABOVE are set + m_windows.push_back(window); +} +void CCompositor::HideWindow(CWindow* window) +{ + DamageArea(window->m_surface.m_rect); + m_windows.remove(window); } -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() { // Redraw the screen and clear damage rects - if( m_damageRects.empty() ) + if( m_damageRects.empty() ) { + _SysDebug("- No damaged regions"); return ; + } + + // 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 rect + // 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( window->m_is_shown && rect.HasIntersection( window->m_surface.m_rect ) ) + { + // TODO: just reblit + CRect rel_rect = window->m_surface.m_rect.RelativeIntersection(rect); + _SysDebug("Reblit (%i,%i) %ix%i", rel_rect.m_x, rel_rect.m_y, rel_rect.m_w, rel_rect.m_h); + 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+i, src_rect.m_x), + dest.m_rect.m_y + src_rect.m_y + i, + dest.m_rect.m_x + src_rect.m_x, + src_rect.m_w + ); + } +} + +void CCompositor::MouseMove(unsigned int Cursor, unsigned int X, unsigned int Y, int dX, int dY) +{ + _SysDebug("MouseButton(%i, %i,%i, %+i,%+i)", Cursor, X, Y, dX, dY); + m_video.SetCursorPos(X+dX, Y+dY); + // TODO: Pass event on to window +} + +void CCompositor::MouseButton(unsigned int Cursor, unsigned int X, unsigned int Y, eMouseButton Button, bool Press) +{ + _SysDebug("MouseButton(%i, %i,%i, %i=%i)", Cursor, X, Y, Button, Press); + // TODO: Pass event on to window +} + +void CCompositor::KeyState(unsigned int KeyboardID, uint32_t KeySym, bool Press, uint32_t Codepoint) +{ + _SysDebug("KeyState(%i, 0x%x, %b, 0x%x)", KeyboardID, KeySym, Press, Codepoint); } } // namespace AxWin