3 * - By John Hodge (thePowersGang)
8 #include <CSurface.hpp>
15 CSurface::CSurface(int x, int y, unsigned int w, unsigned int h):
20 m_data = new uint32_t[w * h];
28 void CSurface::Resize(unsigned int W, unsigned int H)
31 // TODO: Should I maintain window contents sanely? NOPE!
33 m_data = new uint32_t[W * H];
37 void CSurface::DrawScanline(unsigned int row, unsigned int x_ofs, unsigned int w, const void* data)
39 _SysDebug("DrawScanline(%i,%i,%i,%p)", row, x_ofs, w, data);
40 if( row >= m_rect.m_h )
41 throw ::std::out_of_range("CSurface::DrawScanline row");
42 if( x_ofs >= m_rect.m_w )
43 throw ::std::out_of_range("CSurface::DrawScanline x_ofs");
46 throw ::std::out_of_range("CSurface::DrawScanline width");
48 _SysDebug(" memcpy(%p, %p, %i)", &m_data[row*m_rect.m_w + x_ofs], data, w*4 );
49 ::memcpy( &m_data[row*m_rect.m_w + x_ofs], data, w*4 );
52 const uint32_t* CSurface::GetScanline(unsigned int row, unsigned int x_ofs) const
54 if( row >= m_rect.m_h )
55 throw ::std::out_of_range("CSurface::GetScanline row");
56 if( x_ofs >= m_rect.m_w )
57 throw ::std::out_of_range("CSurface::GetScanline x_ofs");
59 return &m_data[row * m_rect.m_w + x_ofs];