Stefan Dösinger : wined3d: Add IWineD3DSurface:: GetPitch.
Alexandre Julliard
julliard at wine.codeweavers.com
Mon May 8 08:02:27 CDT 2006
Module: wine
Branch: refs/heads/master
Commit: 18e95ee969f0bb04865fadca474b60faa3ff9fd5
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=18e95ee969f0bb04865fadca474b60faa3ff9fd5
Author: Stefan Dösinger <stefan at codeweavers.com>
Date: Sat May 6 17:39:45 2006 +0200
wined3d: Add IWineD3DSurface::GetPitch.
---
dlls/wined3d/surface.c | 43 ++++++++++++++++++++++++--------------
include/wine/wined3d_interface.h | 2 ++
2 files changed, 29 insertions(+), 16 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index da51768..9bb0916 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -312,22 +312,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LockR
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_Priva
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 IWineD3DSurfac
IWineD3DSurfaceImpl_SetPalette,
IWineD3DSurfaceImpl_RealizePalette,
IWineD3DSurfaceImpl_SetColorKey,
+ IWineD3DSurfaceImpl_GetPitch,
/* Internal use: */
IWineD3DSurfaceImpl_CleanDirtyRect,
IWineD3DSurfaceImpl_AddDirtyRect,
diff --git a/include/wine/wined3d_interface.h b/include/wine/wined3d_interface.h
index 87ee1c9..745a37b 100644
--- a/include/wine/wined3d_interface.h
+++ b/include/wine/wined3d_interface.h
@@ -1152,6 +1152,7 @@ DECLARE_INTERFACE_(IWineD3DSurface,IWine
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 @@ #define IWineD3DSurface_GetPalette(p, a)
#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)
More information about the wine-cvs
mailing list