public override void BlitFromMemory( PixelBox src, Media.BasicBox dstBox )
{
if ( !_buffer.Contains( dstBox ) )
{
throw new ArgumentOutOfRangeException( "Destination box out of range, GLESHardwarePixelBuffer.BlitToMemory" );
}
PixelBox scaled;
if ( src.Width != dstBox.Width ||
src.Height != dstBox.Height ||
src.Depth != dstBox.Depth )
{
LogManager.Instance.Write( "[GLESHardwarePixelBuffer] Scale to destination size." );
// Scale to destination size. Use DevIL and not iluScale because ILU screws up for
// floating point textures and cannot cope with 3D images.
// This also does pixel format conversion if needed
AllocateBuffer();
scaled = _buffer.GetSubVolume( dstBox );
Image.Scale( src, scaled, ImageFilter.Bilinear );
}
else if ( ( src.Format != Format ) ||
( ( GLESPixelUtil.GetGLOriginFormat( src.Format ) == 0 ) && ( src.Format != PixelFormat.R8G8B8 ) ) )
{
LogManager.Instance.Write( "[GLESHardwarePixelBuffer] Extents match, but format is not accepted as valid source format for GL." );
LogManager.Instance.Write( "[GLESHardwarePixelBuffer] Source.Format = {0}, Format = {1}, GLOriginFormat = {2}", src.Format, Format, GLESPixelUtil.GetGLOriginFormat( src.Format ) );
// Extents match, but format is not accepted as valid source format for GL
// do conversion in temporary buffer
AllocateBuffer();
scaled = _buffer.GetSubVolume( dstBox );
PixelConverter.BulkPixelConversion( src, scaled );
}
else
{
LogManager.Instance.Write( "[GLESHardwarePixelBuffer] No scaling or conversion needed." );
scaled = src;
if ( src.Format == PixelFormat.R8G8B8 )
{
scaled.Format = PixelFormat.R8G8B8;
PixelConverter.BulkPixelConversion( src, scaled );
}
// No scaling or conversion needed
// Set extents for upload
scaled.Left = dstBox.Left;
scaled.Right = dstBox.Right;
scaled.Top = dstBox.Top;
scaled.Bottom = dstBox.Bottom;
scaled.Front = dstBox.Front;
scaled.Back = dstBox.Back;
}
Upload( scaled, dstBox );
FreeBuffer();
}