mirror of
https://github.com/reactos/wine.git
synced 2025-02-12 07:32:23 +00:00
wined3d: Clean up SetFormatDesc.
This commit is contained in:
parent
2600041703
commit
e56c6610c6
@ -2518,50 +2518,23 @@ extern HRESULT WINAPI IWineD3DSurfaceImpl_AddDirtyRect(IWineD3DSurface *iface, C
|
||||
|
||||
HRESULT WINAPI IWineD3DSurfaceImpl_SetFormat(IWineD3DSurface *iface, WINED3DFORMAT format) {
|
||||
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
|
||||
HRESULT hr;
|
||||
const GlPixelFormatDesc *glDesc;
|
||||
const StaticPixelFormatDesc *formatEntry = getFormatDescEntry(format, &GLINFO_LOCATION, &glDesc);
|
||||
getFormatDescEntry(format, &GLINFO_LOCATION, &glDesc);
|
||||
|
||||
if (This->resource.format != WINED3DFMT_UNKNOWN) {
|
||||
FIXME("(%p) : The format of the surface must be WINED3DFORMAT_UNKNOWN\n", This);
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
TRACE("(%p) : Calling base function first\n", This);
|
||||
hr = IWineD3DBaseSurfaceImpl_SetFormat(iface, format);
|
||||
if(SUCCEEDED(hr)) {
|
||||
/* Setup some glformat defaults */
|
||||
This->glDescription.glFormat = glDesc->glFormat;
|
||||
This->glDescription.glFormatInternal = glDesc->glInternal;
|
||||
This->glDescription.glType = glDesc->glType;
|
||||
|
||||
This->Flags &= ~SFLAG_ALLOCATED;
|
||||
TRACE("(%p) : glFormat %d, glFotmatInternal %d, glType %d\n", This,
|
||||
This->glDescription.glFormat, This->glDescription.glFormatInternal, This->glDescription.glType);
|
||||
}
|
||||
|
||||
TRACE("(%p) : Setting texture format to (%d,%s)\n", This, format, debug_d3dformat(format));
|
||||
if (format == WINED3DFMT_UNKNOWN) {
|
||||
This->resource.size = 0;
|
||||
} else if (format == WINED3DFMT_DXT1) {
|
||||
/* DXT1 is half byte per pixel */
|
||||
This->resource.size = ((max(This->pow2Width, 4) * formatEntry->bpp) * max(This->pow2Height, 4)) >> 1;
|
||||
|
||||
} else if (format == WINED3DFMT_DXT2 || format == WINED3DFMT_DXT3 ||
|
||||
format == WINED3DFMT_DXT4 || format == WINED3DFMT_DXT5) {
|
||||
This->resource.size = ((max(This->pow2Width, 4) * formatEntry->bpp) * max(This->pow2Height, 4));
|
||||
} else {
|
||||
unsigned char alignment = This->resource.wineD3DDevice->surface_alignment;
|
||||
This->resource.size = ((This->pow2Width * formatEntry->bpp) + alignment - 1) & ~(alignment - 1);
|
||||
This->resource.size *= This->pow2Height;
|
||||
}
|
||||
|
||||
|
||||
/* Setup some glformat defaults */
|
||||
This->glDescription.glFormat = glDesc->glFormat;
|
||||
This->glDescription.glFormatInternal = glDesc->glInternal;
|
||||
This->glDescription.glType = glDesc->glType;
|
||||
|
||||
if (format != WINED3DFMT_UNKNOWN) {
|
||||
This->bytesPerPixel = formatEntry->bpp;
|
||||
} else {
|
||||
This->bytesPerPixel = 0;
|
||||
}
|
||||
|
||||
This->Flags |= (WINED3DFMT_D16_LOCKABLE == format) ? SFLAG_LOCKABLE : 0;
|
||||
This->Flags &= ~SFLAG_ALLOCATED;
|
||||
|
||||
This->resource.format = format;
|
||||
|
||||
TRACE("(%p) : Size %d, bytesPerPixel %d, glFormat %d, glFotmatInternal %d, glType %d\n", This, This->resource.size, This->bytesPerPixel, This->glDescription.glFormat, This->glDescription.glFormatInternal, This->glDescription.glType);
|
||||
|
||||
return WINED3D_OK;
|
||||
return hr;
|
||||
}
|
||||
|
||||
HRESULT WINAPI IWineD3DSurfaceImpl_SetMem(IWineD3DSurface *iface, void *Mem) {
|
||||
|
@ -436,3 +436,43 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetContainer(IWineD3DSurface *iface, IWin
|
||||
|
||||
return WINED3D_OK;
|
||||
}
|
||||
|
||||
HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetFormat(IWineD3DSurface *iface, WINED3DFORMAT format) {
|
||||
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
|
||||
const StaticPixelFormatDesc *formatEntry = getFormatDescEntry(format, NULL, NULL);
|
||||
|
||||
if (This->resource.format != WINED3DFMT_UNKNOWN) {
|
||||
FIXME("(%p) : The format of the surface must be WINED3DFORMAT_UNKNOWN\n", This);
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
}
|
||||
|
||||
TRACE("(%p) : Setting texture format to (%d,%s)\n", This, format, debug_d3dformat(format));
|
||||
if (format == WINED3DFMT_UNKNOWN) {
|
||||
This->resource.size = 0;
|
||||
} else if (format == WINED3DFMT_DXT1) {
|
||||
/* DXT1 is half byte per pixel */
|
||||
This->resource.size = ((max(This->pow2Width, 4) * formatEntry->bpp) * max(This->pow2Height, 4)) >> 1;
|
||||
|
||||
} else if (format == WINED3DFMT_DXT2 || format == WINED3DFMT_DXT3 ||
|
||||
format == WINED3DFMT_DXT4 || format == WINED3DFMT_DXT5) {
|
||||
This->resource.size = ((max(This->pow2Width, 4) * formatEntry->bpp) * max(This->pow2Height, 4));
|
||||
} else {
|
||||
unsigned char alignment = This->resource.wineD3DDevice->surface_alignment;
|
||||
This->resource.size = ((This->pow2Width * formatEntry->bpp) + alignment - 1) & ~(alignment - 1);
|
||||
This->resource.size *= This->pow2Height;
|
||||
}
|
||||
|
||||
if (format != WINED3DFMT_UNKNOWN) {
|
||||
This->bytesPerPixel = formatEntry->bpp;
|
||||
} else {
|
||||
This->bytesPerPixel = 0;
|
||||
}
|
||||
|
||||
This->Flags |= (WINED3DFMT_D16_LOCKABLE == format) ? SFLAG_LOCKABLE : 0;
|
||||
|
||||
This->resource.format = format;
|
||||
|
||||
TRACE("(%p) : Size %d, bytesPerPixel %d\n", This, This->resource.size, This->bytesPerPixel);
|
||||
|
||||
return WINED3D_OK;
|
||||
}
|
||||
|
@ -1614,6 +1614,6 @@ const IWineD3DSurfaceVtbl IWineGDISurface_Vtbl =
|
||||
IWineGDISurfaceImpl_SetGlTextureDesc,
|
||||
IWineGDISurfaceImpl_GetGlDesc,
|
||||
IWineD3DSurfaceImpl_GetData,
|
||||
IWineD3DSurfaceImpl_SetFormat,
|
||||
IWineD3DBaseSurfaceImpl_SetFormat,
|
||||
IWineGDISurfaceImpl_PrivateSetup
|
||||
};
|
||||
|
@ -1168,13 +1168,13 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlayZOrder(IWineD3DSurface *ifac
|
||||
HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlay(IWineD3DSurface *iface, RECT *SrcRect, IWineD3DSurface *DstSurface, RECT *DstRect, DWORD Flags, WINEDDOVERLAYFX *FX);
|
||||
HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetClipper(IWineD3DSurface *iface, IWineD3DClipper *clipper);
|
||||
HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetClipper(IWineD3DSurface *iface, IWineD3DClipper **clipper);
|
||||
HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetFormat(IWineD3DSurface *iface, WINED3DFORMAT format);
|
||||
|
||||
ULONG WINAPI IWineD3DSurfaceImpl_Release(IWineD3DSurface *iface);
|
||||
void WINAPI IWineD3DSurfaceImpl_PreLoad(IWineD3DSurface *iface);
|
||||
HRESULT WINAPI IWineD3DSurfaceImpl_SetPixelFormat(IWineD3DSurface *iface, WINED3DFORMAT Format, BYTE *Surface, DWORD Size);
|
||||
extern HRESULT WINAPI IWineD3DSurfaceImpl_AddDirtyRect(IWineD3DSurface *iface, CONST RECT* pDirtyRect);
|
||||
const void *WINAPI IWineD3DSurfaceImpl_GetData(IWineD3DSurface *iface);
|
||||
HRESULT WINAPI IWineD3DSurfaceImpl_SetFormat(IWineD3DSurface *iface, WINED3DFORMAT format);
|
||||
HRESULT WINAPI IWineD3DSurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC);
|
||||
HRESULT WINAPI IWineD3DSurfaceImpl_ReleaseDC(IWineD3DSurface *iface, HDC hDC);
|
||||
HRESULT WINAPI IWineD3DSurfaceImpl_SetMem(IWineD3DSurface *iface, void *Mem);
|
||||
|
Loading…
x
Reference in New Issue
Block a user