wined3d: Add IWineD3DSurface::GetPitch.

This commit is contained in:
Stefan Dösinger 2006-05-06 17:39:45 +02:00 committed by Alexandre Julliard
parent a173c8e35a
commit 18e95ee969
2 changed files with 29 additions and 16 deletions

View File

@ -312,22 +312,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, WINED3DLOCKE
TRACE("(%p) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->resource.allocatedMemory);
}
/* DXTn formats don't have exact pitches as they are to the new row of blocks,
where each block is 4x4 pixels, 8 bytes (dxt1) and 16 bytes (dxt2/3/4/5)
ie pitch = (width/4) * bytes per block */
if (This->resource.format == WINED3DFMT_DXT1) /* DXT1 is 8 bytes per block */
pLockedRect->Pitch = (This->currentDesc.Width >> 2) << 3;
else if (This->resource.format == WINED3DFMT_DXT2 || This->resource.format == WINED3DFMT_DXT3 ||
This->resource.format == WINED3DFMT_DXT4 || This->resource.format == WINED3DFMT_DXT5) /* DXT2/3/4/5 is 16 bytes per block */
pLockedRect->Pitch = (This->currentDesc.Width >> 2) << 4;
else {
if (NP2_REPACK == wined3d_settings.nonpower2_mode || This->resource.usage & WINED3DUSAGE_RENDERTARGET) {
/* Front and back buffers are always lockes/unlocked on currentDesc.Width */
pLockedRect->Pitch = This->bytesPerPixel * This->currentDesc.Width; /* Bytes / row */
} else {
pLockedRect->Pitch = This->bytesPerPixel * This->pow2Width;
}
}
pLockedRect->Pitch = IWineD3DSurface_GetPitch(iface);
if (NULL == pRect) {
pLockedRect->pBits = This->resource.allocatedMemory;
@ -1524,6 +1509,31 @@ HRESULT WINAPI IWineD3DSurfaceImpl_PrivateSetup(IWineD3DSurface *iface) {
return WINED3D_OK;
}
DWORD WINAPI IWineD3DSurfaceImpl_GetPitch(IWineD3DSurface *iface) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
DWORD ret;
TRACE("(%p)\n", This);
/* DXTn formats don't have exact pitches as they are to the new row of blocks,
where each block is 4x4 pixels, 8 bytes (dxt1) and 16 bytes (dxt2/3/4/5)
ie pitch = (width/4) * bytes per block */
if (This->resource.format == WINED3DFMT_DXT1) /* DXT1 is 8 bytes per block */
ret = (This->currentDesc.Width >> 2) << 3;
else if (This->resource.format == WINED3DFMT_DXT2 || This->resource.format == WINED3DFMT_DXT3 ||
This->resource.format == WINED3DFMT_DXT4 || This->resource.format == WINED3DFMT_DXT5) /* DXT2/3/4/5 is 16 bytes per block */
ret = (This->currentDesc.Width >> 2) << 4;
else {
if (NP2_REPACK == wined3d_settings.nonpower2_mode || This->resource.usage & WINED3DUSAGE_RENDERTARGET) {
/* Front and back buffers are always lockes/unlocked on currentDesc.Width */
ret = This->bytesPerPixel * This->currentDesc.Width; /* Bytes / row */
} else {
ret = This->bytesPerPixel * This->pow2Width;
}
}
TRACE("(%p) Returning %ld\n", This, ret);
return ret;
}
const IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl =
{
/* IUnknown */
@ -1560,6 +1570,7 @@ const IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl =
IWineD3DSurfaceImpl_SetPalette,
IWineD3DSurfaceImpl_RealizePalette,
IWineD3DSurfaceImpl_SetColorKey,
IWineD3DSurfaceImpl_GetPitch,
/* Internal use: */
IWineD3DSurfaceImpl_CleanDirtyRect,
IWineD3DSurfaceImpl_AddDirtyRect,

View File

@ -1152,6 +1152,7 @@ DECLARE_INTERFACE_(IWineD3DSurface,IWineD3DResource)
STDMETHOD(SetPalette)(THIS_ struct IWineD3DPalette *Palette) PURE;
STDMETHOD(RealizePalette)(THIS) PURE;
STDMETHOD(SetColorKey)(THIS_ DWORD Flags, DDCOLORKEY *CKey) PURE;
STDMETHOD_(DWORD,GetPitch)(THIS) PURE;
/* Internally used methods */
STDMETHOD(CleanDirtyRect)(THIS) PURE;
STDMETHOD(AddDirtyRect)(THIS_ CONST RECT* pRect) PURE;
@ -1203,6 +1204,7 @@ DECLARE_INTERFACE_(IWineD3DSurface,IWineD3DResource)
#define IWineD3DSurface_SetPalette(p, a) (p)->lpVtbl->SetPalette(p, a)
#define IWineD3DSurface_RealizePalette(p) (p)->lpVtbl->RealizePalette(p)
#define IWineD3DSurface_SetColorKey(p, a, b) (p)->lpVtbl->SetColorKey(p, a, b)
#define IWineD3DSurface_GetPitch(p) (p)->lpVtbl->GetPitch(p)
/*** IWineD3DSurface (Internal, no d3d mapping) methods ***/
#define IWineD3DSurface_CleanDirtyRect(p) (p)->lpVtbl->CleanDirtyRect(p)
#define IWineD3DSurface_AddDirtyRect(p,a) (p)->lpVtbl->AddDirtyRect(p,a)