X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FApplications%2Faxwin4_src%2FServer%2FCSurface.cpp;fp=Usermode%2FApplications%2Faxwin4_src%2FServer%2FCSurface.cpp;h=429657a345cb7a684141ed0bbb0cfef675f30b78;hb=4696a38ba9ea5798e67ccd475c8b77f318db133d;hp=d52298cdfd4beb303c19e12f86742bf4947f99be;hpb=31bf9d6faae9630f2de1244fc4317fc91db8bc07;p=tpg%2Facess2.git diff --git a/Usermode/Applications/axwin4_src/Server/CSurface.cpp b/Usermode/Applications/axwin4_src/Server/CSurface.cpp index d52298cd..429657a3 100644 --- a/Usermode/Applications/axwin4_src/Server/CSurface.cpp +++ b/Usermode/Applications/axwin4_src/Server/CSurface.cpp @@ -7,12 +7,18 @@ */ #include #include +#include +#include namespace AxWin { CSurface::CSurface(int x, int y, unsigned int w, unsigned int h): m_rect(x,y, w,h) { + if( w > 0 && h > 0 ) + { + m_data = new uint32_t[w * h]; + } } CSurface::~CSurface() @@ -21,12 +27,36 @@ CSurface::~CSurface() void CSurface::Resize(unsigned int W, unsigned int H) { - assert(!"TODO: CSurface::Resize"); + // Easy realloc + // TODO: Should I maintain window contents sanely? NOPE! + delete m_data; + m_data = new uint32_t[W * H]; + m_rect.Resize(W, H); +} + +void CSurface::DrawScanline(unsigned int row, unsigned int x_ofs, unsigned int w, const void* data) +{ + _SysDebug("DrawScanline(%i,%i,%i,%p)", row, x_ofs, w, data); + if( row >= m_rect.m_h ) + throw ::std::out_of_range("CSurface::DrawScanline row"); + if( x_ofs >= m_rect.m_w ) + throw ::std::out_of_range("CSurface::DrawScanline x_ofs"); + + if( w > m_rect.m_w ) + throw ::std::out_of_range("CSurface::DrawScanline width"); + + _SysDebug(" memcpy(%p, %p, %i)", &m_data[row*m_rect.m_w + x_ofs], data, w*4 ); + ::memcpy( &m_data[row*m_rect.m_w + x_ofs], data, w*4 ); } const uint32_t* CSurface::GetScanline(unsigned int row, unsigned int x_ofs) const { - return 0; + if( row >= m_rect.m_h ) + throw ::std::out_of_range("CSurface::GetScanline row"); + if( x_ofs >= m_rect.m_w ) + throw ::std::out_of_range("CSurface::GetScanline x_ofs"); + + return &m_data[row * m_rect.m_w + x_ofs]; }