|
|
Definition at line 437 of file surface.c.
Referenced by D3DXLoadSurfaceFromSurface().
{
CONST PixelFormatDesc *srcformatdesc, *destformatdesc;
D3DSURFACE_DESC surfdesc;
D3DLOCKED_RECT lockrect;
POINT srcsize, destsize;
HRESULT hr;
TRACE("(void)\n");
if( !pDestSurface || !pSrcMemory || !pSrcRect ) return D3DERR_INVALIDCALL;
if(SrcFormat == D3DFMT_UNKNOWN || pSrcRect->left >= pSrcRect->right || pSrcRect->top >= pSrcRect->bottom) return E_FAIL;
if(dwFilter != D3DX_FILTER_NONE) return E_NOTIMPL;
IDirect3DSurface9_GetDesc(pDestSurface, &surfdesc);
srcformatdesc = get_format_info(SrcFormat);
destformatdesc = get_format_info(surfdesc.Format);
if( srcformatdesc->type == FORMAT_UNKNOWN || srcformatdesc->bytes_per_pixel > 4) return E_NOTIMPL;
if(destformatdesc->type == FORMAT_UNKNOWN || destformatdesc->bytes_per_pixel > 4) return E_NOTIMPL;
srcsize.x = pSrcRect->right - pSrcRect->left;
srcsize.y = pSrcRect->bottom - pSrcRect->top;
if( !pDestRect ) {
destsize.x = surfdesc.Width;
destsize.y = surfdesc.Height;
} else {
destsize.x = pDestRect->right - pDestRect->left;
destsize.y = pDestRect->bottom - pDestRect->top;
}
hr = IDirect3DSurface9_LockRect(pDestSurface, &lockrect, pDestRect, 0);
if(FAILED(hr)) return D3DXERR_INVALIDDATA;
copy_simple_data((CONST BYTE*)pSrcMemory, SrcPitch, srcsize, srcformatdesc,
(CONST BYTE*)lockrect.pBits, lockrect.Pitch, destsize, destformatdesc,
dwFilter);
IDirect3DSurface9_UnlockRect(pDestSurface);
return D3D_OK;
}
|