X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FApplications%2Faxwin4_src%2FServer%2FCSurface.cpp;h=d0eddc428ef3101a7abb5bd54746c2808619e7a4;hb=98bd9c0c8985c50c42231c116a4e18fedd47761e;hp=91bbb9ae6dcb2bc8ab701002f0f55d79ef19e282;hpb=5f8480455a9e2172b15dfc7fb96480a68506c30d;p=tpg%2Facess2.git diff --git a/Usermode/Applications/axwin4_src/Server/CSurface.cpp b/Usermode/Applications/axwin4_src/Server/CSurface.cpp index 91bbb9ae..d0eddc42 100644 --- a/Usermode/Applications/axwin4_src/Server/CSurface.cpp +++ b/Usermode/Applications/axwin4_src/Server/CSurface.cpp @@ -11,6 +11,7 @@ #include #include #include +#include namespace AxWin { @@ -92,6 +93,40 @@ void CSurface::DrawScanline(unsigned int row, unsigned int x_ofs, unsigned int w ::memcpy( &m_data[ofs], data, w*4 ); } +void CSurface::BlendScanline(unsigned int row, unsigned int x_ofs, unsigned int w, const void* 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"); + + const uint32_t* in_data = (const uint32_t*)data; + size_t ofs = row*m_rect.m_w + x_ofs; + for( unsigned int x = 0; x < w; x ++ ) + { + CColour out = CColour::from_argb(m_data[ofs+x]).blend( CColour::from_argb(in_data[x]) ); + m_data[ofs+x] = out.to_argb(); + } +} + +void CSurface::FillScanline(unsigned int row, unsigned int x_ofs, unsigned int w, uint32_t colour) +{ + if( row >= m_rect.m_h ) + throw ::std::out_of_range("CSurface::FillScanline row"); + if( x_ofs >= m_rect.m_w ) + throw ::std::out_of_range("CSurface::FillScanline x_ofs"); + + if( w > m_rect.m_w ) + throw ::std::out_of_range("CSurface::FillScanline width"); + + size_t ofs = row*m_rect.m_w + x_ofs; + while( w -- ) + m_data[ofs++] = colour; +} + const uint32_t* CSurface::GetScanline(unsigned int row, unsigned int x_ofs) const { if( row >= m_rect.m_h )